Elysia Tranche Pool
Spec
-
TranchePool
- Users cannot withdraw & redeem in the live status.
-
Roles
- Protocol Admin has a DEFAULT_ADMIN_ROLE of contracts
- Each contract has a manager
-
Pausable
- These functions are possible when
portfolio
is not paused- Portfolio: start, closeSenior, closeEquity, addLoan, fundLoan, repayLoan, repayDefaultedLoan, markLoanAsDefaulted.
- TranchePool: deposit, mint, withdraw, redeem
- These functions are possible when
Dev Notes
- It is only periphery contracts where users interact that inherit
Context
. - An equity tranche always lies in
tranches[0]
to find the equity tranche easily regardless of the number of tranches.
Test
forge test
# coverage report
forge coverage
Naming conventions
To distinguish between the function name in the test name and the actual use of the function, we uses Pascal case for the function name in the test name.
function test_Foo() public {
foo();
}
Deploy
# 1. create .env
cp .env.example .env
# 2. Fill out .env
# 3. Deploy
source .env
yarn hardhat deploy --network bsc_testnet
yarn hardhat etherscan-verify --network bsc_testnet --api-key $BSCSCAN_API_KEY
Openzeppelin defender
BSC Testnet https://defender.openzeppelin.com/#/autotask/6f72f14e-83d6-4716-a4aa-0204f9d2c613
yarn defender-autotask update-code 6f72f14e-83d6-4716-a4aa-0204f9d2c613 ./autotask/update-exchange-rate
BSC
yarn defender-autotask update-code 70413fb3-d05d-46f3-8730-9dae58e86639 ./autotask/update-exchange-rate
Upgrade Portfolio contract
# 1. Validate upgrade
yarn hardhat run scripts/validate-upgrade-startPortfolio.ts --network bsc_testnet
# 2. Comment out skip option in `deploy/07-UpgradeablePortfolio.ts`
# 3. Execute upgrade
yarn hardhat deploy --network bsc_testnet --tags Portfolio
Static analysis
mythx
pip install mythx-cli
export MYTHX_API_KEY=
mythx analyze
Solither
pip3 install slither-analyzer
slither .
# or
slither . > output.txt 2>&1
Docs
forge doc
Manuals
Deposit
yarn hardhat deposit --network bsc_testnet --amount 70000000000000000000000 --tranche senior
Start portfolio
yarn hardhat portfolio:start --network bsc_testnet
Repay a loan
1. uint256 debtAmountInUSD = fixedInterestBulletLoans.expectedRepayAmount(loanId)
2. usdt.approve(address(portfolio), debtAmountInUSD)
3. portfolio.repayLoan(loanId)
Addresses
BSC Mainnet
Contracts | Address |
---|---|
ProtocolConfig | 0x81cbfbad416d0c1336d32b20d099138ba28a1b14 |
CurrencyConverter | 0xeD8Fa605dAc543F733d8791fc8D1724bd14598c3 |
DepositController | 0x0846956F3451f84e37682D3450C37415A92f4530 |
WithdrawController | 0x4A792B48CEA2A6a9dc07960A9c79DaF657D2DB71 |
FixedInterestBulletLoans | 0x30cE372a51058aC08C57574ee8e7FcC940823Bb5 |
OrderController | 0x50E4CfC351916d4887B1d2892212863Ab86C62B0 |
Portfolio | 0x924B375Ea2E8f1F2E686E53823748C7C29ad6466 |
EquityTranche | 0x9DD2eD12bB25e79A1DD4b66c76a3067638E5D749 |
SeniorTranche | 0xeaE15c522700498895F4Ffc5Dad539E3FcF141FE |
- Exchange rate Autotask: https://defender.openzeppelin.com/#/autotask/70413fb3-d05d-46f3-8730-9dae58e86639
BSC Testnet
Contracts | Address |
---|---|
ProtocolConfig | 0x96607B297Ef79935912d5c0711A371a8Bc663E2c |
CurrencyConverter | 0x9DEDdABdA5Df821906A8e2b80FC820825d7AB022 |
DepositController | 0xe6F2e4009a9633230975Bf2923563E50c91824d0 |
WithdrawController | 0xcd91E5F86E221A43Ed568A2EEe11Ec33f846f05B |
FixedInterestBulletLoans | 0x4B1B1BC012f63B08bbFeA11fF37f003d1006f12a |
OrderController | 0x6099256Ed184b976C13f5b9778EBE262d542aA2C |
Portfolio | 0xDbdd1a9868db25300b6a0EDF4a43D7bBf5D85113 |
EquityTranche | 0x3d645f1dFf6107BFFB4913EdEc7e914aEF7D6715 |
SeniorTranche | 0x0505aC8DBca0d198a2CA0edd99EEe496717fF419 |
- Exchange rate autotask: https://defender.openzeppelin.com/#/autotask/6f72f14e-83d6-4716-a4aa-0204f9d2c613/edit-settings
Status Live
Contracts | Address |
---|---|
FixedInterestBulletLoans | 0xA804bfccc7d57999856c7Ae58F70ce6A3D3E75e9 |
OrderController | 0x264b6c52DfDeaB92196C725b024fa2e110f20204 |
Portfolio | 0x06eC9F7341Cf7cda72ff8F1Ecbf353B70d94792B |
EquityTranche | 0xaFCBb0451E0a00676B762DaA9885b248F3E1CD48 |
SeniorTranche | 0x16678a4B5Ba8722C8230E881D81096947165dbe8 |