[ARCHIVE] Developers
  • 📌Getting Started
  • Integrating with BarnBridge
  • Setting up your private testnet
  • Using our public testnet
  • Specs
    • DAO Specifications
    • SMART Yield Specifications
    • SMART Exposure Specifications
  • SMART Yield
    • Minting and Redeeming Junior Tranche tokens (ERC-20)
    • Minting and Redeeming Senior Tranche Tokens (ERC-721)
    • Originator Yield Oracle
    • Governance Token Harvesting
  • Resources
  • 📎Smart Contract Addresses
    • BarnBridge DAO
    • SMART Yield
    • SMART Alpha
    • Yield Farming
  • 📋GitHub Repos
  • 🔒Security Audits
  • 👥Discord Community
  • Unofficial Code Walkthrough - SMART Yield
  • Unofficial Code Walkthrough - SMART Exposure
  • Access Controls
Powered by GitBook
On this page
  • Overview
  • Minting Senior Tranche Bonds
  • Redeeming Senior Tranche Bonds
  • Senior Redemption Fees

Was this helpful?

  1. SMART Yield

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.

event BuySeniorBond(address indexed buyer, uint256 indexed seniorBondId, uint256 underlyingIn, uint256 gain, uint256 forDays);

Upon redemption, the user burns the ERC-721 token in exchange for the sum of the principal and the fixed yield, minus a fee.

event RedeemSeniorBond(address indexed owner, uint256 indexed seniorBondId, uint256 fee)

Minting Senior Tranche Bonds

To mint a senior tranche bond, the user must be able to secure a positive interest rate...

uint256 gain = bondGain(principalAmount_, forDays_);

require(
          gain >= minGain_,
          "SY: buyBond minGain"
        );

require(
          gain > 0,
          "SY: buyBond gain 0"
        );

require(
          gain < underlyingLoanable(),
          "SY: buyBond underlyingLoanable"
        );

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.

require(
            0 < forDays_ && forDays_ <= IController(controller).BOND_LIFE_MAX(),
            "SY: buyBond forDays"
        );
address buyer = msg.sender;

IProvider(pool)._takeUnderlying(buyer, principalAmount_);
IProvider(pool)._depositProvider(principalAmount_, 0);

SeniorBond memory b =
    SeniorBond(
            principalAmount_,
            gain,
            issuedAt,
            uint256(1 days) * uint256(forDays_) + issuedAt,
            false
    );

_mintBond(buyer, b);

emit BuySeniorBond(buyer, seniorBondId, principalAmount_, gain, forDays_);

return gain;

Redeeming Senior Tranche Bonds

address payTo = IBond(seniorBond).ownerOf(bondId_)

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.

uint256 payAmnt = seniorBonds[bondId_].gain.add(seniorBonds[bondId_].principal)
IBond(seniorBond).burn(bondId_);
IProvider(pool)._withdrawProvider(payAmnt, fee);
IProvider(pool)._sendUnderlying(payTo, payAmnt);

emit RedeemSeniorBond(payTo, bondId_, fee);

Senior Redemption Fees

Senior tranche bonds are charged a 5% fee on the fixed yield upon redemption.

uint256 fee = MathUtils.fractionOf(seniorBonds[bondId_].gain, IController(controller).FEE_REDEEM_SENIOR_BOND())

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.

payAmnt = payAmnt.sub(fee)
PreviousMinting and Redeeming Junior Tranche tokens (ERC-20)NextOriginator Yield Oracle

Last updated 4 years ago

Was this helpful?

... as well as select a maturity date within the approved range. (See: )

With these requirements met, the ERC-721 token can be minted with properties for principal amount, the fixed yield, and its maturity date. (See )

Senior tranche bonds can be redeemed by whomever holds the ERC-721 token upon maturity. (See: )

The ERC-721 token is burned upon redemption. (See: )

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 )

This fee is then directed to the address set as "feesOwner" in . In practice, this is the DAO's treasury address.

IController.sol
IProvider.sol
IBond.sol
IBond.sol
IProvider.sol
IController.sol