@xoxno/sdk-js 1.0.104 → 1.0.106
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.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/sdk/stellar/contracts.d.ts +30 -6
- package/dist/sdk/stellar/index.d.ts +2 -0
- package/dist/sdk/stellar/lending.d.ts +26 -16
- package/dist/sdk/stellar/quote.d.ts +58 -0
- package/dist/sdk/stellar/swap.d.ts +41 -0
- package/dist/sdk/swagger.d.ts +2 -0
- package/package.json +2 -2
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stellar
|
|
2
|
+
* Stellar Soroban contract addresses + Soroban RPC + quote-server config
|
|
3
|
+
* per network.
|
|
3
4
|
*
|
|
4
|
-
* Addresses are env-sourced so ops can rotate mainnet/testnet deployments
|
|
5
|
-
* a code change. Defaults fall back to empty
|
|
6
|
-
* clear "
|
|
5
|
+
* Addresses are env-sourced so ops can rotate mainnet/testnet deployments
|
|
6
|
+
* without a code change. Defaults fall back to empty strings so a missing
|
|
7
|
+
* env surfaces as a clear "not configured" error at call time rather than
|
|
7
8
|
* silently pointing at the wrong contract.
|
|
8
9
|
*/
|
|
9
10
|
export type StellarNetwork = 'mainnet' | 'testnet';
|
|
10
11
|
/**
|
|
11
|
-
* Stellar controller contract addresses per network.
|
|
12
|
+
* Stellar lending controller contract addresses per network.
|
|
12
13
|
* Env vars:
|
|
13
14
|
* - STELLAR_LENDING_CONTROLLER_MAINNET
|
|
14
15
|
* - STELLAR_LENDING_CONTROLLER_TESTNET
|
|
15
16
|
*/
|
|
16
17
|
export declare const STELLAR_LENDING_CONTROLLER: Record<StellarNetwork, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Stellar aggregator router contract addresses per network.
|
|
20
|
+
* Targets `batch_execute(BatchSwap)` for direct (non-lending) swaps.
|
|
21
|
+
* Env vars:
|
|
22
|
+
* - STELLAR_AGGREGATOR_ROUTER_MAINNET
|
|
23
|
+
* - STELLAR_AGGREGATOR_ROUTER_TESTNET
|
|
24
|
+
*/
|
|
25
|
+
export declare const STELLAR_AGGREGATOR_ROUTER: Record<StellarNetwork, string>;
|
|
17
26
|
/**
|
|
18
27
|
* Default Soroban RPC URLs per network.
|
|
19
28
|
* Overridable at runtime via the `sorobanRpcUrl` option on each builder.
|
|
20
29
|
*/
|
|
21
30
|
export declare const STELLAR_SOROBAN_RPC_URL: Record<StellarNetwork, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Stellar aggregator quote-server base URLs per network. The quote server
|
|
33
|
+
* exposes `GET /api/v1/tokens` and `GET /api/v1/quote`.
|
|
34
|
+
*
|
|
35
|
+
* Env vars:
|
|
36
|
+
* - STELLAR_QUOTE_URL_MAINNET
|
|
37
|
+
* - STELLAR_QUOTE_URL_TESTNET
|
|
38
|
+
*/
|
|
39
|
+
export declare const STELLAR_QUOTE_URL: Record<StellarNetwork, string>;
|
|
22
40
|
/**
|
|
23
41
|
* Stellar network passphrases (Soroban tx signing domain separator).
|
|
24
42
|
* These are fixed by the Stellar network itself and must not be overridden.
|
|
@@ -26,6 +44,12 @@ export declare const STELLAR_SOROBAN_RPC_URL: Record<StellarNetwork, string>;
|
|
|
26
44
|
export declare const STELLAR_NETWORK_PASSPHRASE: Record<StellarNetwork, string>;
|
|
27
45
|
/**
|
|
28
46
|
* Assert a controller address is configured for the target network.
|
|
29
|
-
* Throws early with a clear message rather than building an XDR that
|
|
47
|
+
* Throws early with a clear message rather than building an XDR that
|
|
48
|
+
* points at `""`.
|
|
30
49
|
*/
|
|
31
50
|
export declare function getStellarLendingController(network: StellarNetwork): string;
|
|
51
|
+
/**
|
|
52
|
+
* Assert an aggregator router address is configured for the target network.
|
|
53
|
+
* Used by `buildStellarBatchSwapTx` for direct user→router swaps.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getStellarAggregatorRouter(network: StellarNetwork): string;
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* (which handles simulation + Soroban footprint/auth/resource fee) before
|
|
37
37
|
* handing the XDR to the wallet to sign.
|
|
38
38
|
*/
|
|
39
|
-
import type { BorrowArgs, FlashLoanArgs, LiquidateArgs, MultiplyArgs, RepayArgs, RepayDebtWithCollateralArgs, SupplyArgs, SwapCollateralArgs, SwapDebtArgs, WithdrawArgs } from '@xoxno/types';
|
|
39
|
+
import type { AggregatorSwapDto, BorrowArgs, FlashLoanArgs, LiquidateArgs, MultiplyArgs, RepayArgs, RepayDebtWithCollateralArgs, SupplyArgs, SwapCollateralArgs, SwapDebtArgs, SwapHopDto, SwapPathDto, SwapVenue, WithdrawArgs } from '@xoxno/types';
|
|
40
40
|
import { type StellarNetwork } from './contracts';
|
|
41
41
|
/**
|
|
42
42
|
* Stellar `G...` public key of the caller (tx source account).
|
|
@@ -68,32 +68,42 @@ export interface BuiltStellarTx {
|
|
|
68
68
|
xdr: string;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Input shape for the Stellar-specific `
|
|
71
|
+
* Input shape for the Stellar-specific `swap` payload carried on
|
|
72
72
|
* `MultiplyArgs.steps`, `SwapDebtArgs.steps`, `SwapCollateralArgs.steps`,
|
|
73
73
|
* `RepayDebtWithCollateralArgs.steps`.
|
|
74
74
|
*
|
|
75
75
|
* @xoxno/types declares `steps: unknown` on the Wave 0 DTOs so every chain
|
|
76
|
-
* owns its own encoding. On Stellar,
|
|
77
|
-
* which is serialised
|
|
78
|
-
* rs-lending
|
|
76
|
+
* owns its own encoding. On Stellar, callers MUST pass an
|
|
77
|
+
* `AggregatorSwapDto` which is serialised into the Soroban
|
|
78
|
+
* `AggregatorSwap` struct from `rs-lending-xlm common/src/types.rs`:
|
|
79
79
|
*
|
|
80
80
|
* pub struct SwapHop {
|
|
81
|
-
* pub
|
|
81
|
+
* pub fee_bps: u32,
|
|
82
|
+
* pub pool: Address,
|
|
82
83
|
* pub token_in: Address,
|
|
83
84
|
* pub token_out: Address,
|
|
85
|
+
* pub venue: SwapVenue, // tag-only enum
|
|
86
|
+
* }
|
|
87
|
+
* pub struct SwapPath {
|
|
88
|
+
* pub amount_in: i128,
|
|
89
|
+
* pub hops: Vec<SwapHop>,
|
|
84
90
|
* pub min_amount_out: i128,
|
|
85
91
|
* }
|
|
92
|
+
* pub struct AggregatorSwap { // controller payload
|
|
93
|
+
* pub paths: Vec<SwapPath>,
|
|
94
|
+
* pub total_min_out: i128,
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* The controller wraps `AggregatorSwap` in `BatchSwap` (filling
|
|
98
|
+
* `sender = current_contract_address`) before forwarding to the router.
|
|
99
|
+
*
|
|
100
|
+
* Re-exported from this module so consumers can `import { StellarSwapStepsInput }`
|
|
101
|
+
* and get the canonical typed shape without reaching into `@xoxno/types`.
|
|
86
102
|
*/
|
|
87
|
-
export
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export
|
|
91
|
-
poolAddress: string;
|
|
92
|
-
tokenIn: string;
|
|
93
|
-
tokenOut: string;
|
|
94
|
-
/** Decimal string i128. */
|
|
95
|
-
minAmountOut: string;
|
|
96
|
-
}
|
|
103
|
+
export type StellarSwapStepsInput = AggregatorSwapDto;
|
|
104
|
+
export type StellarSwapHopInput = SwapHopDto;
|
|
105
|
+
export type StellarSwapPathInput = SwapPathDto;
|
|
106
|
+
export type StellarSwapVenue = SwapVenue;
|
|
97
107
|
/**
|
|
98
108
|
* supply(caller, account_id: u64, e_mode_category: u32, assets: Vec<(Address, i128)>)
|
|
99
109
|
* @xoxno/types `SupplyArgs` is a single-asset shape; the Stellar contract
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed client for the Stellar aggregator quote server
|
|
3
|
+
* (`GET /api/v1/quote`, `GET /api/v1/tokens`).
|
|
4
|
+
*
|
|
5
|
+
* The quote server is a standalone Rust service (deployed independently
|
|
6
|
+
* of the main XOXNO API), so this module hits its base URL directly
|
|
7
|
+
* rather than routing through the swagger-driven endpoints map.
|
|
8
|
+
*
|
|
9
|
+
* All response shapes are mirrored 1:1 by `@xoxno/types` DTOs
|
|
10
|
+
* (`StellarAggregatorQuoteResponseDto`, `StellarQuotePathDto`, etc.) —
|
|
11
|
+
* the wire shape is camelCase, the Soroban contract receives snake_case
|
|
12
|
+
* after the SDK encoder rewrites field names.
|
|
13
|
+
*/
|
|
14
|
+
import type { StellarAggregatorQuoteRequestDto, StellarAggregatorQuoteResponseDto, StellarTokenKind } from '@xoxno/types';
|
|
15
|
+
import { type StellarNetwork } from './contracts';
|
|
16
|
+
/**
|
|
17
|
+
* Resolved token entry returned by the quote server's tokens endpoint.
|
|
18
|
+
* Mirrors the indexer's `TokenEntry` JSON exactly.
|
|
19
|
+
*/
|
|
20
|
+
export interface StellarQuoteToken {
|
|
21
|
+
/** Canonical token id. `C…` for Soroban contracts; `CODE:GISSUER…`
|
|
22
|
+
* for Classic; `XLM` for native. */
|
|
23
|
+
id: string;
|
|
24
|
+
kind: StellarTokenKind;
|
|
25
|
+
decimals: number;
|
|
26
|
+
/** Soroban Asset Contract peer for Classic assets (null otherwise). */
|
|
27
|
+
sacPeer: string | null;
|
|
28
|
+
/** Classic asset code (for Classic / SAC entries; null for Soroban). */
|
|
29
|
+
code: string | null;
|
|
30
|
+
/** Number of pools touching this token in the current snapshot. */
|
|
31
|
+
degree: number;
|
|
32
|
+
}
|
|
33
|
+
export interface StellarQuoteFetchOptions {
|
|
34
|
+
/** Network selects which base URL to hit. */
|
|
35
|
+
network: StellarNetwork;
|
|
36
|
+
/** Override the resolved base URL (useful for tests / preview). */
|
|
37
|
+
baseUrl?: string;
|
|
38
|
+
/** Per-call fetch options (signal, headers, etc.). */
|
|
39
|
+
fetchOptions?: RequestInit;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Fetch a route quote from the Stellar aggregator quote server.
|
|
43
|
+
*
|
|
44
|
+
* Forward mode: pass `amountIn` to compute the maximum reachable
|
|
45
|
+
* `amountOut`. Reverse mode: pass `amountOut` to compute the minimum
|
|
46
|
+
* `amountIn` that delivers at least that output.
|
|
47
|
+
*
|
|
48
|
+
* Pass both `sender` (G-strkey) and `router` (C-strkey) to receive a
|
|
49
|
+
* ready-to-sign envelope under `transaction.envelopeXdr`. The caller
|
|
50
|
+
* must still run `simulateTransaction` to attach Soroban resource fees
|
|
51
|
+
* before signing.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getStellarAggregatorQuote(request: StellarAggregatorQuoteRequestDto, opts: StellarQuoteFetchOptions): Promise<StellarAggregatorQuoteResponseDto>;
|
|
54
|
+
/**
|
|
55
|
+
* List tokens currently indexed by the quote server. Useful to populate
|
|
56
|
+
* pickers or validate that a user-supplied token has on-chain liquidity.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getStellarQuoteTokens(opts: StellarQuoteFetchOptions): Promise<StellarQuoteToken[]>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellar aggregator router direct-call transaction builder.
|
|
3
|
+
*
|
|
4
|
+
* Builds an unsigned XDR for `router.batch_execute(BatchSwap)` so a
|
|
5
|
+
* user can swap A → B without involving the lending controller. The
|
|
6
|
+
* `BatchSwap.sender` is filled with the caller's G-strkey (the user's
|
|
7
|
+
* own SAC balances fund the swap and receive the output).
|
|
8
|
+
*
|
|
9
|
+
* For lending strategies (multiply / swap_debt / swap_collateral /
|
|
10
|
+
* repay_debt_with_collateral) the controller wraps the same payload
|
|
11
|
+
* itself and sets `sender = current_contract_address` — those flows
|
|
12
|
+
* use the strategy builders in `./lending.ts`, NOT this builder.
|
|
13
|
+
*/
|
|
14
|
+
import type { AggregatorSwapDto, StellarAggregatorQuoteResponseDto } from '@xoxno/types';
|
|
15
|
+
import type { BuiltStellarTx, StellarBuilderOptions } from './lending';
|
|
16
|
+
export interface StellarBatchSwapBuilderOptions extends StellarBuilderOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Override the resolved aggregator router contract address. Normally
|
|
19
|
+
* resolved from `STELLAR_AGGREGATOR_ROUTER[network]`.
|
|
20
|
+
*/
|
|
21
|
+
routerAddress?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build an unsigned XDR for a direct user → aggregator router swap.
|
|
25
|
+
*
|
|
26
|
+
* The `swap` payload (paths + per-path min-outs + total-min-out) comes
|
|
27
|
+
* straight from the quote server; map a
|
|
28
|
+
* `StellarAggregatorQuoteResponseDto` to `AggregatorSwapDto` via
|
|
29
|
+
* `mapQuoteResponseToAggregatorSwap` before calling this.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildStellarBatchSwapTx(opts: StellarBatchSwapBuilderOptions, swap: AggregatorSwapDto): BuiltStellarTx;
|
|
32
|
+
/**
|
|
33
|
+
* Translate a quote-server response into the controller-facing
|
|
34
|
+
* `AggregatorSwapDto`. The mapping is purely a key rename plus the
|
|
35
|
+
* fallback for single-path quotes that omit `paths` (we wrap the flat
|
|
36
|
+
* `hops` list as a single path).
|
|
37
|
+
*
|
|
38
|
+
* Throws if `amountOutMin` is missing — the controller refuses
|
|
39
|
+
* unbounded swaps so the SDK rejects them at the boundary.
|
|
40
|
+
*/
|
|
41
|
+
export declare function mapQuoteResponseToAggregatorSwap(quote: StellarAggregatorQuoteResponseDto): AggregatorSwapDto;
|
package/dist/sdk/swagger.d.ts
CHANGED
|
@@ -398,6 +398,7 @@ export declare const endpoints: {
|
|
|
398
398
|
readonly "/user/lending/image/:nonce": {
|
|
399
399
|
readonly input: {
|
|
400
400
|
isStatic: boolean;
|
|
401
|
+
chain?: ActivityChain[];
|
|
401
402
|
};
|
|
402
403
|
readonly output: string;
|
|
403
404
|
};
|
|
@@ -430,6 +431,7 @@ export declare const endpoints: {
|
|
|
430
431
|
orderBy?: LendingPositionOrderByColumn;
|
|
431
432
|
orderDirection?: KustoOrderDirection;
|
|
432
433
|
token?: string;
|
|
434
|
+
chain?: ActivityChain[];
|
|
433
435
|
};
|
|
434
436
|
readonly output: LendingPositionStatus[];
|
|
435
437
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xoxno/sdk-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.106",
|
|
4
4
|
"description": "The SDK to interact with the XOXNO Protocol!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -94,6 +94,6 @@
|
|
|
94
94
|
"@multiversx/sdk-core": "^15.3.2",
|
|
95
95
|
"@multiversx/sdk-network-providers": "^2.9.3",
|
|
96
96
|
"@stellar/stellar-sdk": "^15.0.1",
|
|
97
|
-
"@xoxno/types": "^1.0.
|
|
97
|
+
"@xoxno/types": "^1.0.392"
|
|
98
98
|
}
|
|
99
99
|
}
|