@xoxno/sdk-js 1.0.218 → 1.0.219

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 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Pre-signing allowlist for the Soroban authorization tree of a PREPARED
3
+ * transaction.
4
+ *
5
+ * Simulation records every `require_auth` that code on the call stack makes
6
+ * for the caller — including one made by a rogue pool or token inside a swap
7
+ * hop, e.g. `any_token.transfer(caller, attacker, x)`. The wallet signature
8
+ * covers the whole tree, so whatever `prepareTransaction` returns is what the
9
+ * user authorizes. Each policy below is the set of sub-invocations the
10
+ * contracts legitimately request from the caller, with the source that proves
11
+ * it (paths are in the `rs-lending-xlm` repository):
12
+ *
13
+ * | Entrypoint | Caller sub-invocations | Source |
14
+ * |---|---|---|
15
+ * | controller `supply` | `asset.transfer(caller, pool, <= amount)` per asset | `contracts/controller/src/positions/supply.rs:118` |
16
+ * | controller `repay` | `asset.transfer(caller, pool, <= amount)` per asset | `contracts/controller/src/positions/debt.rs:144` |
17
+ * | controller `liquidate` | `asset.transfer(liquidator, pool, <= payment)` per asset | `contracts/controller/src/positions/liquidation/apply.rs:50` |
18
+ * | controller `multiply` | `asset.transfer(caller, controller, <= initial_payment)` when present | `contracts/controller/src/strategies/multiply.rs:169` |
19
+ * | controller `migrate_from_blend` | `blend_pool.submit(caller, controller, controller, [withdraw / withdraw_collateral / repay])`, at most twice | `contracts/controller/src/external/blend.rs:46-97` |
20
+ * | controller `borrow`, `withdraw`, `swap_debt`, `swap_collateral`, `repay_debt_with_collateral`, `flash_loan`, `flash_position`, any other | none | the controller funds these from its own custody (`strategies/legs.rs:50`, `strategies/flash_position.rs:285`) |
21
+ * | governance, any | none | proposer auth only |
22
+ * | router `execute_strategy` | `token_in.transfer(sender, router, <= total_in)` | `contracts/swap-aggregator/src/execute/mod.rs:81` |
23
+ */
24
+ import { xdr } from '@stellar/stellar-sdk';
25
+ import { type StellarNetwork } from './contracts.js';
26
+ export type StellarAuthPolicyErrorCode = 'MALFORMED_TRANSACTION' | 'INVOCATION_CHANGED' | 'UNSUPPORTED_CONTRACT' | 'CALLER_MISMATCH' | 'DUPLICATE_ENTRY' | 'UNEXPECTED_ROOT' | 'UNEXPECTED_CALL' | 'NESTED_INVOCATION' | 'UNEXPECTED_TOKEN' | 'UNEXPECTED_SENDER' | 'UNEXPECTED_RECIPIENT' | 'AMOUNT_EXCEEDED';
27
+ /** The invocation that broke the policy, in readable form. */
28
+ export interface StellarAuthOffender {
29
+ contract: string;
30
+ fn: string;
31
+ args: string[];
32
+ }
33
+ /** Thrown when the authorization tree holds anything the policy does not allow. */
34
+ export declare class StellarAuthPolicyError extends Error {
35
+ readonly code: StellarAuthPolicyErrorCode;
36
+ readonly offender?: StellarAuthOffender;
37
+ constructor(code: StellarAuthPolicyErrorCode, message: string, offender?: StellarAuthOffender);
38
+ }
39
+ /** Total the caller may send to `to` in `token` across all sub-invocations. */
40
+ export interface StellarAuthTransferAllowance {
41
+ token: string;
42
+ to: string;
43
+ maxAmount: bigint;
44
+ }
45
+ /** A non-transfer sub-invocation the caller legitimately authorizes. */
46
+ export interface StellarAuthCallAllowance {
47
+ contract: string;
48
+ fn: string;
49
+ maxCount: number;
50
+ /** Returns why `args` are not acceptable, or `undefined` when they are. */
51
+ reject: (args: xdr.ScVal[]) => string | undefined;
52
+ }
53
+ export interface StellarAuthPolicy {
54
+ caller: string;
55
+ root: {
56
+ contract: string;
57
+ fn: string;
58
+ };
59
+ transfers: StellarAuthTransferAllowance[];
60
+ calls?: StellarAuthCallAllowance[];
61
+ }
62
+ /**
63
+ * Enforce `policy` on the authorization entries of a prepared transaction.
64
+ * Entries that belong to other addresses are ignored. For the caller: at most
65
+ * one entry, the expected root, and only allowlisted leaf sub-invocations.
66
+ * @param sourceAccount - Account that source-account credentials stand for
67
+ * (the operation source, else the transaction source). When omitted, such
68
+ * entries are treated as the caller's.
69
+ * @throws StellarAuthPolicyError
70
+ */
71
+ export declare function assertStellarAuthEntries(entries: readonly xdr.SorobanAuthorizationEntry[], policy: StellarAuthPolicy, sourceAccount?: string): void;
72
+ /** Contract addresses a policy is derived against. */
73
+ export interface StellarAuthDeployment {
74
+ lendingController: string;
75
+ lendingPool: string;
76
+ aggregatorRouter: string;
77
+ governance: string;
78
+ }
79
+ /**
80
+ * Derive the policy for one contract invocation from its own arguments. The
81
+ * arguments are what the application built from the user's intent, so the
82
+ * allowed transfers are bounded by exactly what the user asked to pay.
83
+ * @throws StellarAuthPolicyError for a contract outside `deployment`.
84
+ */
85
+ export declare function stellarAuthPolicyForInvocation(caller: string, invocation: xdr.InvokeContractArgs, deployment: StellarAuthDeployment): StellarAuthPolicy;
86
+ export interface StellarPreparedTxAuthOptions {
87
+ network: StellarNetwork;
88
+ /** The wallet address that will sign. */
89
+ caller: string;
90
+ /**
91
+ * The unsigned builder output that was sent to `prepareTransaction`. When
92
+ * given, the prepared invocation must be byte-identical to it.
93
+ */
94
+ builtXdr?: string;
95
+ /** Replaces the derived policy (other contracts, custom flash receivers). */
96
+ policy?: StellarAuthPolicy;
97
+ /** Overrides manifest addresses for a non-standard deployment. */
98
+ deployment?: Partial<StellarAuthDeployment>;
99
+ }
100
+ /**
101
+ * Check a prepared transaction (base64 XDR, as `prepareTransaction` returns
102
+ * it) before it is passed to a wallet. Takes XDR strings so no live SDK object
103
+ * crosses the consumer's bundle boundary. Never sign when this throws.
104
+ * @throws StellarAuthPolicyError | StellarRouteVerificationError
105
+ */
106
+ export declare function assertStellarPreparedTxAuth(preparedXdr: string, opts: StellarPreparedTxAuthOptions): void;
@@ -20,6 +20,8 @@ export interface StellarDeployment {
20
20
  readonly aquariusApiUrl: string;
21
21
  readonly aquariusRouter: string;
22
22
  readonly lendingController: string;
23
+ /** The controller's single liquidity pool: the recipient of supply, repay and liquidation transfers. */
24
+ readonly lendingPool: string;
23
25
  readonly aggregatorRouter: string;
24
26
  readonly governance: string;
25
27
  readonly priceAggregator: string;
@@ -41,6 +43,7 @@ export declare const STELLAR_NETWORKS: {
41
43
  readonly aquariusApiUrl: "https://amm-api.aqua.network";
42
44
  readonly aquariusRouter: "CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK";
43
45
  readonly lendingController: "CAUCMIN5KSXEVZ7NMXR3LZATGD5EFIEUI5XWTFLYRO2R5OTXI22WE5JX";
46
+ readonly lendingPool: "CBXRNDQMAJFG4VUKMKFEMFS75UUXE2SPSNV4LEEFCSNBCN66PYRWBKXO";
44
47
  readonly aggregatorRouter: "CCVENFSVCBYDHVOACFZXMNNYVOZ3LKXPZYU5LUI4N7KTXOKRVYD7F3TR";
45
48
  readonly governance: "CC44PEQW7HSEPKAZ5ZRPH2JS5M5KVJXCUBLJ2ZX4E3WCDKMNFILHC2AD";
46
49
  readonly priceAggregator: "CBGUF2G2Q7HCVCWYISDXBHPVBGMYNXA7PG2VET66YBZX6IKOOV27NSMV";
@@ -56,6 +59,7 @@ export declare const STELLAR_NETWORKS: {
56
59
  readonly aquariusApiUrl: "https://amm-api-testnet.aqua.network";
57
60
  readonly aquariusRouter: "CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD";
58
61
  readonly lendingController: "CCXRWJ6SIU2WPFEGLFGJVITPL57QAYIMIO6OAM2NBGNDQSSCK2FFV3F3";
62
+ readonly lendingPool: "CBSGF6QOQAMPFBEVSYPEQHSZRIHJ6RCGUPCRDMUX36DEKRWFAO2PZB5A";
59
63
  readonly aggregatorRouter: "CDNTWMWW2WGYTKIZTJYNGNVQQZI4KTC5BQRZ3275KESRX5T4O3AYECL5";
60
64
  readonly governance: "CDS33JDOYH3F3FL4QUQ6DV4WKHML2AKHF4LADTZ57FRUAEBTE7NMY5FQ";
61
65
  readonly priceAggregator: "CAALOOTIDXCX7D7FMQIBSSAJLPKOM3GMXS4UUSTDIG42JCRRJHOPUHOP";
@@ -74,6 +78,7 @@ export declare const stellarNetworks: {
74
78
  readonly aquariusApiUrl: "https://amm-api.aqua.network";
75
79
  readonly aquariusRouter: "CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK";
76
80
  readonly lendingController: "CAUCMIN5KSXEVZ7NMXR3LZATGD5EFIEUI5XWTFLYRO2R5OTXI22WE5JX";
81
+ readonly lendingPool: "CBXRNDQMAJFG4VUKMKFEMFS75UUXE2SPSNV4LEEFCSNBCN66PYRWBKXO";
77
82
  readonly aggregatorRouter: "CCVENFSVCBYDHVOACFZXMNNYVOZ3LKXPZYU5LUI4N7KTXOKRVYD7F3TR";
78
83
  readonly governance: "CC44PEQW7HSEPKAZ5ZRPH2JS5M5KVJXCUBLJ2ZX4E3WCDKMNFILHC2AD";
79
84
  readonly priceAggregator: "CBGUF2G2Q7HCVCWYISDXBHPVBGMYNXA7PG2VET66YBZX6IKOOV27NSMV";
@@ -89,6 +94,7 @@ export declare const stellarNetworks: {
89
94
  readonly aquariusApiUrl: "https://amm-api-testnet.aqua.network";
90
95
  readonly aquariusRouter: "CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD";
91
96
  readonly lendingController: "CCXRWJ6SIU2WPFEGLFGJVITPL57QAYIMIO6OAM2NBGNDQSSCK2FFV3F3";
97
+ readonly lendingPool: "CBSGF6QOQAMPFBEVSYPEQHSZRIHJ6RCGUPCRDMUX36DEKRWFAO2PZB5A";
92
98
  readonly aggregatorRouter: "CDNTWMWW2WGYTKIZTJYNGNVQQZI4KTC5BQRZ3275KESRX5T4O3AYECL5";
93
99
  readonly governance: "CDS33JDOYH3F3FL4QUQ6DV4WKHML2AKHF4LADTZ57FRUAEBTE7NMY5FQ";
94
100
  readonly priceAggregator: "CAALOOTIDXCX7D7FMQIBSSAJLPKOM3GMXS4UUSTDIG42JCRRJHOPUHOP";