Open hats-bug-reporter[bot] opened 5 months ago
Github username: @0xLogos Twitter username: -- Submission hash (on-chain): 0x5bf82eb6ab1b98d2e17926c06b24d8eb7e286afd766862cb0ae9e6f40cdd2017 Severity: high
Description: Here is how swap cost is calculated:
uint swapCost = outEthValue.subSaturate(inEthValue);
But it's wrong. For example if out value > in value swap cost will be > 0, but in reality it should be 0.
Correct way to calculate swap cost is:
uint swapCost = inEthValue.subSaturate(outEthValue);
Impact is bad rebalance can pass validation, this can lead to huge amount of loss for vault.
The idea here is that "out value" is the amount leaving the vault and the "in value" is what we are getting back. When the in value is less, i.e. we lost value, we consider that a cost.
Github username: @0xLogos Twitter username: -- Submission hash (on-chain): 0x5bf82eb6ab1b98d2e17926c06b24d8eb7e286afd766862cb0ae9e6f40cdd2017 Severity: high
Description: Here is how swap cost is calculated:
But it's wrong. For example if out value > in value swap cost will be > 0, but in reality it should be 0.
Correct way to calculate swap cost is:
Impact is bad rebalance can pass validation, this can lead to huge amount of loss for vault.