This document presents a mini DeFi project centered around a primary smart contract, Treasury.sol.
The contracts are being deployed to Arbitrum
. The testing of the contracts has been done forking the Arbitrum chain. The integrated pools and protocol for executing the swaps is Sushiswap
.
You should include an .env
file with PRIVATE_KEY
refering to your account private key.
The deployed Treasury
address is: 0x79efC7932cc9EdB8D0d3D7D5fab95e0B77f09859
The integrated pools are:
USDT/USDC.e
:0x8165c70b01b7807351EF0c5ffD3EF010cAbC16fB
.USDT/MIM
:0xB7a2F46B196DeCB610a3046053f757264AcF0537
.
The protocol comprises three primary functionalities:
- Users have the ability to directly exchange tokens from their wallets and subsequently receive the exchanged tokens back into their wallets by invoking the
swapTokens
function. - Users can deposit any type of ERC20 token into the treasury by calling the
deposit
function, their balance is saved in a mapping calleduserBalance
. Each user can also swap their internal contract balance by callingswapInternalBalance
. - The most important functionality: The
Treasury
contract can receiveStableCoin
funds, which has been deployed as USDT in Arbitrum. Users can deposit stableCoin by callingdepositStableCoinForDistributeInPools
. This funds are being accumulated in the contract and counted in thestableCoinBalanceForPools
variable. Then this funds can be used for adding liquidity to theUSDT/MIM
andUSDT/USDCe
pairs in SushiSwap.
TO DO: The addLiquidity and removeLiquidity functions should implement and access modifier if it is wanted to. It would be also a good idea to implement some logic for swapping assets back to StableCoin
after removing liquidity.
Here are some diagrams for each funcitonality: