Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
on unknown borrow price, still allow withdrawal of non-collateral uTo…
…kens
  • Loading branch information
toteki committed Feb 15, 2023
commit 1ea883f8f535fb5c62c5df7f8cdad982ca42877d
9 changes: 8 additions & 1 deletion x/leverage/keeper/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ func (k *Keeper) maxWithdraw(ctx sdk.Context, addr sdk.AccAddress, denom string)

// calculate borrowed value for the account, using the higher of spot or historic prices for each token
borrowedValue, err := k.TotalTokenValue(ctx, totalBorrowed, types.PriceModeHigh)
if err != nil {
if nonOracleError(err) {
// for errors besides a missing price, the whole transaction fails
return sdk.Coin{}, err
}
if err != nil {
// for missing prices on borrowed assets, we can't withdraw any collateral
// but can withdraw non-collateral uTokens
withdrawAmount := sdk.MinInt(walletUtokens, availableUTokens.Amount)
return sdk.NewCoin(uDenom, withdrawAmount), nil
}

// if no non-blacklisted tokens are borrowed, withdraw the maximum available amount
if borrowedValue.IsZero() {
Expand Down