CurveUser.sol

The CurveUser contract is a specialized component within the TurtleShell SDK, designed for DeFi protocols that engage with the Curve platform. Drawing from the functionalities of the TvlTracker contract, it provides an automated mechanism to adjust the Total Value Locked (TVL) based on swap outcomes on Curve.

Please note that both this contract is an extensions built upon the foundational TvlTracker contract. For these contracts to function correctly and provide the intended TVL tracking capabilities, it is essential that the TvlTracker contract is already implemented and integrated within the protocol.

Contract Functions

_executeSwap(uint256 amount, address tokenA, address tokenB) internal;

This function enables a swap between tokenA and tokenB on Curve for a specified amount. Upon completion, the contract autonomously updates the TVL based on the result of the swap, either incrementing or decrementing liquidity as necessary.

contract YourProtocol is TvlTracker, CurveUser {

    function swapTokens(uint256 amount, address tokenA, address tokenB) public {
        // Logic for token swap on Curve
        _executeSwap(amount, tokenA, tokenB);
    }
}

_updateTVLAfterSwap() internal;

An internal function that is triggered post executeSwap. It evaluates the net impact of the swap on the protocol's liquidity and modifies the TVL accordingly. This ensures that the TVL accurately mirrors the current state of liquidity after every swap transaction.

To leverage the features of the CurveUser contract, DeFi protocols can inherit it. This equips them with the inherent logic to handle TVL modifications based on Curve swaps, obviating the need for manual interventions or supplementary coding.

contract YourProtocol is TvlTracker, CurveUser {
    // Protocol-specific logic and functions
}

To conclude, the CurveUser contract provides DeFi protocols with a structured approach to manage their TVL when conducting swaps on Curve. By adopting this contract, protocols can maintain an up-to-date and accurate representation of their TVL, accounting for real-time liquidity changes due to swap activities.

Last updated