Strategist Role

Strategist Parameters

Strategists are provided with the 'keeper' role. This role comes with some special management permissions for the Strategy.

The key parameters that a Strategist will be able to manage are outlined below:

    //Key Parameters that a 'Strategist / Keeper' will be able to change 
    int256[] deltaIds; // The bins you want to add liquidity to. Each value is relative to the active bin ID
    uint256[] distributionX; // The percentage of X you want to add to each bin in deltaIds
    uint256[] distributionY; // The percentage of Y you want to add to each bin in deltaIds
    uint256 idSlippage; // The slippage tolerance in case active bin moves during time it takes to transact

For more information on the above parameters see link from TraderJoe docs: https://docs.traderjoexyz.com/guides/manage-a-liquidity-position

Execute Rebalance

By far the most important manager function is the executeRebalance method on the SteakHutLBStrategy.sol.

This permissioned method is the only way to change the bin range of the underlying TraderJoe V2 liquidity position.

Manager accounts who control this function are the means by which custom rebalancing strategies can be built on top of SteakHut Liquidity.

These strategies can be implemented by governance (slow, but decentralized) or by some central managerial party (more responsive but requiring much more trust).

In order to execute a rebalance the above parameters must be provided to the strategy and the executeRebalance function called.

    /// -----------------------------------------------------------
    /// Rebalance function
    /// -----------------------------------------------------------

    /// @notice point of call to execute a rebalance of the strategy
    /// @param _deltaIds the distibution of liquidity around the active bin
    /// @param _distributionX the distibution of tokenX liquidity around the active bin
    /// @param _distributionY the distibution of tokenY liquidity around the active bin
    /// @param _idSlippage slippage of bins acceptable
    /// @return amountX total amountX supplied after the rebalance
    /// @return amountY total amountY supplied after the rebalance
    function executeRebalance(
        int256[] memory _deltaIds,
        uint256[] memory _distributionX,
        uint256[] memory _distributionY,
        uint256 _idSlippage
    ) external onlyManager returns (uint256 amountX, uint256 amountY)

The executeRebalance() function handles the below automatically:

  1. Harvest any pending rewards from the TJ LB contracts

  2. Removes liquidity from current bins where liquidity exists

  3. Sets the new parameters

  4. Swaps the required amounts of tokens to provide liquidity

  5. Adds the amounts to a new liquidity bin range

Harvesting

Whilst anyone is able to perform a harvest it should be noted that a strategist is also able to perform this function. A harvest does not automatically reinvest funds. In order to place the funds to work the 'keeper' is required to call the earn() function.

Funds that have been harvested remain idle in the strategy contract until put to work by the 'keeper'.

    /// @notice harvest the rewards from the strategy using tx origin
    /// @return amountXReceived amount of tokenX received from harvest
    /// @return amountYReceived amount of tokenY received from harvest
    function harvest()
        external
        virtual
        returns (uint256 amountXReceived, uint256 amountYReceived)
    {
        (amountXReceived, amountYReceived) = _harvest(tx.origin);
    }

    /// @notice harvest the rewards from the strategy using custom fee receiver
    /// @param callFeeRecipient the address to be compensated for gas
    /// @return amountXReceived amount of tokenX received from harvest
    /// @return amountYReceived amount of tokenY received from harvest
    function harvest(
        address callFeeRecipient
    )
        external
        virtual
        returns (uint256 amountXReceived, uint256 amountYReceived)
    {
        (amountXReceived, amountYReceived) = _harvest(callFeeRecipient);
    }

The key differentiation between the two functions here is that a 'keeper' may chose to send the gas reimbursement to another wallet. If this is the case, pass an address into the function.

Earn (Placing Funds to Work)

The earn function is key in managing a strategy. Only a 'manager' is able to call this function. Essentially it places the idle funds in the Strategy contract to work in a Trader Joe Dex V2 liquidity pool.

Typically a keeper will call the earn function when the active bin in the underlying TJ pool meets particular conditions. Sample Manager contracts can be found in the Githhub Repo.

An earn() does not need to be called when performing an rebalance, as the rebalance function handles this logic.

    /// @notice puts any available tokenX or tokenY to work
    /// @return amountX amount of token X added as liquidity
    /// @return amountY amount of token Y added as liquidity
    function earn()
        external
        onlyManager
        returns (uint256 amountX, uint256 amountY)
    {
        uint256 balanceX = tokenX.balanceOf(address(this));
        uint256 balanceY = tokenY.balanceOf(address(this));

        //gas saving check if there is idle funds in the contract
        require(
            balanceX > 1e3 || balanceY > 1e3,
            "Vault: Insufficient idle funds in strategy"
        );

        //require the amounts to be deposited into the correct bin distributions
        (amountX, amountY) = _calculateAmountsPerformSwap(
            deltaIds,
            balanceX,
            balanceY
        );

        //use the funds in the strategy to add liquidty.
        if (amountX > 0 || amountY > 0) {
            _addLiquidity(amountX, amountY, 0, 0);
        }
    }

Advanced Usage

The 'keeper' role may be assigned to a third-party smart contract to manage the strategy. This allows potentially unlimited possibilities when it comes to building a strategy.

The 'keeper' role may be set to a potential Chainlink keepers contract which will allow for some very advanced strategies to be constructed on top of SteakHut Liquidity.

We are excited about the unlimited possibilities that this will allow.

Last updated