This is a more general abstraction to the 0x protocol that allows for an incentivized Matching Agent Swarm
to form around ERC20
token permutations. The notion of maker-taker orders are abstracted away in favor of a single Limit Order
definition.
{
id: PERMUTATION_HASH
sellAddress: TOKEN_ADDRESS,
sellPrice: '0.00000000',
filled: 0,
lifetime: UNIX_TIMESTAMP
signature: '',
}
The permutation hash is derived from the address of the token pair it points to.
Given tokenAddressA
and tokenAddressB
,
-
Compute an alphanumeric sort on the token pair. This is a replicable calculation on the cipher text to ensure the token pair is always hashed in the same order.
-
Given the alphanumeric ordering, concatenate the the public address strings as 'tokenAddress1' + 'tokenAddress2'
-
Take the sha256() of the concatenated string, the result is a unique 256 bit hex string identification for the token permutation.
The orderer specifies the public address of the erc20 token contract they are selling. The buying address is inferred by the permutation id. The contract will check the approval mapping in the specified ERC20 contract to ensure the approval has already been mined.
Sell Price is specified by bytes32 representation of the minimum accepted price.
A user initiates an order by performing an ECDSA signature with there private key on the stringified json object. Given the users private key and the order object, an r
s
v
output is appended to the order object.
There are a finite number of permutations given a set of tokens. A contract registry will exist containing the mapping between unique contract hashes and the address of the corresponding settlement contract. This "name space" can be auctioned off similair to ENS.
- Optional Order Broadcasting
- "In the Market" Enforcement
- Partial Fills
- Order Canceling