@xoxno/sdk-js 1.0.220 → 1.0.222
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/cjs/sdk/stellar/__tests__/quote.test.d.ts +1 -0
- package/dist/cjs/sdk/stellar/prepare.d.ts +14 -9
- package/dist/cjs/sdk/stellar/quote.d.ts +79 -15
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/sdk/stellar/__tests__/quote.test.d.ts +1 -0
- package/dist/sdk/stellar/index.cjs +1 -1
- package/dist/sdk/stellar/index.esm.js +1 -1
- package/dist/sdk/stellar/prepare.d.ts +14 -9
- package/dist/sdk/stellar/quote.d.ts +79 -15
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rpc } from '@stellar/stellar-sdk';
|
|
1
2
|
import type { FeeBumpTransaction, Transaction } from '@stellar/stellar-sdk';
|
|
2
3
|
import type { BuiltStellarTx } from './lending.js';
|
|
3
4
|
import { type StellarNetwork } from './contracts.js';
|
|
@@ -7,17 +8,21 @@ export interface StellarPrepareOptions {
|
|
|
7
8
|
network?: StellarNetwork;
|
|
8
9
|
/** Contract used to qualify errors before mapping controller/pool error codes. */
|
|
9
10
|
invokedContractId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Extra CPU instructions requested from simulation (default 20,000,000).
|
|
13
|
+
* Covers the measured ~11.84M instruction increase across a ledger boundary
|
|
14
|
+
* for a ten-position accrual flow, with headroom.
|
|
15
|
+
* Must be an integer from 0 to 4294967295. Increase for measured execution
|
|
16
|
+
* variance; this margin does not guarantee coverage of later state changes
|
|
17
|
+
* or maximum-position flows. The resulting resources must fit network limits.
|
|
18
|
+
*/
|
|
19
|
+
instructionLeeway?: number;
|
|
10
20
|
}
|
|
11
|
-
/**
|
|
12
|
-
* The single `rpc.Server` capability the prepare helpers need. Declared
|
|
13
|
-
* structurally instead of `Pick<rpc.Server, 'prepareTransaction'>` so the
|
|
14
|
-
* published `.d.ts` references stellar-sdk's concrete `Transaction` exports
|
|
15
|
-
* rather than its `rpc` namespace — the namespaced form trips
|
|
16
|
-
* `dts-bundle-generator`'s external-type resolution under stellar-sdk v16. A
|
|
17
|
-
* real `rpc.Server` satisfies this structurally, so call sites are unchanged.
|
|
18
|
-
*/
|
|
21
|
+
/** The simulation capability the prepare helpers need from `rpc.Server`. */
|
|
19
22
|
export interface StellarTxPreparer {
|
|
20
|
-
|
|
23
|
+
simulateTransaction(tx: Transaction | FeeBumpTransaction, resources?: {
|
|
24
|
+
cpuInstructions?: number;
|
|
25
|
+
}): Promise<rpc.Api.SimulateTransactionResponse>;
|
|
21
26
|
}
|
|
22
27
|
export declare function tagStellarInvokedContractError(contractId: string, error: unknown): Error;
|
|
23
28
|
/**
|
|
@@ -11,25 +11,86 @@
|
|
|
11
11
|
* the wire shape is camelCase, the Soroban contract receives snake_case
|
|
12
12
|
* after the SDK encoder rewrites field names.
|
|
13
13
|
*/
|
|
14
|
-
import type { StellarAggregatorQuoteRequestDto, StellarAggregatorQuoteResponseDto,
|
|
14
|
+
import type { StellarAggregatorQuoteRequestDto, StellarAggregatorQuoteResponseDto, StellarQuoteTransactionPayloadDto } from '@xoxno/types';
|
|
15
15
|
import type { StellarNetwork } from './contracts.js';
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Token entry returned by `GET /api/v1/tokens`. Mirrors the service's
|
|
18
|
+
* `TokenEntry` schema exactly.
|
|
19
19
|
*/
|
|
20
20
|
export interface StellarQuoteToken {
|
|
21
|
-
/** Canonical token id
|
|
22
|
-
*
|
|
21
|
+
/** Canonical Soroban token contract id (`C…`). `XLM` and `CODE:ISSUER`
|
|
22
|
+
* forms are rejected by the service. */
|
|
23
23
|
id: string;
|
|
24
|
-
|
|
24
|
+
/** Decimal places: divide atomic amounts by 10^decimals for display. */
|
|
25
25
|
decimals: number;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
26
|
+
/** `true` for a pool share token; quoting from/to it is a liquidity route. */
|
|
27
|
+
lp: boolean;
|
|
28
|
+
/** Venues the token appears on, sorted. For an LP token, the issuing venue. */
|
|
29
|
+
dexes: string[];
|
|
30
|
+
/** LP only: the pool contract that issued the shares. */
|
|
31
|
+
pool?: string | null;
|
|
32
|
+
/** LP only: constituent token ids in pool order. */
|
|
33
|
+
assets?: string[] | null;
|
|
34
|
+
/** @deprecated Not returned by the service; always `undefined`. */
|
|
35
|
+
kind?: never;
|
|
36
|
+
/** @deprecated Not returned by the service; always `undefined`. */
|
|
37
|
+
sacPeer?: never;
|
|
38
|
+
/** @deprecated Not returned by the service; always `undefined`. */
|
|
39
|
+
code?: never;
|
|
40
|
+
/** @deprecated Not returned by the service; always `undefined`. */
|
|
41
|
+
degree?: never;
|
|
32
42
|
}
|
|
43
|
+
/** Liquidity snapshot the route was searched against. */
|
|
44
|
+
export interface StellarQuoteSnapshot {
|
|
45
|
+
ledger: number;
|
|
46
|
+
ageSeconds: number;
|
|
47
|
+
/** Live ledger compared against; present only when `fresh=true`. */
|
|
48
|
+
checkedLiveLedger?: number | null;
|
|
49
|
+
}
|
|
50
|
+
/** Set when the route was reduced to fit the simulation budget. */
|
|
51
|
+
export interface StellarQuoteDegraded {
|
|
52
|
+
requestedMaxSplits: number;
|
|
53
|
+
effectiveMaxSplits: number;
|
|
54
|
+
requestedMaxHops: number;
|
|
55
|
+
effectiveMaxHops: number;
|
|
56
|
+
fallbackAttempts: number;
|
|
57
|
+
reason: string;
|
|
58
|
+
}
|
|
59
|
+
export interface StellarQuoteLpConstituent {
|
|
60
|
+
token: string;
|
|
61
|
+
tokenKind: string;
|
|
62
|
+
/** Raw u128 amount as a string. */
|
|
63
|
+
amount: string;
|
|
64
|
+
amountShort: number;
|
|
65
|
+
}
|
|
66
|
+
/** Liquidity breakdown for add/remove/convert-liquidity quotes. Informational. */
|
|
67
|
+
export interface StellarQuoteLp {
|
|
68
|
+
pool: string;
|
|
69
|
+
dex: string;
|
|
70
|
+
kind: string;
|
|
71
|
+
feeBps: number;
|
|
72
|
+
shareToken: string;
|
|
73
|
+
amounts: StellarQuoteLpConstituent[];
|
|
74
|
+
refunded?: StellarQuoteLpConstituent[];
|
|
75
|
+
preSwap?: unknown;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Quote response as the service returns it. Extends the `@xoxno/types` DTO with
|
|
79
|
+
* fields the DTO does not yet declare. `alternatives` is still on the DTO but
|
|
80
|
+
* the service no longer returns it.
|
|
81
|
+
*/
|
|
82
|
+
export type StellarQuoteResponse = StellarAggregatorQuoteResponseDto & {
|
|
83
|
+
snapshot?: StellarQuoteSnapshot | null;
|
|
84
|
+
degraded?: StellarQuoteDegraded | null;
|
|
85
|
+
lp?: StellarQuoteLp | null;
|
|
86
|
+
/** Ordered LP-conversion steps; mutually exclusive with `transaction`. */
|
|
87
|
+
transactions?: StellarQuoteTransactionPayloadDto[] | null;
|
|
88
|
+
};
|
|
89
|
+
/** Quote request; adds `simulate`, which the DTO does not yet declare. */
|
|
90
|
+
export type StellarQuoteRequest = StellarAggregatorQuoteRequestDto & {
|
|
91
|
+
/** With `sender`: simulate and prepare resource data (service default `true`). */
|
|
92
|
+
simulate?: boolean;
|
|
93
|
+
};
|
|
33
94
|
export interface StellarQuoteFetchOptions {
|
|
34
95
|
/** Quote-server base URL selected by the host application. */
|
|
35
96
|
baseUrl: string;
|
|
@@ -49,14 +110,17 @@ export interface StellarQuoteFetchOptions {
|
|
|
49
110
|
* `steps`. Amounts are token base-unit decimal strings. Requote after changes
|
|
50
111
|
* to amount, direction or slippage; preparation is the execution check.
|
|
51
112
|
*
|
|
52
|
-
* Passing
|
|
53
|
-
* envelope under `transaction.envelopeXdr`.
|
|
113
|
+
* Passing `sender` (G...) together with `slippage` returns a direct-swap
|
|
114
|
+
* envelope under `transaction.envelopeXdr`. The router comes from the service's
|
|
115
|
+
* `/api/v1/config`; the `router` request field is ignored by the service and is
|
|
116
|
+
* no longer sent. Prepare the envelope before wallet signing unless
|
|
117
|
+
* `transaction.simulated` is true.
|
|
54
118
|
* @param request - Exactly one of amountIn or amountOut; optional referralId is forwarded unchanged.
|
|
55
119
|
* @param opts - Quote-server URL and optional fetch options supplied by the host.
|
|
56
120
|
* @returns Quote estimates and opaque route bytes; does not execute a swap.
|
|
57
121
|
* @category Strategy quotes
|
|
58
122
|
*/
|
|
59
|
-
export declare function getStellarAggregatorQuote(request:
|
|
123
|
+
export declare function getStellarAggregatorQuote(request: StellarQuoteRequest, opts: StellarQuoteFetchOptions): Promise<StellarQuoteResponse>;
|
|
60
124
|
/**
|
|
61
125
|
* List tokens currently indexed by the quote server. Useful to populate
|
|
62
126
|
* pickers or validate that a user-supplied token has on-chain liquidity.
|