Closed deemru closed 2 years ago
@deemru thanks for your help. very appreciate it! fixing the points you mentioned would love your help on a brief overview of other functions (generateIndex, redeemIndex and claimIndexRewards)
Lets finish with swap()
first:
AssetOutBalance - AmountOut
if AssetOut
== AssetIn
to _balance
which can lead to very high interest rates for LPs and full contract wipe. https://github.com/vlzhr/puzzleswap-contracts/blob/6ceffd5ab6d236ff2fa6baf97c8e3a2d3f842385/puzzle-custompool.ride#L476As the CRITICAL is still here, you should at least disable swap()
that AssetIn
== AssetOut
after: https://github.com/vlzhr/puzzleswap-contracts/blob/6ceffd5ab6d236ff2fa6baf97c8e3a2d3f842385/puzzle-custompool.ride#L437
Only watched
swap()
function as the most important one:else
construction. https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L478✅ LOW: No check for payments size == 1. https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L434
✅ HIGH: Logic flaw. (see below) https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L173
✅ CRITICAL: Unexpected key-value overwrites (same assetId possible as stated above) https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L483-L484
✅ MEDIUM: Performance. You should
throw()
as soon as possible to bypass failed transaction status for a user. Not after your service invoke. The best place is just afterlet AmountOut = ...
. https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L449-L462✅ MEDIUM: Performance. Same as above. https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L466-L467
✅ TRIVIAL: Unused variables. https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L6 https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L438
✅ HIGH: Wrong calculations.
AssetInBalance
andfeeAssetOutBalance
could be changed after firstcalculateOutAmount
(virtual swap happened) https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L449-L450✅ HIGH: Wrong calculations. If
feeAssetOut
equalsAssetIn
orAssetOut
(basically one of the assets is USDN) its still MUST be accounted or it will lead to wrong higher interest rates (for USDN). https://github.com/vlzhr/puzzleswap-contracts/blob/6297d0555840b8ec6a08acd847571a9c232aba4a/puzzle-custompool.ride#L473