Skip to content

Commit

Permalink
adam comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kosegor committed Jul 26, 2023
1 parent 5177377 commit 6b03f82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
12 changes: 9 additions & 3 deletions x/metoken/keeper/interest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ func (k Keeper) ClaimInterest() error {
}

if k.ctx.BlockTime().After(interestClaimTime) {
leverageLiquidity, err := k.leverageKeeper.GetAllSupplied(*k.ctx,
authtypes.NewModuleAddress(metoken.ModuleName))
indexes := k.GetAllRegisteredIndexes()
if len(indexes) == 0 {
return nil
}

leverageLiquidity, err := k.leverageKeeper.GetAllSupplied(
*k.ctx,
authtypes.NewModuleAddress(metoken.ModuleName),
)
if err != nil {
return err
}

indexes := k.GetAllRegisteredIndexes()
for _, index := range indexes {
balances, err := k.IndexBalances(index.Denom)
if err != nil {
Expand Down
17 changes: 3 additions & 14 deletions x/metoken/keeper/redeem.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,11 @@ func (k Keeper) withdrawFromLeverage(tokensToWithdraw sdk.Coin) (sdk.Coin, error
return coin.Zero(tokensToWithdraw.Denom), nil
}

uTokensToWithdraw := sdk.NewCoin(
uTokensFromLeverage.Denom,
sdk.MinInt(
availableUTokensFromLeverage,
uTokensFromLeverage.Amount,
),
)
if _, _, err = k.leverageKeeper.Withdraw(
tokensWithdrawn, _, err := k.leverageKeeper.Withdraw(
*k.ctx,
authtypes.NewModuleAddress(metoken.ModuleName),
uTokensToWithdraw,
); err != nil {
return sdk.Coin{}, err
}

tokensWithdrawn, err := k.leverageKeeper.ExchangeUToken(*k.ctx, uTokensToWithdraw)
sdk.NewCoin(uTokensFromLeverage.Denom, sdk.MinInt(availableUTokensFromLeverage, uTokensFromLeverage.Amount)),
)
if err != nil {
return sdk.Coin{}, err
}
Expand Down

0 comments on commit 6b03f82

Please sign in to comment.