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

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

  • Exchange rate Autotask: https://defender.openzeppelin.com/#/autotask/70413fb3-d05d-46f3-8730-9dae58e86639

BSC Testnet

ContractsAddress
ProtocolConfig0x96607B297Ef79935912d5c0711A371a8Bc663E2c
CurrencyConverter0x9DEDdABdA5Df821906A8e2b80FC820825d7AB022
DepositController0xe6F2e4009a9633230975Bf2923563E50c91824d0
WithdrawController0xcd91E5F86E221A43Ed568A2EEe11Ec33f846f05B
FixedInterestBulletLoans0x4B1B1BC012f63B08bbFeA11fF37f003d1006f12a
OrderController0x6099256Ed184b976C13f5b9778EBE262d542aA2C
Portfolio0xDbdd1a9868db25300b6a0EDF4a43D7bBf5D85113
EquityTranche0x3d645f1dFf6107BFFB4913EdEc7e914aEF7D6715
SeniorTranche0x0505aC8DBca0d198a2CA0edd99EEe496717fF419
  • Exchange rate autotask: https://defender.openzeppelin.com/#/autotask/6f72f14e-83d6-4716-a4aa-0204f9d2c613/edit-settings

Status Live

ContractsAddress
FixedInterestBulletLoans0xA804bfccc7d57999856c7Ae58F70ce6A3D3E75e9
OrderController0x264b6c52DfDeaB92196C725b024fa2e110f20204
Portfolio0x06eC9F7341Cf7cda72ff8F1Ecbf353B70d94792B
EquityTranche0xaFCBb0451E0a00676B762DaA9885b248F3E1CD48
SeniorTranche0x16678a4B5Ba8722C8230E881D81096947165dbe8