# ReFi DeFi Mash ## Narrative - dedollarization - we need real world assets - environmental assets (link / screenshot of sources -> rating agencies, big4 ...) - https://cointelegraph.com/news/de-dollarization-is-it-really-happening - however, we still need stable assets to execute daily operations - DeFi surges 444% after SEC-CEX troubles: https://cointelegraph.com/news/defi-volumes-surge-after-binance-coinbase-lawsuits-finance-redefined - now is the time for ReFi ## Flow Alice, based in New York, decided to buy Ecological assets for $120k, which will be used to impact investment of new New York Green City Project: - `SCC`: Sky Scrapper Cow - bring farms to the top of NYC sky scrappers. - `MilkyWay` - new fresh water river in NYC. - `FucSEC` - project related alternative means of payment. She wants to keep them as a long term investment. However, she doesn't want to lock the value. Lending systems allow to take long positions and unlock the value. Alice enters the `ReFiUmee` system, which has the `ReFi Leverage` lending pool and integrates with the vast Gho Aave inter-chain facilitator. She supplies and collaterizes the ReFi tokens at `ReFiUmee`. Then she leverages her position and borrows `100k Gho`. Aave inter-chain facilitator validates the request from the `ReFiUmee` using Axelar bridge, and mints `Gho` to Alice in the Optimism layer-2. In the meantime a new bull market started. She used `50k` of liquid `Gho` to purchase optimistic, shit NFTs. Optimism is the new them of the bull run and she managed to sell them for `300k` making `250k`. The whole `ReFi Leverage` module is designed to get Gho and leverage ReFi assets. The fees are extreamly low, because she borrows from the system, rather than another liquidity provider. The fee is used only to compensate the risk, and will depend on the market conditions and system performance. At the beginning the fee is set to 1% / year. 3 years later, Alice decides to close her position. Her collateral is worth now `$200k`, the interest she had to pay is `100k (1.01**3 - 1) = 3.03k`. In summary, she was able to keep her long position with ecological assets: initial purchase of `120k` worth of `SCC, MilkyWay` and `Fuc*SEC` , she was able to use `100k` liquid `Gho`. At the end she has `250k - 100k - 3.03k = 146.07k Gho` and liquid (uncollaterized) `A, B, C` eco credits. Soon after that the market wants to celebrate the success of the _New York Green City Project_ and provides a way to bundle the ReFi tokens into an immortal _optimistic green_ NFT. Her NFT is worth `400k`. The Green City project has just been completed, and now she enjoys her city even more, breathing a fresh air :smiley: ## Aave ### Facilitator FACIL contract spec ```solidity //uint256 _mint_limit = 1_000_000; //uint256 _minted = 0; address _gho; address _aave_gov; function on_axelar_gmp(account addres, amount uint256) onlyBridge { // check if we don't pass the mint_limit -- _gho.mint() does validation logic too, do we need it here? // call _gho.mint to the address and amount _gho.mint(address, amount); } function update_mint_limit(uint256 mint_limit) onlyBridge { assert msg.sender == _aave_gov; // sets _mint_limit = mint_limit; // does not validate the new value (eg if !=0) _gho.setFacilitatorBucketCapacity(address(this), mint_limit); } // I think we don't need it because the contract itself is facilitator function add_faciliator(uint mint_limit, string label) { _gho.addFacilitator(address(this), label, mint_limit); } } ``` ### Aave GhoToken GHO contract: - FACILITATOR_MANAGER = contract above ? - BUCKET_MANAGER = contract above How to call: 1. deploy GhoToken gho & set an address we control to admin 2. call from admin gho.grantRole(FACILITATOR_MANAGER_ROLE, FACIL), or whichever account we set 3. call from admin gho.grantRole(BUCKET_MANAGER, FACIL), or whichever account we set 4. call from FACILITATOR_MANAGER_ROLE gho.addFacilitator(FACIL, label, mint_limit) => FACIL.add_faciliator() 5. now gho.mint() is only successful from our FACIL contract :) 6. to change mint_limit: call from BUCKET_MANAGER gho.setFacilitatorBucketCapacity(new_limit) => FACIL.update_mint_limit() code: https://github.com/ReFi-DeFi-hack-ethprague-2023/gho-refi-faciliator/blob/e9804c1526e47bd52a2f711ca15d758023a78d49/src/contracts/gho/GhoToken.sol currently deployed on optimism testnet : 0x83eCdb25F2E678baEEEBC814D35Fa7528A676792 ### Burn 1. User approves facilitator for burn amount 2. User calls burn(): a. Facilitator transferFrom Gho from user to itself b. send burn message over Axelar birdge This way the burn happens in one atomic transaction. ## Axelar bridge - Send message from native chain to evm (optimism chain) - GMP: specify `destination_chain`: "optimism", `destination_address` (contract address) and `message` - Send above message using ibc to axelar testnet address `axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5s` - We will need to run relayer from refi chain to axelar testnet chain - https://docs.axelar.dev/dev/general-message-passing/cosmos-gmp#messages-from-native-cosmos - Test tx: https://testnet.axelarscan.io/gmp/search - https://testnet.axelarscan.io/gmp/D0809072D2F1F3AFF74CA8E9C61091082EF8F7027CC88149497920AD08B3456D - Payload for call ``` Enocde the payload in Solidity and call the Axelar gateway. Axelar will build the CosmWasm contract call from the ABI-encoded payload uint32 version = 1; string[] memory dynamicParamArray = new string[](1); dynamicParamArray[0] = "greeting"; string[] memory dynamicTypeArray = new string[](1); dynamicTypeArray[0] = "string"; bytes memory payload = abi.encodePacked( bytes4(version), abi.encode( "hello_world", dynamicParamArray, dynamicTypeArray, abi.encode("hello!") ) ); ```` ## ReFi Assets * NCT (nature carbon tonne) / toucan * Green City * moss.earth * flowcarbon (dunno if live? ) *