Contracts Explained

Smart contract architecture

We will have 3 smart contracts to start:

  • Oracle

  • SharedDeposit

  • CoinYieldCoin (ERC20) (CY-USDT) (Mintable/burnable)

The oracle contract will be updated by admins to represent yield earned off-chain via our algorithmic trader

Oracle

An oracle contract is used as a data feed of price changes to track performance on chain

Method name

Description

getPrice

Returns the price per share

setPrice

Admin only function to set the price per share

PriceSet(Event)

setPrice emits this event to create a historical record of price changes

SharedDeposit

A contract for users to deposit funds into that will be used by the coinyield algorithmic trader.

When a user deposits funds, the contract will mint CY-USDT based on the pricePerShare

Therefore users that come later will get less CY-USDT for their USDT

When the user withdraws, likewise the contract will use the pricePerShare to reward them

Method name

Description

deposit

Accepts USDT deposits from users and mints CY-USDT

withdraw

Allows user to burn CY-USDT to redeem deposit

stakeForWithdraw

If the contract is empty, users can stake their CY-USDT in it to signal intent to withdraw

pricePerShare

View - Uses the oracle to set a dynamic price for CY-USDT based on algo gains

adminFee

View - Initially a 0% management fee. Deducted on deposit

setAdminFee

Set a management fee

sendFunds

Sends user deposited funds to Binance or Okex for the algorithmic trading

totalDeposits

View - Total deposited into the platform

epoch

Current epoch

Basic flow:

  • User deposits 1000 USDT with pricePershare = 1, thus getting 1000 CY-USDT at time T0

  • An admin calls sendFunds, depositing user funds into algo trader managed Binance or Okex account

  • Algo trader executes trades against the funds to realize gains

  • One month later, the user uses stakeForWithdraw to signal their intent to withdraw gains by staking their CY-USDT

  • Imagine the algo trader realized a 40% APY, representing 3.33% over the month

  • The oracle is updated from a pricePerShare of 1 to 1.0333

  • The admins return 1033.33 USDT to the contract

  • The user can now burn 1000 CY-USDT to redeem 1033.33 USDT

  • New users will need to deposit 1033.33 USDT to receive 1000 CY-USDT

Last updated