---
# System prepended metadata

title: Consortium

---

# Consortium

A project for the Web3 ATL hackathon.

## Summary
- We implement a new financial primitive on DeFi called Consortium (based on brazilian Consorcio, see refs below). 
- This product is wildly popular in Brazil as a financing mechanism, since interest rates there are normally high (currently ~ 12% per annum) thus represents an interesting alternative to house (or car) mortgages.
    - Another reason why this is interesting is because it allows depositors to accrue interest with leverage (more details below), just like with a mortgage but with smaller interest rates

References:
- https://www.quora.com/How-does-consorcio-planned-purchase-program-in-Brazil-work
- https://lauder.wharton.upenn.edu/wp-content/uploads/2015/06/Consorcios_and_Brazils_Consumer_Credit_Innovation.pdf

## Consortium smart contracts on Arbitrum Stylus

ToDo:
- (Revest on Arbitrum) Controller + TokenVault
- (Chainlink) Chainlink integration (VRF + (optional) function for calling Controller at pre-defined intervals))
- (Frontend) Frontend integration (calls Controller)


Controller's Functions:
- payInstallment() payable
    - User transfers X USDC (or DAI) to the smart contract
- executeLottery() onlyOwner
    - Called every month by owner
    - Calls Chainlink VRF and determines a winner (== *luckyUser*)
    - Updates balance of *luckyUser*

- Scripts (using Hardhat or Foundry):
    - How can userA withdraw funds from smart wallet created by tokenVaultV2
    - Run user flow to the end, print balances in betweem

## Revest finance vaults

2 smart contracts:
    - Controller implements IController
    - TokenVaultV2 implements ITokenVault (see tests for deployment) - tests use Foundry

How it works:
- 10 users deposit 100 USDC each at time t=0 into Controller (total 1000 USDC - these are the monthly installments
    - User also stakes some money as collateral for the case he doesn't pay all the remaining installments (or we can have an NFT representing the house that can get pulled back if installments are not paid)
    - Controller deposits 1000 USDC into Aave,
receives 1000 aUSDC (yield-generating tokens) back
    - 1000 aUSDC are deposited into  TokenVaultV2
- After 20 days, a lottery occurs
    - Controller calls Chainlink VRF, determines userA is the winner. He should receive 500 USDC (arbitrary amount). -> Use FNFT more interesting
    - (Revest input) "They are mostly interested in seeing a. new locking mechanisms and b. FNFT use cases, where users get an NFT (claim on future assets (e.g. you can withdraw 100 USDC in a week, but now it's locked) or future earnings) 
    
     " Deposit and get NFT back, controller burns/mints NFTs instead of working directly with tokens
    - Scope: implement locking mechanism as part of the idea
    - Each user will win the lottery exactly once.
	- TokenVaultV2 creates a new smart wallet (see example https://revest-finance.gitbook.io/revestv2-developer-documentation/smart-contracts/itokenvault) for userA. Only userA is able to withdraw tokens if he wishes, else it stays there accruing value.
- Now another monthly installment should be paid. Controller again receives 1000 USDC, interacts with Aave, get 1000 aUSDC, transfers these to tokenVaultV2. This happens monthly.
- After the maturity has passed (let's imagine 12 months), then all remaining aUSDC should be distributed to users equally (this should occur, as aUSDC is a rebasing token)


## Yield source
    Aave - see above

## Chainlink integration
    - VRF for lottery
    - (Optional) We want a CRON-like trigger for starting lotteries in the contract.
        - If too complicated, we can trigger things manually.
 
## ToDos

- Chainlink (Michael)
    - Mock VRF function
    - Real VRF function (after Chainlink's office hours)
- Revest Finance
    - Deploy Revest infra on Arbitrum (see Foundry [script](https://github.com/Revest-Finance/RevestV2-Public/blob/master/script/RevestV2_deployment.s.sol))
    - Controller (implements IController)
        - Lottery logic
            - This should involve minting FNFT with address-based locking mechanism
        - Aave integration
        - WithdrawAtMaturity() - allows users to withdraw funds at maturity
        - WithdrawLotteryPrize() - allows users to withdraw their prize, otherwise it keeps accruing value (locked in the FNFT)
- Hardhat
    - Write some scripts for testing the contracts
        - Controller
        - Chainlink contract (call VRF)
- Frontend
    - Call the Controller contract
    - Allow people to pay installment
    - Allow people to withdraw prizes
    - Display balance of each user
- Financial modelling
    - See TG chat
- Pitch
    - Danny