@sodax/skills 2.1.0-rc.2 → 2.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/skills/sodax-dapp-kit/integration/knowledge/architecture.md +31 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/bridge.md +5 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/dex.md +5 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/leverage-yield.md +5 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/migration.md +5 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/money-market.md +5 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/staking.md +5 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/swap.md +5 -0
- package/skills/sodax-dapp-kit/integration/knowledge/reference/hooks-index.md +2 -1
- package/skills/sodax-dapp-kit/integration/knowledge/reference/querykey-conventions.md +1 -0
- package/skills/sodax-sdk/integration/knowledge/architecture.md +19 -0
- package/skills/sodax-sdk/integration/knowledge/features/backend-api.md +5 -0
- package/skills/sodax-sdk/integration/knowledge/features/bridge.md +6 -0
- package/skills/sodax-sdk/integration/knowledge/features/dex.md +6 -0
- package/skills/sodax-sdk/integration/knowledge/features/leverage-yield.md +6 -0
- package/skills/sodax-sdk/integration/knowledge/features/migration.md +6 -0
- package/skills/sodax-sdk/integration/knowledge/features/money-market.md +6 -0
- package/skills/sodax-sdk/integration/knowledge/features/staking.md +6 -0
- package/skills/sodax-sdk/integration/knowledge/features/swap.md +6 -0
- package/skills/sodax-sdk/integration/knowledge/features/swaps-api.md +23 -0
package/README.md
CHANGED
|
@@ -49,4 +49,4 @@ LLM training data drifts: snippets from chat often use stale method names, resha
|
|
|
49
49
|
|
|
50
50
|
## Feedback
|
|
51
51
|
|
|
52
|
-
If your agent generates wrong code despite reading the docs, that's a doc bug — please open an issue on the [
|
|
52
|
+
If your agent generates wrong code despite reading the docs, that's a doc bug — please open an issue on the [SODAX SDKs repo](https://github.com/icon-project/sodax-sdks/issues) with the prompt and the incorrect output. The per-skill `knowledge/` subtrees are structurally CI-guarded (frontmatter, link resolution); prose claims benefit from real-world feedback.
|
package/package.json
CHANGED
|
@@ -198,6 +198,37 @@ After translating, the public hook signature is `SafeUseMutationResult<T, Error,
|
|
|
198
198
|
|
|
199
199
|
The dual API means consumers never have to choose between React Query's error model and `Result<T>` ergonomics — both are exposed by the same hook.
|
|
200
200
|
|
|
201
|
+
## Approve hooks can prompt the wallet twice
|
|
202
|
+
|
|
203
|
+
Every `use*Approve` hook is unchanged and still resolves to a single transaction hash. But a few
|
|
204
|
+
ERC-20s of the 2017 TetherToken lineage — Ethereum USDT is the only one in the SODAX token list today
|
|
205
|
+
— reject an allowance change from one non-zero value to another. When the connected wallet already
|
|
206
|
+
holds a stale allowance on such a token, the SDK sends `approve(0)` first, waits for it to be mined,
|
|
207
|
+
and only then sends the real approval. The user therefore signs **twice**, and the hash the hook
|
|
208
|
+
resolves with is the **last** transaction's.
|
|
209
|
+
|
|
210
|
+
Nothing about the hook contract changes and there is no flag to set. What matters for UI:
|
|
211
|
+
|
|
212
|
+
- An `isPending` that renders a single "Approving…" now spans two wallet prompts. Say so in the copy,
|
|
213
|
+
or the second prompt reads as a bug.
|
|
214
|
+
- Anything estimating gas or counting transactions from "one approve = one transaction" is wrong on
|
|
215
|
+
that branch.
|
|
216
|
+
- If the second signature is rejected after the reset landed, the allowance is now zero, so the next
|
|
217
|
+
attempt is a single transaction — retrying is always safe.
|
|
218
|
+
|
|
219
|
+
On the unsigned (swaps-API) path, prefer **`useSwapsApiApproveAndBroadcast`**: it asks the API for
|
|
220
|
+
the transactions, then signs, broadcasts, and waits for each, resolving with
|
|
221
|
+
`{ approveTxHash, resetTxHash? }` only once the final approval has landed. A transaction that mines
|
|
222
|
+
but reverts rejects the mutation naming that step, so the approve is never sent over a reset that
|
|
223
|
+
did not take. It also invalidates `['swapsApi','allowance']` itself, because confirmation now
|
|
224
|
+
happens inside the hook.
|
|
225
|
+
|
|
226
|
+
`useSwapsApiApprove` still exists and returns the API's `{ tx, resetTx? }` verbatim — use it only
|
|
227
|
+
when you need to own signing. If you do, broadcast `resetTx` **first and wait for it to succeed**;
|
|
228
|
+
the approve is not a valid state transition until the reset has landed, so sending both together
|
|
229
|
+
spends the user's gas on a certain revert. Waiting is not enough on its own — check the receipt's
|
|
230
|
+
status, because a mined-and-reverted reset leaves the allowance exactly where it was.
|
|
231
|
+
|
|
201
232
|
## queryKey / mutationKey conventions (mandatory)
|
|
202
233
|
|
|
203
234
|
Every `queryKey` and `mutationKey` follows the same structural rule. Enforced by `_mutationContract.test.ts` for mutation keys; reviewer-enforced for query keys.
|
|
@@ -19,6 +19,11 @@ useGetBridgeableAmount({ params: { from: XToken, to: XToken }, queryOptions });
|
|
|
19
19
|
useGetBridgeableTokens({ params: { from: SpokeChainKey, to: SpokeChainKey, token: string }, queryOptions });
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
`use*Approve` is unchanged and still resolves to one transaction hash, but the SDK may send **two**
|
|
23
|
+
transactions on a token that rejects a non-zero to non-zero allowance change (Ethereum USDT today) —
|
|
24
|
+
the user signs twice and the hash is the **last** one's. An `isPending`-driven "Approving…" should say
|
|
25
|
+
so. See "Approve hooks can prompt the wallet twice" in [`architecture.md`](../architecture.md).
|
|
26
|
+
|
|
22
27
|
## Mutation params
|
|
23
28
|
|
|
24
29
|
```ts
|
|
@@ -35,6 +35,11 @@ useCreateSupplyLiquidityParams({ poolData, poolKey, minPrice, maxPrice, liquidit
|
|
|
35
35
|
useCreateDecreaseLiquidityParams({ /* see source for fields */ });
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
`use*Approve` is unchanged and still resolves to one transaction hash, but the SDK may send **two**
|
|
39
|
+
transactions on a token that rejects a non-zero to non-zero allowance change (Ethereum USDT today) —
|
|
40
|
+
the user signs twice and the hash is the **last** one's. An `isPending`-driven "Approving…" should say
|
|
41
|
+
so. See "Approve hooks can prompt the wallet twice" in [`architecture.md`](../architecture.md).
|
|
42
|
+
|
|
38
43
|
## SDK param types (passed via `mutate({ params, walletProvider })`)
|
|
39
44
|
|
|
40
45
|
Each dex mutation hook's TVars is `{ params: <SDKParamsType>, walletProvider, timeout? }`. The SDK param types below are what goes INSIDE `params` — they are not the TVars themselves.
|
|
@@ -22,6 +22,11 @@ useLeverageYieldShareBalances({ params, queryOptions }); // per-chain share bala
|
|
|
22
22
|
|
|
23
23
|
`deposit` / `withdraw` are **builders** — they assemble a `LeverageYieldSwapPayload`, they do NOT broadcast. Spread the built payload into `useLeverageYieldVaultSwap`'s `mutate`, adding the `walletProvider`. There is no dedicated leverage-yield approve hook: the swap-style deposit approves the spoke-side asset manager, so reuse `useSwapApprove` / `useSwapAllowance` (see Approval pattern).
|
|
24
24
|
|
|
25
|
+
`use*Approve` is unchanged and still resolves to one transaction hash, but the SDK may send **two**
|
|
26
|
+
transactions on a token that rejects a non-zero to non-zero allowance change (Ethereum USDT today) —
|
|
27
|
+
the user signs twice and the hash is the **last** one's. An `isPending`-driven "Approving…" should say
|
|
28
|
+
so. See "Approve hooks can prompt the wallet twice" in [`architecture.md`](../architecture.md).
|
|
29
|
+
|
|
25
30
|
## Mutation TVars
|
|
26
31
|
|
|
27
32
|
```ts
|
|
@@ -20,6 +20,11 @@ useMigrationApprove({ mutationOptions });
|
|
|
20
20
|
useMigrationAllowance({ params: { params: <inner>, action: 'migrate' | 'revert' }, queryOptions });
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
`use*Approve` is unchanged and still resolves to one transaction hash, but the SDK may send **two**
|
|
24
|
+
transactions on a token that rejects a non-zero to non-zero allowance change (Ethereum USDT today) —
|
|
25
|
+
the user signs twice and the hash is the **last** one's. An `isPending`-driven "Approving…" should say
|
|
26
|
+
so. See "Approve hooks can prompt the wallet twice" in [`architecture.md`](../architecture.md).
|
|
27
|
+
|
|
23
28
|
## Mutation params
|
|
24
29
|
|
|
25
30
|
```ts
|
|
@@ -66,6 +66,11 @@ type UseATokensBalancesParams = ReadHookParams<Map<Address, bigint>, {
|
|
|
66
66
|
|
|
67
67
|
> **Bitcoin `userAddress`**: always pass the **personal** address (the user's wallet address), not the Bound Exchange trading address. The read hooks (`useATokensBalances`, `useUserReservesData`, `useUserFormattedSummary`, `useGetUserHubWalletAddress`) automatically resolve to the trading-wallet-derived hub wallet when a Bound Exchange session is active — this is a local lookup with no network call and no throw on an unauthenticated session. See [`features/bitcoin.md`](bitcoin.md) for Bound Exchange session setup.
|
|
68
68
|
|
|
69
|
+
`use*Approve` is unchanged and still resolves to one transaction hash, but the SDK may send **two**
|
|
70
|
+
transactions on a token that rejects a non-zero to non-zero allowance change (Ethereum USDT today) —
|
|
71
|
+
the user signs twice and the hash is the **last** one's. An `isPending`-driven "Approving…" should say
|
|
72
|
+
so. See "Approve hooks can prompt the wallet twice" in [`architecture.md`](../architecture.md).
|
|
73
|
+
|
|
69
74
|
## Mutation params
|
|
70
75
|
|
|
71
76
|
All four user mutations share the same TVars shape (only the `action` literal differs):
|
|
@@ -35,6 +35,11 @@ useInstantUnstakeRatio({ params, queryOptions });
|
|
|
35
35
|
useConvertedAssets({ params, queryOptions });
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
`use*Approve` is unchanged and still resolves to one transaction hash, but the SDK may send **two**
|
|
39
|
+
transactions on a token that rejects a non-zero to non-zero allowance change (Ethereum USDT today) —
|
|
40
|
+
the user signs twice and the hash is the **last** one's. An `isPending`-driven "Approving…" should say
|
|
41
|
+
so. See "Approve hooks can prompt the wallet twice" in [`architecture.md`](../architecture.md).
|
|
42
|
+
|
|
38
43
|
## Mutation TVars
|
|
39
44
|
|
|
40
45
|
```ts
|
|
@@ -24,6 +24,11 @@ useCancelLimitOrder({ mutationOptions }); // TVars are FLAT: { srcChai
|
|
|
24
24
|
|
|
25
25
|
(In actual code, you import each hook directly: `import { useSwap, useSwapAllowance, ... } from '@sodax/dapp-kit'`.)
|
|
26
26
|
|
|
27
|
+
`use*Approve` is unchanged and still resolves to one transaction hash, but the SDK may send **two**
|
|
28
|
+
transactions on a token that rejects a non-zero to non-zero allowance change (Ethereum USDT today) —
|
|
29
|
+
the user signs twice and the hash is the **last** one's. An `isPending`-driven "Approving…" should say
|
|
30
|
+
so. See "Approve hooks can prompt the wallet twice" in [`architecture.md`](../architecture.md).
|
|
31
|
+
|
|
27
32
|
## Mutation params
|
|
28
33
|
|
|
29
34
|
```ts
|
|
@@ -197,7 +197,8 @@ Typed React Query wrappers over the backend Swaps API v2 (`sodax.api.swaps.*`),
|
|
|
197
197
|
|
|
198
198
|
| Hook | Type |
|
|
199
199
|
|---|---|
|
|
200
|
-
| `useSwapsApiApprove` | Mutation; builds unsigned approval tx |
|
|
200
|
+
| `useSwapsApiApprove` | Mutation; builds unsigned approval tx(s) — `{ tx, resetTx? }`, caller signs |
|
|
201
|
+
| `useSwapsApiApproveAndBroadcast` | Mutation; builds **and** signs/broadcasts/waits — preferred; `{ approveTxHash, resetTxHash? }` |
|
|
201
202
|
| `useSwapsApiCreateIntent` | Mutation; builds `{ tx, intent, relayData }` |
|
|
202
203
|
| `useSwapsApiSubmitIntent` | Mutation; submits broadcast intent to the relay |
|
|
203
204
|
| `useSwapsApiCancelIntent` | Mutation; builds unsigned cancel tx |
|
|
@@ -176,6 +176,7 @@ Typed wrappers over `sodax.api.swaps.*` (one per Swaps API v2 endpoint), all key
|
|
|
176
176
|
| `['swapsApi', 'solverFee', amount]` | `useSwapsApiSolverFee` |
|
|
177
177
|
| `['swapsApi', 'submitTx', 'status', txHash, srcChainKey]` | `useSwapsApiSubmitTxStatus` — both identifiers required |
|
|
178
178
|
| `['swapsApi', 'approve']` | `useSwapsApiApprove` mutation |
|
|
179
|
+
| `['swapsApi', 'approveAndBroadcast']` | `useSwapsApiApproveAndBroadcast` mutation |
|
|
179
180
|
| `['swapsApi', 'createIntent']` | `useSwapsApiCreateIntent` mutation |
|
|
180
181
|
| `['swapsApi', 'submitIntent']` | `useSwapsApiSubmitIntent` mutation |
|
|
181
182
|
| `['swapsApi', 'cancelIntent']` | `useSwapsApiCancelIntent` mutation |
|
|
@@ -88,6 +88,25 @@ The chain key on the request payload (e.g. `srcChainKey: ChainKeys.ETHEREUM_MAIN
|
|
|
88
88
|
|
|
89
89
|
The chain key is the bridge between the type system and runtime routing.
|
|
90
90
|
|
|
91
|
+
### ERC-20 approval can take two transactions
|
|
92
|
+
|
|
93
|
+
A few ERC-20s of the 2017 TetherToken lineage reject an allowance change from one non-zero value to
|
|
94
|
+
another, so a wallet holding a stale allowance cannot approve at all until the allowance is zeroed.
|
|
95
|
+
Before a signed approval, `SpokeService` simulates the approve and, when it reverts, sends
|
|
96
|
+
`approve(0)` first, waits for it to be mined, then sends the real approval. The user signs twice.
|
|
97
|
+
|
|
98
|
+
Detection is behavioural — the simulated approve either reverts or it does not — never a token list,
|
|
99
|
+
so a token added or upgraded later is handled without a code change. Consumer impact:
|
|
100
|
+
|
|
101
|
+
- **Signed flows (`raw: false`)** are unchanged. Every feature `approve` still resolves to a single
|
|
102
|
+
transaction hash: the hash of the **last** transaction. Show step progress in the UI if you want,
|
|
103
|
+
but nothing breaks if you do not.
|
|
104
|
+
- **Unsigned flows (`raw: true`)** still return exactly one transaction from `approve`, which cannot
|
|
105
|
+
express a two-step plan. Use `sodax.swaps.buildApproveTxs({ params, raw: true })` instead — it
|
|
106
|
+
returns `{ approveTx, resetTx? }`. `resetTx` is present only for a guarded token holding a stale
|
|
107
|
+
allowance — broadcast it and wait for it to be mined first, because `approveTx` is not valid until
|
|
108
|
+
the reset has landed.
|
|
109
|
+
|
|
91
110
|
---
|
|
92
111
|
|
|
93
112
|
## 3. `Sodax` facade and service graph
|
|
@@ -59,6 +59,11 @@ if (!submitResult.ok) return;
|
|
|
59
59
|
|
|
60
60
|
## Swap-intent request DTO — `bound.accessToken` (Bitcoin TRADING)
|
|
61
61
|
|
|
62
|
+
`/swaps/approve` answers `ApproveResponseV2 = { tx, resetTx? }`. `resetTx` appears only when the
|
|
63
|
+
source token rejects a non-zero to non-zero allowance change (Ethereum USDT is the only listed one
|
|
64
|
+
today) **and** the wallet already holds a stale allowance — broadcast it first, wait for it to be
|
|
65
|
+
mined, then broadcast `tx`. Absent for every other token, so a client that ignores it keeps working.
|
|
66
|
+
|
|
62
67
|
`CreateIntentParamsV2` is the shared wire-level request body behind the typed `/swaps/allowance/check`, `/swaps/approve`, and `/swaps/intents` calls (the `IBackendApiV2` methods the SDK drives internally). It inherits the swap extras — `partnerFee`, `srcPublicKey`, and `bound` — from `SwapExtrasV2`, the JSON-safe mirror of the SDK `SwapExtras` (`QuoteRequestV2` inherits the same trio for its `includeTxData=true` path). For Bitcoin **TRADING**-mode `raw` intents the Bound Exchange (Radfi) token is carried as `bound.accessToken` — passed in the request body instead of an `x-bound-access-token` header so it stays inside the typed DTO. Required only when the source chain is Bitcoin in TRADING mode; ignored otherwise.
|
|
63
68
|
|
|
64
69
|
You rarely build this DTO yourself: `sodax.swaps.createIntent` takes the token via the chain-key-gated `extras.bound.accessToken` slot and maps it onto `CreateIntentParamsV2.bound.accessToken`. See [`swap.md`](swap.md) § `SwapExtras` and [`../chain-specifics.md`](../chain-specifics.md) § "Bitcoin PSBT and Bound Exchange" for the consumer-facing flow and token-injection points.
|
|
@@ -199,6 +199,12 @@ if (result.ok) {
|
|
|
199
199
|
| `getBridgeableAmount` | `BridgeLimit = { amount, decimals, type }` |
|
|
200
200
|
| `getBridgeableTokens` | `XToken[]` |
|
|
201
201
|
|
|
202
|
+
`approve` can send **two** transactions on a token that rejects a non-zero to non-zero allowance
|
|
203
|
+
change (Ethereum USDT is the only listed one today): `approve(0)` is mined first, then the real
|
|
204
|
+
approval, so the user signs twice. The returned value is unchanged — one hash, the **last**
|
|
205
|
+
transaction's. Detection simulates the approval, so never gate on a token list. Full note: "ERC-20
|
|
206
|
+
approval can take two transactions" in [`architecture.md`](../architecture.md).
|
|
207
|
+
|
|
202
208
|
## Error codes
|
|
203
209
|
|
|
204
210
|
`feature: 'bridge'`. Per-method narrow unions:
|
|
@@ -165,6 +165,12 @@ The underlying read does not consult the wallet provider; pass `raw: true` to sa
|
|
|
165
165
|
|
|
166
166
|
> `getPools()` is **synchronous** in v2 (was `Promise<PoolKey[]>` in v1). v2 reads from cached config — no I/O. `await sodax.dex.clService.getPools()` works (TS allows `await` on non-promise) but `.then(...)` is a runtime error.
|
|
167
167
|
|
|
168
|
+
`approve` can send **two** transactions on a token that rejects a non-zero to non-zero allowance
|
|
169
|
+
change (Ethereum USDT is the only listed one today): `approve(0)` is mined first, then the real
|
|
170
|
+
approval, so the user signs twice. The returned value is unchanged — one hash, the **last**
|
|
171
|
+
transaction's. Detection simulates the approval, so never gate on a token list. Full note: "ERC-20
|
|
172
|
+
approval can take two transactions" in [`architecture.md`](../architecture.md).
|
|
173
|
+
|
|
168
174
|
## Error codes
|
|
169
175
|
|
|
170
176
|
`feature: 'dex'`. Per-method narrow unions:
|
|
@@ -152,6 +152,12 @@ await sodax.leverageYield.notifySolver({ intent_tx_hash: hubIntentTxHash });
|
|
|
152
152
|
| `getAsset` | `Address` |
|
|
153
153
|
| `listVaults` / `getVault` / `getVaultByAddress` | `LeverageYieldVault[]` / `LeverageYieldVault \| undefined` (synchronous) |
|
|
154
154
|
|
|
155
|
+
`approve` can send **two** transactions on a token that rejects a non-zero to non-zero allowance
|
|
156
|
+
change (Ethereum USDT is the only listed one today): `approve(0)` is mined first, then the real
|
|
157
|
+
approval, so the user signs twice. The returned value is unchanged — one hash, the **last**
|
|
158
|
+
transaction's. Detection simulates the approval, so never gate on a token list. Full note: "ERC-20
|
|
159
|
+
approval can take two transactions" in [`architecture.md`](../architecture.md).
|
|
160
|
+
|
|
155
161
|
## Error codes
|
|
156
162
|
|
|
157
163
|
`feature: 'leverageYield'`. Action discriminator on `context.action`: `'deposit' | 'withdraw' | 'approve' | 'allowanceCheck' | 'vaultSwap'`. Read methods partition on `context.method`.
|
|
@@ -205,6 +205,12 @@ try {
|
|
|
205
205
|
| `getAvailableAmount` | `bigint` |
|
|
206
206
|
| `BalnSwapService.claim` etc. | `TxReturnType<K, false>` (raw, not `Result`-wrapped) |
|
|
207
207
|
|
|
208
|
+
`approve` can send **two** transactions on a token that rejects a non-zero to non-zero allowance
|
|
209
|
+
change (Ethereum USDT is the only listed one today): `approve(0)` is mined first, then the real
|
|
210
|
+
approval, so the user signs twice. The returned value is unchanged — one hash, the **last**
|
|
211
|
+
transaction's. Detection simulates the approval, so never gate on a token list. Full note: "ERC-20
|
|
212
|
+
approval can take two transactions" in [`architecture.md`](../architecture.md).
|
|
213
|
+
|
|
208
214
|
## Error codes
|
|
209
215
|
|
|
210
216
|
`feature: 'migration'`. Per-method narrow unions:
|
|
@@ -164,6 +164,12 @@ The `action` field routes to the right token under the hood — relevant for rep
|
|
|
164
164
|
|
|
165
165
|
> Every cross-chain mutation across the SDK (bridge, staking, dex, migration, MM) returns `TxHashPair = { srcChainTxHash, dstChainTxHash }` — there is no array-form variant in v2.
|
|
166
166
|
|
|
167
|
+
`approve` can send **two** transactions on a token that rejects a non-zero to non-zero allowance
|
|
168
|
+
change (Ethereum USDT is the only listed one today): `approve(0)` is mined first, then the real
|
|
169
|
+
approval, so the user signs twice. The returned value is unchanged — one hash, the **last**
|
|
170
|
+
transaction's. Detection simulates the approval, so never gate on a token list. Full note: "ERC-20
|
|
171
|
+
approval can take two transactions" in [`architecture.md`](../architecture.md).
|
|
172
|
+
|
|
167
173
|
## Error codes
|
|
168
174
|
|
|
169
175
|
`feature: 'moneyMarket'`. Per-method narrow unions:
|
|
@@ -151,6 +151,12 @@ const allowed = await sodax.staking.isAllowanceValid({
|
|
|
151
151
|
|
|
152
152
|
> All 5 mutation methods return `TxHashPair = { srcChainTxHash, dstChainTxHash }` because the SDK relays spoke→hub internally. When the user is already on the hub, both fields hold the same hash.
|
|
153
153
|
|
|
154
|
+
`approve` can send **two** transactions on a token that rejects a non-zero to non-zero allowance
|
|
155
|
+
change (Ethereum USDT is the only listed one today): `approve(0)` is mined first, then the real
|
|
156
|
+
approval, so the user signs twice. The returned value is unchanged — one hash, the **last**
|
|
157
|
+
transaction's. Detection simulates the approval, so never gate on a token list. Full note: "ERC-20
|
|
158
|
+
approval can take two transactions" in [`architecture.md`](../architecture.md).
|
|
159
|
+
|
|
154
160
|
## Error codes
|
|
155
161
|
|
|
156
162
|
`feature: 'staking'`. Per-method narrow unions:
|
|
@@ -264,6 +264,12 @@ type RelayExtraData = {
|
|
|
264
264
|
};
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
+
`approve` can send **two** transactions on a token that rejects a non-zero to non-zero allowance
|
|
268
|
+
change (Ethereum USDT is the only listed one today): `approve(0)` is mined first, then the real
|
|
269
|
+
approval, so the user signs twice. The returned value is unchanged — one hash, the **last**
|
|
270
|
+
transaction's. Detection simulates the approval, so never gate on a token list. Full note: "ERC-20
|
|
271
|
+
approval can take two transactions" in [`architecture.md`](../architecture.md).
|
|
272
|
+
|
|
267
273
|
## Error codes
|
|
268
274
|
|
|
269
275
|
`feature: 'swap'`. Per-method narrow unions:
|
|
@@ -57,6 +57,29 @@ sodax.api.swaps.getSubmitTxStatus(query: SubmitTxStatusQueryV2, config?): Promis
|
|
|
57
57
|
The optional trailing `config?: RequestOverrideConfig` (`{ baseURL?, timeout?, headers? }`) on every method
|
|
58
58
|
applies per-call overrides that take precedence over the service config (see "Per-call overrides" below).
|
|
59
59
|
|
|
60
|
+
## `approve` can return two transactions
|
|
61
|
+
|
|
62
|
+
`ApproveResponseV2` is `{ tx, resetTx? }`. `resetTx` appears only when the source token rejects an
|
|
63
|
+
allowance change from one non-zero value to another (the 2017 TetherToken lineage) **and** the wallet
|
|
64
|
+
already holds a stale allowance — a wallet in that state cannot approve at all until it is zeroed.
|
|
65
|
+
|
|
66
|
+
Broadcast `resetTx` first and wait for it to be mined, then broadcast `tx`. The two cannot be
|
|
67
|
+
batched: the approval is only valid once the reset has landed on-chain.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const { tx, resetTx } = approveResponse;
|
|
71
|
+
|
|
72
|
+
if (resetTx) {
|
|
73
|
+
const resetHash = await sendTransaction(resetTx);
|
|
74
|
+
await waitForTransactionReceipt(resetHash);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
await sendTransaction(tx);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The field is optional and absent for every other token, so ignoring it keeps existing behaviour —
|
|
81
|
+
it just cannot rescue a wallet stuck on a guarded token.
|
|
82
|
+
|
|
60
83
|
## Wire shapes — `bigint` vs decimal strings
|
|
61
84
|
|
|
62
85
|
Request bodies that carry an `intent` struct (`cancelIntent`, `getIntentHash`,
|