Skip to content

Commit

Permalink
Merge branch 'main' into docs/use-new-testnet-chain-id
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond authored Dec 9, 2024
2 parents c9b2c1f + 72b5aa5 commit 9b43c67
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion x/amm/keeper/keeper_swap_exact_amount_in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (suite *AmmKeeperTestSuite) TestSwapExactAmountIn() {

track := suite.app.AmmKeeper.GetSlippageTrack(suite.ctx, 1, uint64(suite.ctx.BlockTime().Unix()))
if tc.isOraclePool {
suite.Require().Equal(track.Tracked.String(), "25uusdc")
suite.Require().Equal(track.Tracked.String(), "50uusdc")
} else {
suite.Require().Equal(track.Tracked.String(), "")
}
Expand Down
2 changes: 1 addition & 1 deletion x/amm/keeper/keeper_swap_exact_amount_out_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (suite *AmmKeeperTestSuite) TestSwapExactAmountOut() {

track := suite.app.AmmKeeper.GetSlippageTrack(suite.ctx, 1, uint64(suite.ctx.BlockTime().Unix()))
if tc.isOraclePool {
suite.Require().Equal(track.Tracked.String(), "11112uusda")
suite.Require().Equal(track.Tracked.String(), "22224uusda")
} else {
suite.Require().Equal(track.Tracked.String(), "")
}
Expand Down
2 changes: 1 addition & 1 deletion x/amm/keeper/query_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (k Keeper) PoolExtraInfo(ctx sdk.Context, pool types.Pool) types.PoolExtraI
avg := k.GetWeightBreakingSlippageAvg(ctx, pool.PoolId)
apr := math.LegacyZeroDec()
if tvl.IsPositive() {
apr = avg.Mul(math.LegacyNewDec(52)).Quo(tvl)
apr = avg.Mul(math.LegacyNewDec(365)).Quo(tvl)
}
return types.PoolExtraInfo{
Tvl: tvl,
Expand Down
3 changes: 2 additions & 1 deletion x/amm/types/swap_in_amt_given_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func (p *Pool) SwapInAmtGivenOut(
return sdk.Coin{}, sdkmath.LegacyOneDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err
}
inAmountAfterSlippage := oracleInAmount.Add(slippageAmount.Mul(externalLiquidityRatio))
slippage = slippageAmount.Mul(externalLiquidityRatio).Quo(oracleInAmount)
slippageAmount = slippageAmount.Mul(externalLiquidityRatio)
slippage = slippageAmount.Quo(oracleInAmount)

// calculate weight distance difference to calculate bonus/cut on the operation
newAssetPools, err := p.NewPoolAssetsAfterSwap(ctx,
Expand Down
3 changes: 2 additions & 1 deletion x/amm/types/swap_out_amt_given_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ func (p *Pool) SwapOutAmtGivenIn(
return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err
}
outAmountAfterSlippage := oracleOutAmount.Sub(slippageAmount.Mul(externalLiquidityRatio))
slippage = slippageAmount.Mul(externalLiquidityRatio).Quo(oracleOutAmount)
slippageAmount = slippageAmount.Mul(externalLiquidityRatio)
slippage = slippageAmount.Quo(oracleOutAmount)

// oracleOutAmount = 100 ATOM
// BalancerOutAmount = 95 ATOM
Expand Down
8 changes: 6 additions & 2 deletions x/masterchef/keeper/apr_denom.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat
return math.LegacyZeroDec(), nil
}

// Mutiply by 52 to get yearly rewards
yearlyDexRewardAmount := usdcAmount.Mul(math.LegacyNewDec(52))
// Mutiply by 365 to get yearly rewards
entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency)
if !found {
return math.LegacyZeroDec(), assetprofiletypes.ErrAssetProfileNotFound
}
yearlyDexRewardAmount := usdcAmount.Mul(math.LegacyNewDec(365)).Quo(math.LegacyNewDec(int64(entry.Decimals)))

apr := yearlyDexRewardAmount.
Quo(edenDenomPrice).
Expand Down

0 comments on commit 9b43c67

Please sign in to comment.