Developers
Search…
Minting and Redeeming Senior Tranche Tokens (ERC-721)
Please refer to the SmartYield.sol repo for code references made on this page.

Overview

SMART Yield relies on minting and burning ERC-721 tokens to keep track of outstanding claims on the senior tranche's ABOND variable.
Upon minting, the user secures an ERC-721 token with a specific principal amount, gain amount, and maturity.
1
event BuySeniorBond(address indexed buyer, uint256 indexed seniorBondId, uint256 underlyingIn, uint256 gain, uint256 forDays);
Copied!
Upon redemption, the user burns the ERC-721 token in exchange for the sum of the principal and the fixed yield, minus a fee.
1
event RedeemSeniorBond(address indexed owner, uint256 indexed seniorBondId, uint256 fee)
Copied!

Minting Senior Tranche Bonds

To mint a senior tranche bond, the user must be able to secure a positive interest rate...
1
uint256 gain = bondGain(principalAmount_, forDays_);
2
​
3
require(
4
gain >= minGain_,
5
"SY: buyBond minGain"
6
);
7
​
8
require(
9
gain > 0,
10
"SY: buyBond gain 0"
11
);
12
​
13
require(
14
gain < underlyingLoanable(),
15
"SY: buyBond underlyingLoanable"
16
);
Copied!
... as well as select a maturity date within the approved range. (See: IController.sol)
Currently, senior tranche bonds must be minted with a maturity date between 1 and 365 days out from purchase. Future governance votes can seek to extend this range.
1
require(
2
0 < forDays_ && forDays_ <= IController(controller).BOND_LIFE_MAX(),
3
"SY: buyBond forDays"
4
);
Copied!
With these requirements met, the ERC-721 token can be minted with properties for principal amount, the fixed yield, and its maturity date. (See IProvider.sol)
1
address buyer = msg.sender;
2
​
3
IProvider(pool)._takeUnderlying(buyer, principalAmount_);
4
IProvider(pool)._depositProvider(principalAmount_, 0);
5
​
6
SeniorBond memory b =
7
SeniorBond(
8
principalAmount_,
9
gain,
10
issuedAt,
11
uint256(1 days) * uint256(forDays_) + issuedAt,
12
false
13
);
14
​
15
_mintBond(buyer, b);
16
​
17
emit BuySeniorBond(buyer, seniorBondId, principalAmount_, gain, forDays_);
18
​
19
return gain;
Copied!

Redeeming Senior Tranche Bonds

Senior tranche bonds can be redeemed by whomever holds the ERC-721 token upon maturity. (See: IBond.sol)
1
address payTo = IBond(seniorBond).ownerOf(bondId_)
Copied!
Senior tranche bond holders are entitled to the sum of the principal and its fixed yield at either maturity or any time beyond.
Unredeemed senior tranche bonds continue to earn yield for the junior tranche.
1
uint256 payAmnt = seniorBonds[bondId_].gain.add(seniorBonds[bondId_].principal)
Copied!
The ERC-721 token is burned upon redemption. (See: IBond.sol)
1
IBond(seniorBond).burn(bondId_);
Copied!
With the ERC-721 token burned, the associated principal and yield are withdrawn from the senior tranche and returned to the redeemer, sans the redemption fee. (See IProvider.sol)
1
IProvider(pool)._withdrawProvider(payAmnt, fee);
2
IProvider(pool)._sendUnderlying(payTo, payAmnt);
3
​
4
emit RedeemSeniorBond(payTo, bondId_, fee);
Copied!

Senior Redemption Fees

Senior tranche bonds are charged a 5% fee on the fixed yield upon redemption.
1
uint256 fee = MathUtils.fractionOf(seniorBonds[bondId_].gain, IController(controller).FEE_REDEEM_SENIOR_BOND())
Copied!
For example, a $10,000 senior tranche bond that earns a fixed rate of 10% would be worth $11,000 at maturity and cost $50 to redeem, leaving the user with $10,950.
1
payAmnt = payAmnt.sub(fee)
Copied!
This fee is then directed to the address set as "feesOwner" in IController.sol. In practice, this is the DAO's treasury address.
Last modified 6mo ago