Tokens with more than 18 decimals break liquidation process due to an underflow in distributeAssets
function.
If a token with more than 18 decimals will be accepted as collateral in the future it will disrupt the liquidation process.
In distributeAssets
function the costInEuros
variable scale up assets value to 18 decimals here:
1) LiquidationPool
claim rewards
allows users to claim their accrued rewards:
Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)
at LiquidationPool.distributeAssets (contracts/LiquidationPool.sol:253)
at LiquidationPoolManager.runLiquidation (contracts/LiquidationPoolManager.sol:80)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
at HardhatNode._mineBlockWithPendingTxs (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1866:23)
at HardhatNode.mineBlock (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:524:16)
at EthModule._sendTransactionAndReturnHash (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1482:18)
2) LiquidationPoolManager
runLiquidation
distributes liquidated assets among stake holders if there is enough EUROs to purchase:
AssertionError: Expected transaction NOT to be reverted, but it reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
at Context.<anonymous> (test/liquidationPoolManager.js:238:7)
3) LiquidationPoolManager
runLiquidation
returns unpurchased liquidated assets to protocol address:
Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)
at LiquidationPool.distributeAssets (contracts/LiquidationPool.sol:253)
at LiquidationPoolManager.runLiquidation (contracts/LiquidationPoolManager.sol:80)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
at HardhatNode._mineBlockWithPendingTxs (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1866:23)
at HardhatNode.mineBlock (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:524:16)
at EthModule._sendTransactionAndReturnHash (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1482:18)
4) LiquidationPoolManager
runLiquidation
increases existing rewards with multiple liquidations:
AssertionError: Expected transaction NOT to be reverted, but it reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
at Context.<anonymous> (test/liquidationPoolManager.js:469:7)
Smart Vaults with a token with more than 24 decimals can't be liquidated.
Manual review.
Check token decimals and scale down if a token has more than 18 decimals.