Developer Details
The nerdy code stuff
Roles
DEFAULT_ADMIN_ROLE: Can manage all other roles
AUCTIONEER_ROLE: Can create and manage bond markets
TOKEN_WHITELISTER_ROLE: Can whitelist new tokens for bonding
EMERGENCY_ADMIN_ROLE: Can pause/unpause the contract
Contract Interface
Administrative Functions
grantAuctioneerRole(address _auctioneer)
grantAuctioneerRole(address _auctioneer)
Grants the AUCTIONEER_ROLE to an address.
Requires DEFAULT_ADMIN_ROLE
Emits
RoleGranted
event
whitelistToken(address _token)
whitelistToken(address _token)
Adds a token to the whitelist of acceptable payout tokens.
Requires TOKEN_WHITELISTER_ROLE
Validates token implements IERC20Metadata
Adds token to
_payoutTokens
array
pauseContract()
/ unpauseContract()
pauseContract()
/ unpauseContract()
Emergency controls to pause/unpause contract operations.
Requires EMERGENCY_ADMIN_ROLE
Emits
ContractPaused
/ContractUnpaused
events
Market Creation & Management
newBond()
newBond()
Creates a new bond market with specified parameters:
payoutToken_
: Token to be distributed to bonders_quoteToken
: Token to be received from bonders_terms
: Array containing:[0] amountToBond: Total tokens available for bonding
[1] controlVariable: Scaling factor for price
[2] minimumPrice: Price floor
[3] maxDebt: Maximum debt ratio allowed
_vestingTerms
: Array containing:[0] bondEnds: Timestamp when bond expires
[1] vestingTerm: Duration of vesting in seconds
closeBond(uint256 _id)
closeBond(uint256 _id)
Closes an existing bond market early.
Only callable by original auctioneer
Returns remaining payout tokens to auctioneer
User Functions
deposit()
deposit()
Deposits quote tokens to receive vesting payout tokens:
_id
: Market identifieramount
: Amount of quote tokens to deposituser
: Address to receive the bond
Requirements:
Market must be live
Amount must meet minimum deposit
Total debt must not exceed maximum
redeem(uint256 _id, address user)
redeem(uint256 _id, address user)
Claims vested tokens from a bond:
Calculates claimable amount based on vesting schedule
Transfers available tokens to user
Updates bond record
Returns total amount redeemed
View Functions
bondPrice(uint256 id_)
bondPrice(uint256 id_)
Returns current price for a specific market
isLive(uint256 id_)
isLive(uint256 id_)
Checks if a market is active
calculateLinearPayout(address user, uint256 _bondId)
calculateLinearPayout(address user, uint256 _bondId)
Calculates currently claimable amount for a specific bond
Market Pricing
The bond price is determined by:
Control Variable (CV)
Debt Ratio
Minimum Price Floor
Formula:
The CV can be adjusted over time using the adjustment mechanism to target specific price levels.
Examples
Creating a New Market
Depositing Into a Bond
Redeeming Vested Tokens
Security Considerations
Slippage Protection
Users should verify expected output before depositing
Price can change between blocks
Token Approvals
Only approve exact amounts needed
Revoke approvals after use
Market Parameters
Verify control variables are reasonable
Check minimum price aligns with expectations
Events
ContractPaused(address indexed by)
ContractUnpaused(address indexed by)
newBondCreated(uint256 indexed id, address indexed payoutToken, address indexed quoteToken, uint256 initialPrice)
BondEnded(uint256 indexed id)
BondDeposited(address indexed user, uint256 indexed marketId, uint256 depositAmount, uint256 totalOwed, uint256 bondPrice)
QuoteTokensWithdrawn(uint256 indexed marketId, address indexed auctioneer, uint256 amount, uint256 daoFee)
Error Conditions
The contract will revert if:
Invalid role permissions
Market is closed or expired
Deposit amount too low/high
Maximum debt exceeded
Contract is paused
Token transfers fail
Invalid parameters provided
Best Practices
Always check
isLive()
before depositingMonitor debt ratio to understand pricing
Verify market parameters before participation
Use view functions to simulate outcomes
Consider gas costs during high network usage
Last updated