-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
The Sendcoin code lacks error handling. This will lead to an inability to provide error feedback for transfer operations where the available Sencoins are insufficient to meet the userAmount during migration.
bal := k.bankKeeper.GetBalance(ctx, position.GetPositionAddress(), position.Collateral.Denom)
userAmount := sdk.ZeroInt()
if bal.Amount.LT(repayAmount) {
repayAmount = bal.Amount
} else {
userAmount = bal.Amount.Sub(repayAmount)
}
if repayAmount.IsPositive() {
k.stableKeeper.Repay(ctx, position.GetPositionAddress(), sdk.NewCoin(position.Collateral.Denom, repayAmount))
} else {
userAmount = bal.Amount
}
positionOwner := sdk.MustAccAddressFromBech32(position.Address)
if userAmount.IsPositive() {
k.bankKeeper.SendCoins(ctx, position.GetPositionAddress(), positionOwner, sdk.Coins{sdk.NewCoin(position.Collateral.Denom, userAmount)})
}
if leveragedLpAmount.IsZero() {
// Repay any balance, delete position
k.DestroyPosition(ctx, positionOwner, position.Id)
} else {
// Repay any balance and update position value
position.LeveragedLpAmount = leveragedLpAmount
k.SetPosition(ctx, &position)
}
}
https://github.com/elys-network/elys/blob/624945db82ff57077de206b2a25ed05ae4c33b14/x/leveragelp/keeper/position.go#L369
Considering that the vesting account may cause the operation k.bankKeeper.GetBalance(ctx, position.GetPositionAddress(), position.Collateral.Denom) to return a balance that includes locked coins, which cannot be transferred. This may lead to the Sendcoin not providing correct error feedback in the future when adapting to the vesting account for elys network.
Metadata
Metadata
Assignees
Labels
No labels