Oracle Fixed Discount Auctioneer (OFDA)
Oracle Fixed Discount Auctioneer allows market creators to sell tokens at a discount to a price provided by an oracle, likely in exchange for vesting the tokens over a certain amount of time. Typically, longer duration vesting will require a larger discount. Additionally, larger discounts may be required for smaller cap tokens or when market demand is low. Unlike the SDA auction variants, it will not adjust price to sell out the capacity over the duration.
Market creators can also set a minimum total discount from the starting price, which creates a hard floor for the market price.
The below chart shows a notional example of how price might evolve over an OFDA market.
The Base OFDA contract has the following data structures, variables, and methods.
Data Structures (Structs)
MarketParams
Parameters to create a new OFDA market. Encoded as bytes and provided as input to createMarket
.
Field | Type | Description |
---|---|---|
payoutToken | ERC20 (address) | Payout Token (token paid out by market and provided by creator) |
quoteToken | ERC20 (address) | Quote Token (token to be received by the market and provided by purchaser) |
callbackAddr | address | Callback contract address, should conform to |
oracle | IBondOracle (address) | Oracle contract address, must conform to |
fixedDiscount | uint48 | Fixed discount (%) of the market from the oracle price. Units are a percent with 3 decimals of precision (e.g. |
maxDiscountFromCurrent | uint48 | Max Discount (%) from the oracle price when the time the market is created. Sets a minimum price for the market. Units are a percent with 3 decimals of precision (e.g. |
capacityInQuote | bool | Is Capacity in Quote Token? |
capacity | uint256 | Capacity (amount in quote token decimals or amount in payout token decimals). Set |
depositInterval | uint48 | Target deposit interval for purchases (in seconds). Determines the |
vesting | uint48 | Is fixed term ? Vesting length (seconds) : Vesting expiry (timestamp). A 'vesting' param longer than 50 years is considered a timestamp for fixed expiry |
start | uint48 | Start time of the market as a timestamp. Allows starting a market in the future. If provided, the transaction must be sent prior to the start time. If not provided, the market will start immediately. |
duration | uint48 | Duration of the market in seconds. |
BondMarket
BondMarket contains the token, callback, capacity, owner, and purchased/sold amount data for a Oracle Fixed Discount Market.
BondTerms
BondTerms contains the oracle, pricing, and time parameters of an Oracle Fixed Discount Market.
Public Variables and View Methods
allowNewMarkets
Whether or not the auctioneer allows new markets to be created
Changing to false will sunset the auctioneer after all active markets end
authority
Roles authority contract for the bond system which managed access-control to permissioned functions.
callbackAuthorized
Whether or not the market creator is authorized to use a callback address
Parameters
Name | Type | Description |
---|---|---|
creator_ | address | Market creator address. |
currentCapacity
Returns current capacity of a market
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
getAggregator
Returns the Aggregator that services the Auctioneer
getMarketInfoForPurchase
Provides information for the Teller to execute purchases on a Market
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
Returns
Name | Type | Description |
---|---|---|
owner | address | Address of the market owner (tokens transferred from this address if no callback) |
callbackAddr | address | Address of the callback contract to get tokens for payouts |
payoutToken | contract ERC20 | Payout Token (token paid out) for the Market |
quoteToken | contract ERC20 | Quote Token (token received) for the Market |
vesting | uint48 | Timestamp or duration for vesting, implementation-dependent |
maxPayout_ | uint256 | Maximum amount of payout tokens you can purchase in one transaction |
getTeller
Returns the Teller that services the Auctioneer
isInstantSwap
Does market send payout immediately
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
isLive
Is a given market accepting deposits
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
marketPrice
Calculate current market price. Value returned is the number of quote tokens per payout token. The value is the oracle price scaled by the BondTerms.oracleConversion factor. marketPrice
and marketScale
can be used to convert between amounts of quote tokens and payout tokens at the current price.
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
marketScale
Scale value to use when converting between quote token and payout token amounts with marketPrice()
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
markets
Returns the token, callback, capacity, owner, and purchased/sold amount data for a market. See BondMarket.
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
maxAmountAccepted
Returns maximum amount of quote token accepted by the market
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
referrer_ | address | Address of referrer, used to get fees to calculate accurate payout amount. Inputting the zero address will take into account just the protocol fee. |
maxPayout
Calculate max payout of the market in payout tokens
Returns a dynamically calculated payout or the maximum set by the creator, whichever is less. If the remaining capacity is less than the max payout, then that amount will be returned.
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
minDepositInterval
Minimum deposit interval for a market
minMarketDuration
Minimum market duration in seconds
newOwners
New address to designate as market owner. They must accept ownership to transfer permissions.
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
ownerOf
Returns the address of the market owner
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
payoutFor
Payout due for amount of quote tokens at current market price
Parameters
Name | Type | Description |
---|---|---|
amount_ | uint256 | Amount of quote tokens to spend |
id_ | uint256 | Market ID |
referrer_ | address | Address of referrer, used to get fees to calculate accurate payout amount. Inputting the zero address will take into account just the protocol fee. |
terms
Information pertaining to oracle, pricing, and time parameters. See BondTerms.
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
State-Mutating Methods
closeMarket
Disable existing bond market. Must be market owner
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
createMarket
Creates a new bond market
See MarketParams for the required formatting for the abi-encoded input params.
Parameters
Name | Type | Description |
---|---|---|
params_ | bytes | Configuration data needed for market creation, encoded in a bytes array |
Returns
id_ | uint256 | Market ID |
pullOwnership
Accept ownership of a marketMust be market newOwner
The existing owner must call pushOwnership prior to the newOwner calling this function
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
purchaseBond
Exchange quote tokens for a bond in a specified market. Must be teller. End users interact with the Teller contract to purchase.
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
amount_ | uint256 | Amount to deposit in exchange for bond (after fee has been deducted) |
minAmountOut_ | uint256 | Minimum acceptable amount of bond to receive. Prevents front-running |
Returns
Name | Type | Description |
---|---|---|
payout | uint256 | Amount of payout token to be received from the bond |
pushOwnership
Designate a new owner of a marketMust be market owner
Doesn't change permissions until newOwner calls pullOwnership
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
newOwner_ | address | New address to give ownership to |
setAllowNewMarkets
Change the status of the auctioneer to allow creation of new markets
Setting to false and allowing active markets to end will sunset the auctioneer
Parameters
Name | Type | Description |
---|---|---|
status_ | bool | Allow market creation (true) : Disallow market creation (false) |
setCallbackAuthStatus
Change whether a market creator is allowed to use a callback address in their markets or not. Must be guardian
Callback is believed to be safe, but a whitelist is implemented to prevent abuse
Parameters
Name | Type | Description |
---|---|---|
creator_ | address | Address of market creator |
status_ | bool | Allow callback (true) : Disallow callback (false) |
setMinDepositInterval
Set the minimum deposit interval. Access controlled
Parameters
Name | Type | Description |
---|---|---|
depositInterval_ | uint48 | Minimum deposit interval in seconds |
setMinMarketDuration
Set the minimum market duration. Access controlled
Parameters
Name | Type | Description |
---|---|---|
duration_ | uint48 | Minimum market duration in seconds |
Events
MarketClosed
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Market ID |
MarketCreated
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Market ID |
payoutToken | address | Address of the payout token |
quoteToken | address | Address of the quote token |
vesting | uint48 | Vesting duration or timestamp |
Errors
The following custom errors are used in the OFDA contract to denote specific revert conditions. The errors are prefixed with "Auctioneer" to denote that it is within this contract when multi-contract actions are performed (such as buying a bond).