Open Senna46 opened 10 months ago
internally
UT required (x) = YT desired - PT swapped to UT
let YT desired = y x = y - y (1 -moduleBonded/YT supply) swapRate(PT/UT) y = x * YT supply / moduleBonded / swapRate(PT/UT)
~It can be implemented if SwapRate can be calculated.~ This is quite difficult because y is used to calculate SwapRate. As an alternative, I'll use the rate for 1 Token for now.
The same method uses on chain/x/irs/keeper/grpc_query_tranche_apys.go
chain/x/irs/keeper/swap_advanced.go
// // TODO: This implementation is better if there is no Redeem time lag
// func (k Keeper) SwapYtToUt(ctx sdk.Context, sender sdk.AccAddress, pool types.TranchePool, requiredUtAmount sdk.Int, token sdk.Coin) error {
Because redeem has a time lag, this is too difficult to achieve. For now, it should be limited to maturities.
PT Required = UT desired PT Supply / moduleBonded YT Required = UT desired YT Supply / moduleBonded
So,
UT desired (output) = PT Required (input) moduleBonded / PT Supply YT Required (output) = PT Required (input) YT Supply / PT Supply
The same method can be for the reverse.
UT required = UT Pool Liquidity LP desired / Pool Total Share (Ceil) PT required = PT Pool Liquidity LP desired / Pool Total Share (Ceil)
So,
LP desired (output) = UT required (input) Pool Total Share / UT Pool Liquidity PT required (output) = UT required (input) PT Pool Liquidity / UT Pool Liquidity
The same method can be for the reverse.
There are several Msg that require specifying the amount requested in the IRS, which hinders UX. The following query is needed to resolve this. (not sure if this can be achieved)
Need queries that return a right estimate for the left input.
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.