Aggregator Contract
The Aggregator Contract implements the functions required in the Aggregator Interface.
Additionally, it implements state variables for the management of markets across multiple Auctioneers, tracking whitelisted Auctioneers.
The Aggregator contract keeps a unique set of market IDs across multiple Tellers and Auctioneers. Additionally, it aggregates market data from multiple Auctioneers in convenient view functions for front-end interfaces.
Methods
currentCapacity
Returns current capacity of a market
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
Returns
Name | Type | Description |
---|---|---|
capacity | uint256 | Current capacity of the market |
findMarketFor
Returns the market ID with the highest current payoutToken payout for depositing quoteToken
Parameters
Name | Type | Description |
---|---|---|
payout_ | address | Address of payout token |
quote_ | address | Address of quote token |
amountIn_ | uint256 | Amount of quote tokens to deposit |
minAmountOut_ | uint256 | Minimum amount of payout tokens to receive as payout |
maxExpiry_ | uint256 | Latest acceptable vesting timestamp for bond Inputting the zero address will take into account just the protocol fee. |
Returns
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
getAuctioneer
Get the auctioneer for the provided market ID
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
Returns
Name | Type | Description |
---|---|---|
auctioneer | contract IBondAuctioneer | Address of the auctioneer that provides the market |
getTeller
Returns the Teller that services the market ID
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID |
Returns
Name | Type | Description |
---|---|---|
teller | contract IBondTeller | Address of the teller that services the market |
isInstantSwap
Does market send payout immediately
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | Market ID to search for |
Returns
Name | Type | Description |
---|---|---|
isInstant | bool | Whether the market is instant swap (true) or has vesting of the payout (false) |
isLive
Is a given market accepting purchases
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of market |
Returns
Name | Type | Description |
---|---|---|
isLive | bool | Whether the market is accepting purchases |
liveMarketsBetween
Returns array of active market IDs within a range
Should be used if length exceeds max to query entire array
Parameters
Name | Type | Description |
---|---|---|
firstIndex_ | uint256 | Start index of market range |
lastIndex_ | uint256 | End index of market range |
Returns
Name | Type | Description |
---|---|---|
ids | uint256[] | IDs of markets |
liveMarketsBy
Returns an array of all active market IDs for a given owner
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | Address of owner to query by |
Returns
Name | Type | Description |
---|---|---|
ids | uint256[] | IDs of markets |
liveMarketsFor
Returns an array of all active market IDs for a given quote token
Parameters
Name | Type | Description |
---|---|---|
token_ | address | Address of token to query by |
isPayout_ | bool | If true, search by payout token, else search for quote token |
Returns
Name | Type | Description |
---|---|---|
ids | uint256[] | IDs of markets |
marketCounter
Counter for bond markets on approved auctioneers
Returns
Name | Type | Description |
---|---|---|
nextId | uint256 | Next market ID to be assigned |
marketPrice
Calculate current market price of payout token in quote tokens
Accounts for debt and control variable decay since last deposit (vs _marketPrice())
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of market |
Returns
Name | Type | Description |
---|---|---|
price | uint256 | Price for market (see the specific auctioneer for units) |
marketScale
Scale value to use when converting between quote token and payout token amounts with marketPrice()
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of market |
Returns
Name | Type | Description |
---|---|---|
scale | uint256 | Scaling factor for market in configured decimals (see auctioneer for units) |
marketsFor
Returns an array of all active market IDs for a given payout and quote token
Parameters
Name | Type | Description |
---|---|---|
payout_ | address | Address of payout token |
quote_ | address | Address of quote token |
Returns
Name | Type | Description |
---|---|---|
ids | uint256[] | IDs of markets |
marketsForPayout
Market IDs for payout token
Parameters
Name | Type | Description |
---|---|---|
payoutToken_ | address | Address of payout token |
Returns
Name | Type | Description |
---|---|---|
ids | uint256 | IDs of markets |
marketsForQuote
Market IDs for quote token
Parameters
Name | Type | Description |
---|---|---|
quoteToken_ | address | Address of quote token |
Returns
Name | Type | Description |
---|---|---|
ids | uint256 | IDs of markets |
marketsToAuctioneers
Auctioneer for Market ID
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of market |
Returns
Name | Type | Description |
---|---|---|
auctioneer | contract IBondAuctioneer | Auctioneer that provides market |
maxAmountAccepted
Returns maximum amount of quote token accepted by the market
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of market |
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. |
Returns
Name | Type | Description |
---|---|---|
amountIn | uint256 | Max amount of quote token that can currently be exchanged with the market |
payoutFor
Payout due for amount of quote tokens
Accounts for debt and control variable decay so it is up to date
Parameters
Name | Type | Description |
---|---|---|
amount_ | uint256 | Amount of quote tokens to spend |
id_ | uint256 | ID of market |
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. |
Returns
Name | Type | Description |
---|---|---|
payout | uint256 | amount of payout tokens to be paid |
registerAuctioneer
Register a auctioneer with the aggregatorOnly Guardian
A auctioneer must be registered with an aggregator to create markets
Parameters
Name | Type | Description |
---|---|---|
auctioneer_ | contract IBondAuctioneer | Address of the Auctioneer to register |
registerMarket
Register a new market with the aggregatorOnly registered depositories
Parameters
Name | Type | Description |
---|---|---|
payoutToken_ | contract ERC20 | Token to be paid out by the market |
quoteToken_ | contract ERC20 | Token to be accepted by the market |
Returns
Name | Type | Description |
---|---|---|
marketId | uint256 | ID of market |
Errors
Aggregator_OnlyAuctioneer
Last updated