@xoxno/sdk-js 1.0.141 → 1.0.142

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.
Files changed (34) hide show
  1. package/dist/cjs/index.d.ts +3 -0
  2. package/dist/cjs/package.json +3 -0
  3. package/dist/cjs/sdk/index.d.ts +4 -0
  4. package/dist/cjs/sdk/parseSwagger.d.ts +1 -0
  5. package/dist/cjs/sdk/stellar/__tests__/admin.test.d.ts +13 -0
  6. package/dist/cjs/sdk/stellar/__tests__/decode.test.d.ts +10 -0
  7. package/dist/cjs/sdk/stellar/__tests__/id.test.d.ts +4 -0
  8. package/dist/cjs/sdk/stellar/__tests__/lending.test.d.ts +21 -0
  9. package/dist/cjs/sdk/stellar/__tests__/swap.test.d.ts +1 -0
  10. package/dist/cjs/sdk/stellar/admin.d.ts +170 -0
  11. package/dist/cjs/sdk/stellar/cctp.d.ts +16 -0
  12. package/dist/cjs/sdk/stellar/contracts.d.ts +70 -0
  13. package/dist/cjs/sdk/stellar/events/decode.d.ts +45 -0
  14. package/dist/cjs/sdk/stellar/events/id.d.ts +40 -0
  15. package/dist/cjs/sdk/stellar/events/index.d.ts +2 -0
  16. package/dist/cjs/sdk/stellar/governance.d.ts +158 -0
  17. package/dist/cjs/sdk/stellar/index.d.ts +11 -0
  18. package/dist/cjs/sdk/stellar/lending.d.ts +171 -0
  19. package/dist/cjs/sdk/stellar/position-mode.d.ts +7 -0
  20. package/dist/cjs/sdk/stellar/prepare.d.ts +25 -0
  21. package/dist/cjs/sdk/stellar/quote.d.ts +58 -0
  22. package/dist/cjs/sdk/stellar/repay-swap.d.ts +7 -0
  23. package/dist/cjs/sdk/stellar/scval-encode.d.ts +115 -0
  24. package/dist/cjs/sdk/stellar/swap.d.ts +70 -0
  25. package/dist/cjs/sdk/swagger.d.ts +1967 -0
  26. package/dist/cjs/sdk/types.d.ts +83 -0
  27. package/dist/cjs/sdk/utils.d.ts +9 -0
  28. package/dist/cjs/utils/api.d.ts +36 -0
  29. package/dist/cjs/utils/const.d.ts +13 -0
  30. package/dist/cjs/utils/errors.d.ts +12 -0
  31. package/dist/cjs/utils/guards.d.ts +7 -0
  32. package/dist/cjs/utils/helpers.d.ts +3 -0
  33. package/dist/cjs/utils/regex.d.ts +2 -0
  34. package/package.json +3 -3
@@ -0,0 +1,3 @@
1
+ export * from './utils/api';
2
+ export * from './utils/regex';
3
+ export * from './sdk';
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,4 @@
1
+ import type { XOXNOClient } from '../utils/api';
2
+ import type { SDK } from './types';
3
+ export * from './stellar';
4
+ export declare function buildSdk(client: XOXNOClient): SDK;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
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, 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.
12
+ */
13
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Decoder tests locked against captured event XDR.
3
+ *
4
+ * `fixtures/lending-events.json` holds the map-encoded controller
5
+ * `#[contractevent]`s' topics + `data` serialized to base64 XDR, exactly as
6
+ * Soroban RPC `getEvents` delivers them. The two vec-encoded ABI v2 topics
7
+ * (`position:batch_update`, `market:batch_state_update`) are constructed below
8
+ * with ScVal builders so the wire field order stays explicit.
9
+ */
10
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Tests for the Stellar lending activity-id primitives, locking their outputs.
3
+ */
4
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Snapshot + sanity tests for the Stellar Soroban lending transaction builders.
3
+ *
4
+ * These tests assert:
5
+ * 1. Every builder returns a non-empty base64 XDR.
6
+ * 2. XDR parses back into a valid Transaction with exactly one InvokeHostFunction
7
+ * operation targeting the configured controller contract.
8
+ * 3. The function name encoded in the XDR matches the Stellar controller
9
+ * entry point exactly (`supply`, `borrow`, `withdraw`, `repay`,
10
+ * `liquidate`, `flash_loan`, `multiply`, `swap_debt`, `swap_collateral`,
11
+ * `repay_debt_with_collateral`).
12
+ * 4. The XDR is deterministic — identical fixture inputs yield identical XDR.
13
+ * 5. Stable snapshots for the full XDR of every builder (regression guard
14
+ * for any unintended encoding change).
15
+ *
16
+ * Builders are RPC-free — they accept a `sourceSequence` so output is
17
+ * fully deterministic and snapshot-testable. The UI layer is responsible
18
+ * for fetching the sequence and running `rpc.Server.prepareTransaction`
19
+ * before signing.
20
+ */
21
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Stellar lending admin / config / keeper / access transaction builders. Each
3
+ * builder returns an unsigned `BuiltStellarTx` XDR.
4
+ *
5
+ * Auth model:
6
+ * - `#[only_owner]` methods take no `caller` param — the tx source
7
+ * (`opts.caller`) must be the contract owner.
8
+ * - `#[only_role(caller, "ROLE")]` and caller-taking methods encode
9
+ * `opts.caller` as the leading `Address` arg; that account must hold the
10
+ * role and sign the tx.
11
+ */
12
+ import type { AssetConfigRawDto, InterestRateModelDto, MarketOracleConfigInputDto, MarketParamsRawDto, OracleSourceConfigInputDto, PositionLimitsDto } from '@xoxno/types';
13
+ import { type BuiltStellarTx, type StellarBuilderOptions } from './lending';
14
+ import { xdr } from '@stellar/stellar-sdk';
15
+ /** `InterestRateModel` — 8 RAY rates + reserve factor bps. */
16
+ export declare const encodeInterestRateModel: (m: InterestRateModelDto) => xdr.ScVal;
17
+ /** `MarketParamsRaw` — `InterestRateModel` plus the pool asset identity. */
18
+ export declare const encodeMarketParamsRaw: (p: MarketParamsRawDto) => xdr.ScVal;
19
+ /** `AssetConfigRaw` — 11 risk/limit fields. */
20
+ export declare const encodeAssetConfigRaw: (c: AssetConfigRawDto) => xdr.ScVal;
21
+ /** `PositionLimits` — per-account supply/borrow position caps. */
22
+ export declare const encodePositionLimits: (l: PositionLimitsDto) => xdr.ScVal;
23
+ /** `OracleSourceConfigInput` data-enum — `Reflector(...)` | `RedStone(...)`. */
24
+ export declare const encodeOracleSourceConfigInput: (src: OracleSourceConfigInputDto) => xdr.ScVal;
25
+ /** `MarketOracleConfigInput` — strategy + primary/anchor sources + sanity bounds. */
26
+ export declare const encodeMarketOracleConfigInput: (cfg: MarketOracleConfigInputDto) => xdr.ScVal;
27
+ export interface RoleGrantArgs {
28
+ account: string;
29
+ role: string;
30
+ }
31
+ export interface TransferOwnershipArgs {
32
+ newOwner: string;
33
+ liveUntilLedger: number;
34
+ }
35
+ export interface EditAssetConfigArgs {
36
+ asset: string;
37
+ config: AssetConfigRawDto;
38
+ }
39
+ export interface EModeAssetArgs {
40
+ asset: string;
41
+ categoryId: number;
42
+ canCollateral: boolean;
43
+ canBorrow: boolean;
44
+ ltv: number;
45
+ threshold: number;
46
+ bonus: number;
47
+ }
48
+ export interface RemoveEModeAssetArgs {
49
+ asset: string;
50
+ categoryId: number;
51
+ }
52
+ export interface ConfigureMarketOracleArgs {
53
+ asset: string;
54
+ config: MarketOracleConfigInputDto;
55
+ }
56
+ export interface EditOracleToleranceArgs {
57
+ asset: string;
58
+ firstTolerance: number;
59
+ lastTolerance: number;
60
+ }
61
+ export interface CreateLiquidityPoolArgs {
62
+ asset: string;
63
+ params: MarketParamsRawDto;
64
+ config: AssetConfigRawDto;
65
+ }
66
+ export interface UpgradeLiquidityPoolParamsArgs {
67
+ asset: string;
68
+ params: InterestRateModelDto;
69
+ }
70
+ export interface UpgradeLiquidityPoolArgs {
71
+ asset: string;
72
+ wasmHash: string;
73
+ }
74
+ export interface RewardEntry {
75
+ token: string;
76
+ amount: string;
77
+ }
78
+ export interface UpdateAccountThresholdArgs {
79
+ asset: string;
80
+ hasRisks: boolean;
81
+ accountNonces: number[];
82
+ }
83
+ /** upgrade(new_wasm_hash: BytesN<32>) */
84
+ export declare function buildStellarUpgradeControllerTx(opts: StellarBuilderOptions, args: {
85
+ wasmHash: string;
86
+ }): BuiltStellarTx;
87
+ /** migrate(new_version: u32) */
88
+ export declare function buildStellarMigrateTx(opts: StellarBuilderOptions, args: {
89
+ newVersion: number;
90
+ }): BuiltStellarTx;
91
+ /** pause() */
92
+ export declare function buildStellarPauseTx(opts: StellarBuilderOptions): BuiltStellarTx;
93
+ /** unpause() */
94
+ export declare function buildStellarUnpauseTx(opts: StellarBuilderOptions): BuiltStellarTx;
95
+ /** grant_role(account: Address, role: Symbol) */
96
+ export declare function buildStellarGrantRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs): BuiltStellarTx;
97
+ /** revoke_role(account: Address, role: Symbol) */
98
+ export declare function buildStellarRevokeRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs): BuiltStellarTx;
99
+ /** transfer_ownership(new_owner: Address, live_until_ledger: u32) */
100
+ export declare function buildStellarTransferOwnershipTx(opts: StellarBuilderOptions, args: TransferOwnershipArgs): BuiltStellarTx;
101
+ /** accept_ownership() */
102
+ export declare function buildStellarAcceptOwnershipTx(opts: StellarBuilderOptions): BuiltStellarTx;
103
+ /** set_aggregator(addr: Address) — #[only_owner] */
104
+ export declare function buildStellarSetAggregatorTx(opts: StellarBuilderOptions, args: {
105
+ aggregator: string;
106
+ }): BuiltStellarTx;
107
+ /** set_accumulator(addr: Address) — #[only_owner] */
108
+ export declare function buildStellarSetAccumulatorTx(opts: StellarBuilderOptions, args: {
109
+ accumulator: string;
110
+ }): BuiltStellarTx;
111
+ /** set_liquidity_pool_template(hash: BytesN<32>) — #[only_owner] */
112
+ export declare function buildStellarSetLiquidityPoolTemplateTx(opts: StellarBuilderOptions, args: {
113
+ wasmHash: string;
114
+ }): BuiltStellarTx;
115
+ /** edit_asset_config(asset: Address, cfg: AssetConfigRaw) — #[only_owner] */
116
+ export declare function buildStellarEditAssetConfigTx(opts: StellarBuilderOptions, args: EditAssetConfigArgs): BuiltStellarTx;
117
+ /** set_position_limits(limits: PositionLimits) — #[only_owner] */
118
+ export declare function buildStellarSetPositionLimitsTx(opts: StellarBuilderOptions, args: PositionLimitsDto): BuiltStellarTx;
119
+ /** add_e_mode_category() -> u32 — #[only_owner]. Risk params are per-asset. */
120
+ export declare function buildStellarAddEModeCategoryTx(opts: StellarBuilderOptions): BuiltStellarTx;
121
+ /** remove_e_mode_category(id: u32) — #[only_owner] */
122
+ export declare function buildStellarRemoveEModeCategoryTx(opts: StellarBuilderOptions, args: {
123
+ id: number;
124
+ }): BuiltStellarTx;
125
+ /** add_asset_to_e_mode_category(asset, category_id, can_collateral, can_borrow, ltv, threshold, bonus) — #[only_owner] */
126
+ export declare function buildStellarAddAssetToEModeCategoryTx(opts: StellarBuilderOptions, args: EModeAssetArgs): BuiltStellarTx;
127
+ /** edit_asset_in_e_mode_category(asset, category_id, can_collateral, can_borrow, ltv, threshold, bonus) — #[only_owner] */
128
+ export declare function buildStellarEditAssetInEModeCategoryTx(opts: StellarBuilderOptions, args: EModeAssetArgs): BuiltStellarTx;
129
+ /** remove_asset_from_e_mode(asset: Address, category_id: u32) — #[only_owner] */
130
+ export declare function buildStellarRemoveAssetFromEModeTx(opts: StellarBuilderOptions, args: RemoveEModeAssetArgs): BuiltStellarTx;
131
+ /** approve_token(token: Address) — #[only_owner] */
132
+ export declare function buildStellarApproveTokenTx(opts: StellarBuilderOptions, args: {
133
+ token: string;
134
+ }): BuiltStellarTx;
135
+ /** revoke_token(token: Address) — #[only_owner] */
136
+ export declare function buildStellarRevokeTokenTx(opts: StellarBuilderOptions, args: {
137
+ token: string;
138
+ }): BuiltStellarTx;
139
+ /** configure_market_oracle(caller, asset, cfg) — #[only_role(caller, "ORACLE")] */
140
+ export declare function buildStellarConfigureMarketOracleTx(opts: StellarBuilderOptions, args: ConfigureMarketOracleArgs): BuiltStellarTx;
141
+ /** edit_oracle_tolerance(caller, asset, first_tolerance, last_tolerance) — #[only_role(caller, "ORACLE")] */
142
+ export declare function buildStellarEditOracleToleranceTx(opts: StellarBuilderOptions, args: EditOracleToleranceArgs): BuiltStellarTx;
143
+ /** disable_token_oracle(caller, asset) — #[only_role(caller, "ORACLE")] */
144
+ export declare function buildStellarDisableTokenOracleTx(opts: StellarBuilderOptions, args: {
145
+ asset: string;
146
+ }): BuiltStellarTx;
147
+ /** update_indexes(caller, assets: Vec<Address>) — #[only_role(caller, "KEEPER")] */
148
+ export declare function buildStellarUpdateIndexesTx(opts: StellarBuilderOptions, args: {
149
+ assets: string[];
150
+ }): BuiltStellarTx;
151
+ /** renew_account(caller, account_id: u64) */
152
+ export declare function buildStellarRenewAccountTx(opts: StellarBuilderOptions, args: {
153
+ accountNonce: number;
154
+ }): BuiltStellarTx;
155
+ /** create_liquidity_pool(asset, params: MarketParamsRaw, config: AssetConfigRaw) -> Address — #[only_owner] */
156
+ export declare function buildStellarCreateLiquidityPoolTx(opts: StellarBuilderOptions, args: CreateLiquidityPoolArgs): BuiltStellarTx;
157
+ /** upgrade_liquidity_pool_params(asset, params: InterestRateModel) — #[only_owner] */
158
+ export declare function buildStellarUpgradeLiquidityPoolParamsTx(opts: StellarBuilderOptions, args: UpgradeLiquidityPoolParamsArgs): BuiltStellarTx;
159
+ /** upgrade_liquidity_pool(asset, new_wasm_hash: BytesN<32>) — #[only_owner] */
160
+ export declare function buildStellarUpgradeLiquidityPoolTx(opts: StellarBuilderOptions, args: UpgradeLiquidityPoolArgs): BuiltStellarTx;
161
+ /** claim_revenue(caller, assets: Vec<Address>) -> Vec<i128> — #[only_role(caller, "REVENUE")] */
162
+ export declare function buildStellarClaimRevenueTx(opts: StellarBuilderOptions, args: {
163
+ assets: string[];
164
+ }): BuiltStellarTx;
165
+ /** add_rewards(caller, rewards: Vec<(Address, i128)>) — #[only_role(caller, "REVENUE")] */
166
+ export declare function buildStellarAddRewardsTx(opts: StellarBuilderOptions, args: {
167
+ rewards: RewardEntry[];
168
+ }): BuiltStellarTx;
169
+ /** update_account_threshold(caller, asset, has_risks, account_ids: Vec<u64>) — #[only_role(caller, "KEEPER")] */
170
+ export declare function buildStellarUpdateAccountThresholdTx(opts: StellarBuilderOptions, args: UpdateAccountThresholdArgs): BuiltStellarTx;
@@ -0,0 +1,16 @@
1
+ import { type StellarNetwork } from './contracts';
2
+ import type { BuiltStellarTx, StellarBuilderOptions } from './lending';
3
+ export interface BuildStellarCctpForwardTxArgs extends StellarBuilderOptions {
4
+ forwarderAddress: string;
5
+ message: string;
6
+ attestation: string;
7
+ /** Default 10_000_000 stroops — CCTP mint_and_forward is resource-heavy. */
8
+ fee?: string;
9
+ /** Default 120 seconds. */
10
+ timeoutSeconds?: number;
11
+ }
12
+ /**
13
+ * Build an unsigned XDR for the Stellar CCTP forwarder `mint_and_forward`.
14
+ */
15
+ export declare function buildStellarCctpForwardTx(opts: BuildStellarCctpForwardTxArgs): BuiltStellarTx;
16
+ export type { StellarNetwork };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Stellar Soroban contract addresses + Soroban RPC + quote-server config
3
+ * per network.
4
+ *
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
8
+ * silently pointing at the wrong contract.
9
+ */
10
+ export type StellarNetwork = 'mainnet' | 'testnet';
11
+ /**
12
+ * Stellar lending controller contract addresses per network.
13
+ * Env vars:
14
+ * - STELLAR_LENDING_CONTROLLER_MAINNET
15
+ * - STELLAR_LENDING_CONTROLLER_TESTNET
16
+ */
17
+ export declare const STELLAR_LENDING_CONTROLLER: Record<StellarNetwork, string>;
18
+ /**
19
+ * Stellar aggregator router contract addresses per network.
20
+ * Targets `execute_strategy(sender, total_in, swap_xdr)` for direct
21
+ * (non-lending) swaps.
22
+ * Env vars:
23
+ * - STELLAR_AGGREGATOR_ROUTER_MAINNET
24
+ * - STELLAR_AGGREGATOR_ROUTER_TESTNET
25
+ */
26
+ export declare const STELLAR_AGGREGATOR_ROUTER: Record<StellarNetwork, string>;
27
+ /**
28
+ * Stellar governance (timelock) contract addresses per network. Owns the
29
+ * controller's admin surface: PROPOSER-gated `propose_*` scheduling and the
30
+ * open `execute` / `execute_*` lifecycle.
31
+ * Env vars:
32
+ * - STELLAR_GOVERNANCE_MAINNET
33
+ * - STELLAR_GOVERNANCE_TESTNET
34
+ */
35
+ export declare const STELLAR_GOVERNANCE: Record<StellarNetwork, string>;
36
+ /**
37
+ * Default Soroban RPC URLs per network.
38
+ * Overridable at runtime via the `sorobanRpcUrl` option on each builder.
39
+ */
40
+ export declare const STELLAR_SOROBAN_RPC_URL: Record<StellarNetwork, string>;
41
+ /**
42
+ * Stellar aggregator quote-server base URLs per network. The quote server
43
+ * exposes `GET /api/v1/tokens` and `GET /api/v1/quote`.
44
+ *
45
+ * Env vars:
46
+ * - STELLAR_QUOTE_URL_MAINNET
47
+ * - STELLAR_QUOTE_URL_TESTNET
48
+ */
49
+ export declare const STELLAR_QUOTE_URL: Record<StellarNetwork, string>;
50
+ /**
51
+ * Stellar network passphrases (Soroban tx signing domain separator).
52
+ * These are fixed by the Stellar network itself and must not be overridden.
53
+ */
54
+ export declare const STELLAR_NETWORK_PASSPHRASE: Record<StellarNetwork, string>;
55
+ /**
56
+ * Assert a controller address is configured for the target network.
57
+ * Throws early with a clear message rather than building an XDR that
58
+ * points at `""`.
59
+ */
60
+ export declare function getStellarLendingController(network: StellarNetwork): string;
61
+ /**
62
+ * Assert an aggregator router address is configured for the target network.
63
+ * Used by `buildStellarExecuteStrategyTx` for direct user -> router swaps.
64
+ */
65
+ export declare function getStellarAggregatorRouter(network: StellarNetwork): string;
66
+ /**
67
+ * Assert a governance address is configured for the target network. Used by
68
+ * the governance `propose_*` / `execute` / `execute_*` builders.
69
+ */
70
+ export declare function getStellarGovernance(network: StellarNetwork): string;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Decoders for the Stellar lending controller `#[contractevent]`s.
3
+ *
4
+ * The controller defines 20 contractevents; this SDK decodes 19. The lone
5
+ * omission is `config:min_borrow_collateral` (a single global `i128` floor with
6
+ * no indexing/UI consumer — the governance `SetMinBorrowCollateral` proposal
7
+ * already surfaces the value), so `decodeStellarLendingEvent` returns `null` for
8
+ * it like any other unhandled topic.
9
+ *
10
+ * The public API takes base64-XDR strings (`decodeStellarLendingEvent(topicsB64,
11
+ * dataB64)`) and parses them with this SDK's bundled `@stellar/stellar-sdk`, so
12
+ * no live `xdr.ScVal` crosses the consumer boundary. Soroban RPC `getEvents`
13
+ * already delivers `topic[]` and `value` as base64 XDR — pass them straight
14
+ * through.
15
+ *
16
+ * Most contractevent `data` serializes as an `ScMap` keyed by field name, so
17
+ * `scValToNative` yields a snake_case-keyed object with `bigint` for i128/u64,
18
+ * `number` for u32, strkey strings for addresses, strings for symbols, `null`
19
+ * for absent `Option`s, and arrays for `Vec`s.
20
+ *
21
+ * The two hot topics (`position:batch_update`, `market:batch_state_update`)
22
+ * use the vec-encoded ABI v2 instead: `data` is an `ScVec` whose field order
23
+ * IS the ABI, so `scValToNative` yields nested arrays decoded positionally.
24
+ */
25
+ import type { StellarLendingDecodedEvent } from '@xoxno/types';
26
+ /**
27
+ * Serialize a live `xdr.ScVal` to base64 XDR for the string-only decoder API.
28
+ * Use this if you hold parsed ScVals (e.g. from the high-level RPC client);
29
+ * `.toXDR` is wire-format/structural, so it is safe across SDK copies.
30
+ */
31
+ export declare const toBase64Xdr: (scv: {
32
+ toXDR(format: "base64"): string;
33
+ }) => string;
34
+ /** Build the `"<domain>:<action>"` dispatch key from the event topic ScVals. */
35
+ export declare const stellarLendingDispatchKey: (topicsB64: readonly string[]) => string;
36
+ /** Topic keys this SDK can decode (19 of the controller's 20 contractevents;
37
+ * `config:min_borrow_collateral` is intentionally not decoded). */
38
+ export declare const STELLAR_LENDING_TOPICS: readonly string[];
39
+ /**
40
+ * Decode a Stellar lending controller event from its base64-XDR topics and
41
+ * data (exactly as Soroban RPC `getEvents` delivers them). Returns `null` for a
42
+ * topic this SDK does not decode (e.g. access-control `role_granted` events),
43
+ * so consumers can skip unknown events without throwing.
44
+ */
45
+ export declare function decodeStellarLendingEvent(topicsB64: readonly string[], dataB64: string): StellarLendingDecodedEvent | null;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Stellar lending activity-id derivation: the inputs that compose
3
+ * `NftActivityDoc.id` (`${txHash}-${eventIdentifier}-${eventOrder}`).
4
+ *
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.
8
+ */
9
+ /** Synthetic NFT collection ticker for Stellar lending accounts. */
10
+ export declare const XOXNO_LENDING_STELLAR_TICKER = "XLENDXLM-a7c9f3";
11
+ /**
12
+ * A child delta's contribution to `eventOrder`: `base * STRIDE + childIndex`.
13
+ * The stride bounds the number of child deltas per base event before two base
14
+ * events could collide.
15
+ */
16
+ export declare const SYNTHETIC_EVENT_ORDER_STRIDE = 10000;
17
+ /** `XoxnoLendingActivity` values used by the position activity mapping. */
18
+ export type StellarLendingActivityType = 'lendingUpdateAccountPosition' | 'lendingLiquidateRepayDebt' | 'lendingLiquidateSeizeCollateral' | 'lendingUpdateAccountParameters';
19
+ /**
20
+ * Synthetic NFT identifier for a Stellar lending account, e.g.
21
+ * `XLENDXLM-a7c9f3-2a` for account 42. The u64 account id is rendered as
22
+ * even-length lowercase hex.
23
+ */
24
+ export declare function buildStellarLendingIdentifier(accountId: string): string;
25
+ /**
26
+ * Extract the base event order from a Soroban RPC event id (`<ledger>-<index>`).
27
+ * Returns 0 when the id is malformed or has no index segment.
28
+ */
29
+ export declare function extractEventOrder(eventId: string): number;
30
+ /**
31
+ * Stable per-child ordering within one base event:
32
+ * `baseEventOrder * 10_000 + childIndex`. Keeps multiple deltas emitted by a
33
+ * single transaction deterministically ordered and collision-free.
34
+ */
35
+ export declare function syntheticEventOrder(baseEventOrder: number, childIndex?: number): number;
36
+ /**
37
+ * Map a position-delta `action` symbol to its `XoxnoLendingActivity` value.
38
+ * The tag list is authoritative in `rs-lending-xlm common/src/events.rs`.
39
+ */
40
+ export declare function mapStellarPositionActivityType(action?: string): StellarLendingActivityType;
@@ -0,0 +1,2 @@
1
+ export * from './decode';
2
+ export * from './id';
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Stellar lending governance (timelock) transaction builders. Each builder
3
+ * returns an unsigned `BuiltStellarTx` XDR targeting the governance contract
4
+ * (`opts.governanceAddress`, or env via `getStellarGovernance(network)`).
5
+ *
6
+ * Flow:
7
+ * - An admin holding the PROPOSER role calls a `propose_*` method. The
8
+ * leading arg is `proposer = opts.caller` (an `Address`); the remaining
9
+ * args mirror the matching controller setter exactly; the trailing arg is
10
+ * a `salt: BytesN<32>`. Validation runs at propose time; the call returns
11
+ * the operation id (`BytesN<32>`).
12
+ * - After the timelock delay, ANYONE executes. Controller-targeted ops go
13
+ * through the generic `execute(executor, target, function, args,
14
+ * predecessor, salt)`; governance-self ops go through typed `execute_*`.
15
+ * Open execution passes `executor = None` (Soroban `Option::None`, encoded
16
+ * as `scvVoid` — mirrors the lending `withdraw` builder's optional `to`).
17
+ * - `predecessor` is ALWAYS the 32-zero-byte `BytesN<32>` in this system.
18
+ *
19
+ * Builders are RPC-free and deterministic (synthetic `Account(caller,
20
+ * sourceSequence)`), exactly like the lending / admin builders. The returned
21
+ * XDR still needs `rpc.Server.prepareTransaction` before signing.
22
+ */
23
+ import type { PositionLimitsDto } from '@xoxno/types';
24
+ import { type ConfigureMarketOracleArgs, type CreateLiquidityPoolArgs, type EditAssetConfigArgs, type EditOracleToleranceArgs, type EModeAssetArgs, type RemoveEModeAssetArgs, type RoleGrantArgs, type TransferOwnershipArgs, type UpgradeLiquidityPoolParamsArgs } from './admin';
25
+ import type { BuiltStellarTx, StellarBuilderOptions } from './lending';
26
+ /**
27
+ * A `salt: BytesN<32>` for a governance proposal/execution. Accepts a 32-byte
28
+ * hex string (optionally `0x`-prefixed) or a 32-byte `Buffer`/`Uint8Array`.
29
+ */
30
+ export type StellarGovernanceSalt = string | Buffer | Uint8Array;
31
+ /** The 32-zero-byte `BytesN<32>` predecessor used for every op in this system. */
32
+ export declare const STELLAR_GOVERNANCE_ZERO_PREDECESSOR: string;
33
+ export interface RemoveEModeCategoryArgs {
34
+ id: number;
35
+ }
36
+ export interface UpgradeArgs {
37
+ wasmHash: string;
38
+ }
39
+ export interface MigrateArgs {
40
+ newVersion: number;
41
+ }
42
+ export interface UpdateDelayArgs {
43
+ newDelay: number;
44
+ }
45
+ /** propose_set_aggregator(proposer, addr: Address, salt) */
46
+ export declare function buildStellarProposeSetAggregatorTx(opts: StellarBuilderOptions, args: {
47
+ aggregator: string;
48
+ }, salt: StellarGovernanceSalt): BuiltStellarTx;
49
+ /** propose_set_accumulator(proposer, addr: Address, salt) */
50
+ export declare function buildStellarProposeSetAccumulatorTx(opts: StellarBuilderOptions, args: {
51
+ accumulator: string;
52
+ }, salt: StellarGovernanceSalt): BuiltStellarTx;
53
+ /** propose_set_pool_template(proposer, hash: BytesN<32>, salt) */
54
+ export declare function buildStellarProposeSetPoolTemplateTx(opts: StellarBuilderOptions, args: {
55
+ wasmHash: string;
56
+ }, salt: StellarGovernanceSalt): BuiltStellarTx;
57
+ /** propose_edit_asset_config(proposer, asset: Address, cfg: AssetConfigRaw, salt) */
58
+ export declare function buildStellarProposeEditAssetConfigTx(opts: StellarBuilderOptions, args: EditAssetConfigArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
59
+ /** propose_set_position_limits(proposer, limits: PositionLimits, salt) */
60
+ export declare function buildStellarProposeSetPositionLimitsTx(opts: StellarBuilderOptions, args: PositionLimitsDto, salt: StellarGovernanceSalt): BuiltStellarTx;
61
+ /** propose_set_min_borrow_collat(proposer, floor_wad: i128, salt) */
62
+ export declare function buildStellarProposeSetMinBorrowCollatTx(opts: StellarBuilderOptions, args: {
63
+ floorWad: string;
64
+ }, salt: StellarGovernanceSalt): BuiltStellarTx;
65
+ /** propose_add_e_mode_category(proposer, salt) — risk params are per-asset */
66
+ export declare function buildStellarProposeAddEModeCategoryTx(opts: StellarBuilderOptions, salt: StellarGovernanceSalt): BuiltStellarTx;
67
+ /** propose_remove_e_mode_category(proposer, id: u32, salt) */
68
+ export declare function buildStellarProposeRemoveEModeCategoryTx(opts: StellarBuilderOptions, args: RemoveEModeCategoryArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
69
+ /** propose_add_asset_to_e_mode(proposer, asset, category_id, can_collateral, can_borrow, ltv, threshold, bonus, salt) */
70
+ export declare function buildStellarProposeAddAssetToEModeTx(opts: StellarBuilderOptions, args: EModeAssetArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
71
+ /** propose_edit_asset_in_e_mode(proposer, asset, category_id, can_collateral, can_borrow, ltv, threshold, bonus, salt) */
72
+ export declare function buildStellarProposeEditAssetInEModeTx(opts: StellarBuilderOptions, args: EModeAssetArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
73
+ /** propose_remove_asset_from_e_mode(proposer, asset: Address, category_id: u32, salt) */
74
+ export declare function buildStellarProposeRemoveAssetFromEModeTx(opts: StellarBuilderOptions, args: RemoveEModeAssetArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
75
+ /** propose_approve_token(proposer, token: Address, salt) */
76
+ export declare function buildStellarProposeApproveTokenTx(opts: StellarBuilderOptions, args: {
77
+ token: string;
78
+ }, salt: StellarGovernanceSalt): BuiltStellarTx;
79
+ /** propose_revoke_token(proposer, token: Address, salt) */
80
+ export declare function buildStellarProposeRevokeTokenTx(opts: StellarBuilderOptions, args: {
81
+ token: string;
82
+ }, salt: StellarGovernanceSalt): BuiltStellarTx;
83
+ /** propose_create_liquidity_pool(proposer, asset, params: MarketParamsRaw, config: AssetConfigRaw, salt) */
84
+ export declare function buildStellarProposeCreateLiquidityPoolTx(opts: StellarBuilderOptions, args: CreateLiquidityPoolArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
85
+ /** propose_upgrade_pool_params(proposer, asset, params: InterestRateModel, salt) */
86
+ export declare function buildStellarProposeUpgradePoolParamsTx(opts: StellarBuilderOptions, args: UpgradeLiquidityPoolParamsArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
87
+ /** propose_deploy_pool(proposer, salt) */
88
+ export declare function buildStellarProposeDeployPoolTx(opts: StellarBuilderOptions, salt: StellarGovernanceSalt): BuiltStellarTx;
89
+ /** propose_upgrade_pool(proposer, new_wasm_hash: BytesN<32>, salt) */
90
+ export declare function buildStellarProposeUpgradePoolTx(opts: StellarBuilderOptions, args: {
91
+ wasmHash: string;
92
+ }, salt: StellarGovernanceSalt): BuiltStellarTx;
93
+ /** propose_grant_controller_role(proposer, account: Address, role: Symbol, salt) */
94
+ export declare function buildStellarProposeGrantControllerRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
95
+ /** propose_revoke_controller_role(proposer, account: Address, role: Symbol, salt) */
96
+ export declare function buildStellarProposeRevokeControllerRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
97
+ /** propose_upgrade_controller(proposer, new_wasm_hash: BytesN<32>, salt) */
98
+ export declare function buildStellarProposeUpgradeControllerTx(opts: StellarBuilderOptions, args: UpgradeArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
99
+ /** propose_migrate_controller(proposer, new_version: u32, salt) */
100
+ export declare function buildStellarProposeMigrateControllerTx(opts: StellarBuilderOptions, args: MigrateArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
101
+ /** propose_transfer_ctrl_ownership(proposer, new_owner: Address, live_until_ledger: u32, salt) */
102
+ export declare function buildStellarProposeTransferCtrlOwnershipTx(opts: StellarBuilderOptions, args: TransferOwnershipArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
103
+ /**
104
+ * propose_configure_market_oracle(proposer, asset, cfg: MarketOracleConfigInput, salt)
105
+ *
106
+ * The SDK passes the oracle INPUT args verbatim; the contract resolves the
107
+ * input to a resolved config at propose time (do NOT resolve in the SDK).
108
+ */
109
+ export declare function buildStellarProposeConfigureMarketOracleTx(opts: StellarBuilderOptions, args: ConfigureMarketOracleArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
110
+ /** propose_edit_oracle_tolerance(proposer, asset, first_tolerance_bps: u32, last_tolerance_bps: u32, salt) */
111
+ export declare function buildStellarProposeEditOracleToleranceTx(opts: StellarBuilderOptions, args: EditOracleToleranceArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
112
+ /** propose_governance_upgrade(proposer, new_wasm_hash: BytesN<32>, salt) */
113
+ export declare function buildStellarProposeGovernanceUpgradeTx(opts: StellarBuilderOptions, args: UpgradeArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
114
+ /** propose_update_delay(proposer, new_delay: u32, salt) */
115
+ export declare function buildStellarProposeUpdateDelayTx(opts: StellarBuilderOptions, args: UpdateDelayArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
116
+ /** propose_grant_governance_role(proposer, account: Address, role: Symbol, salt) */
117
+ export declare function buildStellarProposeGrantGovernanceRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
118
+ /** propose_revoke_governance_role(proposer, account: Address, role: Symbol, salt) */
119
+ export declare function buildStellarProposeRevokeGovernanceRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
120
+ /** propose_transfer_gov_own(proposer, new_owner: Address, live_until_ledger: u32, salt) */
121
+ export declare function buildStellarProposeTransferGovOwnTx(opts: StellarBuilderOptions, args: TransferOwnershipArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
122
+ export interface StellarGovernanceExecuteArgs {
123
+ /** Controller (or other) contract the scheduled op targets. */
124
+ target: string;
125
+ /** Controller method name → Soroban `Symbol`. */
126
+ functionName: string;
127
+ /**
128
+ * The controller-call args, each a base64 ScVal XDR string. These must be the
129
+ * SAME ScVals the matching `propose_*` scheduled (the timelock hashes them
130
+ * into the op id), in the controller method's arg order. Reconstructed via
131
+ * `xdr.ScVal.fromXDR(s, 'base64')`.
132
+ */
133
+ argsXdr: string[];
134
+ /** `salt: BytesN<32>` — the same salt used at propose time. */
135
+ salt: StellarGovernanceSalt;
136
+ /**
137
+ * `predecessor: BytesN<32>` — defaults to the 32-zero-byte value used for
138
+ * every op in this system. Override only if a non-zero predecessor is used.
139
+ */
140
+ predecessor?: StellarGovernanceSalt;
141
+ }
142
+ /**
143
+ * Generic `execute(executor, target, function, args, predecessor, salt)` for a
144
+ * controller-targeted op. `executor = None` (open execution), `target` is the
145
+ * controller `Address`, `function` is a `Symbol`, `args` is the `Vec<Val>`
146
+ * reconstructed from `argsXdr`, `predecessor` defaults to 32 zero bytes.
147
+ */
148
+ export declare function buildStellarGovernanceExecuteTx(opts: StellarBuilderOptions, args: StellarGovernanceExecuteArgs): BuiltStellarTx;
149
+ /** execute_governance_upgrade(executor=None, new_wasm_hash: BytesN<32>, salt) */
150
+ export declare function buildStellarGovernanceExecuteGovernanceUpgradeTx(opts: StellarBuilderOptions, args: UpgradeArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
151
+ /** execute_update_delay(executor=None, new_delay: u32, salt) */
152
+ export declare function buildStellarGovernanceExecuteUpdateDelayTx(opts: StellarBuilderOptions, args: UpdateDelayArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
153
+ /** execute_grant_governance_role(executor=None, account: Address, role: Symbol, salt) */
154
+ export declare function buildStellarGovernanceExecuteGrantGovernanceRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
155
+ /** execute_revoke_governance_role(executor=None, account: Address, role: Symbol, salt) */
156
+ export declare function buildStellarGovernanceExecuteRevokeGovernanceRoleTx(opts: StellarBuilderOptions, args: RoleGrantArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
157
+ /** execute_transfer_gov_own(executor=None, new_owner: Address, live_until_ledger: u32, salt) */
158
+ export declare function buildStellarGovernanceExecuteTransferGovOwnTx(opts: StellarBuilderOptions, args: TransferOwnershipArgs, salt: StellarGovernanceSalt): BuiltStellarTx;
@@ -0,0 +1,11 @@
1
+ export * from './contracts';
2
+ export * from './lending';
3
+ export * from './admin';
4
+ export * from './governance';
5
+ export * from './events';
6
+ export * from './quote';
7
+ export * from './swap';
8
+ export * from './prepare';
9
+ export * from './position-mode';
10
+ export * from './repay-swap';
11
+ export * from './cctp';