@sodax/skills 2.0.0-rc.16 → 2.0.0-rc.18
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/package.json +1 -1
- package/skills/sodax-dapp-kit/integration/knowledge/reference/hooks-index.md +4 -0
- package/skills/sodax-sdk/integration/knowledge/features/partner.md +22 -0
- package/skills/sodax-sdk/integration/knowledge/reference/chain-keys.md +35 -0
- package/skills/sodax-sdk/integration/knowledge/reference/public-api.md +3 -0
package/package.json
CHANGED
|
@@ -173,9 +173,13 @@ Comprehensive hook table across 12 feature domains. Use this when you know the f
|
|
|
173
173
|
| `useFetchAssetsBalances` | Query | Fetch partner asset balances |
|
|
174
174
|
| `useGetAutoSwapPreferences` | Query | Get auto-swap preferences |
|
|
175
175
|
| `useIsTokenApproved` | Query | Check token approval |
|
|
176
|
+
| `useGetUserIntent` | Query | Look up a partner's stored intent hash for a token pair (`0x0…0` = none) |
|
|
177
|
+
| `useGetIntentDetails` | Query | Read full intent details for an intent hash |
|
|
176
178
|
| `useApproveToken` | Mutation | Approve token |
|
|
177
179
|
| `useSetSwapPreference` | Mutation | Set swap preference |
|
|
178
180
|
| `useFeeClaimSwap` | Mutation | Claim partner fees via swap |
|
|
181
|
+
| `useFeeClaimWithdraw` | Mutation | Withdraw a fee token directly (no swap) via the bridge |
|
|
182
|
+
| `usePartnerCancelIntent` | Mutation | Cancel a stuck same-token claim and recover the locked tokens |
|
|
179
183
|
|
|
180
184
|
## Recovery
|
|
181
185
|
|
|
@@ -19,12 +19,34 @@ sodax.partners.feeClaim.setSwapPreference<K, Raw>(args): Promise<Result<TxReturn
|
|
|
19
19
|
sodax.partners.feeClaim.swap(args): Promise<Result<...>>; // immediate fee swap
|
|
20
20
|
sodax.partners.feeClaim.createIntentAutoSwap<Raw>(args): Promise<Result<...>>; // intent-driven auto-swap
|
|
21
21
|
|
|
22
|
+
// Recover a stuck claim. createIntentAutoSwap() (and swap(), which delegates to it) rejects a
|
|
23
|
+
// same-token claim (output === fee token) up front with VALIDATION_FAILED. The guard fails closed: if
|
|
24
|
+
// the preference lookup it relies on fails, the call returns that error instead of submitting. An
|
|
25
|
+
// already-created same-token intent is unfillable and locks the funds. Cancel via ProtocolIntents' own
|
|
26
|
+
// cancelIntent — the only authorized path: the intent's creator is the ProtocolIntents contract, so the
|
|
27
|
+
// generic SwapService.cancelIntent reverts Unauthorized().
|
|
28
|
+
sodax.partners.feeClaim.cancelIntent<Raw>(args): Promise<Result<TxReturnType, Error>>; // args.params: { srcChainKey: Hub, srcAddress, fromToken, toToken }
|
|
29
|
+
|
|
22
30
|
// Reads
|
|
23
31
|
sodax.partners.feeClaim.fetchAssetsBalances(args): Promise<Result<...>>;
|
|
32
|
+
sodax.partners.feeClaim.getUserIntent({ user, fromToken, toToken }): Promise<Result<Hex, Error>>; // 0x0…0 = no open intent
|
|
33
|
+
sodax.partners.feeClaim.getIntentDetails(intentHash): Promise<Result<Intent, Error>>;
|
|
24
34
|
sodax.partners.feeClaim.getOriginalAssetAddress(chainId, hubAsset): OriginalAssetAddress | undefined;
|
|
25
35
|
sodax.partners.feeClaim.getSpokeTokenFromOriginalAssetAddress(...): /* … */;
|
|
26
36
|
```
|
|
27
37
|
|
|
38
|
+
## Same-token fees (no conversion) — withdraw directly
|
|
39
|
+
|
|
40
|
+
When a partner wants the fee token itself (e.g. claim BTC fees as BTC), there is no swap to do — the
|
|
41
|
+
solver rejects a same-token swap, so `createIntentAutoSwap` (and `swap()`, which delegates to it)
|
|
42
|
+
rejects it up front with `VALIDATION_FAILED` rather than locking the funds in an unfillable intent.
|
|
43
|
+
Instead move the wrapped fee token off Sonic with the bridge:
|
|
44
|
+
`sodax.bridge.bridge({ params: { srcChainKey: Sonic, srcAddress, srcToken: <hub asset on Sonic>,
|
|
45
|
+
amount, dstChainKey: <fee's native chain, or Sonic>, dstToken: <original token on dstChain, or the
|
|
46
|
+
hub asset for same-chain delivery>, recipient } })`. Bridging from Sonic pulls via the partner's
|
|
47
|
+
hub-wallet router, so it needs a bridge allowance — a different spender than the ProtocolIntents
|
|
48
|
+
approval used by the swap claim.
|
|
49
|
+
|
|
28
50
|
## Common call shape
|
|
29
51
|
|
|
30
52
|
```ts
|
|
@@ -60,6 +60,41 @@ import {
|
|
|
60
60
|
|
|
61
61
|
---
|
|
62
62
|
|
|
63
|
+
## Chain metadata (`baseChainInfo`)
|
|
64
|
+
|
|
65
|
+
`baseChainInfo` (exported from `@sodax/sdk`, re-exported from `@sodax/types`) maps every `ChainKey` to a static `BaseChainInfo` record:
|
|
66
|
+
|
|
67
|
+
| Field | Type | Notes |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `name` | `string` | Human-readable chain name. |
|
|
70
|
+
| `key` | `ChainKey` | The chain key (equals the map key). |
|
|
71
|
+
| `chainId` | `string \| number` | Native chain id — number for EVM, string for non-EVM. |
|
|
72
|
+
| `type` | `ChainType` | Chain family — same value as `getChainType(key)`. |
|
|
73
|
+
| `mainnet` | `boolean` | Whether the entry is a mainnet chain. |
|
|
74
|
+
| `logo` | `string` | Default chain logo URL (see below). |
|
|
75
|
+
| `explorer` | `{ baseUrl; txUrl; addressUrl; contractUrl }` | Block-explorer URL templates. |
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { baseChainInfo, ChainKeys } from '@sodax/sdk';
|
|
79
|
+
|
|
80
|
+
const { name, logo, explorer } = baseChainInfo[ChainKeys.BASE_MAINNET];
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Chain logos
|
|
84
|
+
|
|
85
|
+
Each entry's `logo` is a default logo URL — **read `baseChainInfo[key].logo` for chain icons; never hardcode icon paths.** The URL is built from the exported `CHAIN_LOGO_BASE_URL` as `${CHAIN_LOGO_BASE_URL}/${key}.png`:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { baseChainInfo, CHAIN_LOGO_BASE_URL, ChainKeys } from '@sodax/sdk';
|
|
89
|
+
|
|
90
|
+
baseChainInfo[ChainKeys.SONIC_MAINNET].logo;
|
|
91
|
+
// → `${CHAIN_LOGO_BASE_URL}/sonic.png`
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The PNGs are hosted in the repo's `@sodax/assets` package and served from `main` via `raw.githubusercontent.com` — so a newly added logo only resolves once merged to `main`. They are not bundled into the SDK.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
63
98
|
|
|
64
99
|
## Cross-references
|
|
65
100
|
|
|
@@ -26,6 +26,9 @@ import {
|
|
|
26
26
|
type SpokeChainKey,
|
|
27
27
|
type HubChainKey,
|
|
28
28
|
type EvmChainKey,
|
|
29
|
+
baseChainInfo, // per-chain static metadata (name, key, logo, explorer, …)
|
|
30
|
+
type BaseChainInfo,
|
|
31
|
+
CHAIN_LOGO_BASE_URL, // base URL for default chain logos — baseChainInfo[key].logo
|
|
29
32
|
getChainType,
|
|
30
33
|
isEvmChainKeyType,
|
|
31
34
|
isSolanaChainKeyType,
|