AIP 12: SupportedTokenRegistry

Migrated from AIP 12: SupportedTokenRegistry · Issue #12 · airswap/AIPs · GitHub

Summary

This proposal sets to decrease the cost of supporting additional token pairs by allowing market makers to announce a set of tokens they can quote.

Specification

Smart Contract

There is to be a secondary locator registry with the following interface:

addTokens(address[])
removeTokens(uint256[])
removeAllTokens()
setProtocol(bytes4, bytes32)
protocols(address[])->((bytes4,bytes32)[])
stakers(address)->address[]
tokens(address)->address[]

Stake

Unlike the pairwise locator, staking in this registry is mandatory. A staker’s obligation is 100,000 AST, plus 100 AST per token, and stake is deposited or withdrawn automatically when stakers addTokens(address[]), removeTokens(uint256[]), or removeAllTokens().

Staked AST should still be able to participate in governance via authorizedSigners and receive the same community benefits as AST staked elsewhere.

Client

To find a list of market makers for a pair, the client queries stakers(address) on both tokens, and then intersects the lists.
They then query protocols(address[]) on those makers to get their server addresses, which they should cache but refresh at least daily.
This should be done in addition to the pairwise locators until a future AIP deprecates that system.

Server

Makers should only announce tokens if they support all of their pairwise markets.
The maker sets their protocol as they do in setIntent.
Makers can remove tokens individually or all at once.
Makers are responsible for not adding a token twice, and if they do they can correct the issue by removing all duplicates and then re-adding.

Motivation

The current locator design has a quadratic cost to creating new pairs, and the gas cost per pair is 975,448. Further, each pair has to be indexed in both directions. Between 38 tokens there are 1406 pairs, and that many createIndex would cost over a billion gas, which is 21 ETH at 15 gwei.

The staking means demand for AST, while discouraging spam that would clutter client software; when makers unstake they cleanup the registry on their way out.

Copyright

Copyright and related rights waived via CC0.