Asset Notation
Before diving into the scenarios, let’s define the asset types used:A- ERC1155 outcome tokenA'- ERC1155 outcome token, complement ofAC- ERC20 collateral token (e.g., USDC)
Complements assumes 1 outcome token and 1 of its complement can always be merged into 1 unit of collateral and 1 unit of collateral can always be split into 1 outcome token and 1 of its complement (i.e.,
A + A' = C).Outcome tokens and collateral have the same decimals/base unit.Matching Scenarios
- NORMAL
- MINT
- MERGE
Scenario 1: NORMAL Matching
The NORMAL scenario matches a buy order against a sell order for the same outcome token. This is a standard exchange where tokens are transferred directly between users.Example: Buy vs Sell
1
Maker Order
UserA wants to BUY 100 token UserA is offering 50 USDC to receive 100 token A (price: $0.50 per token)
A @ $0.50Order Structure
2
Taker Order
UserB wants to SELL 50 token UserB is offering 50 token A to receive 25 USDC (price: $0.50 per token)
A @ $0.50Order Structure
3
Match Execution
The exchange calls
matchOrders(makerOrder, [takerOrder], 50, [25])Transfer Flow:- Transfer 50 token
Afrom userB intoCTFExchange - Transfer 25
Cfrom userA intoCTFExchange - Transfer 50 token
AfromCTFExchangeto userA - Transfer 25
CfromCTFExchangeto userB
Match Type Enum
The contract defines aMatchType enum to identify these scenarios:
OrderStructs.sol
Key Takeaways
NORMAL
Direct token exchange between a buyer and seller of the same outcome token
MINT
Mints new token sets when two buyers want complementary outcomes
MERGE
Merges complementary tokens into collateral when two sellers have opposite positions