Base Callback
The Base Callback contract is an optional feature of the Bond system. Callbacks allow issuers (market creators) to apply custom logic on receipt and payout of tokens.
In addition to the Callback Interface, the Base Callback is also implemented to provide a secure starting point for creating a Callback contract.
The base handles permissioning of Tellers (and specific markets served by the Teller) to avoid unauthorized contracts from accessing the callback function.
Additionally, the setup and data storage for getting data from an Aggregator.
Finally, the external callback function is implemented to ensure the Teller is providing the stated amount of Quote Tokens prior to disbursing Payout Tokens. Issuer-specific logic can be implemented in the _callback
internal function which is called by the external one.
The Callback must be created prior to market creation and the address passed in as an argument. The Callback depends on the Aggregator contract for the Auctioneer that the market is created to get market data. Without a Callback contract, payout tokens are transferred directly from the market owner on each bond purchase (market owners must approve the Teller serving that market for the amount of Payout Tokens equivalent to the capacity of a market when created.
Methods
amountsForMarket
Returns the number of quote tokens received and payout tokens paid out for a market
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of the market |
Returns
Name | Type | Description |
---|---|---|
in_ | uint256 | Amount of quote tokens bonded to the market |
out_ | uint256 | Amount of payout tokens paid out to the market |
approvedMarkets
Parameters
Name | Type | Description |
---|---|---|
teller_ | address | Address of the Teller contract |
id_ | uint256 | ID of the market |
Returns
Name | Type | Description |
---|---|---|
approved | bool | Whether the Teller and Market ID combination are approved on the callback |
callback
Send payout tokens to Teller while allowing market owners to perform custom logic on received or paid out tokensMarket ID on Teller must be whitelisted
Must transfer the output amount of payout tokens back to the TellerShould check that the quote tokens have been transferred to the contract in the _callback function
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of the market |
inputAmount_ | uint256 | Amount of quote tokens bonded to the market |
outputAmount_ | uint256 | Amount of payout tokens to be paid out to the market |
deposit
Deposit tokens to the callback and update balancesOnly callback owner
Parameters
Name | Type | Description |
---|---|---|
token_ | contract ERC20 | Address of the token to deposit |
amount_ | uint256 | Amount of tokens to deposit |
owner
Returns the address of the current owner.
Returns
Name | Type | Description |
---|---|---|
owner | address | Owner of the callback with admin privileges |
renounceOwnership
Leaves the contract without owner. It will not be possible to call onlyOwner
functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
transferOwnership
Transfers ownership of the contract to a new account (newOwner
). Can only be called by the current owner.
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | Address to transfer ownership to |
whitelist
Whitelist a teller and market ID combinationMust be callback owner
Parameters
Name | Type | Description |
---|---|---|
teller_ | address | Address of the Teller contract which serves the market |
id_ | uint256 | ID of the market |
withdraw
Withdraw tokens from the callback and update balancesOnly callback owner
Parameters
Name | Type | Description |
---|---|---|
to_ | address | Address of the recipient |
token_ | contract ERC20 | Address of the token to withdraw |
amount_ | uint256 | Amount of tokens to withdraw |
Events
OwnershipTransferred
Parameters
Name | Type | Description |
---|---|---|
previousOwner | address | Address of previous owner |
newOwner | address | Address of new owner |
Errors
Callback_MarketNotSupported
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | ID of market |