code-423n4 / 2024-03-saltyio-mitigation-findings

0 stars 0 forks source link

E-02 MitigationConfirmed #115

Open c4-bot-3 opened 4 months ago

c4-bot-3 commented 4 months ago

Lines of code

Vulnerability details

Additional Scope Issue

https://github.com/othernet-global/salty-io/commit/75901cae57382a87b5f049d7afb9c5d9b9ba4c19 https://github.com/othernet-global/salty-io/commit/7de25bca740332ae7a4b2f25c3a6f6419eaa7569

Comments

The commits are specifically aimed to add a few code optimizations to reduce gas used when attempting arbitrage. code was also refactored and made cleaner. for example the function "_adjustReservesforSwapNoRevert" were removed, since its basically a replica of _adjustReservesForSwap, but with the additional check that reserves were more than dust. so the check was done by the caller of function instead, and the original _adjustReservesForSwap was used, as such:

       // Only swap for SALT with sufficient reserves
    if ( ( reserves.reserve0 > PoolUtils.DUST ) && ( reserves.reserve1 > PoolUtils.DUST ) )
        {
        uint256 saltOut = _adjustReservesForSwap(reserves, flipped, arbitrageProfit);

    // Prevent users from zapping too much at once as they may encounter unexpected slippage
    if ( flipped )
        require( zapSwapAmountIn < reserves.reserve1 / 100, "Cannot zap more than 1% of the reserves" );
    else
        require( zapSwapAmountIn < reserves.reserve0 / 100, "Cannot zap more than 1% of the reserves" ); 

More importantly _adjustReservesForSwap was modified, it longer has to access storage everytime its called to get the pool reserves, but instead the reserves are passed to it by the caller.

Conclusion

LGTM

liveactionllama commented 4 months ago

Updating the ID label here, simply for consistency across all warden submissions.

c4-judge commented 4 months ago

Picodes marked the issue as satisfactory

c4-judge commented 4 months ago

Picodes marked the issue as confirmed for report