Transactions
Buy Transaction Flow
-
Specify Purchase Amount
The buyer inputs the desired number of tokens. -
Calculate Cost
The platform computes the expected cost in the paired token, accounting for slippage (refer to TokenMaster Pools for cost calculations by pool type). -
Approval Handling (ERC20)
- Using PermitC:
- Verify user’s token approval for PermitC. If insufficient, prompt an approval transaction.
- Generate a signed PermitC transfer order. See PermitTransfer.
- Using Direct Approvals:
- Verify user’s token approval for TokenMaster Router. If insufficient, prompt an approval transaction.
- Using PermitC:
-
Cosignature (Optional)
Obtain cosignature if required by the advanced order. See Cosigning. -
Transaction Execution
- Advanced Buy or PermitC Orders:
- Call
buyTokensAdvancedwith the required parameters (BuyOrder, SignedOrder, and PermitTransfer).- Set
signedOrder.hooktoaddress(0)for basic orders. - Set
permitTransfer.permitProcessortoaddress(0)for direct approvals.
- Set
- Call
- Basic Buy Orders:
- Call
buyTokenswith the BuyOrder.
- Call
- Native Token Pairing:
- Include the native token value as
msg.valuewhen invoking the router.
- Include the native token value as
- Advanced Buy or PermitC Orders:
Sell Transaction Flow
-
Specify Sale Amount
The user inputs the desired number of tokens to sell. -
Calculate Expected Value
The platform computes the expected value in the paired token, accounting for slippage (refer to TokenMaster Pools for sell value calculations by pool type). -
Cosignature (Optional)
Obtain cosignature if the advanced order requires it. See Cosigning. -
Transaction Execution
- Advanced Sell Orders:
- Call
sellTokensAdvancedwith the SellOrder and SignedOrder.
- Call
- Basic Sell Orders:
- Call
sellTokenswith the SellOrder.
- Call
- Advanced Sell Orders:
Spend Transaction Flow
-
Select Spend Order
The user selects a signed spend order to execute. -
Specify Multiples
The user inputs the number of multiples of the spend order to execute. -
Calculate Maximum Spend
The platform determines the maximum spend amount based on the signed spend order and the specified multiples, adjusting for value and slippage if an oracle price adjustment is involved. -
Cosignature (Optional)
Obtain cosignature if the advanced order requires it. See Cosigning. -
Transaction Execution
- Call
spendTokenswith the SpendOrder and SignedOrder.
- Call
Example Use Cases
-
Game Development
A game developer could use spends to sell items and lives to players using event indexing to issue the items offchain. -
NFT Minting
A project could use spends with onchain hooks to mint NFTs using their ecosystem apptoken. -
Retail Payments
A retail point-of-sale system could generate signed orders for customers to pay onchain using the store's token.
