@ravnexchange/sdk 0.1.11 → 0.1.13
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/dist/client.d.ts +6 -3
- package/dist/client.js +9 -4
- package/dist/types.d.ts +24 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export interface RavnClientConfig {
|
|
|
4
4
|
apiKey?: string;
|
|
5
5
|
/** Default: https://app.ravn.exchange/api/v1 */
|
|
6
6
|
baseUrl?: string;
|
|
7
|
-
/** Swap in your own fetch (e.g. for React Native, or a test double). Defaults to global fetch.
|
|
7
|
+
/** Swap in your own fetch (e.g. for React Native, or a test double). Defaults to global fetch.
|
|
8
|
+
* Called as a plain function (no `this`): pass fetch itself, or a plain or bound wrapper. */
|
|
8
9
|
fetch?: typeof fetch;
|
|
9
10
|
}
|
|
10
11
|
export declare class RavnClient {
|
|
@@ -29,8 +30,10 @@ export declare class RavnClient {
|
|
|
29
30
|
}>;
|
|
30
31
|
/** POST /v1/status: pass the quoteToken execute() returned (not the quote's own), and as `ref`
|
|
31
32
|
* the execution's statusRef, submitSignature's statusRef, or the origin tx hash. POST, not GET:
|
|
32
|
-
* a 2-hop quoteToken in a query string can exceed header limits and fail with 431.
|
|
33
|
-
|
|
33
|
+
* a 2-hop quoteToken in a query string can exceed header limits and fail with 431. `txHash`:
|
|
34
|
+
* a two-hop route's hop-1 transaction, or the fee payment a DEPOSIT's `fee.transaction` asked
|
|
35
|
+
* for; it's how RAVN proves the fee your share is paid from. */
|
|
36
|
+
getStatus(quoteToken: string, ref: string, txHash?: string): Promise<StatusDTO>;
|
|
34
37
|
/** GET /v1/tokens: RAVN's listed token registry for one chain. Not a per-pair routability guarantee. */
|
|
35
38
|
getTokens(chainId: number): Promise<TokenDTO[]>;
|
|
36
39
|
/** GET /v1/chains: every chain RAVN lists tokens for. Static; safe to cache client-side. */
|
package/dist/client.js
CHANGED
|
@@ -13,7 +13,10 @@ class RavnClient {
|
|
|
13
13
|
this.fetchImpl = config.fetch ?? globalThis.fetch;
|
|
14
14
|
}
|
|
15
15
|
async request(path, init) {
|
|
16
|
-
|
|
16
|
+
// Called unbound, never as this.fetchImpl(...): a browser's own fetch (the default, or one
|
|
17
|
+
// passed in) throws "Illegal invocation" when `this` is the client, failing every call.
|
|
18
|
+
const fetchImpl = this.fetchImpl;
|
|
19
|
+
const res = await fetchImpl(`${this.baseUrl}${path}`, {
|
|
17
20
|
...init,
|
|
18
21
|
headers: {
|
|
19
22
|
"content-type": "application/json",
|
|
@@ -62,11 +65,13 @@ class RavnClient {
|
|
|
62
65
|
}
|
|
63
66
|
/** POST /v1/status: pass the quoteToken execute() returned (not the quote's own), and as `ref`
|
|
64
67
|
* the execution's statusRef, submitSignature's statusRef, or the origin tx hash. POST, not GET:
|
|
65
|
-
* a 2-hop quoteToken in a query string can exceed header limits and fail with 431.
|
|
66
|
-
|
|
68
|
+
* a 2-hop quoteToken in a query string can exceed header limits and fail with 431. `txHash`:
|
|
69
|
+
* a two-hop route's hop-1 transaction, or the fee payment a DEPOSIT's `fee.transaction` asked
|
|
70
|
+
* for; it's how RAVN proves the fee your share is paid from. */
|
|
71
|
+
getStatus(quoteToken, ref, txHash) {
|
|
67
72
|
return this.request("/status", {
|
|
68
73
|
method: "POST",
|
|
69
|
-
body: JSON.stringify({ quoteToken, ref }),
|
|
74
|
+
body: JSON.stringify({ quoteToken, ref, ...(txHash ? { txHash } : {}) }),
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
77
|
/** GET /v1/tokens: RAVN's listed token registry for one chain. Not a per-pair routability guarantee. */
|
package/dist/types.d.ts
CHANGED
|
@@ -180,7 +180,31 @@ export type ExecutionDTO = {
|
|
|
180
180
|
};
|
|
181
181
|
/** Poll getStatus with this, not `deposit.address`. */
|
|
182
182
|
statusRef: string;
|
|
183
|
+
/** Only when your key sets a fee and the venue has no fee of its own (today Rift). Skip it
|
|
184
|
+
* and the swap still fills on `deposit.amount`; no fee is owed to you. */
|
|
185
|
+
fee?: DepositFeeDTO;
|
|
183
186
|
};
|
|
187
|
+
/** RAVN's integrator fee beside a deposit, in the input token, paid by your user to RAVN; your
|
|
188
|
+
* share is paid out as usual. `deposit.amount` already leaves it out. */
|
|
189
|
+
export interface DepositFeeDTO {
|
|
190
|
+
/** Base units of the input token. */
|
|
191
|
+
amount: string;
|
|
192
|
+
/** RAVN's fee address on the input chain. */
|
|
193
|
+
address: string;
|
|
194
|
+
chainId: number;
|
|
195
|
+
/** EVM: send this transaction too, exactly as given and as a transaction of its own from the
|
|
196
|
+
* user's regular wallet (it names the order, which ties the fee to this swap; bundled into a
|
|
197
|
+
* smart-wallet batch it can't be proven, and nothing is owed on it), then pass its hash as
|
|
198
|
+
* `txHash` to getStatus once it has confirmed (simplest: on every poll). Absent on Bitcoin: pay `amount` to `address`
|
|
199
|
+
* as an extra output of the SAME transaction that pays the deposit; RAVN finds it there once
|
|
200
|
+
* that transaction confirms. */
|
|
201
|
+
transaction?: {
|
|
202
|
+
to: string;
|
|
203
|
+
data: string;
|
|
204
|
+
value: string;
|
|
205
|
+
chainId: number;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
184
208
|
export type SettlementStatus = "pending" | "processing" | "expired" | "success" | "refunded" | "failed" | "not_found" | "unknown";
|
|
185
209
|
export interface StatusDTO {
|
|
186
210
|
status: SettlementStatus;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ravnexchange/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Typed client for the RAVN integrator API (/api/v1): quote, execute, submit-signature, status.",
|
|
5
5
|
"keywords": ["ravn", "cross-chain", "swap", "swap-api", "dex-aggregator", "bitcoin", "native-btc", "solana", "evm", "crypto", "defi", "typescript", "sdk", "api-client"],
|
|
6
6
|
"main": "./dist/index.js",
|