@xoxno/sdk-js 1.0.119 → 1.0.123
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/index.bundled.d.cts +88 -38
- package/dist/index.bundled.d.ts +88 -38
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/sdk/stellar/__tests__/swap.test.d.ts +1 -0
- package/dist/sdk/stellar/contracts.d.ts +3 -2
- package/dist/sdk/stellar/lending.d.ts +16 -13
- package/dist/sdk/stellar/scval-encode.d.ts +49 -13
- package/dist/sdk/stellar/swap.d.ts +47 -32
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,7 +17,8 @@ export type StellarNetwork = 'mainnet' | 'testnet';
|
|
|
17
17
|
export declare const STELLAR_LENDING_CONTROLLER: Record<StellarNetwork, string>;
|
|
18
18
|
/**
|
|
19
19
|
* Stellar aggregator router contract addresses per network.
|
|
20
|
-
* Targets `
|
|
20
|
+
* Targets `execute_strategy(sender, total_in, swap_xdr)` for direct
|
|
21
|
+
* (non-lending) swaps.
|
|
21
22
|
* Env vars:
|
|
22
23
|
* - STELLAR_AGGREGATOR_ROUTER_MAINNET
|
|
23
24
|
* - STELLAR_AGGREGATOR_ROUTER_TESTNET
|
|
@@ -50,6 +51,6 @@ export declare const STELLAR_NETWORK_PASSPHRASE: Record<StellarNetwork, string>;
|
|
|
50
51
|
export declare function getStellarLendingController(network: StellarNetwork): string;
|
|
51
52
|
/**
|
|
52
53
|
* Assert an aggregator router address is configured for the target network.
|
|
53
|
-
* Used by `
|
|
54
|
+
* Used by `buildStellarExecuteStrategyTx` for direct user -> router swaps.
|
|
54
55
|
*/
|
|
55
56
|
export declare function getStellarAggregatorRouter(network: StellarNetwork): string;
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
* `rpc.Server.prepareTransaction` (simulation + Soroban footprint/auth/resource
|
|
16
16
|
* fee) before handing the XDR to the wallet to sign.
|
|
17
17
|
*/
|
|
18
|
-
import type {
|
|
18
|
+
import type { BorrowArgs, FlashLoanArgs, LiquidateArgs, MultiplyArgs, RepayArgs, RepayDebtWithCollateralArgs, SupplyArgs, SwapCollateralArgs, SwapDebtArgs, WithdrawArgs } from '@xoxno/types';
|
|
19
19
|
import { xdr } from '@stellar/stellar-sdk';
|
|
20
20
|
import { type StellarNetwork } from './contracts';
|
|
21
|
+
import { type StellarStrategySwapHopInput, type StellarStrategySwapInput, type StellarStrategySwapPathInput } from './scval-encode';
|
|
21
22
|
/**
|
|
22
23
|
* Stellar `G...` public key of the caller (tx source account).
|
|
23
24
|
*/
|
|
@@ -52,14 +53,16 @@ export interface BuiltStellarTx {
|
|
|
52
53
|
* `MultiplyArgs.steps`, `SwapDebtArgs.steps`, `SwapCollateralArgs.steps`, and
|
|
53
54
|
* `RepayDebtWithCollateralArgs.steps`.
|
|
54
55
|
*
|
|
55
|
-
* `@xoxno/types` declares `steps: unknown` on these DTOs so every chain owns
|
|
56
|
-
* own encoding. On Stellar, callers
|
|
57
|
-
*
|
|
56
|
+
* `@xoxno/types` declares `steps: unknown` on these DTOs so every chain owns
|
|
57
|
+
* its own encoding. On Stellar, callers pass opaque aggregator strategy bytes,
|
|
58
|
+
* normally the quote response `routeXdr` (base64 ScVal XDR) or `{ routeXdr }`.
|
|
59
|
+
* The lending controller forwards those bytes to the aggregator and does not
|
|
60
|
+
* decode the aggregator route.
|
|
58
61
|
*/
|
|
59
|
-
export type StellarSwapStepsInput =
|
|
60
|
-
export type StellarSwapHopInput =
|
|
61
|
-
export type StellarSwapPathInput =
|
|
62
|
-
export type StellarSwapVenue
|
|
62
|
+
export type StellarSwapStepsInput = StellarStrategySwapInput;
|
|
63
|
+
export type StellarSwapHopInput = StellarStrategySwapHopInput;
|
|
64
|
+
export type StellarSwapPathInput = StellarStrategySwapPathInput;
|
|
65
|
+
export type { StellarSwapVenue } from './scval-encode';
|
|
63
66
|
/**
|
|
64
67
|
* Assemble an unsigned XDR that invokes a single Soroban contract method.
|
|
65
68
|
*
|
|
@@ -98,8 +101,8 @@ export declare function buildStellarFlashLoanTx(opts: StellarBuilderOptions, arg
|
|
|
98
101
|
/**
|
|
99
102
|
* multiply(caller, account_id, e_mode_category, collateral_token,
|
|
100
103
|
* debt_to_flash_loan: i128, debt_token, mode: PositionMode,
|
|
101
|
-
* swap:
|
|
102
|
-
* convert_swap: Option<
|
|
104
|
+
* swap: Bytes, initial_payment: Option<(Address, i128)>,
|
|
105
|
+
* convert_swap: Option<Bytes>) -> u64
|
|
103
106
|
*
|
|
104
107
|
* `mode` is a repr(u32) `PositionMode` → encoded as `scvU32`. The two trailing
|
|
105
108
|
* `Option`s seed an optional initial collateral payment and a secondary swap
|
|
@@ -108,17 +111,17 @@ export declare function buildStellarFlashLoanTx(opts: StellarBuilderOptions, arg
|
|
|
108
111
|
export declare function buildStellarMultiplyTx(opts: StellarBuilderOptions, args: MultiplyArgs): BuiltStellarTx;
|
|
109
112
|
/**
|
|
110
113
|
* swap_debt(caller, account_id, existing_debt_token, new_debt_amount: i128,
|
|
111
|
-
* new_debt_token, steps:
|
|
114
|
+
* new_debt_token, steps: Bytes)
|
|
112
115
|
*/
|
|
113
116
|
export declare function buildStellarSwapDebtTx(opts: StellarBuilderOptions, args: SwapDebtArgs): BuiltStellarTx;
|
|
114
117
|
/**
|
|
115
118
|
* swap_collateral(caller, account_id, current_collateral, from_amount: i128,
|
|
116
|
-
* new_collateral, steps:
|
|
119
|
+
* new_collateral, steps: Bytes)
|
|
117
120
|
*/
|
|
118
121
|
export declare function buildStellarSwapCollateralTx(opts: StellarBuilderOptions, args: SwapCollateralArgs): BuiltStellarTx;
|
|
119
122
|
/**
|
|
120
123
|
* repay_debt_with_collateral(caller, account_id, collateral_token,
|
|
121
124
|
* collateral_amount: i128, debt_token,
|
|
122
|
-
* steps:
|
|
125
|
+
* steps: Bytes, close_position: bool)
|
|
123
126
|
*/
|
|
124
127
|
export declare function buildStellarRepayDebtWithCollateralTx(opts: StellarBuilderOptions, args: RepayDebtWithCollateralArgs): BuiltStellarTx;
|
|
@@ -5,14 +5,39 @@
|
|
|
5
5
|
* Addresses (Stellar `G...` accounts and Soroban `C...` contracts) encode via
|
|
6
6
|
* `new Address(str).toScVal()`.
|
|
7
7
|
*/
|
|
8
|
-
import type { AggregatorSwapDto, SwapVenue } from '@xoxno/types';
|
|
9
8
|
import { xdr } from '@stellar/stellar-sdk';
|
|
10
9
|
/**
|
|
11
10
|
* On-chain swap venues, validated at runtime for a caller-supplied venue.
|
|
12
|
-
* Mirrors
|
|
11
|
+
* Mirrors the Soroban-only aggregator router's `SwapVenue` enum.
|
|
13
12
|
*/
|
|
14
|
-
export declare const STELLAR_SWAP_VENUES: readonly ["Soroswap", "Aquarius", "Phoenix", "
|
|
15
|
-
export type
|
|
13
|
+
export declare const STELLAR_SWAP_VENUES: readonly ["Soroswap", "Aquarius", "Phoenix", "Sushi", "CometDex"];
|
|
14
|
+
export type StellarSwapVenue = (typeof STELLAR_SWAP_VENUES)[number];
|
|
15
|
+
export interface StellarStrategySwapHopInput {
|
|
16
|
+
amountOut: string;
|
|
17
|
+
pool: string;
|
|
18
|
+
tokenIn: string;
|
|
19
|
+
tokenOut: string;
|
|
20
|
+
venue: StellarSwapVenue;
|
|
21
|
+
}
|
|
22
|
+
export interface StellarStrategySwapPathInput {
|
|
23
|
+
hops: StellarStrategySwapHopInput[];
|
|
24
|
+
splitPpm: number;
|
|
25
|
+
}
|
|
26
|
+
export interface StellarStrategyPayloadInput {
|
|
27
|
+
paths: StellarStrategySwapPathInput[];
|
|
28
|
+
referralId?: number | string;
|
|
29
|
+
tokenIn: string;
|
|
30
|
+
tokenOut: string;
|
|
31
|
+
totalMinOut: string;
|
|
32
|
+
}
|
|
33
|
+
export type StellarStrategySwapInput = string | Uint8Array | {
|
|
34
|
+
routeXdr: string;
|
|
35
|
+
} | {
|
|
36
|
+
swapXdr: string;
|
|
37
|
+
} | {
|
|
38
|
+
bytes: string | Uint8Array;
|
|
39
|
+
} | StellarStrategyPayloadInput;
|
|
40
|
+
export type StellarSwapStepsInput = StellarStrategySwapInput;
|
|
16
41
|
export declare const addr: (a: string) => xdr.ScVal;
|
|
17
42
|
export declare const i128: (s: string) => xdr.ScVal;
|
|
18
43
|
export declare const u32: (n: number) => xdr.ScVal;
|
|
@@ -57,21 +82,32 @@ export declare const scStruct: (fields: Record<string, xdr.ScVal>) => xdr.ScVal;
|
|
|
57
82
|
* Encode a Soroban `enum SwapVenue` (tag-only / unit variant). At the XDR level
|
|
58
83
|
* a unit variant is `scvVec([symbol_name])`.
|
|
59
84
|
*/
|
|
60
|
-
export declare const encodeSwapVenue: (venue:
|
|
85
|
+
export declare const encodeSwapVenue: (venue: StellarSwapVenue) => xdr.ScVal;
|
|
61
86
|
/**
|
|
62
|
-
* Encode the
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* `SwapPath` is the PPM-split shape: each path declares `split_ppm`
|
|
66
|
-
* (parts-per-million share of the batch's total input) and a `hops` chain.
|
|
87
|
+
* Encode the aggregator router's decoded `StrategyPayload` struct. The caller
|
|
88
|
+
* usually receives this as quote `routeXdr`; this helper is for tests and for
|
|
89
|
+
* callers that construct routes locally.
|
|
67
90
|
*/
|
|
68
|
-
export declare const
|
|
91
|
+
export declare const encodeStrategyPayload: (payload: StellarStrategyPayloadInput) => xdr.ScVal;
|
|
92
|
+
/** @deprecated Use `encodeStrategyPayload`. */
|
|
93
|
+
export declare const encodeAggregatorSwap: (payload: StellarStrategyPayloadInput) => xdr.ScVal;
|
|
94
|
+
export declare const encodeStrategyPayloadToBytes: (payload: StellarStrategyPayloadInput) => xdr.ScVal;
|
|
69
95
|
/**
|
|
70
|
-
* Validate the untyped `steps` field and narrow it to `
|
|
96
|
+
* Validate the untyped `steps` field and narrow it to `StrategyPayload`.
|
|
71
97
|
* Throws if the caller passed the wrong shape so the failure surfaces at the
|
|
72
98
|
* SDK boundary, not inside the Soroban host on-chain.
|
|
73
99
|
*/
|
|
74
|
-
export declare const
|
|
100
|
+
export declare const asStellarStrategyPayload: (steps: unknown) => StellarStrategyPayloadInput;
|
|
101
|
+
/**
|
|
102
|
+
* Encode opaque strategy bytes for the lending controller. Accepted inputs:
|
|
103
|
+
* - quote `routeXdr` base64 string
|
|
104
|
+
* - `{ routeXdr }` / `{ swapXdr }`
|
|
105
|
+
* - raw `Uint8Array` / `{ bytes }`
|
|
106
|
+
* - decoded `StrategyPayload` object
|
|
107
|
+
*/
|
|
108
|
+
export declare const asStellarStrategySwapBytes: (steps: unknown) => xdr.ScVal;
|
|
109
|
+
/** @deprecated Use `asStellarStrategyPayload` or `asStellarStrategySwapBytes`. */
|
|
110
|
+
export declare const asStellarSwapSteps: (steps: unknown) => StellarStrategyPayloadInput;
|
|
75
111
|
/**
|
|
76
112
|
* Validate the untyped `data` field on FlashLoanArgs and narrow it to
|
|
77
113
|
* Buffer / hex string for Soroban `Bytes` encoding.
|
|
@@ -1,55 +1,70 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stellar aggregator router direct-call transaction builder.
|
|
3
3
|
*
|
|
4
|
-
* Builds an unsigned XDR for
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Builds an unsigned XDR for
|
|
5
|
+
* `router.execute_strategy(sender, total_in, swap_xdr)` so a user can swap
|
|
6
|
+
* A -> B without involving the lending controller. The strategy route is
|
|
7
|
+
* opaque bytes: normally the quote response `routeXdr`, decoded into Soroban
|
|
8
|
+
* `Bytes` for the contract call.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* itself and sets `sender = current_contract_address` — those flows
|
|
12
|
-
* use the strategy builders in `./lending.ts`, NOT this builder.
|
|
10
|
+
* Lending strategies use the builders in `./lending.ts`; they pass the same
|
|
11
|
+
* opaque route bytes to the controller, which forwards them to the aggregator.
|
|
13
12
|
*/
|
|
14
|
-
import type {
|
|
13
|
+
import type { StellarAggregatorQuoteResponseDto } from '@xoxno/types';
|
|
15
14
|
import type { BuiltStellarTx, StellarBuilderOptions } from './lending';
|
|
16
|
-
|
|
15
|
+
import { type StellarStrategyPayloadInput, type StellarStrategySwapHopInput, type StellarStrategySwapInput, type StellarStrategySwapPathInput } from './scval-encode';
|
|
16
|
+
export type StellarStrategyPayload = StellarStrategyPayloadInput;
|
|
17
|
+
export type StellarStrategySwap = StellarStrategySwapInput;
|
|
18
|
+
export type StellarStrategySwapHop = StellarStrategySwapHopInput;
|
|
19
|
+
export type StellarStrategySwapPath = StellarStrategySwapPathInput;
|
|
20
|
+
export interface StellarExecuteStrategyBuilderOptions extends StellarBuilderOptions {
|
|
17
21
|
/**
|
|
18
22
|
* Override the resolved aggregator router contract address. Normally
|
|
19
23
|
* resolved from `STELLAR_AGGREGATOR_ROUTER[network]`.
|
|
20
24
|
*/
|
|
21
25
|
routerAddress?: string;
|
|
22
26
|
/**
|
|
23
|
-
* Total input amount
|
|
24
|
-
*
|
|
25
|
-
* allocations are derived inside the router from each path's
|
|
26
|
-
* `splitPpm`. For a quote-derived swap, pass `quote.amountIn`.
|
|
27
|
+
* Total input amount passed to `execute_strategy` (i128 decimal string).
|
|
28
|
+
* For a quote-derived swap, pass `quote.amountIn`.
|
|
27
29
|
*/
|
|
28
30
|
totalIn: string;
|
|
29
31
|
/**
|
|
30
|
-
* Referral identifier
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* router reverts at execution.
|
|
32
|
+
* Referral identifier used only when the `swap` input is a decoded
|
|
33
|
+
* `StrategyPayload` object and does not already include `referralId`.
|
|
34
|
+
* Quote `routeXdr` already contains the referral chosen by the quote server.
|
|
34
35
|
*/
|
|
35
36
|
referralId?: number | string;
|
|
36
37
|
}
|
|
38
|
+
/** @deprecated Use `StellarExecuteStrategyBuilderOptions`. */
|
|
39
|
+
export interface StellarBatchSwapBuilderOptions extends StellarExecuteStrategyBuilderOptions {
|
|
40
|
+
}
|
|
41
|
+
export declare const encodeStrategyPayloadToRouteXdr: (payload: StellarStrategyPayloadInput) => string;
|
|
37
42
|
/**
|
|
38
|
-
* Build an unsigned XDR for a direct user
|
|
43
|
+
* Build an unsigned XDR for a direct user -> aggregator router swap.
|
|
39
44
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* calling this. `opts.totalIn` is the authoritative input amount.
|
|
45
|
+
* Pass the quote response `routeXdr` string or `{ routeXdr }` directly when
|
|
46
|
+
* available. Decoded `StrategyPayload` objects are accepted for local tests and
|
|
47
|
+
* custom route builders.
|
|
44
48
|
*/
|
|
45
|
-
export declare function
|
|
49
|
+
export declare function buildStellarExecuteStrategyTx(opts: StellarExecuteStrategyBuilderOptions, swap: StellarStrategySwapInput): BuiltStellarTx;
|
|
46
50
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* @deprecated The router no longer exposes `batch_execute`; this wrapper now
|
|
52
|
+
* builds `execute_strategy(sender, total_in, swap_xdr)`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildStellarBatchSwapTx(opts: StellarBatchSwapBuilderOptions, swap: StellarStrategySwapInput): BuiltStellarTx;
|
|
55
|
+
/**
|
|
56
|
+
* Translate a quote-server response into the decoded `StrategyPayload` shape.
|
|
57
|
+
* Prefer `mapQuoteResponseToStrategySwap` when the quote includes `routeXdr`.
|
|
54
58
|
*/
|
|
55
|
-
export declare function
|
|
59
|
+
export declare function mapQuoteResponseToStrategyPayload(quote: StellarAggregatorQuoteResponseDto, opts?: {
|
|
60
|
+
referralId?: number | string;
|
|
61
|
+
}): StellarStrategyPayloadInput;
|
|
62
|
+
/**
|
|
63
|
+
* Return the executable quote route when the API provided it; otherwise build
|
|
64
|
+
* the decoded fallback payload from hop/path fields.
|
|
65
|
+
*/
|
|
66
|
+
export declare function mapQuoteResponseToStrategySwap(quote: StellarAggregatorQuoteResponseDto, opts?: {
|
|
67
|
+
referralId?: number | string;
|
|
68
|
+
}): StellarStrategySwapInput;
|
|
69
|
+
/** @deprecated Use `mapQuoteResponseToStrategyPayload`. */
|
|
70
|
+
export declare const mapQuoteResponseToAggregatorSwap: typeof mapQuoteResponseToStrategyPayload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xoxno/sdk-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.123",
|
|
4
4
|
"description": "The SDK to interact with the XOXNO Protocol!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -104,6 +104,6 @@
|
|
|
104
104
|
"@multiversx/sdk-core": "^15.3.2",
|
|
105
105
|
"@multiversx/sdk-network-providers": "^2.9.3",
|
|
106
106
|
"@stellar/stellar-sdk": "^15.0.1",
|
|
107
|
-
"@xoxno/types": "^1.0.
|
|
107
|
+
"@xoxno/types": "^1.0.410"
|
|
108
108
|
}
|
|
109
109
|
}
|