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

function currentCapacity(uint256 id_) external view returns (uint256)

Returns current capacity of a market

Parameters

NameTypeDescription

id_

uint256

Market ID

Returns

NameTypeDescription

capacity

uint256

Current capacity of the market

findMarketFor

function findMarketFor(address payout_, address quote_, uint256 amountIn_, uint256 minAmountOut_, uint256 maxExpiry_) external view returns (uint256)

Returns the market ID with the highest current payoutToken payout for depositing quoteToken

Parameters

NameTypeDescription

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

NameTypeDescription

id_

uint256

Market ID

getAuctioneer

function getAuctioneer(uint256 id_) external view returns (contract IBondAuctioneer)

Get the auctioneer for the provided market ID

Parameters

NameTypeDescription

id_

uint256

Market ID

Returns

NameTypeDescription

auctioneer

contract IBondAuctioneer

Address of the auctioneer that provides the market

getTeller

function getTeller(uint256 id_) external view returns (contract IBondTeller)

Returns the Teller that services the market ID

Parameters

NameTypeDescription

id_

uint256

Market ID

Returns

NameTypeDescription

teller

contract IBondTeller

Address of the teller that services the market

isInstantSwap

function isInstantSwap(uint256 id_) external view returns (bool)

Does market send payout immediately

Parameters

NameTypeDescription

id_

uint256

Market ID to search for

Returns

NameTypeDescription

isInstant

bool

Whether the market is instant swap (true) or has vesting of the payout (false)

isLive

function isLive(uint256 id_) external view returns (bool)

Is a given market accepting purchases

Parameters

NameTypeDescription

id_

uint256

ID of market

Returns

NameTypeDescription

isLive

bool

Whether the market is accepting purchases

liveMarketsBetween

function liveMarketsBetween(uint256 firstIndex_, uint256 lastIndex_) external view returns (uint256[])

Returns array of active market IDs within a range

Should be used if length exceeds max to query entire array

Parameters

NameTypeDescription

firstIndex_

uint256

Start index of market range

lastIndex_

uint256

End index of market range

Returns

NameTypeDescription

ids

uint256[]

IDs of markets

liveMarketsBy

function liveMarketsBy(address owner_) external view returns (uint256[])

Returns an array of all active market IDs for a given owner

Parameters

NameTypeDescription

owner_

address

Address of owner to query by

Returns

NameTypeDescription

ids

uint256[]

IDs of markets

liveMarketsFor

function liveMarketsFor(address token_, bool isPayout_) external view returns (uint256[])

Returns an array of all active market IDs for a given quote token

Parameters

NameTypeDescription

token_

address

Address of token to query by

isPayout_

bool

If true, search by payout token, else search for quote token

Returns

NameTypeDescription

ids

uint256[]

IDs of markets

marketCounter

function marketCounter() external view returns (uint256)

Counter for bond markets on approved auctioneers

Returns

NameTypeDescription

nextId

uint256

Next market ID to be assigned

marketPrice

function marketPrice(uint256 id_) external view returns (uint256)

Calculate current market price of payout token in quote tokens

Accounts for debt and control variable decay since last deposit (vs _marketPrice())

Parameters

NameTypeDescription

id_

uint256

ID of market

Returns

NameTypeDescription

price

uint256

Price for market (see the specific auctioneer for units)

marketScale

function marketScale(uint256 id_) external view returns (uint256)

Scale value to use when converting between quote token and payout token amounts with marketPrice()

Parameters

NameTypeDescription

id_

uint256

ID of market

Returns

NameTypeDescription

scale

uint256

Scaling factor for market in configured decimals (see auctioneer for units)

marketsFor

function marketsFor(address payout_, address quote_) external view returns (uint256[])

Returns an array of all active market IDs for a given payout and quote token

Parameters

NameTypeDescription

payout_

address

Address of payout token

quote_

address

Address of quote token

Returns

NameTypeDescription

ids

uint256[]

IDs of markets

marketsForPayout

function marketsForPayout(address, uint256) external view returns (uint256)

Market IDs for payout token

Parameters

NameTypeDescription

payoutToken_

address

Address of payout token

Returns

NameTypeDescription

ids

uint256

IDs of markets

marketsForQuote

function marketsForQuote(address) external view returns (uint256)

Market IDs for quote token

Parameters

NameTypeDescription

quoteToken_

address

Address of quote token

Returns

NameTypeDescription

ids

uint256

IDs of markets

marketsToAuctioneers

function marketsToAuctioneers(uint256) external view returns (contract IBondAuctioneer)

Auctioneer for Market ID

Parameters

NameTypeDescription

id_

uint256

ID of market

Returns

NameTypeDescription

auctioneer

contract IBondAuctioneer

Auctioneer that provides market

maxAmountAccepted

function maxAmountAccepted(uint256 id_, address referrer_) external view returns (uint256)

Returns maximum amount of quote token accepted by the market

Parameters

NameTypeDescription

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

NameTypeDescription

amountIn

uint256

Max amount of quote token that can currently be exchanged with the market

payoutFor

function payoutFor(uint256 amount_, uint256 id_, address referrer_) external view returns (uint256)

Payout due for amount of quote tokens

Accounts for debt and control variable decay so it is up to date

Parameters

NameTypeDescription

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

NameTypeDescription

payout

uint256

amount of payout tokens to be paid

registerAuctioneer

function registerAuctioneer(contract IBondAuctioneer auctioneer_) external nonpayable

Register a auctioneer with the aggregatorOnly Guardian

A auctioneer must be registered with an aggregator to create markets

Parameters

NameTypeDescription

auctioneer_

contract IBondAuctioneer

Address of the Auctioneer to register

registerMarket

function registerMarket(contract ERC20 payoutToken_, contract ERC20 quoteToken_) external nonpayable returns (uint256 marketId)

Register a new market with the aggregatorOnly registered depositories

Parameters

NameTypeDescription

payoutToken_

contract ERC20

Token to be paid out by the market

quoteToken_

contract ERC20

Token to be accepted by the market

Returns

NameTypeDescription

marketId

uint256

ID of market

Errors

Aggregator_OnlyAuctioneer

error Aggregator_OnlyAuctioneer()

Last updated