Skip to content

Commit 11bb5c3

Browse files
chore: add more context to max accounts (#687)
* chore: add more context to max accounts * chore: minor fix
1 parent 9a152c0 commit 11bb5c3

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

docs/100-swap-api/1-get-quote.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,57 @@ Please be aware that using `onlyDirectRoutes` can often yield unfavorable trades
140140

141141
In some cases, you may want to add more accounts to the transaction for specific use cases, but it might exceed the transaction size limit. You can use the `maxAccounts` parameter to limit the number of accounts in the transaction.
142142

143+
:::warning unfavorable trades
144+
Please be aware that the misuse of `maxAccounts` can yield unfavorable trades or outcomes.
145+
:::
146+
143147
:::tip
144148
- Refer to the [Requote with Lower Max Accounts](/docs/swap-api/requote-with-lower-max-accounts) guide for more information on how to requote and adjust the swap when using `maxAccounts`.
145149
:::
146150

147151
:::note
148-
- `maxAccounts` is only an estimation and the actual number of accounts may vary.
152+
- `maxAccounts` is an estimation and the actual number of accounts may vary.
153+
- `maxAccounts` only applies to the total number of accounts of the inner swaps in the swap instruction and not any of the setup, cleanup or other instructions (see the example below).
149154
- We recommend setting `maxAccounts` to 64
150155
- Keep `maxAccounts` as large as possible, only reduce `maxAccounts` if you exceed the transaction size limit.
151-
- If `maxAccounts` is set too low, example to 30, the computed routes may drop DEXes/AMMs like Meteora DLMM that require more than 30 accounts.
156+
- If `maxAccounts` is set too low, example to 30, the computed route may drop DEXes/AMMs like Meteora DLMM that require more than 30 accounts.
152157

153158
<br/>
154-
**Jupiter has 2 types of routing instructions** and if you plan to limit `maxAccounts`, you will need to account for if the market is routable with [ALTs](https://docs.solana.com/developing/lookup-tables) or not:
159+
**Jupiter has 2 types of routing instructions**, if you plan to limit `maxAccounts`, you will need to account for if the market is routable with [ALTs](https://docs.solana.com/developing/lookup-tables) or not:
155160
- **`Routing Instruction`** (Simple Routing): The market is still new, and we do not have ALTs set up for the market, hence the number of accounts required is higher as there are more accounts required.
156161
- **`Shared Accounts Routing Instruction`**: The market has sufficient liquidity (and has been live for a while), and we have [ALTs](https://docs.solana.com/developing/lookup-tables) set up for the market to be used in the routing instruction, hence the number of accounts required is lower as there are less accounts required.
157162
:::
158163

164+
<details>
165+
<summary>
166+
<div>
167+
<div>
168+
<b>Counting the accounts using an example transaction</b>
169+
</div>
170+
</div>
171+
</summary>
172+
173+
[In this transaction](https://solscan.io/tx/2xpiniSn5z61hE6gB6EUaeRZCqeg8rLBEbiSnAjSD28tjVTSpBogSLfrMRaJiDzuqDyZ8v49Z7WL2TKvGQVwYbB7):
174+
175+
<img src="/dev/max_accounts_stabble.png" alt="Max Accounts Stabble Example" style={{ width: "50%" }} />
176+
<img src="/dev/max_accounts_lifinity_v2.png" alt="Max Accounts Lifinity V2 Example" style={{ width: "50%" }} />
177+
<img src="/dev/max_accounts_shared_accounts_route.png" alt="Max Accounts Shared Accounts Route Example" style={{ width: "50%" }} />
178+
179+
- You can see that there are a total of 2 inner swaps where the number of accounts respectively are
180+
- Stabble Stable Swap: 12
181+
- Lifinity Swap V2: 13
182+
- Total: 25
183+
- The `maxAccounts` parameter is to control this value - to limit the total number of accounts in the inner swaps.
184+
- It doesn’t take into the consideration of a few things:
185+
- Each of the inner swap's program address, so 2 in this case.
186+
- Top level routing instruction accounts where in this case Shared Accounts Route is 13 and Route is 9.
187+
- There are also other accounts that are required to set up, clean up, etc which are not counted in the `maxAccounts` parameter
188+
189+
190+
191+
</details>
192+
193+
159194
<details>
160195
<summary>
161196
<div>
@@ -187,7 +222,3 @@ Notes:
187222
| Solfi | 22 | 9 |
188223

189224
</details>
190-
191-
:::warning unfavorable trades
192-
Please be aware that the misuse of `maxAccounts` can yield unfavorable trades or outcomes.
193-
:::
294 KB
Loading
342 KB
Loading
243 KB
Loading

0 commit comments

Comments
 (0)