DebtUsageExample

Git Source

Example contract showing how to use the debt instrument system

This demonstrates various debt scenarios and best practices

State Variables

assetDiamond

address public assetDiamond;

Functions

constructor

constructor(address _assetDiamond);

issueSimpleBond

Example 1: Issue a Simple Bond

  • Fixed rate, bullet payment at maturity

  • Interest accrues but is paid at maturity with principal

function issueSimpleBond(
    address creditor,
    address debtor,
    uint256 principal,
    uint256 annualRateBps,
    uint256 termMonths,
    address paymentToken
) external returns (uint256 debtId, bytes32 assetLotId);

issueAmortizingLoan

Example 2: Issue an Amortizing Loan

  • Monthly payments of principal + interest

  • Principal paid down over time

function issueAmortizingLoan(
    address creditor,
    address debtor,
    uint256 principal,
    uint256 annualRateBps,
    uint256 termYears,
    address paymentToken
) external returns (uint256 debtId, bytes32 assetLotId);

issueCorporateBond

Example 3: Issue a Corporate Bond with Quarterly Interest

  • Quarterly interest payments

  • Principal repaid at maturity (balloon)

function issueCorporateBond(
    address creditor,
    address debtor,
    uint256 principal,
    uint256 annualRateBps,
    uint256 termYears,
    address paymentToken
) external returns (uint256 debtId, bytes32 assetLotId);

makeDebtPayment

Example 4: Make a payment on debt

function makeDebtPayment(uint256 debtId, uint256 amount) external;

checkAmountDue

Example 5: Check what's due

function checkAmountDue(uint256 debtId)
    external
    view
    returns (uint256 principalDue, uint256 interestDue, uint256 totalDue, bool isOverdue);

getPayoffAmount

Example 6: Get full payoff amount

function getPayoffAmount(uint256 debtId) external view returns (uint256);

viewPaymentSchedule

Example 7: View payment schedule

function viewPaymentSchedule(uint256 debtId) external view returns (IDebtInstrument.PaymentScheduleItem[] memory);

transferDebtToNewCreditor

Example 8: Transfer debt to new creditor Note: This happens automatically when the asset lot is transferred

function transferDebtToNewCreditor(bytes32 assetLotId, address newCreditor, uint256 price) external;

getDebtorObligations

Example 9: Check debtor's obligations

function getDebtorObligations(address debtor) external view returns (uint256[] memory debtIds);

Last updated

Was this helpful?