@lifi/sdk-provider-stellar 4.2.3 → 4.3.0
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/CHANGELOG.md +17 -0
- package/dist/esm/StellarProvider.d.ts +2 -3
- package/dist/esm/StellarProvider.d.ts.map +1 -1
- package/dist/esm/StellarProvider.js +5 -0
- package/dist/esm/StellarProvider.js.map +1 -1
- package/dist/esm/actions/getStellarBalance.d.ts +1 -2
- package/dist/esm/actions/getStellarBalance.d.ts.map +1 -1
- package/dist/esm/actions/resolveStellarAddress.d.ts +1 -2
- package/dist/esm/actions/resolveStellarAddress.d.ts.map +1 -1
- package/dist/esm/client/getStellarRpc.d.ts +2 -3
- package/dist/esm/client/getStellarRpc.d.ts.map +1 -1
- package/dist/esm/core/StellarStepExecutor.d.ts +1 -2
- package/dist/esm/core/StellarStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/tasks/StellarCheckAllowanceTask.d.ts +1 -2
- package/dist/esm/core/tasks/StellarCheckAllowanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/StellarPrepareTransactionTask.d.ts +1 -2
- package/dist/esm/core/tasks/StellarPrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/StellarSetAllowanceTask.d.ts +1 -2
- package/dist/esm/core/tasks/StellarSetAllowanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/StellarSignAndExecuteTask.d.ts +1 -2
- package/dist/esm/core/tasks/StellarSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/StellarWaitForTransactionTask.d.ts +1 -2
- package/dist/esm/core/tasks/StellarWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/assertApprovalStillCovers.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/assertApprovalStillCovers.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/buildApproveTransaction.d.ts +6 -2
- package/dist/esm/core/tasks/helpers/buildApproveTransaction.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/buildApproveTransaction.js +13 -3
- package/dist/esm/core/tasks/helpers/buildApproveTransaction.js.map +1 -1
- package/dist/esm/core/tasks/helpers/deriveTransactionHash.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/deriveTransactionHash.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getStellarTxLink.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/getStellarTxLink.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/probeStellarTransaction.d.ts +2 -3
- package/dist/esm/core/tasks/helpers/probeStellarTransaction.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/readAllowance.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/readAllowance.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/resolveApprovalRequirement.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/resolveApprovalRequirement.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/resolveInclusionFee.d.ts +25 -0
- package/dist/esm/core/tasks/helpers/resolveInclusionFee.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/resolveInclusionFee.js +70 -0
- package/dist/esm/core/tasks/helpers/resolveInclusionFee.js.map +1 -0
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/submitStellarTransaction.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/waitForStellarTransaction.d.ts.map +1 -1
- package/dist/esm/errors/parseStellarErrors.d.ts +1 -2
- package/dist/esm/errors/parseStellarErrors.d.ts.map +1 -1
- package/dist/esm/types.d.ts +11 -12
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/version.d.ts +2 -3
- package/dist/esm/version.d.ts.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +2 -2
- package/src/StellarProvider.ts +6 -0
- package/src/core/tasks/helpers/buildApproveTransaction.ts +9 -3
- package/src/core/tasks/helpers/resolveInclusionFee.ts +84 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @lifi/sdk-provider-stellar
|
|
2
2
|
|
|
3
|
+
## 4.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#471](https://github.com/lifinance/sdk/pull/471) [`a57b439`](https://github.com/lifinance/sdk/commit/a57b4391b52d9bc535577dcbfad1523ab4d2e32f) Thanks [@chybisov](https://github.com/chybisov)! - Add optional `SDKProvider.isTokenAddress`, so callers can validate a token identifier without knowing how each ecosystem shapes one: `C…` contract ids on Stellar, `0x…::module::TYPE` coin types on Sui, an address in any letter case on Ethereum, and the wallet format on Solana and Tron. `BitcoinProvider` omits the method, because the token list names its native coin `bitcoin` rather than giving it an address. A missing method means the ecosystem has no token address format, so a caller must not fall back to `isAddress`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`d7d8abb`](https://github.com/lifinance/sdk/commit/d7d8abb776aa943aafda62d17926b8575f770478), [`a57b439`](https://github.com/lifinance/sdk/commit/a57b4391b52d9bc535577dcbfad1523ab4d2e32f)]:
|
|
12
|
+
- @lifi/sdk@4.7.0
|
|
13
|
+
|
|
14
|
+
## 4.2.4
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#462](https://github.com/lifinance/sdk/pull/462) [`83a179b`](https://github.com/lifinance/sdk/commit/83a179b2d25d84a38e8ff9972f46508dd0a970c3) Thanks [@thesems](https://github.com/thesems)! - Bid the live Soroban inclusion fee for the approval transaction instead of the network minimum, so it doesn't expire unincluded on a congested ledger.
|
|
19
|
+
|
|
3
20
|
## 4.2.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -5,8 +5,7 @@ import { StellarProviderOptions, StellarSDKProvider } from "./types.js";
|
|
|
5
5
|
* Signing prefers the connected wallet's passphrase instead, and
|
|
6
6
|
* `StellarStepExecutor.checkWallet` refuses a route whose networks disagree.
|
|
7
7
|
*/
|
|
8
|
-
declare const DEFAULT_NETWORK_PASSPHRASE: string;
|
|
9
|
-
declare function StellarProvider(options?: StellarProviderOptions): StellarSDKProvider;
|
|
8
|
+
export declare const DEFAULT_NETWORK_PASSPHRASE: string;
|
|
9
|
+
export declare function StellarProvider(options?: StellarProviderOptions): StellarSDKProvider;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { DEFAULT_NETWORK_PASSPHRASE, StellarProvider };
|
|
12
11
|
//# sourceMappingURL=StellarProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarProvider.d.ts","names":[],"sources":["../../src/StellarProvider.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"StellarProvider.d.ts","names":[],"sources":["../../src/StellarProvider.ts"],"mappings":";;;;;;;qBAqBa;wBAgBG,gBACd,UAAU,yBACT"}
|
|
@@ -18,6 +18,10 @@ const DEFAULT_NETWORK_PASSPHRASE = Networks.PUBLIC;
|
|
|
18
18
|
function isStellarAddress(address) {
|
|
19
19
|
return StrKey.isValidEd25519PublicKey(address);
|
|
20
20
|
}
|
|
21
|
+
/** Tokens are Soroban contracts, not the `G…` accounts that hold balances. */
|
|
22
|
+
function isStellarTokenAddress(address) {
|
|
23
|
+
return StrKey.isValidContract(address);
|
|
24
|
+
}
|
|
21
25
|
function StellarProvider(options) {
|
|
22
26
|
const _options = options ?? {};
|
|
23
27
|
return {
|
|
@@ -25,6 +29,7 @@ function StellarProvider(options) {
|
|
|
25
29
|
return ChainType.STL;
|
|
26
30
|
},
|
|
27
31
|
isAddress: isStellarAddress,
|
|
32
|
+
isTokenAddress: isStellarTokenAddress,
|
|
28
33
|
resolveAddress: resolveStellarAddress,
|
|
29
34
|
getBalance: (client, walletAddress, tokens) => getStellarBalance(client, walletAddress, tokens, _options.networkPassphrase ?? DEFAULT_NETWORK_PASSPHRASE),
|
|
30
35
|
async getStepExecutor(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarProvider.js","names":[],"sources":["../../src/StellarProvider.ts"],"sourcesContent":["import {\n ChainType,\n LiFiErrorCode,\n ProviderError,\n type SDKClient,\n type StepExecutor,\n type StepExecutorOptions,\n type Token,\n type TokenAmount,\n} from '@lifi/sdk'\nimport { Networks, StrKey } from '@stellar/stellar-sdk'\nimport { getStellarBalance } from './actions/getStellarBalance.js'\nimport { resolveStellarAddress } from './actions/resolveStellarAddress.js'\nimport { StellarStepExecutor } from './core/StellarStepExecutor.js'\nimport type { StellarProviderOptions, StellarSDKProvider } from './types.js'\n\n/**\n * The network every read defaults to when the integrator configures none.\n * Signing prefers the connected wallet's passphrase instead, and\n * `StellarStepExecutor.checkWallet` refuses a route whose networks disagree.\n */\nexport const DEFAULT_NETWORK_PASSPHRASE: string = Networks.PUBLIC\n\n/**\n * Validates a Stellar account address. Only ed25519 G-addresses are accepted as\n * senders — muxed `M`-addresses and contract `C`-addresses are intentionally\n * rejected (see backend EXBE-227: muxed senders validate-and-throw).\n */\nfunction isStellarAddress(address: string): boolean {\n return StrKey.isValidEd25519PublicKey(address)\n}\n\nexport function StellarProvider(\n options?: StellarProviderOptions\n): StellarSDKProvider {\n const _options: StellarProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.STL\n },\n isAddress: isStellarAddress,\n resolveAddress: resolveStellarAddress,\n getBalance: (\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n ): Promise<TokenAmount[]> =>\n getStellarBalance(\n client,\n walletAddress,\n tokens,\n _options.networkPassphrase ?? DEFAULT_NETWORK_PASSPHRASE\n ),\n async getStepExecutor(options: StepExecutorOptions): Promise<StepExecutor> {\n if (!_options.getWallet) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'getWallet is not provided.'\n )\n }\n const wallet = await _options.getWallet()\n return new StellarStepExecutor({\n wallet,\n networkPassphrase:\n _options.networkPassphrase ?? wallet.networkPassphrase,\n routeId: options.routeId,\n executionOptions: { ...options.executionOptions },\n })\n },\n setOptions(options: StellarProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,6BAAqC,SAAS;;;;;;AAO3D,SAAS,iBAAiB,SAA0B;CAClD,OAAO,OAAO,wBAAwB,OAAO;AAC/C;AAEA,SAAgB,gBACd,SACoB;CACpB,MAAM,WAAmC,WAAW,CAAC;CACrD,OAAO;EACL,IAAI,OAAO;GACT,OAAO,UAAU;EACnB;EACA,WAAW;EACX,gBAAgB;EAChB,aACE,QACA,eACA,WAEA,kBACE,QACA,eACA,QACA,SAAS,qBAAqB,0BAChC;EACF,MAAM,gBAAgB,SAAqD;GACzE,IAAI,CAAC,SAAS,WACZ,MAAM,IAAI,cACR,cAAc,qBACd,4BACF;GAEF,MAAM,SAAS,MAAM,SAAS,UAAU;GACxC,OAAO,IAAI,oBAAoB;IAC7B;IACA,mBACE,SAAS,qBAAqB,OAAO;IACvC,SAAS,QAAQ;IACjB,kBAAkB,EAAE,GAAG,QAAQ,iBAAiB;GAClD,CAAC;EACH;EACA,WAAW,SAAiC;GAC1C,OAAO,OAAO,UAAU,OAAO;EACjC;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"StellarProvider.js","names":[],"sources":["../../src/StellarProvider.ts"],"sourcesContent":["import {\n ChainType,\n LiFiErrorCode,\n ProviderError,\n type SDKClient,\n type StepExecutor,\n type StepExecutorOptions,\n type Token,\n type TokenAmount,\n} from '@lifi/sdk'\nimport { Networks, StrKey } from '@stellar/stellar-sdk'\nimport { getStellarBalance } from './actions/getStellarBalance.js'\nimport { resolveStellarAddress } from './actions/resolveStellarAddress.js'\nimport { StellarStepExecutor } from './core/StellarStepExecutor.js'\nimport type { StellarProviderOptions, StellarSDKProvider } from './types.js'\n\n/**\n * The network every read defaults to when the integrator configures none.\n * Signing prefers the connected wallet's passphrase instead, and\n * `StellarStepExecutor.checkWallet` refuses a route whose networks disagree.\n */\nexport const DEFAULT_NETWORK_PASSPHRASE: string = Networks.PUBLIC\n\n/**\n * Validates a Stellar account address. Only ed25519 G-addresses are accepted as\n * senders — muxed `M`-addresses and contract `C`-addresses are intentionally\n * rejected (see backend EXBE-227: muxed senders validate-and-throw).\n */\nfunction isStellarAddress(address: string): boolean {\n return StrKey.isValidEd25519PublicKey(address)\n}\n\n/** Tokens are Soroban contracts, not the `G…` accounts that hold balances. */\nfunction isStellarTokenAddress(address: string): boolean {\n return StrKey.isValidContract(address)\n}\n\nexport function StellarProvider(\n options?: StellarProviderOptions\n): StellarSDKProvider {\n const _options: StellarProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.STL\n },\n isAddress: isStellarAddress,\n isTokenAddress: isStellarTokenAddress,\n resolveAddress: resolveStellarAddress,\n getBalance: (\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n ): Promise<TokenAmount[]> =>\n getStellarBalance(\n client,\n walletAddress,\n tokens,\n _options.networkPassphrase ?? DEFAULT_NETWORK_PASSPHRASE\n ),\n async getStepExecutor(options: StepExecutorOptions): Promise<StepExecutor> {\n if (!_options.getWallet) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'getWallet is not provided.'\n )\n }\n const wallet = await _options.getWallet()\n return new StellarStepExecutor({\n wallet,\n networkPassphrase:\n _options.networkPassphrase ?? wallet.networkPassphrase,\n routeId: options.routeId,\n executionOptions: { ...options.executionOptions },\n })\n },\n setOptions(options: StellarProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,6BAAqC,SAAS;;;;;;AAO3D,SAAS,iBAAiB,SAA0B;CAClD,OAAO,OAAO,wBAAwB,OAAO;AAC/C;;AAGA,SAAS,sBAAsB,SAA0B;CACvD,OAAO,OAAO,gBAAgB,OAAO;AACvC;AAEA,SAAgB,gBACd,SACoB;CACpB,MAAM,WAAmC,WAAW,CAAC;CACrD,OAAO;EACL,IAAI,OAAO;GACT,OAAO,UAAU;EACnB;EACA,WAAW;EACX,gBAAgB;EAChB,gBAAgB;EAChB,aACE,QACA,eACA,WAEA,kBACE,QACA,eACA,QACA,SAAS,qBAAqB,0BAChC;EACF,MAAM,gBAAgB,SAAqD;GACzE,IAAI,CAAC,SAAS,WACZ,MAAM,IAAI,cACR,cAAc,qBACd,4BACF;GAEF,MAAM,SAAS,MAAM,SAAS,UAAU;GACxC,OAAO,IAAI,oBAAoB;IAC7B;IACA,mBACE,SAAS,qBAAqB,OAAO;IACvC,SAAS,QAAQ;IACjB,kBAAkB,EAAE,GAAG,QAAQ,iBAAiB;GAClD,CAAC;EACH;EACA,WAAW,SAAiC;GAC1C,OAAO,OAAO,UAAU,OAAO;EACjC;CACF;AACF"}
|
|
@@ -9,7 +9,6 @@ import { SDKClient, Token, TokenAmount } from "@lifi/sdk";
|
|
|
9
9
|
* Stellar RPC, which works for native XLM, wrapped classic assets, and
|
|
10
10
|
* Soroban-native tokens alike.
|
|
11
11
|
*/
|
|
12
|
-
declare const getStellarBalance: (client: SDKClient, walletAddress: string, tokens: Token[], networkPassphrase?: string) => Promise<TokenAmount[]>;
|
|
12
|
+
export declare const getStellarBalance: (client: SDKClient, walletAddress: string, tokens: Token[], networkPassphrase?: string) => Promise<TokenAmount[]>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { getStellarBalance };
|
|
15
14
|
//# sourceMappingURL=getStellarBalance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStellarBalance.d.ts","names":[],"sources":["../../../src/actions/getStellarBalance.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getStellarBalance.d.ts","names":[],"sources":["../../../src/actions/getStellarBalance.ts"],"mappings":";;;;;;;;;;;qBAkCa,oBACX,QAAQ,WACR,uBACA,QAAQ,SACR,+BACC,QAAQ"}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
* materialise — and the entry's own static import of the root keeps that chunk
|
|
12
12
|
* eager anyway.
|
|
13
13
|
*/
|
|
14
|
-
declare function resolveStellarAddress(name: string): Promise<string | undefined>;
|
|
14
|
+
export declare function resolveStellarAddress(name: string): Promise<string | undefined>;
|
|
15
15
|
//#endregion
|
|
16
|
-
export { resolveStellarAddress };
|
|
17
16
|
//# sourceMappingURL=resolveStellarAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveStellarAddress.d.ts","names":[],"sources":["../../../src/actions/resolveStellarAddress.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resolveStellarAddress.d.ts","names":[],"sources":["../../../src/actions/resolveStellarAddress.ts"],"mappings":";;;;;;;;;;;;;wBAcsB,sBACpB,eACC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SDKClient } from "@lifi/sdk";
|
|
2
2
|
import { Server } from "@stellar/stellar-sdk/rpc";
|
|
3
3
|
//#region src/client/getStellarRpc.d.ts
|
|
4
|
-
declare const getStellarRpcs: (client: SDKClient) => Promise<Server[]>;
|
|
4
|
+
export declare const getStellarRpcs: (client: SDKClient) => Promise<Server[]>;
|
|
5
5
|
/**
|
|
6
6
|
* Calls a function on Stellar RPC instances with retry logic. Tries each RPC in
|
|
7
7
|
* sequence until one succeeds.
|
|
8
8
|
*/
|
|
9
|
-
declare const callStellarRpcsWithRetry: <R>(client: SDKClient, fn: (server: Server) => Promise<R>) => Promise<R>;
|
|
9
|
+
export declare const callStellarRpcsWithRetry: <R>(client: SDKClient, fn: (server: Server) => Promise<R>) => Promise<R>;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { callStellarRpcsWithRetry, getStellarRpcs };
|
|
12
11
|
//# sourceMappingURL=getStellarRpc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStellarRpc.d.ts","names":[],"sources":["../../../src/client/getStellarRpc.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getStellarRpc.d.ts","names":[],"sources":["../../../src/client/getStellarRpc.ts"],"mappings":";;;qBAmBa,iBAAwB,QAAQ,cAAY,QAAQ;;;;;qBAWpD,2BAAkC,GAC7C,QAAQ,WACR,KAAK,QAAQ,WAAW,QAAQ,OAC/B,QAAQ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StellarStepExecutorContext, StellarStepExecutorOptions } from "../types.js";
|
|
2
2
|
import { BaseStepExecutor, ExecutionAction, LiFiStepExtended, SDKError, StepExecutorBaseContext, TaskPipeline } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/StellarStepExecutor.d.ts
|
|
4
|
-
declare class StellarStepExecutor extends BaseStepExecutor {
|
|
4
|
+
export declare class StellarStepExecutor extends BaseStepExecutor {
|
|
5
5
|
private wallet;
|
|
6
6
|
private networkPassphrase;
|
|
7
7
|
constructor(options: StellarStepExecutorOptions);
|
|
@@ -11,5 +11,4 @@ declare class StellarStepExecutor extends BaseStepExecutor {
|
|
|
11
11
|
override createPipeline: (context: StellarStepExecutorContext) => TaskPipeline;
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
|
-
export { StellarStepExecutor };
|
|
15
14
|
//# sourceMappingURL=StellarStepExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarStepExecutor.d.ts","names":[],"sources":["../../../src/core/StellarStepExecutor.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StellarStepExecutor.d.ts","names":[],"sources":["../../../src/core/StellarStepExecutor.ts"],"mappings":";;;qBAwBa,4BAA4B;UAC/B;UACA;EAER,YAAY,SAAS;EAMrB,cAAe,MAAM;WAqBZ,cACP,OAAO,OACP,OAAO,kBACP,SAAS,oBACR,QAAQ;WAEF,gBACP,aAAa,4BACZ,QAAQ;WAUF,iBACP,SAAS,+BACR"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { StellarStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/tasks/StellarCheckAllowanceTask.d.ts
|
|
4
|
-
declare class StellarCheckAllowanceTask extends BaseStepExecutionTask {
|
|
4
|
+
export declare class StellarCheckAllowanceTask extends BaseStepExecutionTask {
|
|
5
5
|
run(context: StellarStepExecutorContext): Promise<TaskResult>;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
|
-
export { StellarCheckAllowanceTask };
|
|
9
8
|
//# sourceMappingURL=StellarCheckAllowanceTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarCheckAllowanceTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarCheckAllowanceTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StellarCheckAllowanceTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarCheckAllowanceTask.ts"],"mappings":";;;qBAKa,kCAAkC;EAC7C,IAAU,SAAS,6BAA6B,QAAQ"}
|
|
@@ -25,10 +25,9 @@ import { PrepareTransactionTask, TaskResult } from "@lifi/sdk";
|
|
|
25
25
|
* Re-quoting also invalidates the allowance the pipeline just granted, so the
|
|
26
26
|
* refreshed route is re-checked against the chain before the step is signed.
|
|
27
27
|
*/
|
|
28
|
-
declare class StellarPrepareTransactionTask extends PrepareTransactionTask {
|
|
28
|
+
export declare class StellarPrepareTransactionTask extends PrepareTransactionTask {
|
|
29
29
|
protected override shouldRefetchTransaction(): boolean;
|
|
30
30
|
override run(context: StellarStepExecutorContext): Promise<TaskResult>;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
|
-
export { StellarPrepareTransactionTask };
|
|
34
33
|
//# sourceMappingURL=StellarPrepareTransactionTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarPrepareTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarPrepareTransactionTask.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StellarPrepareTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarPrepareTransactionTask.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4Ba,sCAAsC;qBAC9B;WAIJ,IAAI,SAAS,6BAA6B,QAAQ"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { StellarStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/tasks/StellarSetAllowanceTask.d.ts
|
|
4
|
-
declare class StellarSetAllowanceTask extends BaseStepExecutionTask {
|
|
4
|
+
export declare class StellarSetAllowanceTask extends BaseStepExecutionTask {
|
|
5
5
|
override shouldRun(context: StellarStepExecutorContext): Promise<boolean>;
|
|
6
6
|
run(context: StellarStepExecutorContext): Promise<TaskResult>;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
|
-
export { StellarSetAllowanceTask };
|
|
10
9
|
//# sourceMappingURL=StellarSetAllowanceTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarSetAllowanceTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarSetAllowanceTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StellarSetAllowanceTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarSetAllowanceTask.ts"],"mappings":";;;qBAQa,gCAAgC;WAClC,UAAU,SAAS,6BAA6B;EAMzD,IAAU,SAAS,6BAA6B,QAAQ"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { StellarStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/tasks/StellarSignAndExecuteTask.d.ts
|
|
4
|
-
declare class StellarSignAndExecuteTask extends BaseStepExecutionTask {
|
|
4
|
+
export declare class StellarSignAndExecuteTask extends BaseStepExecutionTask {
|
|
5
5
|
run(context: StellarStepExecutorContext): Promise<TaskResult>;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
|
-
export { StellarSignAndExecuteTask };
|
|
9
8
|
//# sourceMappingURL=StellarSignAndExecuteTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarSignAndExecuteTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StellarSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarSignAndExecuteTask.ts"],"mappings":";;;qBAYa,kCAAkC;EAC7C,IAAU,SAAS,6BAA6B,QAAQ"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { StellarStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/tasks/StellarWaitForTransactionTask.d.ts
|
|
4
|
-
declare class StellarWaitForTransactionTask extends BaseStepExecutionTask {
|
|
4
|
+
export declare class StellarWaitForTransactionTask extends BaseStepExecutionTask {
|
|
5
5
|
run(context: StellarStepExecutorContext): Promise<TaskResult>;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
|
-
export { StellarWaitForTransactionTask };
|
|
9
8
|
//# sourceMappingURL=StellarWaitForTransactionTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarWaitForTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarWaitForTransactionTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StellarWaitForTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/StellarWaitForTransactionTask.ts"],"mappings":";;;qBAYa,sCAAsC;EACjD,IAAU,SAAS,6BAA6B,QAAQ"}
|
|
@@ -15,7 +15,6 @@ import { StellarStepExecutorContext } from "../../../types.js";
|
|
|
15
15
|
* far above what this route asked for, and comparing the two would reject a
|
|
16
16
|
* route that works.
|
|
17
17
|
*/
|
|
18
|
-
declare const assertApprovalStillCovers: (context: StellarStepExecutorContext) => Promise<void>;
|
|
18
|
+
export declare const assertApprovalStillCovers: (context: StellarStepExecutorContext) => Promise<void>;
|
|
19
19
|
//#endregion
|
|
20
|
-
export { assertApprovalStillCovers };
|
|
21
20
|
//# sourceMappingURL=assertApprovalStillCovers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertApprovalStillCovers.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/assertApprovalStillCovers.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"assertApprovalStillCovers.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/assertApprovalStillCovers.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAoBa,4BACX,SAAS,+BACR"}
|
|
@@ -8,8 +8,12 @@ import { SDKClient } from "@lifi/sdk";
|
|
|
8
8
|
* entries and resource fee into the envelope in one step — the client-side
|
|
9
9
|
* equivalent of what the backend's invocation builder does for route
|
|
10
10
|
* transactions.
|
|
11
|
+
*
|
|
12
|
+
* The inclusion fee is bid off the live distribution rather than left at
|
|
13
|
+
* `BASE_FEE`: this transaction is submitted, and a minimum bid on a busy
|
|
14
|
+
* Soroban ledger expires unincluded instead of failing. See
|
|
15
|
+
* {@link resolveSorobanInclusionFee}.
|
|
11
16
|
*/
|
|
12
|
-
declare const buildApproveTransaction: (client: SDKClient, token: string, from: string, spender: string, amount: bigint, networkPassphrase: string) => Promise<string>;
|
|
17
|
+
export declare const buildApproveTransaction: (client: SDKClient, token: string, from: string, spender: string, amount: bigint, networkPassphrase: string) => Promise<string>;
|
|
13
18
|
//#endregion
|
|
14
|
-
export { buildApproveTransaction };
|
|
15
19
|
//# sourceMappingURL=buildApproveTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildApproveTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/buildApproveTransaction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildApproveTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/buildApproveTransaction.ts"],"mappings":";;;;;;;;;;;;;;;;qBAgCa,0BACX,QAAQ,WACR,eACA,cACA,iBACA,gBACA,8BACC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { callStellarRpcsWithRetry } from "../../../client/getStellarRpc.js";
|
|
2
|
-
import {
|
|
2
|
+
import { resolveSorobanInclusionFee } from "./resolveInclusionFee.js";
|
|
3
|
+
import { Address, Contract, TransactionBuilder, nativeToScVal } from "@stellar/stellar-sdk";
|
|
3
4
|
//#region src/core/tasks/helpers/buildApproveTransaction.ts
|
|
4
5
|
/**
|
|
5
6
|
* How long the granted allowance stays live, in ledgers. Ledgers close roughly
|
|
@@ -16,11 +17,20 @@ const APPROVAL_TTL_LEDGERS = 17280;
|
|
|
16
17
|
* entries and resource fee into the envelope in one step — the client-side
|
|
17
18
|
* equivalent of what the backend's invocation builder does for route
|
|
18
19
|
* transactions.
|
|
20
|
+
*
|
|
21
|
+
* The inclusion fee is bid off the live distribution rather than left at
|
|
22
|
+
* `BASE_FEE`: this transaction is submitted, and a minimum bid on a busy
|
|
23
|
+
* Soroban ledger expires unincluded instead of failing. See
|
|
24
|
+
* {@link resolveSorobanInclusionFee}.
|
|
19
25
|
*/
|
|
20
26
|
const buildApproveTransaction = async (client, token, from, spender, amount, networkPassphrase) => callStellarRpcsWithRetry(client, async (server) => {
|
|
21
|
-
const [account, latestLedger] = await Promise.all([
|
|
27
|
+
const [account, latestLedger, inclusionFee] = await Promise.all([
|
|
28
|
+
server.getAccount(from),
|
|
29
|
+
server.getLatestLedger(),
|
|
30
|
+
resolveSorobanInclusionFee(server)
|
|
31
|
+
]);
|
|
22
32
|
const transaction = new TransactionBuilder(account, {
|
|
23
|
-
fee:
|
|
33
|
+
fee: inclusionFee,
|
|
24
34
|
networkPassphrase
|
|
25
35
|
}).addOperation(new Contract(token).call("approve", Address.fromString(from).toScVal(), Address.fromString(spender).toScVal(), nativeToScVal(amount, { type: "i128" }), nativeToScVal(latestLedger.sequence + APPROVAL_TTL_LEDGERS, { type: "u32" }))).setTimeout(300).build();
|
|
26
36
|
return (await server.prepareTransaction(transaction)).toXdr();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildApproveTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/buildApproveTransaction.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n Address,\n
|
|
1
|
+
{"version":3,"file":"buildApproveTransaction.js","names":[],"sources":["../../../../../src/core/tasks/helpers/buildApproveTransaction.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n Address,\n Contract,\n nativeToScVal,\n TransactionBuilder,\n} from '@stellar/stellar-sdk'\nimport { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'\nimport { resolveSorobanInclusionFee } from './resolveInclusionFee.js'\n\n/**\n * How long the granted allowance stays live, in ledgers. Ledgers close roughly\n * every 5s, so this is ~24h — far longer than the seconds between approving and\n * executing, but enough that a user who steps away mid-route doesn't have to\n * approve twice.\n */\nconst APPROVAL_TTL_LEDGERS = 17_280\n\n/**\n * Builds and simulation-assembles a SAC `approve(from, spender, amount,\n * expiration_ledger)` transaction, returning the unsigned envelope XDR.\n *\n * Uses `prepareTransaction`, which simulates and folds the footprint, auth\n * entries and resource fee into the envelope in one step — the client-side\n * equivalent of what the backend's invocation builder does for route\n * transactions.\n *\n * The inclusion fee is bid off the live distribution rather than left at\n * `BASE_FEE`: this transaction is submitted, and a minimum bid on a busy\n * Soroban ledger expires unincluded instead of failing. See\n * {@link resolveSorobanInclusionFee}.\n */\nexport const buildApproveTransaction = async (\n client: SDKClient,\n token: string,\n from: string,\n spender: string,\n amount: bigint,\n networkPassphrase: string\n): Promise<string> =>\n callStellarRpcsWithRetry(client, async (server) => {\n const [account, latestLedger, inclusionFee] = await Promise.all([\n server.getAccount(from),\n server.getLatestLedger(),\n resolveSorobanInclusionFee(server),\n ])\n\n const transaction = new TransactionBuilder(account, {\n fee: inclusionFee,\n networkPassphrase,\n })\n .addOperation(\n new Contract(token).call(\n 'approve',\n Address.fromString(from).toScVal(),\n Address.fromString(spender).toScVal(),\n nativeToScVal(amount, { type: 'i128' }),\n nativeToScVal(latestLedger.sequence + APPROVAL_TTL_LEDGERS, {\n type: 'u32',\n })\n )\n )\n .setTimeout(300)\n .build()\n\n const prepared = await server.prepareTransaction(transaction)\n return prepared.toXdr()\n })\n"],"mappings":";;;;;;;;;;AAgBA,MAAM,uBAAuB;;;;;;;;;;;;;;;AAgB7B,MAAa,0BAA0B,OACrC,QACA,OACA,MACA,SACA,QACA,sBAEA,yBAAyB,QAAQ,OAAO,WAAW;CACjD,MAAM,CAAC,SAAS,cAAc,gBAAgB,MAAM,QAAQ,IAAI;EAC9D,OAAO,WAAW,IAAI;EACtB,OAAO,gBAAgB;EACvB,2BAA2B,MAAM;CACnC,CAAC;CAED,MAAM,cAAc,IAAI,mBAAmB,SAAS;EAClD,KAAK;EACL;CACF,CAAC,CAAC,CACC,aACC,IAAI,SAAS,KAAK,CAAC,CAAC,KAClB,WACA,QAAQ,WAAW,IAAI,CAAC,CAAC,QAAQ,GACjC,QAAQ,WAAW,OAAO,CAAC,CAAC,QAAQ,GACpC,cAAc,QAAQ,EAAE,MAAM,OAAO,CAAC,GACtC,cAAc,aAAa,WAAW,sBAAsB,EAC1D,MAAM,MACR,CAAC,CACH,CACF,CAAC,CACA,WAAW,GAAG,CAAC,CACf,MAAM;CAGT,QAAO,MADgB,OAAO,mBAAmB,WAAW,EAAA,CAC5C,MAAM;AACxB,CAAC"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* knowable before submission — which is what lets a signing task persist the
|
|
7
7
|
* hash first and resume by polling instead of re-signing.
|
|
8
8
|
*/
|
|
9
|
-
declare const deriveTransactionHash: (signedTxXdr: string, networkPassphrase: string) => string;
|
|
9
|
+
export declare const deriveTransactionHash: (signedTxXdr: string, networkPassphrase: string) => string;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { deriveTransactionHash };
|
|
12
11
|
//# sourceMappingURL=deriveTransactionHash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deriveTransactionHash.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/deriveTransactionHash.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"deriveTransactionHash.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/deriveTransactionHash.ts"],"mappings":";;;;;;;;qBASa,wBACX,qBACA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ExtendedChain } from "@lifi/sdk";
|
|
2
2
|
//#region src/core/tasks/helpers/getStellarTxLink.d.ts
|
|
3
|
-
declare const getStellarTxLink: (fromChain: ExtendedChain, transactionHash: string) => string;
|
|
3
|
+
export declare const getStellarTxLink: (fromChain: ExtendedChain, transactionHash: string) => string;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { getStellarTxLink };
|
|
6
5
|
//# sourceMappingURL=getStellarTxLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStellarTxLink.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/getStellarTxLink.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getStellarTxLink.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/getStellarTxLink.ts"],"mappings":";;qBAEa,mBACX,WAAW,eACX"}
|
|
@@ -7,14 +7,13 @@ import { SDKClient } from "@lifi/sdk";
|
|
|
7
7
|
* is a definite answer. A re-submit error after `'unknown'` may come from a
|
|
8
8
|
* transaction that in fact settled, so the caller must not report it.
|
|
9
9
|
*/
|
|
10
|
-
type StellarTransactionProbe = "landed" | "not-found" | "unknown";
|
|
10
|
+
export type StellarTransactionProbe = "landed" | "not-found" | "unknown";
|
|
11
11
|
/**
|
|
12
12
|
* Asks whether the network already knows a transaction, without waiting for it.
|
|
13
13
|
*
|
|
14
14
|
* Soroban RPC only knows a transaction once it has been applied, so `NOT_FOUND`
|
|
15
15
|
* stays ambiguous — never broadcast, or broadcast and still pending.
|
|
16
16
|
*/
|
|
17
|
-
declare const probeStellarTransaction: (client: SDKClient, transactionHash: string) => Promise<StellarTransactionProbe>;
|
|
17
|
+
export declare const probeStellarTransaction: (client: SDKClient, transactionHash: string) => Promise<StellarTransactionProbe>;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { StellarTransactionProbe, probeStellarTransaction };
|
|
20
19
|
//# sourceMappingURL=probeStellarTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probeStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/probeStellarTransaction.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"probeStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/probeStellarTransaction.ts"],"mappings":";;;;;;;;;YAWY;;;;;;;qBAQC,0BACX,QAAQ,WACR,4BACC,QAAQ"}
|
|
@@ -10,7 +10,6 @@ import { SDKClient } from "@lifi/sdk";
|
|
|
10
10
|
* the result is classified outside it, so a deterministic contract-level failure
|
|
11
11
|
* is not retried against every RPC and is not buried in an `AggregateError`.
|
|
12
12
|
*/
|
|
13
|
-
declare const readAllowance: (client: SDKClient, token: string, from: string, spender: string, networkPassphrase: string) => Promise<bigint>;
|
|
13
|
+
export declare const readAllowance: (client: SDKClient, token: string, from: string, spender: string, networkPassphrase: string) => Promise<bigint>;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { readAllowance };
|
|
16
15
|
//# sourceMappingURL=readAllowance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAllowance.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/readAllowance.ts"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"readAllowance.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/readAllowance.ts"],"mappings":";;;;;;;;;;;;qBAsBa,gBACX,QAAQ,WACR,eACA,cACA,iBACA,8BACC"}
|
|
@@ -24,7 +24,6 @@ import { LiFiStep } from "@lifi/sdk";
|
|
|
24
24
|
* is written against the intermediate USDC the swap produces, not the route's
|
|
25
25
|
* `fromToken`.
|
|
26
26
|
*/
|
|
27
|
-
declare const resolveApprovalRequirement: (step: LiFiStep) => StellarApprovalRequirement | undefined;
|
|
27
|
+
export declare const resolveApprovalRequirement: (step: LiFiStep) => StellarApprovalRequirement | undefined;
|
|
28
28
|
//#endregion
|
|
29
|
-
export { resolveApprovalRequirement };
|
|
30
29
|
//# sourceMappingURL=resolveApprovalRequirement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveApprovalRequirement.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/resolveApprovalRequirement.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resolveApprovalRequirement.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/resolveApprovalRequirement.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCa,6BACX,MAAM,aACL"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Server } from "@stellar/stellar-sdk/rpc";
|
|
2
|
+
//#region src/core/tasks/helpers/resolveInclusionFee.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the per-operation inclusion fee to bid for a Soroban transaction.
|
|
5
|
+
*
|
|
6
|
+
* `BASE_FEE` is the network *minimum*, not a market price: Soroban validators
|
|
7
|
+
* rank transactions by the inclusion component alone, and when the Soroban
|
|
8
|
+
* ledger is at capacity every included transaction pays well above the minimum.
|
|
9
|
+
* A minimum bid is then accepted into the mempool, never wins a slot, and dies
|
|
10
|
+
* silently when its timebound expires — `sendTransaction` reports `PENDING` and
|
|
11
|
+
* `getTransaction` reports `NOT_FOUND` forever, with nothing on chain to
|
|
12
|
+
* explain it. Reading the live distribution is what avoids that.
|
|
13
|
+
*
|
|
14
|
+
* Note the resource fee cannot substitute for this. `prepareTransaction` folds
|
|
15
|
+
* a large resource fee into the total, but that buys nothing in the inclusion
|
|
16
|
+
* queue.
|
|
17
|
+
*
|
|
18
|
+
* Fee stats are read best-effort: the surrounding RPC failover has already
|
|
19
|
+
* proven this server answers, so a `getFeeStats` hiccup falls back to a bid
|
|
20
|
+
* rather than failing the approval. Both degraded paths warn, because a silent
|
|
21
|
+
* fallback re-creates the undiagnosable failure this helper exists to remove.
|
|
22
|
+
*/
|
|
23
|
+
export declare const resolveSorobanInclusionFee: (server: Server) => Promise<string>;
|
|
24
|
+
//#endregion
|
|
25
|
+
//# sourceMappingURL=resolveInclusionFee.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveInclusionFee.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/resolveInclusionFee.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;qBA2Da,6BACX,QAAQ,WACP"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BASE_FEE } from "@stellar/stellar-sdk";
|
|
2
|
+
//#region src/core/tasks/helpers/resolveInclusionFee.ts
|
|
3
|
+
/** stroops/op — the network minimum, and the floor under any bid. */
|
|
4
|
+
const MIN_BASE_FEE = Number(BASE_FEE);
|
|
5
|
+
/** stroops/op — the bid placed when fee stats cannot be read or decoded. */
|
|
6
|
+
const FALLBACK_FEE = 1e4;
|
|
7
|
+
/**
|
|
8
|
+
* stroops/op cap (0.1 XLM). A broken RPC percentile must never reach a real
|
|
9
|
+
* bid, so the ceiling is enforced even on a value the network reported.
|
|
10
|
+
*/
|
|
11
|
+
const MAX_FEE_STROOPS = 1e6;
|
|
12
|
+
/**
|
|
13
|
+
* Percentile read for the inclusion bid.
|
|
14
|
+
*
|
|
15
|
+
* `p70` matches the backend's `standard` fee tier — `getFeeTiers` in
|
|
16
|
+
* lifi-backend `apps/backend-api/src/stellar/gas/stellar.gas.ts` maps
|
|
17
|
+
* slow/standard/fast to p20/p70/p95, and the three constants above mirror that
|
|
18
|
+
* module. Bidding the same percentile keeps the approval and the route it
|
|
19
|
+
* unblocks on equal terms: a cheaper approval is not a cheaper route — it is a
|
|
20
|
+
* route that never starts.
|
|
21
|
+
*
|
|
22
|
+
* Known limitation. `getFeeStats` reports the inclusion fees transactions were
|
|
23
|
+
* *charged*, not the fees they bid. Under surge pricing every transaction in an
|
|
24
|
+
* included set pays the lowest bid in that set, so the reported values cluster
|
|
25
|
+
* at recent clearing prices rather than spanning a range of bids — a 2026-09
|
|
26
|
+
* mainnet sample over ~7k transactions returned `p10` through `p99` all equal.
|
|
27
|
+
* A mid percentile of clearing prices is therefore a marginal bid. Raising it
|
|
28
|
+
* is worth doing, but only alongside the backend so the two stay aligned.
|
|
29
|
+
*/
|
|
30
|
+
const INCLUSION_FEE_PERCENTILE = "p70";
|
|
31
|
+
/** Bounds a bid to an integer in range — the builder rejects non-integers. */
|
|
32
|
+
const clampBid = (value) => Math.floor(Math.min(MAX_FEE_STROOPS, Math.max(MIN_BASE_FEE, value)));
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the per-operation inclusion fee to bid for a Soroban transaction.
|
|
35
|
+
*
|
|
36
|
+
* `BASE_FEE` is the network *minimum*, not a market price: Soroban validators
|
|
37
|
+
* rank transactions by the inclusion component alone, and when the Soroban
|
|
38
|
+
* ledger is at capacity every included transaction pays well above the minimum.
|
|
39
|
+
* A minimum bid is then accepted into the mempool, never wins a slot, and dies
|
|
40
|
+
* silently when its timebound expires — `sendTransaction` reports `PENDING` and
|
|
41
|
+
* `getTransaction` reports `NOT_FOUND` forever, with nothing on chain to
|
|
42
|
+
* explain it. Reading the live distribution is what avoids that.
|
|
43
|
+
*
|
|
44
|
+
* Note the resource fee cannot substitute for this. `prepareTransaction` folds
|
|
45
|
+
* a large resource fee into the total, but that buys nothing in the inclusion
|
|
46
|
+
* queue.
|
|
47
|
+
*
|
|
48
|
+
* Fee stats are read best-effort: the surrounding RPC failover has already
|
|
49
|
+
* proven this server answers, so a `getFeeStats` hiccup falls back to a bid
|
|
50
|
+
* rather than failing the approval. Both degraded paths warn, because a silent
|
|
51
|
+
* fallback re-creates the undiagnosable failure this helper exists to remove.
|
|
52
|
+
*/
|
|
53
|
+
const resolveSorobanInclusionFee = async (server) => {
|
|
54
|
+
try {
|
|
55
|
+
const reported = (await server.getFeeStats())?.sorobanInclusionFee?.[INCLUSION_FEE_PERCENTILE];
|
|
56
|
+
const percentile = Number(reported);
|
|
57
|
+
if (!Number.isFinite(percentile) || percentile <= 0) {
|
|
58
|
+
console.warn("[resolveSorobanInclusionFee] Unusable fee percentile, using fallback bid:", FALLBACK_FEE, reported);
|
|
59
|
+
return String(FALLBACK_FEE);
|
|
60
|
+
}
|
|
61
|
+
return String(clampBid(percentile));
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.warn("[resolveSorobanInclusionFee] Fee stats unreadable, using fallback bid:", FALLBACK_FEE, error);
|
|
64
|
+
return String(FALLBACK_FEE);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { resolveSorobanInclusionFee };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=resolveInclusionFee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveInclusionFee.js","names":[],"sources":["../../../../../src/core/tasks/helpers/resolveInclusionFee.ts"],"sourcesContent":["import { BASE_FEE } from '@stellar/stellar-sdk'\nimport type { Server } from '@stellar/stellar-sdk/rpc'\n\n/** stroops/op — the network minimum, and the floor under any bid. */\nconst MIN_BASE_FEE = Number(BASE_FEE)\n\n/** stroops/op — the bid placed when fee stats cannot be read or decoded. */\nconst FALLBACK_FEE = 10_000\n\n/**\n * stroops/op cap (0.1 XLM). A broken RPC percentile must never reach a real\n * bid, so the ceiling is enforced even on a value the network reported.\n */\nconst MAX_FEE_STROOPS = 1_000_000\n\n/**\n * Percentile read for the inclusion bid.\n *\n * `p70` matches the backend's `standard` fee tier — `getFeeTiers` in\n * lifi-backend `apps/backend-api/src/stellar/gas/stellar.gas.ts` maps\n * slow/standard/fast to p20/p70/p95, and the three constants above mirror that\n * module. Bidding the same percentile keeps the approval and the route it\n * unblocks on equal terms: a cheaper approval is not a cheaper route — it is a\n * route that never starts.\n *\n * Known limitation. `getFeeStats` reports the inclusion fees transactions were\n * *charged*, not the fees they bid. Under surge pricing every transaction in an\n * included set pays the lowest bid in that set, so the reported values cluster\n * at recent clearing prices rather than spanning a range of bids — a 2026-09\n * mainnet sample over ~7k transactions returned `p10` through `p99` all equal.\n * A mid percentile of clearing prices is therefore a marginal bid. Raising it\n * is worth doing, but only alongside the backend so the two stay aligned.\n */\nconst INCLUSION_FEE_PERCENTILE = 'p70' as const\n\n/** Bounds a bid to an integer in range — the builder rejects non-integers. */\nconst clampBid = (value: number): number =>\n Math.floor(Math.min(MAX_FEE_STROOPS, Math.max(MIN_BASE_FEE, value)))\n\n/**\n * Resolves the per-operation inclusion fee to bid for a Soroban transaction.\n *\n * `BASE_FEE` is the network *minimum*, not a market price: Soroban validators\n * rank transactions by the inclusion component alone, and when the Soroban\n * ledger is at capacity every included transaction pays well above the minimum.\n * A minimum bid is then accepted into the mempool, never wins a slot, and dies\n * silently when its timebound expires — `sendTransaction` reports `PENDING` and\n * `getTransaction` reports `NOT_FOUND` forever, with nothing on chain to\n * explain it. Reading the live distribution is what avoids that.\n *\n * Note the resource fee cannot substitute for this. `prepareTransaction` folds\n * a large resource fee into the total, but that buys nothing in the inclusion\n * queue.\n *\n * Fee stats are read best-effort: the surrounding RPC failover has already\n * proven this server answers, so a `getFeeStats` hiccup falls back to a bid\n * rather than failing the approval. Both degraded paths warn, because a silent\n * fallback re-creates the undiagnosable failure this helper exists to remove.\n */\nexport const resolveSorobanInclusionFee = async (\n server: Server\n): Promise<string> => {\n try {\n const feeStats = await server.getFeeStats()\n const reported = feeStats?.sorobanInclusionFee?.[INCLUSION_FEE_PERCENTILE]\n const percentile = Number(reported)\n if (!Number.isFinite(percentile) || percentile <= 0) {\n console.warn(\n '[resolveSorobanInclusionFee] Unusable fee percentile, using fallback bid:',\n FALLBACK_FEE,\n reported\n )\n return String(FALLBACK_FEE)\n }\n return String(clampBid(percentile))\n } catch (error) {\n console.warn(\n '[resolveSorobanInclusionFee] Fee stats unreadable, using fallback bid:',\n FALLBACK_FEE,\n error\n )\n return String(FALLBACK_FEE)\n }\n}\n"],"mappings":";;;AAIA,MAAM,eAAe,OAAO,QAAQ;;AAGpC,MAAM,eAAe;;;;;AAMrB,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;AAoBxB,MAAM,2BAA2B;;AAGjC,MAAM,YAAY,UAChB,KAAK,MAAM,KAAK,IAAI,iBAAiB,KAAK,IAAI,cAAc,KAAK,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;AAsBrE,MAAa,6BAA6B,OACxC,WACoB;CACpB,IAAI;EAEF,MAAM,YAAW,MADM,OAAO,YAAY,EAAA,EACf,sBAAsB;EACjD,MAAM,aAAa,OAAO,QAAQ;EAClC,IAAI,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,GAAG;GACnD,QAAQ,KACN,6EACA,cACA,QACF;GACA,OAAO,OAAO,YAAY;EAC5B;EACA,OAAO,OAAO,SAAS,UAAU,CAAC;CACpC,SAAS,OAAO;EACd,QAAQ,KACN,0EACA,cACA,KACF;EACA,OAAO,OAAO,YAAY;CAC5B;AACF"}
|
|
@@ -17,7 +17,6 @@ import { SDKClient } from "@lifi/sdk";
|
|
|
17
17
|
* `TRY_AGAIN_LATER` is retried a bounded number of times rather than thrown:
|
|
18
18
|
* core is telling us the envelope was not queued, not that it is invalid.
|
|
19
19
|
*/
|
|
20
|
-
declare const submitStellarTransaction: (client: SDKClient, signedTxXdr: string, networkPassphrase: string) => Promise<string>;
|
|
20
|
+
export declare const submitStellarTransaction: (client: SDKClient, signedTxXdr: string, networkPassphrase: string) => Promise<string>;
|
|
21
21
|
//#endregion
|
|
22
|
-
export { submitStellarTransaction };
|
|
23
22
|
//# sourceMappingURL=submitStellarTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submitStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/submitStellarTransaction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"submitStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/submitStellarTransaction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBA8Ba,2BACX,QAAQ,WACR,qBACA,8BACC"}
|
|
@@ -16,7 +16,6 @@ import { Api } from "@stellar/stellar-sdk/rpc";
|
|
|
16
16
|
* {@link callStellarRpcsWithRetry}; only the read goes through the failover
|
|
17
17
|
* wrapper, which would otherwise wrap a classified error in an `AggregateError`.
|
|
18
18
|
*/
|
|
19
|
-
declare const waitForStellarTransaction: (client: SDKClient, transactionHash: string, pollingIntervalMs?: number) => Promise<Api.GetSuccessfulTransactionResponse>;
|
|
19
|
+
export declare const waitForStellarTransaction: (client: SDKClient, transactionHash: string, pollingIntervalMs?: number) => Promise<Api.GetSuccessfulTransactionResponse>;
|
|
20
20
|
//#endregion
|
|
21
|
-
export { waitForStellarTransaction };
|
|
22
21
|
//# sourceMappingURL=waitForStellarTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForStellarTransaction.ts"],"mappings":";;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"waitForStellarTransaction.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForStellarTransaction.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBA6Ba,4BACX,QAAQ,WACR,yBACA,+BACC,QAAQ,IAAI"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ExecutionAction, LiFiStep, SDKError } from "@lifi/sdk";
|
|
2
2
|
//#region src/errors/parseStellarErrors.d.ts
|
|
3
|
-
declare const parseStellarErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
|
|
3
|
+
export declare const parseStellarErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { parseStellarErrors };
|
|
6
5
|
//# sourceMappingURL=parseStellarErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseStellarErrors.d.ts","names":[],"sources":["../../../src/errors/parseStellarErrors.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"parseStellarErrors.d.ts","names":[],"sources":["../../../src/errors/parseStellarErrors.ts"],"mappings":";;qBAWa,qBACX,GAAG,OACH,OAAO,UACP,SAAS,oBACR,QAAQ"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { LiFiStepExtended, SDKProvider, StepExecutorContext, StepExecutorOptions
|
|
|
5
5
|
* (`@creit.tech/stellar-wallets-kit`) signing surface so a widget adapter can
|
|
6
6
|
* forward calls directly.
|
|
7
7
|
*/
|
|
8
|
-
interface StellarSignOptions {
|
|
8
|
+
export interface StellarSignOptions {
|
|
9
9
|
networkPassphrase?: string;
|
|
10
10
|
address?: string;
|
|
11
11
|
}
|
|
@@ -13,7 +13,7 @@ interface StellarSignOptions {
|
|
|
13
13
|
* Result of signing a transaction envelope — a base64 XDR string plus the
|
|
14
14
|
* signer's public key. Matches the Stellar Wallets Kit `signTransaction` return.
|
|
15
15
|
*/
|
|
16
|
-
interface StellarSignedTransaction {
|
|
16
|
+
export interface StellarSignedTransaction {
|
|
17
17
|
signedTxXdr: string;
|
|
18
18
|
signerAddress?: string;
|
|
19
19
|
}
|
|
@@ -22,7 +22,7 @@ interface StellarSignedTransaction {
|
|
|
22
22
|
* Kit `signAuthEntry` return. Not required for the router routes (source-account
|
|
23
23
|
* auth), exposed for future-proofing.
|
|
24
24
|
*/
|
|
25
|
-
interface StellarSignedAuthEntry {
|
|
25
|
+
export interface StellarSignedAuthEntry {
|
|
26
26
|
signedAuthEntry: string;
|
|
27
27
|
signerAddress?: string;
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@ interface StellarSignedAuthEntry {
|
|
|
30
30
|
* The minimal signer surface the SDK provider needs from a connected wallet.
|
|
31
31
|
* The widget builds this adapter from the Stellar Wallets Kit instance.
|
|
32
32
|
*/
|
|
33
|
-
interface StellarWallet {
|
|
33
|
+
export interface StellarWallet {
|
|
34
34
|
/** The connected G-address (source account). */
|
|
35
35
|
address: string;
|
|
36
36
|
/** The network passphrase the wallet is expected to sign against. */
|
|
@@ -42,7 +42,7 @@ interface StellarWallet {
|
|
|
42
42
|
*/
|
|
43
43
|
signAuthEntry?: (authEntry: string, opts?: StellarSignOptions) => Promise<StellarSignedAuthEntry>;
|
|
44
44
|
}
|
|
45
|
-
interface StellarProviderOptions {
|
|
45
|
+
export interface StellarProviderOptions {
|
|
46
46
|
getWallet?: () => Promise<StellarWallet>;
|
|
47
47
|
/**
|
|
48
48
|
* Network passphrase for the Stellar network this provider targets.
|
|
@@ -55,15 +55,15 @@ interface StellarProviderOptions {
|
|
|
55
55
|
*/
|
|
56
56
|
networkPassphrase?: string;
|
|
57
57
|
}
|
|
58
|
-
interface StellarSDKProvider extends SDKProvider {
|
|
58
|
+
export interface StellarSDKProvider extends SDKProvider {
|
|
59
59
|
setOptions(options: StellarProviderOptions): void;
|
|
60
60
|
}
|
|
61
|
-
declare function isStellarProvider(provider: SDKProvider): provider is StellarSDKProvider;
|
|
61
|
+
export declare function isStellarProvider(provider: SDKProvider): provider is StellarSDKProvider;
|
|
62
62
|
/**
|
|
63
63
|
* A SAC allowance an included leg of a Stellar route needs before the route can
|
|
64
64
|
* be executed. Resolved by {@link resolveApprovalRequirement}.
|
|
65
65
|
*/
|
|
66
|
-
interface StellarApprovalRequirement {
|
|
66
|
+
export interface StellarApprovalRequirement {
|
|
67
67
|
/** Soroban `C`-address that calls `transfer_from` and so consumes the allowance. */
|
|
68
68
|
spender: string;
|
|
69
69
|
/** SAC contract id of the token the allowance is written against. */
|
|
@@ -72,7 +72,7 @@ interface StellarApprovalRequirement {
|
|
|
72
72
|
amount: bigint;
|
|
73
73
|
}
|
|
74
74
|
/** Execution context passed between {@link StellarStepExecutor} tasks. */
|
|
75
|
-
interface StellarTaskContext {
|
|
75
|
+
export interface StellarTaskContext {
|
|
76
76
|
/** Hash of the submitted route transaction. */
|
|
77
77
|
transactionHash?: string;
|
|
78
78
|
/**
|
|
@@ -83,15 +83,14 @@ interface StellarTaskContext {
|
|
|
83
83
|
/** Whether the sender's SAC allowance already covers {@link approval}. */
|
|
84
84
|
hasSufficientAllowance?: boolean;
|
|
85
85
|
}
|
|
86
|
-
interface StellarStepExecutorContext extends StepExecutorContext, StellarTaskContext {
|
|
86
|
+
export interface StellarStepExecutorContext extends StepExecutorContext, StellarTaskContext {
|
|
87
87
|
wallet: StellarWallet;
|
|
88
88
|
networkPassphrase: string;
|
|
89
89
|
checkWallet: (step: LiFiStepExtended) => void;
|
|
90
90
|
}
|
|
91
|
-
interface StellarStepExecutorOptions extends StepExecutorOptions {
|
|
91
|
+
export interface StellarStepExecutorOptions extends StepExecutorOptions {
|
|
92
92
|
wallet: StellarWallet;
|
|
93
93
|
networkPassphrase: string;
|
|
94
94
|
}
|
|
95
95
|
//#endregion
|
|
96
|
-
export { StellarApprovalRequirement, StellarProviderOptions, StellarSDKProvider, StellarSignOptions, StellarSignedAuthEntry, StellarSignedTransaction, StellarStepExecutorContext, StellarStepExecutorOptions, StellarTaskContext, StellarWallet, isStellarProvider };
|
|
97
96
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;;;iBAaiB;EACf;EACA;;;;;;iBAOe;EACf;EACA;;;;;;;iBAQe;EACf;EACA;;;;;;iBAOe;;EAEf;;EAEA;EACA,kBACE,aACA,OAAO,uBACJ,QAAQ;;;;;EAKb,iBACE,mBACA,OAAO,uBACJ,QAAQ;;iBAGE;EACf,kBAAkB,QAAQ;;;;;;;;;;EAU1B;;iBAGe,2BAA2B;EAC1C,WAAW,SAAS;;wBAGN,kBACd,UAAU,cACT,YAAY;;;;;iBAQE;;EAEf;;EAEA;;EAEA;;;iBAIe;;EAEf;;;;;EAKA,WAAW;;EAEX;;iBAGe,mCACP,qBACN;EACF,QAAQ;EACR;EACA,cAAc,MAAM;;iBAGL,mCAAmC;EAClD,QAAQ;EACR"}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//#region src/version.d.ts
|
|
2
|
-
declare const name = "@lifi/sdk-provider-stellar";
|
|
3
|
-
declare const version = "4.
|
|
2
|
+
export declare const name = "@lifi/sdk-provider-stellar";
|
|
3
|
+
export declare const version = "4.3.0";
|
|
4
4
|
//#endregion
|
|
5
|
-
export { name, version };
|
|
6
5
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","names":[],"sources":["../../src/version.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"version.d.ts","names":[],"sources":["../../src/version.ts"],"mappings":";qBAAa;qBACA"}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-stellar'\nexport const version = '4.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-stellar'\nexport const version = '4.3.0'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk-provider-stellar",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "LI.FI Stellar SDK Provider for Any-to-Any Cross-Chain-Swap",
|
|
5
5
|
"homepage": "https://github.com/lifinance/sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@lifi/sdk": "4.
|
|
31
|
+
"@lifi/sdk": "4.7.0",
|
|
32
32
|
"@stellar/stellar-sdk": "^17.0.1"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
package/src/StellarProvider.ts
CHANGED
|
@@ -30,6 +30,11 @@ function isStellarAddress(address: string): boolean {
|
|
|
30
30
|
return StrKey.isValidEd25519PublicKey(address)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** Tokens are Soroban contracts, not the `G…` accounts that hold balances. */
|
|
34
|
+
function isStellarTokenAddress(address: string): boolean {
|
|
35
|
+
return StrKey.isValidContract(address)
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
export function StellarProvider(
|
|
34
39
|
options?: StellarProviderOptions
|
|
35
40
|
): StellarSDKProvider {
|
|
@@ -39,6 +44,7 @@ export function StellarProvider(
|
|
|
39
44
|
return ChainType.STL
|
|
40
45
|
},
|
|
41
46
|
isAddress: isStellarAddress,
|
|
47
|
+
isTokenAddress: isStellarTokenAddress,
|
|
42
48
|
resolveAddress: resolveStellarAddress,
|
|
43
49
|
getBalance: (
|
|
44
50
|
client: SDKClient,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { SDKClient } from '@lifi/sdk'
|
|
2
2
|
import {
|
|
3
3
|
Address,
|
|
4
|
-
BASE_FEE,
|
|
5
4
|
Contract,
|
|
6
5
|
nativeToScVal,
|
|
7
6
|
TransactionBuilder,
|
|
8
7
|
} from '@stellar/stellar-sdk'
|
|
9
8
|
import { callStellarRpcsWithRetry } from '../../../client/getStellarRpc.js'
|
|
9
|
+
import { resolveSorobanInclusionFee } from './resolveInclusionFee.js'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* How long the granted allowance stays live, in ledgers. Ledgers close roughly
|
|
@@ -24,6 +24,11 @@ const APPROVAL_TTL_LEDGERS = 17_280
|
|
|
24
24
|
* entries and resource fee into the envelope in one step — the client-side
|
|
25
25
|
* equivalent of what the backend's invocation builder does for route
|
|
26
26
|
* transactions.
|
|
27
|
+
*
|
|
28
|
+
* The inclusion fee is bid off the live distribution rather than left at
|
|
29
|
+
* `BASE_FEE`: this transaction is submitted, and a minimum bid on a busy
|
|
30
|
+
* Soroban ledger expires unincluded instead of failing. See
|
|
31
|
+
* {@link resolveSorobanInclusionFee}.
|
|
27
32
|
*/
|
|
28
33
|
export const buildApproveTransaction = async (
|
|
29
34
|
client: SDKClient,
|
|
@@ -34,13 +39,14 @@ export const buildApproveTransaction = async (
|
|
|
34
39
|
networkPassphrase: string
|
|
35
40
|
): Promise<string> =>
|
|
36
41
|
callStellarRpcsWithRetry(client, async (server) => {
|
|
37
|
-
const [account, latestLedger] = await Promise.all([
|
|
42
|
+
const [account, latestLedger, inclusionFee] = await Promise.all([
|
|
38
43
|
server.getAccount(from),
|
|
39
44
|
server.getLatestLedger(),
|
|
45
|
+
resolveSorobanInclusionFee(server),
|
|
40
46
|
])
|
|
41
47
|
|
|
42
48
|
const transaction = new TransactionBuilder(account, {
|
|
43
|
-
fee:
|
|
49
|
+
fee: inclusionFee,
|
|
44
50
|
networkPassphrase,
|
|
45
51
|
})
|
|
46
52
|
.addOperation(
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BASE_FEE } from '@stellar/stellar-sdk'
|
|
2
|
+
import type { Server } from '@stellar/stellar-sdk/rpc'
|
|
3
|
+
|
|
4
|
+
/** stroops/op — the network minimum, and the floor under any bid. */
|
|
5
|
+
const MIN_BASE_FEE = Number(BASE_FEE)
|
|
6
|
+
|
|
7
|
+
/** stroops/op — the bid placed when fee stats cannot be read or decoded. */
|
|
8
|
+
const FALLBACK_FEE = 10_000
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* stroops/op cap (0.1 XLM). A broken RPC percentile must never reach a real
|
|
12
|
+
* bid, so the ceiling is enforced even on a value the network reported.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_FEE_STROOPS = 1_000_000
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Percentile read for the inclusion bid.
|
|
18
|
+
*
|
|
19
|
+
* `p70` matches the backend's `standard` fee tier — `getFeeTiers` in
|
|
20
|
+
* lifi-backend `apps/backend-api/src/stellar/gas/stellar.gas.ts` maps
|
|
21
|
+
* slow/standard/fast to p20/p70/p95, and the three constants above mirror that
|
|
22
|
+
* module. Bidding the same percentile keeps the approval and the route it
|
|
23
|
+
* unblocks on equal terms: a cheaper approval is not a cheaper route — it is a
|
|
24
|
+
* route that never starts.
|
|
25
|
+
*
|
|
26
|
+
* Known limitation. `getFeeStats` reports the inclusion fees transactions were
|
|
27
|
+
* *charged*, not the fees they bid. Under surge pricing every transaction in an
|
|
28
|
+
* included set pays the lowest bid in that set, so the reported values cluster
|
|
29
|
+
* at recent clearing prices rather than spanning a range of bids — a 2026-09
|
|
30
|
+
* mainnet sample over ~7k transactions returned `p10` through `p99` all equal.
|
|
31
|
+
* A mid percentile of clearing prices is therefore a marginal bid. Raising it
|
|
32
|
+
* is worth doing, but only alongside the backend so the two stay aligned.
|
|
33
|
+
*/
|
|
34
|
+
const INCLUSION_FEE_PERCENTILE = 'p70' as const
|
|
35
|
+
|
|
36
|
+
/** Bounds a bid to an integer in range — the builder rejects non-integers. */
|
|
37
|
+
const clampBid = (value: number): number =>
|
|
38
|
+
Math.floor(Math.min(MAX_FEE_STROOPS, Math.max(MIN_BASE_FEE, value)))
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the per-operation inclusion fee to bid for a Soroban transaction.
|
|
42
|
+
*
|
|
43
|
+
* `BASE_FEE` is the network *minimum*, not a market price: Soroban validators
|
|
44
|
+
* rank transactions by the inclusion component alone, and when the Soroban
|
|
45
|
+
* ledger is at capacity every included transaction pays well above the minimum.
|
|
46
|
+
* A minimum bid is then accepted into the mempool, never wins a slot, and dies
|
|
47
|
+
* silently when its timebound expires — `sendTransaction` reports `PENDING` and
|
|
48
|
+
* `getTransaction` reports `NOT_FOUND` forever, with nothing on chain to
|
|
49
|
+
* explain it. Reading the live distribution is what avoids that.
|
|
50
|
+
*
|
|
51
|
+
* Note the resource fee cannot substitute for this. `prepareTransaction` folds
|
|
52
|
+
* a large resource fee into the total, but that buys nothing in the inclusion
|
|
53
|
+
* queue.
|
|
54
|
+
*
|
|
55
|
+
* Fee stats are read best-effort: the surrounding RPC failover has already
|
|
56
|
+
* proven this server answers, so a `getFeeStats` hiccup falls back to a bid
|
|
57
|
+
* rather than failing the approval. Both degraded paths warn, because a silent
|
|
58
|
+
* fallback re-creates the undiagnosable failure this helper exists to remove.
|
|
59
|
+
*/
|
|
60
|
+
export const resolveSorobanInclusionFee = async (
|
|
61
|
+
server: Server
|
|
62
|
+
): Promise<string> => {
|
|
63
|
+
try {
|
|
64
|
+
const feeStats = await server.getFeeStats()
|
|
65
|
+
const reported = feeStats?.sorobanInclusionFee?.[INCLUSION_FEE_PERCENTILE]
|
|
66
|
+
const percentile = Number(reported)
|
|
67
|
+
if (!Number.isFinite(percentile) || percentile <= 0) {
|
|
68
|
+
console.warn(
|
|
69
|
+
'[resolveSorobanInclusionFee] Unusable fee percentile, using fallback bid:',
|
|
70
|
+
FALLBACK_FEE,
|
|
71
|
+
reported
|
|
72
|
+
)
|
|
73
|
+
return String(FALLBACK_FEE)
|
|
74
|
+
}
|
|
75
|
+
return String(clampBid(percentile))
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.warn(
|
|
78
|
+
'[resolveSorobanInclusionFee] Fee stats unreadable, using fallback bid:',
|
|
79
|
+
FALLBACK_FEE,
|
|
80
|
+
error
|
|
81
|
+
)
|
|
82
|
+
return String(FALLBACK_FEE)
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-stellar'
|
|
2
|
-
export const version = '4.
|
|
2
|
+
export const version = '4.3.0'
|