@xoxno/sdk-js 1.0.117 → 1.0.119
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 +9 -39
- package/dist/index.bundled.d.ts +9 -39
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/sdk/stellar/__tests__/admin.test.d.ts +9 -10
- package/dist/sdk/stellar/__tests__/decode.test.d.ts +4 -7
- package/dist/sdk/stellar/__tests__/id.test.d.ts +1 -7
- package/dist/sdk/stellar/admin.d.ts +2 -10
- package/dist/sdk/stellar/events/decode.d.ts +10 -19
- package/dist/sdk/stellar/events/id.d.ts +5 -11
- package/dist/sdk/stellar/lending.d.ts +15 -60
- package/dist/sdk/stellar/scval-encode.d.ts +7 -19
- package/package.json +2 -2
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Snapshot + structural tests for the Stellar lending
|
|
3
|
-
*
|
|
2
|
+
* Snapshot + structural tests for the Stellar lending admin / config / keeper /
|
|
3
|
+
* access transaction builders.
|
|
4
4
|
*
|
|
5
|
-
* Beyond the function-name / arg-count / determinism / snapshot guards
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* used here, JS lexicographic order matches Soroban's symbol collation.
|
|
5
|
+
* Beyond the function-name / arg-count / determinism / snapshot guards, this
|
|
6
|
+
* suite decodes the complex `#[contracttype]` struct args
|
|
7
|
+
* (`MarketOracleConfigInput`, `AssetConfigRaw`) back out of the XDR and asserts
|
|
8
|
+
* the ScMap keys are ascending-sorted (the Soroban host requires sorted symbol
|
|
9
|
+
* keys) and that the oracle union / custom-option tags are well-formed. For the
|
|
10
|
+
* all-lowercase snake_case field sets used here, JS lexicographic order matches
|
|
11
|
+
* Soroban's symbol collation.
|
|
13
12
|
*/
|
|
14
13
|
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Decoder tests locked against
|
|
2
|
+
* Decoder tests locked against captured event XDR.
|
|
3
3
|
*
|
|
4
|
-
* `fixtures/lending-events.json`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
4
|
+
* `fixtures/lending-events.json` holds every controller `#[contractevent]`'s
|
|
5
|
+
* topics + `data` serialized to base64 XDR, exactly as Soroban RPC `getEvents`
|
|
6
|
+
* delivers them.
|
|
10
7
|
*/
|
|
11
8
|
export {};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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.
|
|
2
|
+
* Tests for the Stellar lending activity-id primitives, locking their outputs.
|
|
9
3
|
*/
|
|
10
4
|
export {};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stellar
|
|
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.
|
|
2
|
+
* Stellar lending admin / config / keeper / access transaction builders. Each
|
|
3
|
+
* builder returns an unsigned `BuiltStellarTx` XDR.
|
|
8
4
|
*
|
|
9
5
|
* Auth model:
|
|
10
6
|
* - `#[only_owner]` methods take no `caller` param — the tx source
|
|
@@ -12,10 +8,6 @@
|
|
|
12
8
|
* - `#[only_role(caller, "ROLE")]` and caller-taking methods encode
|
|
13
9
|
* `opts.caller` as the leading `Address` arg; that account must hold the
|
|
14
10
|
* 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
11
|
*/
|
|
20
12
|
import type { AssetConfigRawDto, InterestRateModelDto, MarketOracleConfigInputDto, MarketParamsRawDto, OracleSourceConfigInputDto, PositionLimitsDto } from '@xoxno/types';
|
|
21
13
|
import { type BuiltStellarTx, type StellarBuilderOptions } from './lending';
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Decoders for the 21
|
|
2
|
+
* Decoders for the 21 Stellar lending controller `#[contractevent]`s.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* dataB64)` parses with
|
|
6
|
-
* `xdr.ScVal`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `value` as base64 XDR — pass them straight through).
|
|
4
|
+
* The public API takes base64-XDR strings (`decodeStellarLendingEvent(topicsB64,
|
|
5
|
+
* dataB64)`) and parses them with this SDK's bundled `@stellar/stellar-sdk`, so
|
|
6
|
+
* no live `xdr.ScVal` crosses the consumer boundary. Soroban RPC `getEvents`
|
|
7
|
+
* already delivers `topic[]` and `value` as base64 XDR — pass them straight
|
|
8
|
+
* through.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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).
|
|
10
|
+
* Each contractevent `data` serializes as an `ScMap` keyed by field name, so
|
|
11
|
+
* `scValToNative` yields a snake_case-keyed object with `bigint` for i128/u64,
|
|
12
|
+
* `number` for u32, strkey strings for addresses, strings for symbols, `null`
|
|
13
|
+
* for absent `Option`s, and arrays for `Vec`s.
|
|
23
14
|
*/
|
|
24
15
|
import type { StellarLendingDecodedEvent } from '@xoxno/types';
|
|
25
16
|
/**
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stellar lending activity-id derivation
|
|
3
|
-
*
|
|
2
|
+
* Stellar lending activity-id derivation: the inputs that compose
|
|
3
|
+
* `NftActivityDoc.id` (`${txHash}-${eventIdentifier}-${eventOrder}`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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.
|
|
5
|
+
* The activity-type string values mirror `@xoxno/types` `XoxnoLendingActivity`,
|
|
6
|
+
* inlined rather than imported since `@xoxno/types` does not re-export its enums
|
|
7
|
+
* on its top-level type surface.
|
|
14
8
|
*/
|
|
15
9
|
/** Synthetic NFT collection ticker for Stellar lending accounts. */
|
|
16
10
|
export declare const XOXNO_LENDING_STELLAR_TICKER = "XLENDXLM-a7c9f3";
|
|
@@ -1,40 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stellar
|
|
2
|
+
* Stellar lending user-operation transaction builders.
|
|
3
3
|
*
|
|
4
|
-
* Each builder takes
|
|
5
|
-
* `StellarBuilderOptions` ({ network, caller, sourceSequence, ... }) and
|
|
6
|
-
*
|
|
7
|
-
* (Freighter / LOBSTR / xBull / WalletConnect via StellarWalletsKit).
|
|
4
|
+
* Each builder takes an `*Args` DTO from `@xoxno/types` plus a shared
|
|
5
|
+
* `StellarBuilderOptions` ({ network, caller, sourceSequence, ... }) and returns
|
|
6
|
+
* an unsigned transaction XDR string ready for wallet signing.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* supply(caller, account_id: u64, e_mode_category: u32, assets: Vec<(Address, i128)>) -> u64
|
|
13
|
-
* borrow(caller, account_id: u64, borrows: Vec<(Address, i128)>)
|
|
14
|
-
* withdraw(caller, account_id: u64, withdrawals: Vec<(Address, i128)>)
|
|
15
|
-
* repay(caller, account_id: u64, payments: Vec<(Address, i128)>)
|
|
16
|
-
* liquidate(liquidator, account_id: u64, debt_payments: Vec<(Address, i128)>)
|
|
17
|
-
* flash_loan(caller, asset, amount: i128, receiver, data: Bytes)
|
|
18
|
-
* multiply(caller, account_id, e_mode_category, collateral_token,
|
|
19
|
-
* debt_to_flash_loan: i128, debt_token, mode: u32, steps: SwapSteps) -> u64
|
|
20
|
-
* swap_debt(caller, account_id, existing_debt_token, new_debt_amount: i128,
|
|
21
|
-
* new_debt_token, steps: SwapSteps)
|
|
22
|
-
* swap_collateral(caller, account_id, current_collateral, from_amount: i128,
|
|
23
|
-
* new_collateral, steps: SwapSteps)
|
|
24
|
-
* repay_debt_with_collateral(caller, account_id, collateral_token,
|
|
25
|
-
* collateral_amount: i128, debt_token,
|
|
26
|
-
* steps: SwapSteps, close_position: bool)
|
|
27
|
-
*
|
|
28
|
-
* i128 values cross the boundary as decimal strings and are encoded via
|
|
29
|
-
* `new ScInt(str).toI128()`. addresses (Stellar `G...` accounts and Soroban
|
|
8
|
+
* i128 values cross the boundary as decimal strings, encoded via
|
|
9
|
+
* `new ScInt(str).toI128()`. Addresses (Stellar `G...` accounts and Soroban
|
|
30
10
|
* `C...` contracts) are encoded via `new Address(str).toScVal()`.
|
|
31
11
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* handing the XDR to the wallet to sign.
|
|
12
|
+
* Builders are RPC-free: they accept a caller-supplied `sourceSequence` so the
|
|
13
|
+
* returned XDR is deterministic and snapshot-testable. The caller fetches the
|
|
14
|
+
* current sequence via `rpc.Server.getAccount(caller)` and runs
|
|
15
|
+
* `rpc.Server.prepareTransaction` (simulation + Soroban footprint/auth/resource
|
|
16
|
+
* fee) before handing the XDR to the wallet to sign.
|
|
38
17
|
*/
|
|
39
18
|
import type { AggregatorSwapDto, BorrowArgs, FlashLoanArgs, LiquidateArgs, MultiplyArgs, RepayArgs, RepayDebtWithCollateralArgs, SupplyArgs, SwapCollateralArgs, SwapDebtArgs, SwapHopDto, SwapPathDto, SwapVenue, WithdrawArgs } from '@xoxno/types';
|
|
40
19
|
import { xdr } from '@stellar/stellar-sdk';
|
|
@@ -70,36 +49,12 @@ export interface BuiltStellarTx {
|
|
|
70
49
|
}
|
|
71
50
|
/**
|
|
72
51
|
* Input shape for the Stellar-specific `swap` payload carried on
|
|
73
|
-
* `MultiplyArgs.steps`, `SwapDebtArgs.steps`, `SwapCollateralArgs.steps`,
|
|
52
|
+
* `MultiplyArgs.steps`, `SwapDebtArgs.steps`, `SwapCollateralArgs.steps`, and
|
|
74
53
|
* `RepayDebtWithCollateralArgs.steps`.
|
|
75
54
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* `AggregatorSwap` struct from `rs-lending-xlm common/src/types.rs`:
|
|
80
|
-
*
|
|
81
|
-
* pub struct SwapHop {
|
|
82
|
-
* pub fee_bps: u32,
|
|
83
|
-
* pub pool: Address,
|
|
84
|
-
* pub token_in: Address,
|
|
85
|
-
* pub token_out: Address,
|
|
86
|
-
* pub venue: SwapVenue, // tag-only enum
|
|
87
|
-
* }
|
|
88
|
-
* pub struct SwapPath {
|
|
89
|
-
* pub amount_in: i128,
|
|
90
|
-
* pub hops: Vec<SwapHop>,
|
|
91
|
-
* pub min_amount_out: i128,
|
|
92
|
-
* }
|
|
93
|
-
* pub struct AggregatorSwap { // controller payload
|
|
94
|
-
* pub paths: Vec<SwapPath>,
|
|
95
|
-
* pub total_min_out: i128,
|
|
96
|
-
* }
|
|
97
|
-
*
|
|
98
|
-
* The controller wraps `AggregatorSwap` in `BatchSwap` (filling
|
|
99
|
-
* `sender = current_contract_address`) before forwarding to the router.
|
|
100
|
-
*
|
|
101
|
-
* Re-exported from this module so consumers can `import { StellarSwapStepsInput }`
|
|
102
|
-
* and get the canonical typed shape without reaching into `@xoxno/types`.
|
|
55
|
+
* `@xoxno/types` declares `steps: unknown` on these DTOs so every chain owns its
|
|
56
|
+
* own encoding. On Stellar, callers must pass an `AggregatorSwapDto`, which is
|
|
57
|
+
* serialised into the Soroban `AggregatorSwap` struct.
|
|
103
58
|
*/
|
|
104
59
|
export type StellarSwapStepsInput = AggregatorSwapDto;
|
|
105
60
|
export type StellarSwapHopInput = SwapHopDto;
|
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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.
|
|
2
|
+
* Soroban `ScVal` encoding primitives for the Stellar lending builders.
|
|
8
3
|
*
|
|
9
4
|
* i128/u128 values cross the boundary as decimal strings (`new ScInt(str)`).
|
|
10
5
|
* Addresses (Stellar `G...` accounts and Soroban `C...` contracts) encode via
|
|
11
|
-
* `new Address(str).toScVal()`.
|
|
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.
|
|
6
|
+
* `new Address(str).toScVal()`.
|
|
15
7
|
*/
|
|
16
8
|
import type { AggregatorSwapDto, SwapVenue } from '@xoxno/types';
|
|
17
9
|
import { xdr } from '@stellar/stellar-sdk';
|
|
18
10
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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.
|
|
11
|
+
* On-chain swap venues, validated at runtime for a caller-supplied venue.
|
|
12
|
+
* Mirrors `SWAP_VENUES` from `@xoxno/types` and the contract's `SwapVenue` enum.
|
|
24
13
|
*/
|
|
25
14
|
export declare const STELLAR_SWAP_VENUES: readonly ["Soroswap", "Aquarius", "Phoenix", "NativeAmm", "StaticBridge"];
|
|
26
15
|
export type StellarSwapStepsInput = AggregatorSwapDto;
|
|
@@ -78,10 +67,9 @@ export declare const encodeSwapVenue: (venue: SwapVenue) => xdr.ScVal;
|
|
|
78
67
|
*/
|
|
79
68
|
export declare const encodeAggregatorSwap: (swap: StellarSwapStepsInput) => xdr.ScVal;
|
|
80
69
|
/**
|
|
81
|
-
* Validate the untyped `steps` field
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* Soroban host on-chain.
|
|
70
|
+
* Validate the untyped `steps` field and narrow it to `AggregatorSwapDto`.
|
|
71
|
+
* Throws if the caller passed the wrong shape so the failure surfaces at the
|
|
72
|
+
* SDK boundary, not inside the Soroban host on-chain.
|
|
85
73
|
*/
|
|
86
74
|
export declare const asStellarSwapSteps: (steps: unknown) => StellarSwapStepsInput;
|
|
87
75
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xoxno/sdk-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.119",
|
|
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.407"
|
|
108
108
|
}
|
|
109
109
|
}
|