@ravnexchange/sdk 0.1.9 → 0.1.11

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 CHANGED
@@ -1,4 +1,4 @@
1
- import type { ChainDTO, ExecuteParams, ExecutionDTO, GetQuoteParams, QuoteDTO, StatusDTO, SubmitSignatureParams, TokenDTO } from "./types";
1
+ import type { ChainDTO, ExecuteParams, ExecutionDTO, GetQuoteParams, QuoteDTO, StatusDTO, SubmitSignatureParams, SubmitTransactionParams, TokenDTO } from "./types";
2
2
  export interface RavnClientConfig {
3
3
  /** Self-serve or enterprise key. Omit for the anonymous tier (works immediately, lower rate limit). */
4
4
  apiKey?: string;
@@ -21,6 +21,12 @@ export declare class RavnClient {
21
21
  submitSignature(params: SubmitSignatureParams): Promise<{
22
22
  statusRef: string;
23
23
  }>;
24
+ /** POST /v1/submit-transaction: only for a TRANSACTION execution carrying `submit`
25
+ * (broadcastViaRavn quotes). RAVN checks the signed transaction, then sends it; refused, nothing
26
+ * is sent. Returns the Solana signature; poll getStatus with the execution's statusRef. */
27
+ submitTransaction(params: SubmitTransactionParams): Promise<{
28
+ txHash: string;
29
+ }>;
24
30
  /** POST /v1/status: pass the quoteToken execute() returned (not the quote's own), and as `ref`
25
31
  * the execution's statusRef, submitSignature's statusRef, or the origin tx hash. POST, not GET:
26
32
  * a 2-hop quoteToken in a query string can exceed header limits and fail with 431. */
package/dist/client.js CHANGED
@@ -51,6 +51,15 @@ class RavnClient {
51
51
  body: JSON.stringify(params),
52
52
  });
53
53
  }
54
+ /** POST /v1/submit-transaction: only for a TRANSACTION execution carrying `submit`
55
+ * (broadcastViaRavn quotes). RAVN checks the signed transaction, then sends it; refused, nothing
56
+ * is sent. Returns the Solana signature; poll getStatus with the execution's statusRef. */
57
+ submitTransaction(params) {
58
+ return this.request("/submit-transaction", {
59
+ method: "POST",
60
+ body: JSON.stringify(params),
61
+ });
62
+ }
54
63
  /** POST /v1/status: pass the quoteToken execute() returned (not the quote's own), and as `ref`
55
64
  * the execution's statusRef, submitSignature's statusRef, or the origin tx hash. POST, not GET:
56
65
  * a 2-hop quoteToken in a query string can exceed header limits and fail with 431. */
@@ -18,6 +18,11 @@ export interface ExecuteAndTrackHandlers {
18
18
  waitForReceipt(hash: string, chainId?: number): Promise<void>;
19
19
  /** Sign an EIP-712 typed-data payload. Only called for SIGNATURE executions. */
20
20
  signTypedData?(typedData: Record<string, unknown>): Promise<`0x${string}`>;
21
+ /**
22
+ * Sign (don't send) a base64 Solana transaction and return it signed, base64. Only called for a
23
+ * TRANSACTION carrying `submit` (broadcastViaRavn quotes), which RAVN checks and sends itself.
24
+ */
25
+ signSolanaTransaction?(serialized: string): Promise<string>;
21
26
  /**
22
27
  * The API sends `approval` whenever the venue generically needs an allowance: it deliberately
23
28
  * never reads the chain to check whether the caller already has one (that's an RPC round-trip
@@ -33,6 +33,20 @@ async function executeAndTrack(client, params, handlers, options = {}) {
33
33
  await handlers.waitForReceipt(hash, approval.chainId);
34
34
  return hash;
35
35
  };
36
+ if (execution.executionType === "TRANSACTION" && execution.submit) {
37
+ // Never broadcast this one ourselves: a payment Layerswap can't match sits at Layerswap, and
38
+ // RAVN's check before sending is what catches it.
39
+ if (!handlers.signSolanaTransaction) {
40
+ throw new Error("executeAndTrack: this execution must be submitted through RAVN and requires signSolanaTransaction, none was provided");
41
+ }
42
+ if (!execution.transaction.serialized) {
43
+ throw new Error("executeAndTrack: TRANSACTION execution with submit is missing transaction.serialized");
44
+ }
45
+ const signedTransaction = await handlers.signSolanaTransaction(execution.transaction.serialized);
46
+ const { txHash } = await client.submitTransaction({ quoteToken, signedTransaction });
47
+ const statusRef = execution.statusRef ?? txHash;
48
+ return { execution, quoteToken, txHash, statusRef, finalStatus: await pollStatus(statusRef) };
49
+ }
36
50
  if (execution.executionType === "TRANSACTION") {
37
51
  const approvalTxHash = await maybeSendApproval(execution.approval);
38
52
  const txHash = await handlers.sendTransaction(execution.transaction);
package/dist/types.d.ts CHANGED
@@ -52,9 +52,12 @@ export interface QuoteDTO {
52
52
  outputUsd: string | null;
53
53
  estimatedTimeSeconds: number;
54
54
  estimatedTimeIsGuess: boolean;
55
- /** Epoch ms: execute() on `quoteToken` must reach RAVN before this, or it fails with
56
- * QUOTE_EXPIRED. Already 5 s ahead of the venue's own deadline, so compare it to the clock as
57
- * is. 0 means no deadline. A 2-hop route (`venue.id === "compose"`) re-prices at execute instead. */
55
+ /** Epoch ms, always a real time: execute() on `quoteToken` before this, re-quote after. Never
56
+ * refused for age before it; past it most routes fail with QUOTE_EXPIRED. Already 5 s ahead of
57
+ * the venue's own deadline, so compare it to the clock as is. 2-hop routes
58
+ * (`venue.id === "compose"`) and venues with no deadline are never refused for age: it's 60 s
59
+ * from the response, when to re-quote. A 2-hop route re-prices at execute (BUILD_FAILED if the
60
+ * minimum shown can no longer be met). */
58
61
  expiresAt: number;
59
62
  /** Present on 2-hop (`venue.id === "compose"`) and Relay dest-call quotes. Sign hop 1; hop 2 is
60
63
  * a unique deposit, not a second wallet tx. */
@@ -145,6 +148,12 @@ export type ExecutionDTO = {
145
148
  chainId?: number;
146
149
  serialized?: string;
147
150
  };
151
+ /** Only on quotes made with `broadcastViaRavn: true`. Don't broadcast this one: sign
152
+ * `transaction.serialized` and pass it to submitTransaction, which checks the signed
153
+ * transaction still pays Layerswap the way it matches deposits, then sends it. */
154
+ submit?: {
155
+ url: string;
156
+ };
148
157
  } | {
149
158
  executionType: "SIGNATURE";
150
159
  /** Pass this, not the quote's own token, to submitSignature and getStatus. */
@@ -194,7 +203,12 @@ export interface GetQuoteParams {
194
203
  /** Omitting this yields a preview-only quote; see QuoteDTO.executable. */
195
204
  destinationAddress?: string;
196
205
  refundAddress?: string;
206
+ /** Max slippage in bps. Omitted = Auto (50, wider where a route needs it). Setting it keeps
207
+ * venues with no minimum (slippage.noMinimum, today Rift) out of the race unless allowNoMinimum. */
197
208
  slippageBps?: number;
209
+ /** Let venues with no minimum (today Rift) race even though slippageBps is set. Their quotes
210
+ * carry slippage.noMinimum: true and guaranteedMin: null; slippageBps does not protect them. */
211
+ allowNoMinimum?: boolean;
198
212
  rankingMode?: "best_output" | "fastest";
199
213
  /** Drop specific venues from this race, e.g. a risk objection to one of them. */
200
214
  excludeVenues?: string[];
@@ -211,6 +225,12 @@ export interface GetQuoteParams {
211
225
  /** Test quote -> execute -> status with no real funds and no live venue settlement. See
212
226
  * the API's own sandbox field description for per-venue/per-route exceptions. */
213
227
  sandbox?: boolean;
228
+ /** Set if you can post a signed Solana transaction back (submitTransaction) instead of
229
+ * broadcasting it yourself. Adds Layerswap's memo routes (Solana tokens into native BTC or
230
+ * Robinhood Chain stocks, no account rent), which only work when RAVN checks the signed
231
+ * transaction first: a TRANSACTION execution carrying `submit` must go through
232
+ * submitTransaction. executeAndTrack does this when given signSolanaTransaction. */
233
+ broadcastViaRavn?: boolean;
214
234
  }
215
235
  export interface ExecuteParams {
216
236
  quoteToken: string;
@@ -226,6 +246,12 @@ export interface SubmitSignatureParams {
226
246
  signature: `0x${string}`;
227
247
  approvalSignature?: `0x${string}`;
228
248
  }
249
+ export interface SubmitTransactionParams {
250
+ /** The quoteToken execute() returned with that transaction, not the quote's own. */
251
+ quoteToken: string;
252
+ /** `transaction.serialized` after your user's wallet signed it, base64. */
253
+ signedTransaction: string;
254
+ }
229
255
  export interface ErrorMeta {
230
256
  requestId: string;
231
257
  version: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ravnexchange/sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
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",