@galacticcouncil/xc-cfg 2.2.0 → 2.3.0-pr349-c576e3a

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,12 @@
1
+ export declare const NTT_DEFAULT_INSTRUCTIONS = "0x00";
2
+ export declare const NTT_TRIMMED_DECIMALS = 8;
3
+ export declare const EXECUTOR_API = "https://executor.labsapis.com";
4
+ /**
5
+ * Names the ntt message an Executor request is paying to deliver.
6
+ *
7
+ * The sequence is the manager's `nextMessageSequence()` read at build time,
8
+ * so a transfer through the same manager landing in between leaves the
9
+ * request pointing at the wrong message. It relays nothing then, and the
10
+ * transfer stays claimable by hand.
11
+ */
12
+ export declare const encodeNttRequest: (srcWormholeId: number, nttManager: string, sequence: bigint) => `0x${string}`;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ExecutorBudgetBuilder } from './types';
2
+ /** An evm redeem holds nothing - receiveMessage moves no value. */
3
+ export declare const EvmExecutorBudget: () => ExecutorBudgetBuilder;
@@ -0,0 +1,18 @@
1
+ import { EvmExecutorBudget } from './evm';
2
+ import { SolanaExecutorBudget } from './solana';
3
+ import { SuiExecutorBudget } from './sui';
4
+ import { ExecutorBudget, ExecutorBudgetParams } from './types';
5
+ export * from './types';
6
+ /**
7
+ * Executor budget for a destination.
8
+ *
9
+ * Keyed on the destination, not the source: hydration -> sui is an evm source
10
+ * with a sui destination, and it is sui's budget that has to be met.
11
+ *
12
+ * The single place either budget is decided. A signed quote is only honoured
13
+ * for the instructions it was priced against, so the fee builder and the
14
+ * transfer builder have to derive them the same way or the amount paid and
15
+ * the amount requested disagree.
16
+ */
17
+ export declare const executorBudget: (params: ExecutorBudgetParams) => Promise<ExecutorBudget>;
18
+ export { EvmExecutorBudget, SolanaExecutorBudget, SuiExecutorBudget };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { ExecutorBudgetBuilder } from './types';
2
+ /**
3
+ * An svm redeem mints into the recipient's associated token account and the
4
+ * relayer opens it when missing, so its rent is charged only then - mirroring
5
+ * upstream, which adds it on `getAccountInfo(ata) === null`.
6
+ *
7
+ * Budgeting it unconditionally would be simpler, but the executor charges
8
+ * source native for lamports it fronts, so every transfer to an existing
9
+ * account would pay for rent nobody spends.
10
+ */
11
+ export declare const SolanaExecutorBudget: () => ExecutorBudgetBuilder;
@@ -0,0 +1,3 @@
1
+ import { ExecutorBudgetBuilder } from './types';
2
+ /** A sui redeem holds nothing - the coin is minted to the recipient. */
3
+ export declare const SuiExecutorBudget: () => ExecutorBudgetBuilder;
@@ -0,0 +1,22 @@
1
+ import { AnyChain, Asset } from '@galacticcouncil/xc-core';
2
+ /**
3
+ * What the Executor is asked to reserve to redeem on a destination.
4
+ *
5
+ * `gasLimit` budgets execution, `msgValue` budgets what the executor must
6
+ * hold. Both are destination units - evm gas, svm compute units, sui MIST -
7
+ * so neither has a value that is meaningful across chains.
8
+ */
9
+ export type ExecutorBudget = {
10
+ gasLimit: bigint;
11
+ msgValue: bigint;
12
+ };
13
+ export type ExecutorBudgetParams = {
14
+ destination: AnyChain;
15
+ /** Destination asset, resolving the spl mint on an svm destination. */
16
+ asset?: Asset;
17
+ /** Recipient on the destination, whose accounts the redeem may open. */
18
+ recipient?: string;
19
+ };
20
+ export interface ExecutorBudgetBuilder {
21
+ build: (params: ExecutorBudgetParams) => Promise<ExecutorBudget>;
22
+ }
@@ -0,0 +1,2 @@
1
+ export * from './constants';
2
+ export * from './executor';
@@ -1,18 +1,32 @@
1
+ import { ContractConfigBuilder, ContractConfigBuilderParams, ExtrinsicConfigBuilder } from '@galacticcouncil/xc-core';
1
2
  import { Erc20 } from './contracts/Erc20';
2
3
  import { PolkadotXcm } from './contracts/PolkadotXcm';
3
4
  import { Wormhole } from './contracts/Wormhole';
4
5
  export declare function ContractBuilder(): {
5
6
  Batch: () => {
6
- batchAll: (configs: import("@galacticcouncil/xc-core").ContractConfigBuilder[]) => import("@galacticcouncil/xc-core").ContractConfigBuilder;
7
+ batchAll: (configs: ContractConfigBuilder[]) => ContractConfigBuilder;
7
8
  };
8
9
  Erc20: typeof Erc20;
9
10
  Basejump: () => {
10
- bridgeViaWormhole: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
11
+ bridgeViaWormhole: () => ContractConfigBuilder;
11
12
  };
12
13
  PolkadotXcm: typeof PolkadotXcm;
13
14
  Snowbridge: () => {
14
- v2SendMessage: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
15
- sendToken: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
15
+ v2SendMessage: () => ContractConfigBuilder;
16
+ sendToken: () => ContractConfigBuilder;
16
17
  };
17
18
  Wormhole: typeof Wormhole;
18
19
  };
20
+ /**
21
+ * Contract counterpart of {@link ExtrinsicDecorator} - attaches an extrinsic
22
+ * to run ahead of the call.
23
+ *
24
+ * Where the extrinsic decorator can wrap both sides in `Utility.batch_all`
25
+ * itself, a contract call is not a substrate call: the batching happens later,
26
+ * once the platform knows the origin is ss58 and has wrapped the call in
27
+ * `EVM.call`. So this only carries the extrinsic on the config and leaves the
28
+ * assembly to {@link SubstrateEvm}.
29
+ */
30
+ export declare function ContractDecorator(predicate: (params: ContractConfigBuilderParams) => boolean, extrinsic: ExtrinsicConfigBuilder): {
31
+ prior: (config: ContractConfigBuilder) => ContractConfigBuilder;
32
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -13,6 +13,20 @@ declare function XcmPaymentApi(): {
13
13
  reserve?: AnyParachain;
14
14
  }) => FeeAmountConfigBuilder;
15
15
  };
16
+ declare function Wormhole(): {
17
+ /**
18
+ * Native gas an executor-delivered NTT transfer pays on top of itself -
19
+ * the wormhole delivery price plus what the Executor charges to redeem
20
+ * on the far side.
21
+ *
22
+ * Declared as the route's destination fee because an erc20 source pays it
23
+ * out of a balance the amount never competes for, so
24
+ * {@link EvmPlatform.estimateFee} deliberately leaves the call value out.
25
+ * A native gas source must NOT use this - there the value is already part
26
+ * of the source fee, and charging it twice inflates the route minimum.
27
+ */
28
+ quoteExecutorCost: () => FeeAmountConfigBuilder;
29
+ };
16
30
  declare function Basejump(): {
17
31
  quoteFee: () => FeeAmountConfigBuilder;
18
32
  };
@@ -20,5 +34,6 @@ export declare function FeeAmountBuilder(): {
20
34
  Basejump: typeof Basejump;
21
35
  XcmPaymentApi: typeof XcmPaymentApi;
22
36
  Snowbridge: typeof Snowbridge;
37
+ Wormhole: typeof Wormhole;
23
38
  };
24
39
  export {};
@@ -1,4 +1,6 @@
1
1
  import { ContractConfigBuilder } from '@galacticcouncil/xc-core';
2
2
  export declare const Ntt: () => {
3
3
  transfer: () => ContractConfigBuilder;
4
+ transferWithExecutor: () => ContractConfigBuilder;
5
+ transferViaExecutor: () => ContractConfigBuilder;
4
6
  };
@@ -1,5 +1,7 @@
1
1
  export declare function Wormhole(): {
2
2
  Ntt: () => {
3
3
  transfer: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
4
+ transferWithExecutor: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
5
+ transferViaExecutor: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
4
6
  };
5
7
  };
@@ -0,0 +1,27 @@
1
+ import { ExecutorBudget } from '../bridges/wormhole';
2
+ export type ExecutorQuote = {
3
+ /** Quoter-signed cost attestation, passed through to the shim. */
4
+ signedQuote: `0x${string}`;
5
+ /** What the Executor charges for delivery, in source chain native. */
6
+ estimatedCost: bigint;
7
+ /** Serialized delivery request the quote was priced for. */
8
+ relayInstructions: `0x${string}`;
9
+ };
10
+ /**
11
+ * Off-chain Executor quoting service.
12
+ *
13
+ * A signed quote carries its own expiry (an hour, currently) and the executor
14
+ * rejects a stale one, so quotes are reused only while comfortably live.
15
+ */
16
+ export declare class ExecutorClient {
17
+ /**
18
+ * Price the delivery of one NTT transfer.
19
+ *
20
+ * @param srcWormholeId - source chain wormhole id
21
+ * @param dstWormholeId - destination chain wormhole id
22
+ * @param budget - what the executor must reserve on the destination, from
23
+ * {@link executorBudget}. Both halves are keyed here: a quote is only
24
+ * honoured for the instructions it priced.
25
+ */
26
+ quote(srcWormholeId: number, dstWormholeId: number, budget: ExecutorBudget): Promise<ExecutorQuote>;
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  export * from './base';
2
2
  export * from './chain';
3
+ export * from './executor';
@@ -1,3 +1,9 @@
1
1
  import { Asset, AssetRoute } from '@galacticcouncil/xc-core';
2
2
  export declare function toHydrationViaNttTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
3
+ /**
4
+ * Executor-delivered variant, offered alongside the self-redeem route above
5
+ * for the same pair - the sender pays for delivery instead of signing a
6
+ * redeem on the destination. Cost is native gas on the source chain.
7
+ */
8
+ export declare function toHydrationViaNttExecutorTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
3
9
  export declare function toHydrationViaBasejumpTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
@@ -1,4 +1,22 @@
1
1
  import { Asset, AssetRoute } from '@galacticcouncil/xc-core';
2
2
  export declare function toHydrationViaNttTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
3
+ /**
4
+ * Executor-delivered variant, offered alongside the self-redeem route above
5
+ * for the same pair - the sender pays for delivery instead of signing a
6
+ * redeem on the destination.
7
+ *
8
+ * The cost is native gas on the source chain, declared as the destination fee
9
+ * because an erc20 source pays it from a balance the amount never competes
10
+ * for (which is why EvmPlatform.estimateFee leaves the call value out there).
11
+ */
12
+ export declare function toHydrationViaNttExecutorTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
13
+ /**
14
+ * Executor-delivered ntt out of a native gas source.
15
+ *
16
+ * The delivery price & executor cost come out of the very balance being
17
+ * bridged, so they are already folded into the source fee - declaring them
18
+ * as a destination fee too would charge the user twice.
19
+ */
20
+ export declare function toHydrationViaNttExecutorNativeTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
3
21
  export declare function toHydrationViaSnowbridgeTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
4
22
  export declare function toHydrationViaSnowbridgeV1Template(assetIn: Asset, assetOut: Asset): AssetRoute;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,5 +9,24 @@ export declare function toHubExtTemplate(asset: Asset): AssetRoute;
9
9
  export declare function toKusamaHubTemplate(asset: Asset, destFee: number, executionFee: number): AssetRoute;
10
10
  export declare function toParaErc20Template(asset: Asset, destination: AnyParachain, transferType?: XcmTransferType): AssetRoute;
11
11
  export declare function viaNttTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;
12
+ /**
13
+ * Executor-delivered variant, offered alongside the self-redeem route above
14
+ * for the same pair - the sender pays for delivery instead of signing a
15
+ * redeem on the destination.
16
+ *
17
+ * Cost is charged in weth, hydration's evm native gas - `EVM.call { value }`
18
+ * debits the weth balance (asset 20), not hdx - whether the transfer is signed
19
+ * as h160 or wrapped in EVM.call. Ntt still delivers the full amount.
20
+ *
21
+ * Must stay an 18 decimal asset: the builder returns a raw evm value, and hdx
22
+ * would both name the wrong balance and resolve to 12 decimals.
23
+ *
24
+ * A sender holding no weth buys it first: the same destination fee swap the
25
+ * xcm routes use, batched ahead of the call. Only an ss58 origin needs it -
26
+ * that one pays its extrinsic fee in hdx and can hold zero weth. An h160 has
27
+ * nothing to batch into, but pays its own gas in weth, so it already holds
28
+ * some.
29
+ */
30
+ export declare function viaNttExecutorTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;
12
31
  export declare function viaSnowbridgeTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;
13
32
  export declare function viaSnowbridgeV1Template(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;