@xoxno/sdk-js 1.0.113 → 1.0.115

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.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Snapshot + structural tests for the Stellar lending ADMIN / CONFIG / KEEPER /
3
+ * ACCESS transaction builders.
4
+ *
5
+ * Beyond the function-name / arg-count / determinism / snapshot guards shared
6
+ * with `lending.test.ts`, this suite decodes the complex `#[contracttype]`
7
+ * struct args (`MarketOracleConfigInput`, `AssetConfigRaw`) back out of the XDR
8
+ * and asserts the ScMap keys are ascending-sorted (the Soroban host requires
9
+ * sorted symbol keys) and that the oracle union / custom-option tags are
10
+ * well-formed. The encoders reuse the same `scStruct` already proven on-chain
11
+ * by the production swap builders; for the all-lowercase snake_case field sets
12
+ * used here, JS lexicographic order matches Soroban's symbol collation.
13
+ */
14
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Decoder tests locked against REAL captured event XDR.
3
+ *
4
+ * `fixtures/lending-events.json` was produced by publishing every controller
5
+ * `#[contractevent]` in a soroban-sdk 26 test env and serializing each event's
6
+ * topics + `data` to base64 XDR via `ScVal::to_xdr_base64` — byte-identical to
7
+ * what Soroban RPC `getEvents` delivers. These tests prove the decoders match
8
+ * on-chain reality (not a hand-built assumption) and that the four legacy
9
+ * consumer bugs are fixed.
10
+ */
11
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Byte-identical parity guard for the Stellar lending activity-id primitives.
3
+ *
4
+ * Expected values are computed from api-v2's verbatim formula (the source these
5
+ * functions were ported from). Both consumers route their id derivation through
6
+ * these functions, so locking the outputs here is what makes the Phase 4
7
+ * activity-indexing consolidation safe — divergence shows up as a failing
8
+ * assertion, not as duplicated Cosmos docs.
9
+ */
10
+ export {};
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Stellar Soroban lending ADMIN / CONFIG / KEEPER / ACCESS transaction builders.
3
+ *
4
+ * Companion to `lending.ts` (user operations). Every state-changing controller
5
+ * entry point that is not a plain user op lives here, 1:1 with the controller
6
+ * `#[contractimpl]` methods in `rs-lending-xlm/contracts/controller/src/{access,
7
+ * config,router}.rs`. Each builder returns an unsigned `BuiltStellarTx` XDR.
8
+ *
9
+ * Auth model:
10
+ * - `#[only_owner]` methods take no `caller` param — the tx source
11
+ * (`opts.caller`) must be the contract owner.
12
+ * - `#[only_role(caller, "ROLE")]` and caller-taking methods encode
13
+ * `opts.caller` as the leading `Address` arg; that account must hold the
14
+ * role and sign the tx.
15
+ *
16
+ * The complex contract structs (`InterestRateModel`, `MarketParamsRaw`,
17
+ * `AssetConfigRaw`, `PositionLimits`, `MarketOracleConfigInput`) are encoded
18
+ * here from their `@xoxno/types` builder-input DTOs.
19
+ */
20
+ import type { AssetConfigRawDto, InterestRateModelDto, MarketOracleConfigInputDto, MarketParamsRawDto, OracleSourceConfigInputDto, PositionLimitsDto } from '@xoxno/types';
21
+ import { type BuiltStellarTx, type StellarBuilderOptions } from './lending';
22
+ import { xdr } from '@stellar/stellar-sdk';
23
+ /** `InterestRateModel` — 8 RAY rates + reserve factor bps. */
24
+ export declare const encodeInterestRateModel: (m: InterestRateModelDto) => xdr.ScVal;
25
+ /** `MarketParamsRaw` — `InterestRateModel` plus the pool asset identity. */
26
+ export declare const encodeMarketParamsRaw: (p: MarketParamsRawDto) => xdr.ScVal;
27
+ /** `AssetConfigRaw` — 17 risk/limit fields. */
28
+ export declare const encodeAssetConfigRaw: (c: AssetConfigRawDto) => xdr.ScVal;
29
+ /** `PositionLimits` — per-account supply/borrow position caps. */
30
+ export declare const encodePositionLimits: (l: PositionLimitsDto) => xdr.ScVal;
31
+ /** `OracleSourceConfigInput` data-enum — `Reflector(...)` | `RedStone(...)`. */
32
+ export declare const encodeOracleSourceConfigInput: (src: OracleSourceConfigInputDto) => xdr.ScVal;
33
+ /** `MarketOracleConfigInput` — strategy + primary/anchor sources + sanity bounds. */
34
+ export declare const encodeMarketOracleConfigInput: (cfg: MarketOracleConfigInputDto) => xdr.ScVal;
35
+ export interface RoleGrantArgs {
36
+ account: string;
37
+ role: string;
38
+ }
39
+ export interface TransferOwnershipArgs {
40
+ newOwner: string;
41
+ liveUntilLedger: number;
42
+ }
43
+ export interface EditAssetConfigArgs {
44
+ asset: string;
45
+ config: AssetConfigRawDto;
46
+ }
47
+ export interface EModeCategoryEditArgs {
48
+ id: number;
49
+ ltv: number;
50
+ threshold: number;
51
+ bonus: number;
52
+ }
53
+ export interface EModeAssetArgs {
54
+ asset: string;
55
+ categoryId: number;
56
+ canCollateral: boolean;
57
+ canBorrow: boolean;
58
+ }
59
+ export interface RemoveEModeAssetArgs {
60
+ asset: string;
61
+ categoryId: number;
62
+ }
63
+ export interface ConfigureMarketOracleArgs {
64
+ asset: string;
65
+ config: MarketOracleConfigInputDto;
66
+ }
67
+ export interface EditOracleToleranceArgs {
68
+ asset: string;
69
+ firstTolerance: number;
70
+ lastTolerance: number;
71
+ }
72
+ export interface CreateLiquidityPoolArgs {
73
+ asset: string;
74
+ params: MarketParamsRawDto;
75
+ config: AssetConfigRawDto;
76
+ }
77
+ export interface UpgradeLiquidityPoolParamsArgs {
78
+ asset: string;
79
+ params: InterestRateModelDto;
80
+ }
81
+ export interface UpgradeLiquidityPoolArgs {
82
+ asset: string;
83
+ wasmHash: string;
84
+ }
85
+ export interface RewardEntry {
86
+ token: string;
87
+ amount: string;
88
+ }
89
+ export interface UpdateAccountThresholdArgs {
90
+ asset: string;
91
+ hasRisks: boolean;
92
+ accountNonces: number[];
93
+ }
94
+ /** upgrade(new_wasm_hash: BytesN<32>) */
95
+ export declare function buildStellarUpgradeControllerTx(opts: StellarBuilderOptions, args: {
96
+ wasmHash: string;
97
+ }): BuiltStellarTx;
98
+ /** migrate(new_version: u32) */
99
+ export declare function buildStellarMigrateTx(opts: StellarBuilderOptions, args: {
100
+ newVersion: number;
101
+ }): BuiltStellarTx;
102
+ /** pause() */
103
+ export declare function buildStellarPauseTx(opts: StellarBuilderOptions): BuiltStellarTx;
104
+ /** unpause() */
105
+ export declare function buildStellarUnpauseTx(opts: StellarBuilderOptions): BuiltStellarTx;
106
+ /** grant_role(account: Address, role: Symbol) */
107
+ export declare function buildStellarGrantRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs): BuiltStellarTx;
108
+ /** revoke_role(account: Address, role: Symbol) */
109
+ export declare function buildStellarRevokeRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs): BuiltStellarTx;
110
+ /** transfer_ownership(new_owner: Address, live_until_ledger: u32) */
111
+ export declare function buildStellarTransferOwnershipTx(opts: StellarBuilderOptions, args: TransferOwnershipArgs): BuiltStellarTx;
112
+ /** accept_ownership() */
113
+ export declare function buildStellarAcceptOwnershipTx(opts: StellarBuilderOptions): BuiltStellarTx;
114
+ /** set_aggregator(addr: Address) — #[only_owner] */
115
+ export declare function buildStellarSetAggregatorTx(opts: StellarBuilderOptions, args: {
116
+ aggregator: string;
117
+ }): BuiltStellarTx;
118
+ /** set_accumulator(addr: Address) — #[only_owner] */
119
+ export declare function buildStellarSetAccumulatorTx(opts: StellarBuilderOptions, args: {
120
+ accumulator: string;
121
+ }): BuiltStellarTx;
122
+ /** set_liquidity_pool_template(hash: BytesN<32>) — #[only_owner] */
123
+ export declare function buildStellarSetLiquidityPoolTemplateTx(opts: StellarBuilderOptions, args: {
124
+ wasmHash: string;
125
+ }): BuiltStellarTx;
126
+ /** edit_asset_config(asset: Address, cfg: AssetConfigRaw) — #[only_owner] */
127
+ export declare function buildStellarEditAssetConfigTx(opts: StellarBuilderOptions, args: EditAssetConfigArgs): BuiltStellarTx;
128
+ /** set_position_limits(limits: PositionLimits) — #[only_owner] */
129
+ export declare function buildStellarSetPositionLimitsTx(opts: StellarBuilderOptions, args: PositionLimitsDto): BuiltStellarTx;
130
+ /** add_e_mode_category(ltv: u32, threshold: u32, bonus: u32) -> u32 — #[only_owner] */
131
+ export declare function buildStellarAddEModeCategoryTx(opts: StellarBuilderOptions, args: {
132
+ ltv: number;
133
+ threshold: number;
134
+ bonus: number;
135
+ }): BuiltStellarTx;
136
+ /** edit_e_mode_category(id: u32, ltv: u32, threshold: u32, bonus: u32) — #[only_owner] */
137
+ export declare function buildStellarEditEModeCategoryTx(opts: StellarBuilderOptions, args: EModeCategoryEditArgs): BuiltStellarTx;
138
+ /** remove_e_mode_category(id: u32) — #[only_owner] */
139
+ export declare function buildStellarRemoveEModeCategoryTx(opts: StellarBuilderOptions, args: {
140
+ id: number;
141
+ }): BuiltStellarTx;
142
+ /** add_asset_to_e_mode_category(asset, category_id, can_collateral, can_borrow) — #[only_owner] */
143
+ export declare function buildStellarAddAssetToEModeCategoryTx(opts: StellarBuilderOptions, args: EModeAssetArgs): BuiltStellarTx;
144
+ /** edit_asset_in_e_mode_category(asset, category_id, can_collateral, can_borrow) — #[only_owner] */
145
+ export declare function buildStellarEditAssetInEModeCategoryTx(opts: StellarBuilderOptions, args: EModeAssetArgs): BuiltStellarTx;
146
+ /** remove_asset_from_e_mode(asset: Address, category_id: u32) — #[only_owner] */
147
+ export declare function buildStellarRemoveAssetFromEModeTx(opts: StellarBuilderOptions, args: RemoveEModeAssetArgs): BuiltStellarTx;
148
+ /** approve_token(token: Address) — #[only_owner] */
149
+ export declare function buildStellarApproveTokenTx(opts: StellarBuilderOptions, args: {
150
+ token: string;
151
+ }): BuiltStellarTx;
152
+ /** revoke_token(token: Address) — #[only_owner] */
153
+ export declare function buildStellarRevokeTokenTx(opts: StellarBuilderOptions, args: {
154
+ token: string;
155
+ }): BuiltStellarTx;
156
+ /** configure_market_oracle(caller, asset, cfg) — #[only_role(caller, "ORACLE")] */
157
+ export declare function buildStellarConfigureMarketOracleTx(opts: StellarBuilderOptions, args: ConfigureMarketOracleArgs): BuiltStellarTx;
158
+ /** edit_oracle_tolerance(caller, asset, first_tolerance, last_tolerance) — #[only_role(caller, "ORACLE")] */
159
+ export declare function buildStellarEditOracleToleranceTx(opts: StellarBuilderOptions, args: EditOracleToleranceArgs): BuiltStellarTx;
160
+ /** disable_token_oracle(caller, asset) — #[only_role(caller, "ORACLE")] */
161
+ export declare function buildStellarDisableTokenOracleTx(opts: StellarBuilderOptions, args: {
162
+ asset: string;
163
+ }): BuiltStellarTx;
164
+ /** update_indexes(caller, assets: Vec<Address>) — #[only_role(caller, "KEEPER")] */
165
+ export declare function buildStellarUpdateIndexesTx(opts: StellarBuilderOptions, args: {
166
+ assets: string[];
167
+ }): BuiltStellarTx;
168
+ /** renew_account(caller, account_id: u64) */
169
+ export declare function buildStellarRenewAccountTx(opts: StellarBuilderOptions, args: {
170
+ accountNonce: number;
171
+ }): BuiltStellarTx;
172
+ /** create_liquidity_pool(asset, params: MarketParamsRaw, config: AssetConfigRaw) -> Address — #[only_owner] */
173
+ export declare function buildStellarCreateLiquidityPoolTx(opts: StellarBuilderOptions, args: CreateLiquidityPoolArgs): BuiltStellarTx;
174
+ /** upgrade_liquidity_pool_params(asset, params: InterestRateModel) — #[only_owner] */
175
+ export declare function buildStellarUpgradeLiquidityPoolParamsTx(opts: StellarBuilderOptions, args: UpgradeLiquidityPoolParamsArgs): BuiltStellarTx;
176
+ /** upgrade_liquidity_pool(asset, new_wasm_hash: BytesN<32>) — #[only_owner] */
177
+ export declare function buildStellarUpgradeLiquidityPoolTx(opts: StellarBuilderOptions, args: UpgradeLiquidityPoolArgs): BuiltStellarTx;
178
+ /** claim_revenue(caller, assets: Vec<Address>) -> Vec<i128> — #[only_role(caller, "REVENUE")] */
179
+ export declare function buildStellarClaimRevenueTx(opts: StellarBuilderOptions, args: {
180
+ assets: string[];
181
+ }): BuiltStellarTx;
182
+ /** add_rewards(caller, rewards: Vec<(Address, i128)>) — #[only_role(caller, "REVENUE")] */
183
+ export declare function buildStellarAddRewardsTx(opts: StellarBuilderOptions, args: {
184
+ rewards: RewardEntry[];
185
+ }): BuiltStellarTx;
186
+ /** update_account_threshold(caller, asset, has_risks, account_ids: Vec<u64>) — #[only_role(caller, "KEEPER")] */
187
+ export declare function buildStellarUpdateAccountThresholdTx(opts: StellarBuilderOptions, args: UpdateAccountThresholdArgs): BuiltStellarTx;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Decoders for the 21 XOXNO Stellar lending controller `#[contractevent]`s.
3
+ *
4
+ * Public API is **base64-XDR-string in** — `decodeStellarLendingEvent(topicsB64,
5
+ * dataB64)` parses with the SDK's own bundled `@stellar/stellar-sdk`, so no live
6
+ * `xdr.ScVal` ever crosses the consumer boundary. This makes decoding immune to
7
+ * the dual-package hazard and to `@stellar/stellar-sdk` version skew between the
8
+ * SDK and its consumers (Soroban RPC `getEvents` already delivers `topic[]` and
9
+ * `value` as base64 XDR — pass them straight through).
10
+ *
11
+ * soroban-sdk 26 serializes every contractevent `data` as an `ScMap` keyed by
12
+ * field name (verified against real captured emissions, including single-field
13
+ * and batch events), so `scValToNative` yields a snake_case-keyed object with
14
+ * `bigint` for i128/u64, `number` for u32, strkey strings for addresses,
15
+ * strings for symbols, `null` for absent `Option`s, and arrays for `Vec`s.
16
+ *
17
+ * Bug fixes baked in vs the consumers' legacy decoders:
18
+ * - the real `debt:ceiling_batch_update` is decoded (the single
19
+ * `debt:ceiling_update` is dead on-chain but kept for completeness);
20
+ * - `oracle:twap_degraded` is decoded;
21
+ * - borrow-side deltas expose risk fields as `undefined` (not 0);
22
+ * - no `liquidation_fees_bps` is read off position deltas (it does not exist).
23
+ */
24
+ import type { StellarLendingDecodedEvent } from '@xoxno/types';
25
+ /**
26
+ * Serialize a live `xdr.ScVal` to base64 XDR for the string-only decoder API.
27
+ * Use this if you hold parsed ScVals (e.g. from the high-level RPC client);
28
+ * `.toXDR` is wire-format/structural, so it is safe across SDK copies.
29
+ */
30
+ export declare const toBase64Xdr: (scv: {
31
+ toXDR(format: "base64"): string;
32
+ }) => string;
33
+ /** Build the `"<domain>:<action>"` dispatch key from the event topic ScVals. */
34
+ export declare const stellarLendingDispatchKey: (topicsB64: readonly string[]) => string;
35
+ /** Topic keys this SDK can decode (the 21 controller contractevents). */
36
+ export declare const STELLAR_LENDING_TOPICS: readonly string[];
37
+ /**
38
+ * Decode a Stellar lending controller event from its base64-XDR topics and
39
+ * data (exactly as Soroban RPC `getEvents` delivers them). Returns `null` for a
40
+ * topic this SDK does not decode (e.g. access-control `role_granted` events),
41
+ * so consumers can skip unknown events without throwing.
42
+ */
43
+ export declare function decodeStellarLendingEvent(topicsB64: readonly string[], dataB64: string): StellarLendingDecodedEvent | null;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Stellar lending activity-id derivation — the single owner of the inputs that
3
+ * compose `NftActivityDoc.id` (`${txHash}-${eventIdentifier}-${eventOrder}`).
4
+ *
5
+ * Both indexing consumers (xoxno-api-v2, xoxno-az-functions) MUST derive these
6
+ * inputs here so the activity ids they write to `NFT_ACTIVITY_DATA` are
7
+ * byte-identical — the hard gate for consolidating activity indexing into a
8
+ * single producer. Ported verbatim from api-v2's `stellar-lending-activity.mapper`.
9
+ *
10
+ * The activity-type string values mirror `@xoxno/types` `XoxnoLendingActivity`.
11
+ * They are inlined (not imported) because `@xoxno/types` does not re-export its
12
+ * enums on the top-level type surface and the SDK keeps that NestJS-coupled
13
+ * module out of its runtime bundle.
14
+ */
15
+ /** Synthetic NFT collection ticker for Stellar lending accounts. */
16
+ export declare const XOXNO_LENDING_STELLAR_TICKER = "XLENDXLM-a7c9f3";
17
+ /**
18
+ * A child delta's contribution to `eventOrder`: `base * STRIDE + childIndex`.
19
+ * The stride bounds the number of child deltas per base event before two base
20
+ * events could collide.
21
+ */
22
+ export declare const SYNTHETIC_EVENT_ORDER_STRIDE = 10000;
23
+ /** `XoxnoLendingActivity` values used by the position activity mapping. */
24
+ export type StellarLendingActivityType = 'lendingUpdateAccountPosition' | 'lendingLiquidateRepayDebt' | 'lendingLiquidateSeizeCollateral' | 'lendingUpdateAccountParameters';
25
+ /**
26
+ * Synthetic NFT identifier for a Stellar lending account, e.g.
27
+ * `XLENDXLM-a7c9f3-2a` for account 42. The u64 account id is rendered as
28
+ * even-length lowercase hex.
29
+ */
30
+ export declare function buildStellarLendingIdentifier(accountId: string): string;
31
+ /**
32
+ * Extract the base event order from a Soroban RPC event id (`<ledger>-<index>`).
33
+ * Returns 0 when the id is malformed or has no index segment.
34
+ */
35
+ export declare function extractEventOrder(eventId: string): number;
36
+ /**
37
+ * Stable per-child ordering within one base event:
38
+ * `baseEventOrder * 10_000 + childIndex`. Keeps multiple deltas emitted by a
39
+ * single transaction deterministically ordered and collision-free.
40
+ */
41
+ export declare function syntheticEventOrder(baseEventOrder: number, childIndex?: number): number;
42
+ /**
43
+ * Map a position-delta `action` symbol to its `XoxnoLendingActivity` value.
44
+ * The tag list is authoritative in `rs-lending-xlm common/src/events.rs`.
45
+ */
46
+ export declare function mapStellarPositionActivityType(action?: string): StellarLendingActivityType;
@@ -0,0 +1,2 @@
1
+ export * from './decode';
2
+ export * from './id';
@@ -1,4 +1,6 @@
1
1
  export * from './contracts';
2
2
  export * from './lending';
3
+ export * from './admin';
4
+ export * from './events';
3
5
  export * from './quote';
4
6
  export * from './swap';
@@ -37,6 +37,7 @@
37
37
  * handing the XDR to the wallet to sign.
38
38
  */
39
39
  import type { AggregatorSwapDto, BorrowArgs, FlashLoanArgs, LiquidateArgs, MultiplyArgs, RepayArgs, RepayDebtWithCollateralArgs, SupplyArgs, SwapCollateralArgs, SwapDebtArgs, SwapHopDto, SwapPathDto, SwapVenue, WithdrawArgs } from '@xoxno/types';
40
+ import { xdr } from '@stellar/stellar-sdk';
40
41
  import { type StellarNetwork } from './contracts';
41
42
  /**
42
43
  * Stellar `G...` public key of the caller (tx source account).
@@ -104,6 +105,15 @@ export type StellarSwapStepsInput = AggregatorSwapDto;
104
105
  export type StellarSwapHopInput = SwapHopDto;
105
106
  export type StellarSwapPathInput = SwapPathDto;
106
107
  export type StellarSwapVenue = SwapVenue;
108
+ /**
109
+ * Assemble an unsigned XDR that invokes a single Soroban contract method.
110
+ *
111
+ * Uses a synthetic `Account(caller, sourceSequence)` — no RPC call. The
112
+ * returned XDR still needs preparation (simulation to populate Soroban
113
+ * footprint + auth entries + resource fees) before signing. The UI layer
114
+ * does this via `rpc.Server.prepareTransaction`.
115
+ */
116
+ export declare function buildTx(opts: StellarBuilderOptions, method: string, params: xdr.ScVal[]): BuiltStellarTx;
107
117
  /**
108
118
  * supply(caller, account_id: u64, e_mode_category: u32, assets: Vec<(Address, i128)>)
109
119
  * @xoxno/types `SupplyArgs` is a single-asset shape; the Stellar contract
@@ -132,7 +142,13 @@ export declare function buildStellarLiquidateTx(opts: StellarBuilderOptions, arg
132
142
  export declare function buildStellarFlashLoanTx(opts: StellarBuilderOptions, args: FlashLoanArgs): BuiltStellarTx;
133
143
  /**
134
144
  * multiply(caller, account_id, e_mode_category, collateral_token,
135
- * debt_to_flash_loan: i128, debt_token, mode: u32, steps: SwapSteps) -> u64
145
+ * debt_to_flash_loan: i128, debt_token, mode: PositionMode,
146
+ * swap: AggregatorSwap, initial_payment: Option<(Address, i128)>,
147
+ * convert_swap: Option<AggregatorSwap>) -> u64
148
+ *
149
+ * `mode` is a repr(u32) `PositionMode` → encoded as `scvU32`. The two trailing
150
+ * `Option`s seed an optional initial collateral payment and a secondary swap
151
+ * converting it into the collateral token; both omit to Soroban `Void`.
136
152
  */
137
153
  export declare function buildStellarMultiplyTx(opts: StellarBuilderOptions, args: MultiplyArgs): BuiltStellarTx;
138
154
  /**
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Shared Soroban `ScVal` encoding primitives for the Stellar lending SDK.
3
+ *
4
+ * Extracted verbatim from `lending.ts` so both the user-operation builders
5
+ * (`lending.ts`) and the admin/config builders (`admin.ts`) encode against one
6
+ * implementation. Behavior-preserving: the existing builder XDR snapshots must
7
+ * not change.
8
+ *
9
+ * i128/u128 values cross the boundary as decimal strings (`new ScInt(str)`).
10
+ * Addresses (Stellar `G...` accounts and Soroban `C...` contracts) encode via
11
+ * `new Address(str).toScVal()`. Soroban `#[contracttype]` structs are ScMaps
12
+ * with `Symbol` keys in ascending order — `scStruct` lex-sorts the field names,
13
+ * which matches Soroban's small-symbol collation for the all-lowercase
14
+ * snake_case field sets used here.
15
+ */
16
+ import type { AggregatorSwapDto, SwapVenue } from '@xoxno/types';
17
+ import { xdr } from '@stellar/stellar-sdk';
18
+ /**
19
+ * Inlined copy of `SWAP_VENUES` from `@xoxno/types` so the SDK can validate a
20
+ * runtime-supplied venue without forcing the (NestJS-coupled) `@xoxno/types`
21
+ * module to load at runtime. Kept in lockstep with the upstream constant; any
22
+ * new on-chain venue must be added in both places + the contract's `SwapVenue`
23
+ * enum.
24
+ */
25
+ export declare const STELLAR_SWAP_VENUES: readonly ["Soroswap", "Aquarius", "Phoenix", "NativeAmm", "StaticBridge"];
26
+ export type StellarSwapStepsInput = AggregatorSwapDto;
27
+ export declare const addr: (a: string) => xdr.ScVal;
28
+ export declare const i128: (s: string) => xdr.ScVal;
29
+ export declare const u32: (n: number) => xdr.ScVal;
30
+ export declare const u64: (n: number | string) => xdr.ScVal;
31
+ export declare const bool: (b: boolean) => xdr.ScVal;
32
+ export declare const str: (s: string) => xdr.ScVal;
33
+ export declare const sym: (s: string) => xdr.ScVal;
34
+ export declare const voidVal: () => xdr.ScVal;
35
+ export declare const vec: (items: xdr.ScVal[]) => xdr.ScVal;
36
+ export declare const bytes: (hex: string) => xdr.ScVal;
37
+ /**
38
+ * Encode a Soroban `BytesN<N>` (default 32) — a fixed-length byte array such as
39
+ * a WASM hash. Validates the decoded length so a malformed hash fails at the
40
+ * SDK boundary, not deep inside the host.
41
+ */
42
+ export declare const bytesN: (hex: string, length?: number) => xdr.ScVal;
43
+ /**
44
+ * Encode a Soroban `Option<T>`: `None` is `scvVoid`, `Some(x)` is the bare
45
+ * encoded `x` (Soroban does not wrap `Some`). NOT for the contract's custom
46
+ * `OracleSourceConfigInputOption` enum, which is a tagged union — see
47
+ * `encodeOracleSourceConfigInputOption` in `admin.ts`.
48
+ */
49
+ export declare const option: <T>(value: T | undefined | null, encode: (v: T) => xdr.ScVal) => xdr.ScVal;
50
+ /**
51
+ * Encode a single Soroban tuple `(Address, i128)` as a 2-element `scvVec`.
52
+ */
53
+ export declare const tupleAddrAmount: (token: string, amount: string) => xdr.ScVal;
54
+ /**
55
+ * Encode `Vec<(Address, i128)>` — a Soroban tuple-vec of (asset, amount).
56
+ * Each tuple is a 2-element `scvVec`.
57
+ */
58
+ export declare const tupleAddrAmountVec: (entries: Array<{
59
+ token: string;
60
+ amount: string;
61
+ }>) => xdr.ScVal;
62
+ /**
63
+ * Encode a Soroban `struct` — at the XDR level, structs are maps with
64
+ * `Symbol` keys in **lexicographic order** of field names.
65
+ */
66
+ export declare const scStruct: (fields: Record<string, xdr.ScVal>) => xdr.ScVal;
67
+ /**
68
+ * Encode a Soroban `enum SwapVenue` (tag-only / unit variant). At the XDR level
69
+ * a unit variant is `scvVec([symbol_name])`.
70
+ */
71
+ export declare const encodeSwapVenue: (venue: SwapVenue) => xdr.ScVal;
72
+ /**
73
+ * Encode the controller-facing `AggregatorSwap` struct
74
+ * (`{ paths: Vec<SwapPath>, total_min_out: i128 }`).
75
+ *
76
+ * `SwapPath` is the PPM-split shape: each path declares `split_ppm`
77
+ * (parts-per-million share of the batch's total input) and a `hops` chain.
78
+ */
79
+ export declare const encodeAggregatorSwap: (swap: StellarSwapStepsInput) => xdr.ScVal;
80
+ /**
81
+ * Validate the untyped `steps` field from a Wave 0 DTO and narrow it to
82
+ * `AggregatorSwapDto`. Throws a clear error if the caller passed the wrong
83
+ * shape so the failure surfaces at the SDK boundary, not deep inside the
84
+ * Soroban host on-chain.
85
+ */
86
+ export declare const asStellarSwapSteps: (steps: unknown) => StellarSwapStepsInput;
87
+ /**
88
+ * Validate the untyped `data` field on FlashLoanArgs and narrow it to
89
+ * Buffer / hex string for Soroban `Bytes` encoding.
90
+ */
91
+ export declare const asStellarBytes: (data: unknown) => xdr.ScVal;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@xoxno/sdk-js",
3
- "version": "1.0.113",
3
+ "version": "1.0.115",
4
4
  "description": "The SDK to interact with the XOXNO Protocol!",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
+ "types": "./dist/index.d.ts",
8
9
  "import": "./dist/index.esm.js",
9
- "require": "./dist/index.cjs.js",
10
- "types": "./dist/index.d.ts"
10
+ "require": "./dist/index.cjs.js"
11
11
  }
12
12
  },
13
13
  "types": "./dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "test": "jest",
22
22
  "build:sdk": "npx bun run src/sdk/parseSwagger.ts && npx oxlint src/sdk/swagger.ts --fix && npx bun run md/extract.ts",
23
- "build:types": "tsc --emitDeclarationOnly",
23
+ "build:types": "tsc --emitDeclarationOnly && dts-bundle-generator --no-check --external-imports @xoxno/types @stellar/stellar-sdk @nestjs/common @nestjs/swagger -o dist/index.d.ts src/index.ts",
24
24
  "build:esm": "webpack --config webpack-esm.config.mjs",
25
25
  "build:cjs": "webpack --config webpack-cjs.config.mjs",
26
26
  "build": "npm run build:sdk && npm run build:types && npm run build:esm && npm run build:cjs",
@@ -63,6 +63,8 @@
63
63
  "@commitlint/cli": "^20.4.1",
64
64
  "@commitlint/config-conventional": "^20.4.1",
65
65
  "@multiversx/sdk-extension-provider": "^5.1.2",
66
+ "@nestjs/common": "^11.1.24",
67
+ "@nestjs/swagger": "^11.4.4",
66
68
  "@semantic-release/changelog": "^6.0.3",
67
69
  "@semantic-release/git": "^10.0.1",
68
70
  "@swc/cli": "^0.8.0",
@@ -74,6 +76,7 @@
74
76
  "commitizen": "^4.2.4",
75
77
  "cookies-next": "^6.1.1",
76
78
  "cz-conventional-changelog": "^3.3.0",
79
+ "dts-bundle-generator": "^9.5.1",
77
80
  "fork-ts-checker-webpack-plugin": "^9.1.0",
78
81
  "husky": "^9.1.7",
79
82
  "jest": "^30.2.0",
@@ -94,6 +97,6 @@
94
97
  "@multiversx/sdk-core": "^15.3.2",
95
98
  "@multiversx/sdk-network-providers": "^2.9.3",
96
99
  "@stellar/stellar-sdk": "^15.0.1",
97
- "@xoxno/types": "^1.0.398"
100
+ "@xoxno/types": "^1.0.404"
98
101
  }
99
102
  }