Skip to content

Commit 4bc355e

Browse files
committed
docs: added swaps page under transactions
1 parent a501c05 commit 4bc355e

File tree

3 files changed

+90
-10
lines changed

3 files changed

+90
-10
lines changed

docs-site

Submodule docs-site updated 36 files

docs/docs.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,25 +190,25 @@ navigation:
190190
contents:
191191
- page: Overview
192192
path: wallets/pages/transactions/overview.mdx
193-
- page: Send Transactions
193+
- page: Send transactions
194194
path: wallets/pages/transactions/send-transactions.mdx
195-
- page: Sign Requests
195+
- page: Sign requests
196196
path: wallets/pages/transactions/sign-requests.mdx
197197
- page: Using EIP-7702
198198
path: wallets/pages/transactions/using-eip-7702.mdx
199-
- page: Send Batched Transactions
199+
- page: Send batched transactions
200200
path: wallets/pages/transactions/send-batched-transactions.mdx
201-
- page: Sponsor Gas
201+
- page: Sponsor gas
202202
path: wallets/pages/transactions/sponsor-gas.mdx
203-
- page: Pay Gas With Any Token
203+
- page: Pay gas with any token
204204
path: wallets/pages/transactions/pay-gas-with-any-token.mdx
205-
- page: Swap Tokens
205+
- page: "[NEW] Swap tokens"
206206
path: wallets/pages/transactions/swap-tokens.mdx
207-
- page: Send Parallel Transactions
207+
- page: Send parallel transactions
208208
path: wallets/pages/transactions/send-parallel-transactions.mdx
209-
- page: Retry Transactions
209+
- page: Retry transactions
210210
path: wallets/pages/transactions/retry-transactions.mdx
211-
- page: Track Transaction Status
211+
- page: Track transaction status
212212
path: wallets/pages/transactions/track-transaction-status.mdx
213213
- section: Solana
214214
contents:
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Swaps (Alpha)
3+
slug: wallets/transactions/swap-tokens.mdx
4+
---
5+
6+
The Swap API is the easiest way to integrate single-chain token swaps in your app. Cross-chain swaps are coming soon!
7+
8+
Key benefits:
9+
10+
- **Single-step flows:** Batch approve + swap + post-swap action (ex: deposits, transfers, contract calls) into a single transaction - made possible by smart wallets
11+
- **Low latency:**
12+
- Built natively into Smart Wallets. Enables preparing gasless swaps with a single API call
13+
- No need to make calls to two providers to perform a swap
14+
- **Simplified stack:** No need for third-party swap integrations
15+
16+
Key use cases:
17+
18+
- Native token swaps: Enable users to do gasless swaps without ever leaving your app
19+
- Transact with any token: Let users transact with any token they have in their wallet (ex: ETH, WLD), while your contracts still receive your preferred token(ex: USDC).
20+
21+
<Tip>
22+
The Swaps API is in early access. The service is production ready, however there may be changes in the future to simplify the endpoint. We will let you know if/when that happens.
23+
24+
[Request early access!](https://alchemyapi.typeform.com/to/pkjSr57v)
25+
26+
</Tip>
27+
28+
# The Swap flow
29+
30+
## **Flow**
31+
32+
1. Request a swap quote
33+
2. Sign the prepared calls (swap + post swap action)
34+
3. Send prepared calls (swap + post swap action)
35+
4. Poll for confirmation
36+
37+
## **Swap options**
38+
39+
```tsx
40+
// Mode 1: Swap exact input amount
41+
{
42+
fromAmount: "0x2710";
43+
} // Swap exactly 0.01 USDC (10000 in hex, 6 decimals)
44+
45+
// Mode 2: Get minimum output amount
46+
{
47+
minimumToAmount: "0x5AF3107A4000";
48+
} // Get at least 0.0001 ETH (18 decimals). We calculate how much USDC you need to spend to get at least your desired ETH amount!
49+
```
50+
51+
<Tabs>
52+
<Tab title="React"></Tab>
53+
<Tab title="Other JS"></Tab>
54+
<Tab title="APIs"></Tab>
55+
</Tabs>
56+
57+
# FAQs
58+
59+
## What chains are supported?
60+
61+
Chains supported (for now) are: Ethereum, Arbitrum, Base, Berachain, BSC/BNB, Ink, Monad, Optimism, Polygon, Unichain and World Chain mainnets.
62+
63+
## Does the Swap API support cross-chain swaps?
64+
65+
Currently, the Swap API supports only single-chain swaps. Cross-chain swaps are coming soon!
66+
67+
## How do you encode values?
68+
69+
Values are simply passed as hexadecimal strings. The Swap API doesn't add complexity to consider decimals, so 0x01 is always the smallest amount of a given asset.
70+
1 ETH, or DAI (18 decimals) is `0xDE0B6B3A7640000`
71+
1 USDC (6 decimals) is `0xF4240`
72+
This removes any ambiguity— if it’s numerical, it’s a hex.
73+
74+
## What is the expiry?
75+
76+
The expiry is an informational indicator of when you can expect to be able to process the swap request. If you’re at/near the expiry, it might be a good time to request a new quote.
77+
78+
## What if I’m using React?
79+
80+
Use the `@account-kit/react` package to access a `smartWalletClient`. This package automatically uses the Signer for user authentication & signing. [Check out the docs for getting started with React to learn more](/wallets/react/quickstart).

0 commit comments

Comments
 (0)