Skip to content

LienFinance/bondmaker

Repository files navigation

Overview

This repository has 3 components.

  1. BondToken
  2. Generalized Decentralized OTC
  3. Bondshape detection and Pricing function

1. Bond Token

What is Bond Token?

  • 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.

BondToken implementation

Explanation_bm_bt Explanation_bm_bt (1) Explanation_bm_bt (2)

life-cycle of LBT

lienarch (1)

Changes from last audit

  1. 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
  2. Add ERC20 BondMaker that enables tranching ERC20-token cashflow. User can create put options by tranching stablecoins like USDC.

Contracts related to BondToken

  • 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.

2. Generalized Decentralized OTC(GDOTC)

What is Generalized Decentralized OTC?

  • 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.

Advantages of Generalized Decentralized OTC

  1. 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.
  2. No slippage depends on the depth of the liquidity User can exchange BondToken at theoretical price (+ spread) calculated by Pricing contract.
  3. Fund efficiency In AMM, most of token depositted by LP are not used for exchange, but GDOTC can use liquidity more efficiently.

Workflow of Generalized Decentralized OTC

GDOTC

requirement (important)

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

3. Bondshape detection and Pricing function

How they work?

  • 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.

4 types of bond shape

Shape1 Shape2

Pricing bonds

Pricing1 Pricing2

Test

yarn
yarn start-ganache
yarn test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published