IndexAvalanche.sol

The IndexAvalanche contract is an extension of the IndexStrategyUpgradeable contract and includes two additional functions: equityValuation and addSwapRoute.

Here are the key points of the smart contract:

  1. Inheritance: This contract inherits from the IndexStrategyUpgradeable contract, meaning that it has access to all public and internal functions and state variables declared in the IndexStrategyUpgradeable contract.

  2. equityValuation Function: The equityValuation function is used to calculate the equity valuation of the index. The function takes two boolean parameters, maximize and includeAmmPrice, and returns the equity valuation as an unsigned integer. Here are the steps involved:

    • It first retrieves the total supply of the index token.

    • If the total supply is zero, it returns zero.

    • It then calculates the unit amount of WNATIVE for the exact index precision.

    • It retrieves the price of WNATIVE based on the maximize and includeAmmPrice parameters.

    • Finally, it calculates the equity valuation by multiplying the unit amount of WNATIVE, the price of WNATIVE, and the total supply of the index token, and then divides the result by the product of the decimals and precision constants. This result is returned as the equity valuation.

  3. addSwapRoute Function: The addSwapRoute function is an external function that can only be called by the contract owner. It is used to add a new swap route for a token. The function takes four parameters, token (the address of the token), router (the address of the router), dex (the DEX type), and pair (the address of the pair). It creates a PairData struct with the pair address and zero for the binStep value and then calls the addSwapRoute function in the IndexStrategyUpgradeable contract with these parameters.

    It's important to note that this function allows the owner of the contract to add new swap routes, which can impact how tokens are swapped within the contract.

Last updated

About Brokkr

WebsiteXDiscord