Alluo Explained
  • Welcome
    • 🧭 The Basics
  • Getting Started
    • πŸ’» The DeFi Web App
      • ❓ Connecting to the app
      • 🚜 Depositing into the farms
      • πŸ™Œ Other basics
      • 🏦 Importing your Mobile app wallet to Metamask
      • 🧬 Add the polygon network manually in Metamask.
      • ⛓️ Bridging Stablecoins from another chain
    • πŸ“±The Mobile app
      • πŸ—οΈ Setting up your account
      • 🏦 Depositing money into the app
      • πŸ™Œ Other basics
      • πŸ” Exporting your private key
    • πŸ“–Tech deep dive: Contract Address Library
  • Understanding Alluo
    • πŸ’΅ How does Alluo get the yield?
      • 🐰 Going deeper into the Alluo protocol rabbit hole
    • 🧐 FAQ
  • Tokens & Tokenomics
    • πŸͺ™ The tokens
    • πŸ‘¨β€πŸ”¬Tech deep dive: Interest Bearing {asset} token
      • Depositing
      • Withdrawals
      • IbAlluo on different chains
      • StIbAlluo and Superfluid
        • A closer look at the integration between IbAlluo and StIbAlluo
      • Using the IbAlluo contract directly to create streams
      • Liquidity Handler and adapters
        • Deposit process with the Liquidity Handler
        • Withdraw process with the Liquidity Handler
    • πŸ“ˆ Tokenomics
    • πŸ‘¨β€πŸ”¬Tech deep dive: Boosting yield by compounding rewards
      • Deposit into the Vault
      • Withdraw from the Vault
      • Redeem rewards
      • Automatic boosting with Alluo
      • FraxConvex Vaults
      • Managing withdrawal requests in IERC4626
  • Decentralisation and Trust
    • πŸ—³οΈ Trustless governance and execution
    • πŸ‘¨β€πŸ”¬Tech deep dive: Vote Executor Architecture
      • Off chain votes to on chain data
      • Onchain data verifcation
      • Automated execution of votes
        • Tokenomics
        • Liquidity Direction
        • Setting APYs on farms
      • Cross chain execution of votes
      • Manually submitting vote results onchain
    • ↔️Alluo Exchange
      • Interacting with the Exchange
    • vlAlluo Architecture
    • Contracts upgrades
    • Investment strategies
      • πŸ“ˆFrax Convex Finance
        • Adding new pools into the strategy
        • Investing into a pool
  • More Advanced Features
    • πŸ” Repeat payments, streaming IbAlluo
  • Product Updates
    • πŸ‘Œ Product Roadmap: Building the right products
    • πŸ’» Web App releases
    • πŸ“± Mobile App releases
    • 🏎️ Alluo Boost
  • tutorial projects
    • Example: USDC to streaming 1 IbAlluo per second
    • Example: Using IbAlluoUSD and Ricochet to do capital efficient DCA into ETH
Powered by GitBook
On this page
  1. Tokens & Tokenomics
  2. Tech deep dive: Interest Bearing {asset} token
  3. StIbAlluo and Superfluid

A closer look at the integration between IbAlluo and StIbAlluo

Here we dive into the IbAlluo - StIbAlluo integration

Whenever tokens are burnt or transferred (any deduction from a user's IbAlluo balance, the IbAlluo.sol contract makes a check if the amount to be moved is greater than their current IbAlluo balance and whether it is possible to unwrap the difference from the StIbAlluo balance.

  • For example, a user has 50 IbAlluos and 50 StIbAlluos from a CFA. If they called the ERC-20 Transfer to another user for 70 IbAlluos, the IbAlluo contract unwraps 20 StIbAlluos and then carries out the transaction without reverting, even if they had 50 IbAlluos - leaving them with 0 IbAlluos and 30 StIbAlluos.

This is carried out through ERC777 methods implemented in the Super token interface as the IbAlluo is set as a default operator for the StIbAlluo contract. See the functions below.

IbAlluo.sol
function _burn(address account, uint256 amount) internal override {
         // If there are insufficient tokens in IbAlluo, check if we can
         // burn StIbAlluo instead and carry on. If insufficient, revert.
        if (amount > balanceOf(account)) {
            IAlluoSuperToken(superToken).operatorBurn(account, amount - balanceOf(account), "", "");
        }
        super._burn(account, amount);
    }

 function _transfer(address from, address to, uint256 amount) internal override {
         // Similar to the logic above
        if (amount > balanceOf(from)) {
            IAlluoSuperToken(superToken).operatorBurn(from, amount - balanceOf(from), "", "");
        }
        super._transfer(from, to, amount);
    }

Similarly, the two view functions above return the combined balance of IbAlluo and StIbAlluo a user has. getBalance() returns it in USD value, while combinedBalanceOf() returns it as a basic sum.

  • If you only want the balance of IbAlluos a user has, use the standard ERC-20 balanceOf() function.

/// @notice  Returns balance in asset value
/// @param _address address of user
function getBalance(address _address) public view returns (int256) {
    uint256 _growingRatio = changeRatio(
        growingRatio,
        interestPerSecond,
        lastInterestCompound
    );
    (int256 StIbAlluoBalance,,,) = IAlluoSuperToken(superToken).realtimeBalanceOfNow(_address);
    int256 fullBalance = int256(balanceOf(_address)) + StIbAlluoBalance;
    return (fullBalance * int256(_growingRatio) / int256(multiplier));
}

    
/// @notice  Returns combined StIbAlluo and IbAlluo balance 
/// @param _address address of user
/// @dev This is necessary for users with both IbAlluo and StIbAlluo balances so that the frontend and other contracts can accurately calculate balances.
function combinedBalanceOf(address _address) public view returns (int256) {
    (int256 StIbAlluoBalance,,,) = IAlluoSuperToken(superToken).realtimeBalanceOfNow(_address);
    return int256(balanceOf(_address)) + StIbAlluoBalance;
}

PreviousStIbAlluo and SuperfluidNextUsing the IbAlluo contract directly to create streams

Last updated 2 years ago

πŸ‘¨β€πŸ”¬
liquidity-direction-protocol/StIbAlluo.sol at StIbAlluo Β· GetAlluo/liquidity-direction-protocolGitHub
To read the lastest StIbAlluo code
liquidity-direction-protocol/IbAlluo.sol at StIbAlluo Β· GetAlluo/liquidity-direction-protocolGitHub
To read the latest IbAlluodcode
Logo
Logo