# 16. Triggers & Smart Contracts ###### tags: `Done`, `Functions`, `Smart Contracts` **Purpose:** * Understand what the triggers are in 3.Finance that interact with smart contracts and change the state of a users experience within the protocol. **Content:** > Definitions > References > Journeys ## Definitions * (*Definitions*) ## References This document relates specifically to the following documents: * https://hackmd.io/@3Fi-4-DeFi/3Fi-CompoundTokens * https://hackmd.io/@3Fi-4-DeFi/3Fi-Liquid-Tokens * https://hackmd.io/@3Fi-4-DeFi/3Fi-Collateral ## Journeys ### User State Transitions 1. When a new user joins the protocol, each of the app spaces will display their zero states as follows: * The **Dashboard** will display a zero summary state and two (2) widgets: The TVL widget and the NFT widget. * The TVL widget will reflect its zero state; prompting the user to make a deposit. On selecting this prompt the user will be directed to the 'Deposits' space. * The NFT widget will reflect its zero state; prompting the user to mint or buy 3Fi NFTs. On selecting the prompt 'Buy' users will be directed to Deposits / 3Fi tokens / Mint * As the user makes and or gains deposits, the TVL widget will update to reflect that deposit data. * As the user mints or purchases 3Fi NFTs, the NFT widget will update to reflect the sum of that users NFT emissions data. > * No further changes will occur to the dashboard during the MVP phase. > * Post MVP releases, the dashboard will change to include widgets relating to Money Apps added by the user via the Money App space. This will be described in further detail post MVP unless it is otherwise requested. 2. The **Deposits** space will display a zero summary state and the following deposit groups: * If the user has no compatible tokens to deposit, the cards will be divided into the groups: * **3Fi Collateral**, * **Compound deposits**, * **Liquid deposits**. * If the user has compatible tokens to deposit, the cards will be divided into the groups: * **3Fi Collateral**, * **Compound deposits**, * **Liquidity I can deposit**, * If the liquidity a user can deposit originates from the connected wallet, a prompt within the card will state: "**DEPOSIT** BALANCE TO GAIN 3.FINANCE BENEFITS AND PROTOCOL UTILITY." * If the liquidity a user can deposit originates from another protocol, a promt within the card will state: "**REROUTE** BALANCE TO GAIN 3.FINANCE BENEFITS AND PROTOCOL UTILITY." * **Other liquid opportunities**. * As the user makes or gains deposits into the compound and or liquid groups, the cards will be divided into the groups: * **3Fi Collateral**, * **Compound deposits**, * **My liquid deposits**, * **Liquidity I can deposit**, * If the liquidity a user can deposit originates from the connected wallet, a prompt within the card will state: "**DEPOSIT** BALANCE TO GAIN 3.FINANCE BENEFITS AND PROTOCOL UTILITY." * If the liquidity a user can deposit originates from another protocol, a promt within the card will state: "**REROUTE** BALANCE TO GAIN 3.FINANCE BENEFITS AND PROTOCOL UTILITY." * **Other liquid opportunities**. * Further; the summary state will update to reflect deposit data in each of the aforementioned groups. * When the user mints 3Fi tokens; this action will not effect change in the '**Deposits**' space, but it will effect change in the '**Emissions**' space. (See: 3Fi Collateral Wallets) * When the user mints 3Fi NFTs; this action will not effect change in the '**Deposits**' space, but it will effect change in other spaces depending on the power level of the NFT minted and or held in the connected wallet. See: https://hackmd.io/@3Fi-4-DeFi/3Fi-Permissions for more details. 3. The '**Emissions**' space will display a zero summary state and the following emission groups: * If the user has not yet made any deposits and is therefore not earning any emissions, the groups displayed will be: * **3Fi Collateral Wallets**, * **Compound emissions**, * **Liquid emissions**. * If the user has deposits and is earning emissions, the groups displayed will be: * **3Fi Collateral Wallets**, * **Compound emissions**, * **My liquid emissions**, * **Other liquid opportunities**. * If an emission has never been harvested, that emissions card will reflect the title: '**Collected**' and the balance collected. * If an emission is '**Claimed**' and has never harvested, that emissions card will continue to reflect the title: '**Collected**' and the balance collected. * Once an emission is '**Harvested**', that emissions card will display the '**Signal**' (icon) and the balance collected. * When a user mints or purchases 3Fi tokens and holds these in their connected wallet, the '**3Fi Collateral Wallet**' card will activate. * Once activated, the user will be able to explore this section. Emissions will NOT be directed to these wallets until a user mints and or purchases and holds 3Fi NFTs in their connected wallet. * When a user mints or purcahses 3Fi NFTs and holds these in their connected wallet, emissions will be auto-sold for CRV and credited (reflected) to the virtual CRV wallet. (Other virtual wallets will be revealed if or when the user changes the NFT emissions **Signal**) > **Note**: > This section needs to be revised with respect to UX and Design. These revissions will be supplied in due course. 4. As the **Money Apps** space is not due at MVP, notes for this space will follow in due course. ### Key Take Aways * There are two parallel environments in play: * An auto-compounding environment and; * An auto-consolodation environment * While the user holds deposits only; emissions are reflected in the '**Individual**' tab within the emissions space and are auto-compounded on harvest. * The user has direct control over their deposits. * When the user uses their compound deposit receipts to mint 3Fi tokens; only for those deposits locked in the 3Fi token smart contract; emissions are reflected in the '**Individual**' tab within the emissions space and are auto-compounded on harvest but; * The Smart Contract that manages the minting of 3Fi tokens has direct control over user deposits. * Special attention to security is needed here to ensure deposits are safe. For example; because there is a direct relationship between one 3Fi token and the deposits required to mint it, can we create: * An auto-check on withdraw request to ensure there is always a balanced ratio of 3Fi tokens to deposits? * auto-withdraw-pause if this ratio is ever violated? * For reference; There should always be the equivalent of one 'CVX' token and one 'BENT' token for every one '3Fi' token. > The above constitutes the limits of the auto-compound environment. > That is to say, the moment the user mints 3Fi NFTs, the environment changes from auto-compounding to auto-consolodation as follows: * When the user uses their 3Fi tokens and applicable compound deposit receipts to mint 3Fi NFTs; only for those deposits locked in the 3Fi NFT smart contract; emissions are reflected in the '**NFT Holder**' tab within the emissions space and are auto-consolodated on harvest. This is because; * The Smart Contract that manages the minting of 3Fi NFTs has direct control of all underlying assets and deposits. > **Notes**: > It could also be said that: >> The '**Individual**' tab reflects all that is auto-compounded >> The '**NFT Holder**' tab reflects all that is auto-consolodated >> Auto-consolodation means all emissions are sold for a single asset. (Default will be CRV, other options will be DAI and/or FRAX) END