Setting APYs on farms

From Ethereum Mainnet to layer 2 contracts...

At the point when the vote is executed on Ethereum mainnet, information about APYs to be set on the farms are passed through the mainnet farms as well as polygon farms

Setting APYs on Ethereum Mainnet farms

A vote such as below dictates how much APY to set for our IbAlluoXXX farm. https://vote.alluo.com/#/proposal/0x3923acef8207d12525c51adbabd5fca2e82f52ed58e5c2b5ae0ab12f1f723b11 Then on chain, we immediately set the interest rate to the approved APY.

VoteExecutorMaster.sol
if (commandIndex == 0) {
    (
        string memory ibAlluoSymbol,
        uint256 newAnnualInterest,
        uint256 newInterestPerSecond
    ) = abi.decode(
       messages[j].commandData,
       (string, uint256, uint256)
        );
     IIbAlluo ibAlluo = IIbAlluo(
       ibAlluoSymbolToAddress[ibAlluoSymbol]
     );
     if (ibAlluo.annualInterest() != newAnnualInterest) {
        ibAlluo.setInterest(
                 newAnnualInterest,
                 newInterestPerSecond
                );
        }
} 

Setting APYs on Layer 2 farms

Today we have farms on Polygon and Optimism. Setting APYs on these through a decentralised process requires two steps

  1. Execute the vote on Ethereum mainnet and then use a cross-chain messaging protocol such as AnyCall (Multichain).

IAnyCall(crossChainInfo.anyCallAddress).anyCall(
                crossChainInfo.nextChainExecutor,
                finalData,
                address(0),
                crossChainInfo.nextChain,
                0
         );
  1. On receipt of the cross chain data on layer 2 (ex. Polygon), set the APY.

if (currentMessage.commandIndex == 0) {
                (
                    string memory ibAlluoSymbol,
                    uint256 newAnnualInterest,
                    uint256 newInterestPerSecond
                ) = abi.decode(
                        currentMessage.commandData,
                        (string, uint256, uint256)
                    );
                _changeAPY(
                    newAnnualInterest,
                    newInterestPerSecond,
                    ibAlluoSymbol
                );
            }

Last updated