This repository has 3 components.
- ETH/ERC20-backed structured bond, which returns ETH/ERC20 on the pre-specified maturity based on the price from the oracle and the strike price determined in the contract.
- The cashflow of the structured bond is represented by the piecewise linear function, which is a generalized definition of the strike price. ex)
- SBT, Strike Price: 100USD
- (x,y)= (0,0) (100,100) (200,100)
- Normal LBT, Strike price: 100USD
- (x,y)= (0,0) (100,0) (200,100)
- For the right outside the definition area, the rightmost line is extended to infinity. (To be precise, in order to reduce gas cost, the data is held as the value of slope in each domain on the piecewise linear function.)
- bondID
- It will be determined by the maturity and the piecewise linear function. If both of them are the same, ID is the same.
- bondGroup
- BondGroup is a group of bondIDs that can reproduce original ETH/ERC20 cashflow. Technically, it is verified by checking the sum of y axis values at each x axis point on the piecewise linear function equals to x axis value at each point.
- Fix bugs which occurred when a malicious user creates empty an bondgroup and runs
reverseBondToETH()
, they can withdraw all ETH deposited to bondMaker. More info - Add ERC20 BondMaker that enables tranching ERC20-token cashflow. User can create put options by tranching stablecoins like USDC.
- contracts/BondMaker.sol => This contract issues bond tokens from deposited ETH/ERC20.
- contracts/bondTokenName/BondTokenName.sol => This contract generate a bond token name from the bond properties.
- Exchange for buy/sell BondTokens. The price is determined by
(BondToken Theoretical price) * (1 + spread rate)
(Liquidity Provider can customize own spread rate) - Previous Decentralized OTC can deal with only Pure ETH call Option, but GDOTC can handle many shapes of Bonds collateralized by ETH or ERC20 token.
- Previous Decentralized OTC can exchange BondToken with only ERC20 like USDC, but we added BondToken vs BondToken pool and BondToken vs ETH pool.
- Low gas cost When exchange tokens, tokens are transferred from LP to user directly and there is no state writing. This contract processes only price calculation and token transfer.
- No slippage depends on the depth of the liquidity User can exchange BondToken at theoretical price (+ spread) calculated by Pricing contract.
- Fund efficiency In AMM, most of token depositted by LP are not used for exchange, but GDOTC can use liquidity more efficiently.
ERC20 which will be exchanged to LBT needs to be built with openzeppelin ERC20 code. https://docs.openzeppelin.com/contracts/3.x/api/token/erc20
- Bondshape Detection Contract classifies bonds in 5 types of bond, Pure SBT, SBT Shape, LBT Shape, Triangle and None. If None, Pricing contract gives up pricing and reverts transaction.
- Pricing contract calculates bonds price by combination of pure call option.
yarn
yarn start-ganache
yarn test