You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apart from potentially taking more fees than necessary, I guess if the UI quote is different from the actual calc, it may have slippage issues for users.
The text was updated successfully, but these errors were encountered:
frontier159
changed the title
Vault.sellUSDG() feeBasisPoints
Vault.sellUSDG() incorrect feeBasisPoints
Aug 31, 2022
Using increment=false as the signal for a sell in getFeeBasisPoints()
const initialAmount = token.usdgAmount;
if (!increment) {
// The contract code already decrements the initial amount by the amount to sell.
// So to have a matching quote, the same logic needs to be added here.
initialAmount = initialAmount.lte(usdgDelta) ? bigNumberify(0) : initialAmount.sub(usdgDelta);
}
let nextAmount = ...
But I feel like this is a bug in the contract code - so raising here.
gm,
The fee calc when selling GLP (the
vault.sellUSDG()
function) may have a bug.When selling GLP, the fee for the token to sell into is calculated here:
https://github.com/gmx-io/gmx-contracts/blob/master/contracts/core/Vault.sol#L508
This underlying fee calc depends on
vault.usdgAmounts(usg)
for the initialAmount:https://github.com/gmx-io/gmx-contracts/blob/master/contracts/core/VaultUtils.sol#L146
However this
usdgAmount
has already been updated (decreased) prior to this being calledhttps://github.com/gmx-io/gmx-contracts/blob/master/contracts/core/Vault.sol#L497
So it looks like the
initialAmount
var isn't the initial amount, it's already had the usdgDelta applied to it.Also as far as I can tell, the UI quote is inconsistent with this contract calc - since the usdgAmount being used is the amount prior to the transaction.
https://github.com/gmx-io/gmx-interface/blob/master/src/Helpers.js#L655
Apart from potentially taking more fees than necessary, I guess if the UI quote is different from the actual calc, it may have slippage issues for users.
The text was updated successfully, but these errors were encountered: