Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/guide/machine-payments/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The [Machine Payments Protocol](https://mpp.dev) (MPP) adds inline payments to a

## Try it out

See the full payment flow in action. The terminal creates an ephemeral wallet, funds it with testnet USDC, and makes a paid request to fetch a photo.
See the full payment flow in action. The terminal creates an ephemeral wallet, funds it with testnet USDG, and makes a paid request to fetch a photo.

<div style={{ height: 480 }}>
<TerminalDemo />
Expand Down
6 changes: 3 additions & 3 deletions src/pages/guide/payments/accept-a-payment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ contract PaymentReceiver {
If you need to accept payments in a specific stablecoin but receive a different one, use the exchange to swap:

```ts
// User sends USDC, but you need USDT
// Swap USDC to USDT using the exchange
// User sends USDG, but you need USDT
// Swap USDG to USDT using the exchange
const { receipt } = await client.dex.sellSync({
tokenIn: usdcAddress,
tokenIn: usdgAddress,
tokenOut: usdtAddress,
amountIn: receivedAmount,
minAmountOut: receivedAmount * 99n / 100n, // 1% slippage
Expand Down
6 changes: 3 additions & 3 deletions src/pages/protocol/exchange/exchange-balance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function balanceOf(

**Example:**
```solidity
uint128 balance = exchange.balanceOf(msg.sender, USDC_ADDRESS);
uint128 balance = exchange.balanceOf(msg.sender, USDG_ADDRESS);
```

## Using Your DEX Balance
Expand Down Expand Up @@ -58,8 +58,8 @@ function withdraw(

**Example:**
```solidity
// Withdraw 1000 USDC from exchange to your wallet
exchange.withdraw(USDC_ADDRESS, 1000e6);
// Withdraw 1000 USDG from exchange to your wallet
exchange.withdraw(USDG_ADDRESS, 1000e6);
```

:::warning
Expand Down
18 changes: 9 additions & 9 deletions src/pages/protocol/exchange/executing-swaps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ function swapExactAmountIn(
**Returns:**
- `amountOut` - The actual amount of `tokenOut` received

**Example:** Swap exactly 1000 USDC for at least 998 USDT:
**Example:** Swap exactly 1000 USDG for at least 998 USDT:
```solidity
uint128 amountOut = exchange.swapExactAmountIn(
USDC_ADDRESS,
USDG_ADDRESS,
USDT_ADDRESS,
1000e6, // Sell exactly 1000 USDC
1000e6, // Sell exactly 1000 USDG
998e6 // Receive at least 998 USDT
);
```
Expand All @@ -62,13 +62,13 @@ function swapExactAmountOut(
**Returns:**
- `amountIn` - The actual amount of `tokenIn` spent

**Example:** Receive exactly 1000 USDT by spending at most 1002 USDC:
**Example:** Receive exactly 1000 USDT by spending at most 1002 USDG:
```solidity
uint128 amountIn = exchange.swapExactAmountOut(
USDC_ADDRESS,
USDG_ADDRESS,
USDT_ADDRESS,
1000e6, // Receive exactly 1000 USDT
1002e6 // Pay at most 1002 USDC
1002e6 // Pay at most 1002 USDG
);
```

Expand Down Expand Up @@ -102,16 +102,16 @@ Returns how much `tokenIn` you would need to spend to receive a given `amountOut

**Example: Getting a price quote**
```solidity
// Check how much USDT you'd get for 1000 USDC
// Check how much USDT you'd get for 1000 USDG
uint128 expectedOut = exchange.quoteSwapExactAmountIn(
USDC_ADDRESS,
USDG_ADDRESS,
USDT_ADDRESS,
1000e6
);

// Only execute if the price is acceptable
if (expectedOut >= 998e6) {
exchange.swapExactAmountIn(USDC_ADDRESS, USDT_ADDRESS, 1000e6, 998e6);
exchange.swapExactAmountIn(USDG_ADDRESS, USDT_ADDRESS, 1000e6, 998e6);
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/pages/protocol/exchange/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Cards, Card } from 'vocs'

# Exchanging Stablecoins

Tempo features an enshrined decentralized exchange (DEX) designed specifically for trading between stablecoins of the same underlying asset (e.g., USDC to USDT). The exchange provides optimal pricing for cross-stablecoin payments while minimizing chain load from excessive market activity.
Tempo features an enshrined decentralized exchange (DEX) designed specifically for trading between stablecoins of the same underlying asset (e.g., USDG to USDT). The exchange provides optimal pricing for cross-stablecoin payments while minimizing chain load from excessive market activity.

The exchange operates as a singleton precompiled contract at address `0xdec0000000000000000000000000000000000000`. It maintains an orderbook with separate queues for each price tick, using price-time priority for order matching.

Expand Down
30 changes: 15 additions & 15 deletions src/pages/protocol/exchange/providing-liquidity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ function place(
**Returns:**
- `orderId` - Unique identifier for this order

**Example: Place a bid to buy 1000 USDC at $0.9990**
**Example: Place a bid to buy 1000 USDG at $0.9990**
```solidity
// tick = (0.9990 - 1) * 100_000 = -10
uint128 orderId = exchange.place(
USDC_ADDRESS,
1000e6, // Amount: 1000 USDC
true, // isBid: buying USDC
USDG_ADDRESS,
1000e6, // Amount: 1000 USDG
true, // isBid: buying USDG
-10 // tick: price = $0.9990
);
```

**Example: Place an ask to sell 1000 USDC at $1.0010**
**Example: Place an ask to sell 1000 USDG at $1.0010**
```solidity
// tick = (1.0010 - 1) * 100_000 = 10
uint128 orderId = exchange.place(
USDC_ADDRESS,
1000e6, // Amount: 1000 USDC
false, // isBid: selling USDC
USDG_ADDRESS,
1000e6, // Amount: 1000 USDG
false, // isBid: selling USDG
10 // tick: price = $1.0010
);
```
Expand Down Expand Up @@ -89,17 +89,17 @@ function placeFlip(
```solidity
// Place a bid at $0.9990 that flips to an ask at $1.0010
uint128 orderId = exchange.placeFlip(
USDC_ADDRESS,
1000e6, // Amount: 1000 USDC
USDG_ADDRESS,
1000e6, // Amount: 1000 USDG
true, // isBid: start as a buy order
-10, // tick: buy at $0.9990
10 // flipTick: sell at $1.0010 after filled
);
```

When this order is completely filled:
1. You buy 1000 USDC at $0.9990
2. A new order automatically sells 1000 USDC at $1.0010
1. You buy 1000 USDG at $0.9990
2. A new order automatically sells 1000 USDG at $1.0010
3. When that fills, it flips back to a bid at $0.9990
4. This continues indefinitely, earning the spread each time

Expand Down Expand Up @@ -136,9 +136,9 @@ Price ticks are limited to ±2% from peg (±2000 ticks). Orders outside this ran
- **Bid (isBid = true)**: An order to *buy* the token using its quote token
- **Ask (isBid = false)**: An order to *sell* the token for its quote token

For a USDC/USD pair where USD is the quote:
- A bid buys USDC with USD at your specified price
- An ask sells USDC for USD at your specified price
For a USDG/USD pair where USD is the quote:
- A bid buys USDG with USD at your specified price
- An ask sells USDG for USD at your specified price

## Order Execution Timeline

Expand Down
14 changes: 7 additions & 7 deletions src/pages/protocol/fees/spec-fee.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,21 @@ validatorTokenOut = userTokenIn × 0.9970
```

This means:
- User pays 1.0 USDC for fees
- User pays 1.0 USDG for fees
- Validator receives 0.9970 USDT (if that's their preferred token)
- The 0.003 (0.3%) difference goes to liquidity providers as a fee

### Example flow

Here's a complete example of the fee lifecycle:

1. **Alice** wants to send a transaction and pays fees in **USDC** (her preferred token)
1. **Alice** wants to send a transaction and pays fees in **USDG** (her preferred token)
2. **Validator** prefers to receive fees in **USDT**
3. Alice's transaction has a max fee of 1.0 USDC
4. The FeeManager collects 1.0 USDC from Alice before execution
5. Transaction executes and uses 0.8 USDC worth of gas
6. The FeeManager refunds 0.2 USDC to Alice
7. The Fee AMM immediately swaps 0.8 USDC → 0.7976 USDT (0.8 × 0.9970)
3. Alice's transaction has a max fee of 1.0 USDG
4. The FeeManager collects 1.0 USDG from Alice before execution
5. Transaction executes and uses 0.8 USDG worth of gas
6. The FeeManager refunds 0.2 USDG to Alice
7. The Fee AMM immediately swaps 0.8 USDG → 0.7976 USDT (0.8 × 0.9970)
8. The 0.7976 USDT is added to the validator's accumulated fees
9. Validator calls `distributeFees()` to claim their accumulated fees
10. Liquidity providers earn 0.0024 USDT from the 0.3% fee
Expand Down
2 changes: 1 addition & 1 deletion src/pages/protocol/tip20/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ The currency code is **immutable** — it cannot be changed after token creation

TIP-20 tokens can serve as quote tokens in Tempo's decentralized exchange (DEX). When creating trading pairs on the [Stablecoin DEX](/protocol/exchange), TIP-20 tokens function as the quote currency against which other tokens are priced and traded.

This enables efficient stablecoin-to-stablecoin trading and provides optimized routing for liquidity. For example, a USDC TIP-20 token can be paired with other stablecoins, allowing traders to swap between different USD-denominated tokens with minimal slippage through concentrated liquidity pools.
This enables efficient stablecoin-to-stablecoin trading and provides optimized routing for liquidity. For example, a USDG TIP-20 token can be paired with other stablecoins, allowing traders to swap between different USD-denominated tokens with minimal slippage through concentrated liquidity pools.

By using TIP-20 tokens as quote tokens, the DEX benefits from the same payment-optimized features like deterministic addresses, currency identifiers, and compliance policies, ensuring secure and efficient exchange operations.

Expand Down
8 changes: 4 additions & 4 deletions src/pages/protocol/transactions/spec-tempo-transaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ The protocol tracks and enforces spending limits for TIP20 token transfers:
key_id: keyId, // address derived from public key
expiry: timestamp + 86400, // 24 hours from now (or 0 for never)
limits: [
{ token: USDC_ADDRESS, amount: 1000000000 }, // 1000 USDC (6 decimals)
{ token: USDG_ADDRESS, amount: 1000000000 }, // 1000 USDG (6 decimals)
{ token: DAI_ADDRESS, amount: 500000000000000000000 } // 500 DAI (18 decimals)
]
};
Expand Down Expand Up @@ -804,8 +804,8 @@ const tx = {
value: 0,
input: encodeCall("updateSpendingLimit", [
keyId,
USDC_ADDRESS,
2000000000 // New limit: 2000 USDC
USDG_ADDRESS,
2000000000 // New limit: 2000 USDG
])
}],
// ... sign with Root Key
Expand All @@ -824,7 +824,7 @@ const keyInfo = await precompile.getKey(account, keyId);
// Returns: { signatureType, keyId, expiry }

// Check remaining spending limit for a token
const remaining = await precompile.getRemainingLimit(account, keyId, USDC_ADDRESS);
const remaining = await precompile.getRemainingLimit(account, keyId, USDG_ADDRESS);
// Returns: uint256 amount remaining

// Get which key signed current transaction (callable from contracts)
Expand Down
4 changes: 2 additions & 2 deletions src/pages/quickstart/evm-compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ As specified in the preference system above, the simplest way to specify the fee

#### Consideration 2: Paying fees in the TIP-20 contract being interacted with

If the user is calling a method on a TIP-20 token (e.g., `transfer`), the default fee token is that token itself. For example, if the user is calling the `transfer` method on a TIP-20 token with a symbol of "USDC", the default fee token would be "USDC".
If the user is calling a method on a TIP-20 token (e.g., `transfer`), the default fee token is that token itself. For example, if the user is calling the `transfer` method on a TIP-20 token with a symbol of "USDG", the default fee token would be "USDG".

Importantly, note that the `amount` field in this case is sent in full. So, if the user is calling the `transfer` method on a TIP-20 token with a symbol of "USDC" with the `amount` field set to 1000, the full amount of the token will be transferred **and** the sender's balance will be reduced by the amount spent in fees. So, the recipient will receive 1000 USDC.
Importantly, note that the `amount` field in this case is sent in full. So, if the user is calling the `transfer` method on a TIP-20 token with a symbol of "USDG" with the `amount` field set to 1000, the full amount of the token will be transferred **and** the sender's balance will be reduced by the amount spent in fees. So, the recipient will receive 1000 USDG.

#### Consideration 3: The fallback in the case of a non-TIP-20 contract

Expand Down
Loading