@galacticcouncil/xc-cfg 1.1.0 → 1.2.0-pr320-715f299
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/build/builders/ContractBuilder.d.ts +3 -1
- package/build/builders/ExtrinsicBuilder.d.ts +6 -0
- package/build/builders/FeeAmountBuilder.d.ts +23 -1
- package/build/builders/contracts/Across/Snowbridge.d.ts +5 -0
- package/build/builders/contracts/Across/Snowbridge.spec.d.ts +1 -0
- package/build/builders/contracts/Across/index.d.ts +6 -0
- package/build/builders/contracts/Across/swap.d.ts +42 -0
- package/build/builders/contracts/snowbridge/codec.d.ts +8 -0
- package/build/builders/contracts/{Snowbridge.d.ts → snowbridge/index.d.ts} +1 -1
- package/build/builders/extrinsics/xcm/builder/Snowbridge.d.ts +86 -0
- package/build/builders/extrinsics/xcm/builder/buildParaERC20ReceivedV5.d.ts +16 -0
- package/build/builders/extrinsics/xcm/builder/index.d.ts +2 -0
- package/build/builders/extrinsics/xcm/polkadotXcm.d.ts +7 -1
- package/build/chains/evm/arbitrum.d.ts +2 -0
- package/build/chains/evm/index.d.ts +3 -1
- package/build/chains/evm/optimism.d.ts +2 -0
- package/build/clients/base.d.ts +2 -1
- package/build/clients/chain/assethub.d.ts +8 -0
- package/build/configs/evm/base/templates.d.ts +18 -0
- package/build/index.cjs +1 -1
- package/build/index.mjs +1 -1
- package/build/tags.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Across } from './contracts/Across';
|
|
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(): {
|
|
6
|
+
Across: typeof Across;
|
|
5
7
|
Batch: () => {
|
|
6
8
|
batchAll: (configs: import("@galacticcouncil/xc-core").ContractConfigBuilder[]) => import("@galacticcouncil/xc-core").ContractConfigBuilder;
|
|
7
9
|
};
|
|
@@ -11,7 +13,7 @@ export declare function ContractBuilder(): {
|
|
|
11
13
|
};
|
|
12
14
|
PolkadotXcm: typeof PolkadotXcm;
|
|
13
15
|
Snowbridge: () => {
|
|
14
|
-
|
|
16
|
+
v2SendMessage: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
|
|
15
17
|
};
|
|
16
18
|
Wormhole: typeof Wormhole;
|
|
17
19
|
};
|
|
@@ -22,6 +22,12 @@ export declare function ExtrinsicBuilder(): {
|
|
|
22
22
|
transferAssetsUsingTypeAndThen: (opts: {
|
|
23
23
|
transferType: import(".").XcmTransferType;
|
|
24
24
|
}) => ExtrinsicConfigBuilder;
|
|
25
|
+
execute: {
|
|
26
|
+
(messageBuilder: import("./extrinsics/xcm/polkadotXcm").XcmMessageBuilder): ExtrinsicConfigBuilder;
|
|
27
|
+
(): {
|
|
28
|
+
viaSnowbridge: () => ExtrinsicConfigBuilder;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
25
31
|
send: () => {
|
|
26
32
|
transact: (opts: {
|
|
27
33
|
fee: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeeAmountConfigBuilder, Parachain } from '@galacticcouncil/xc-core';
|
|
1
|
+
import { EvmChain, FeeAmountConfigBuilder, Parachain } from '@galacticcouncil/xc-core';
|
|
2
2
|
declare function TokenRelayer(): {
|
|
3
3
|
calculateRelayerFee: () => FeeAmountConfigBuilder;
|
|
4
4
|
};
|
|
@@ -20,7 +20,29 @@ declare function XcmPaymentApi(): {
|
|
|
20
20
|
declare function Basejump(): {
|
|
21
21
|
quoteFee: () => FeeAmountConfigBuilder;
|
|
22
22
|
};
|
|
23
|
+
type AcrossSnowbridgeFeeOpts = {
|
|
24
|
+
hub: Parachain;
|
|
25
|
+
ethereum: EvmChain;
|
|
26
|
+
};
|
|
27
|
+
declare function AcrossSnowbridge(): {
|
|
28
|
+
/**
|
|
29
|
+
* Across-Snowbridge inbound fee composer.
|
|
30
|
+
*
|
|
31
|
+
* Reuses `Snowbridge().calculateInboundFee()` for the Snowbridge V2 fees
|
|
32
|
+
* (executionFee, relayerFee, remoteEtherFee, remoteDotFee) which are
|
|
33
|
+
* amount-independent, then adds:
|
|
34
|
+
* - `swapInputAmount`: how much of the L2 token the Uniswap V3 multicall
|
|
35
|
+
* must consume to obtain `executionFee + relayerFee` ETH on Ethereum.
|
|
36
|
+
* Padded by 33% for AMM slippage, matching Snowfork.
|
|
37
|
+
*
|
|
38
|
+
* The amount-dependent `acrossRelayerFee` is computed at build time by
|
|
39
|
+
* the contract builder (`Across/Snowbridge.sendTokenAndCall`) because
|
|
40
|
+
* the FeeAmountConfigParams shape does not carry the transfer amount.
|
|
41
|
+
*/
|
|
42
|
+
calculateFee: (opts: AcrossSnowbridgeFeeOpts) => FeeAmountConfigBuilder;
|
|
43
|
+
};
|
|
23
44
|
export declare function FeeAmountBuilder(): {
|
|
45
|
+
AcrossSnowbridge: typeof AcrossSnowbridge;
|
|
24
46
|
Basejump: typeof Basejump;
|
|
25
47
|
XcmPaymentApi: typeof XcmPaymentApi;
|
|
26
48
|
Snowbridge: typeof Snowbridge;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-asset swap config consumed by the Across-Snowbridge L2 adaptor multicall
|
|
3
|
+
* on Ethereum: maps a source-L2 ERC20 address to its Ethereum canonical token
|
|
4
|
+
* and the Uniswap V3 pool fee tier used to swap a portion into WETH for the
|
|
5
|
+
* Snowbridge `v2_sendMessage` ether fee.
|
|
6
|
+
*
|
|
7
|
+
* Keyed by L2 chain id + lowercase L2 token address. Extend as routes land.
|
|
8
|
+
* Mirrors the Snowfork registry's `assets[l2Token].swapTokenAddress`/`swapFee`.
|
|
9
|
+
*/
|
|
10
|
+
export type SwapAssetEntry = {
|
|
11
|
+
swapTokenAddress: `0x${string}`;
|
|
12
|
+
swapFee: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function getSwapEntry(l2ChainId: number, l2TokenAddress: string): SwapAssetEntry | undefined;
|
|
15
|
+
export type SwapCallDataParams = {
|
|
16
|
+
router: `0x${string}`;
|
|
17
|
+
tokenIn: `0x${string}`;
|
|
18
|
+
tokenOut: `0x${string}`;
|
|
19
|
+
swapFee: number;
|
|
20
|
+
recipient: `0x${string}`;
|
|
21
|
+
amountOut: bigint;
|
|
22
|
+
amountInMaximum: bigint;
|
|
23
|
+
deadlineSeconds?: number;
|
|
24
|
+
};
|
|
25
|
+
export type AcrossSuggestedFeeParams = {
|
|
26
|
+
inputToken: string;
|
|
27
|
+
outputToken: string;
|
|
28
|
+
originChainId: number;
|
|
29
|
+
destinationChainId: number;
|
|
30
|
+
amount: bigint;
|
|
31
|
+
apiBaseUrl?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Queries Across `/suggested-fees` for the relayer fee at a given input
|
|
35
|
+
* amount. Across relayer fee scales with amount; this is called at contract
|
|
36
|
+
* build time (where amount is known), not at fee-quote time.
|
|
37
|
+
*
|
|
38
|
+
* Returns 0n on any failure so the deposit can still be built; the relayer
|
|
39
|
+
* may then simply not fill at zero fee — slow fill recovers the user funds.
|
|
40
|
+
*/
|
|
41
|
+
export declare function fetchAcrossRelayerFee(params: AcrossSuggestedFeeParams): Promise<bigint>;
|
|
42
|
+
export declare function buildAcrossSnowbridgeSwapCallData(params: SwapCallDataParams): `0x${string}`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Codec } from 'polkadot-api';
|
|
2
|
+
import { XcmVersionedXcm, XcmVersionedLocation } from '@galacticcouncil/descriptors';
|
|
3
|
+
interface XcmCodecs {
|
|
4
|
+
message: Codec<XcmVersionedXcm>;
|
|
5
|
+
location: Codec<XcmVersionedLocation>;
|
|
6
|
+
}
|
|
7
|
+
export declare function getXcmCodecs(): Promise<XcmCodecs>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ExtrinsicConfigBuilderParams } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { XcmV5Instruction, XcmV5Junction } from '@galacticcouncil/descriptors';
|
|
3
|
+
import { SizedHex } from 'polkadot-api';
|
|
4
|
+
/**
|
|
5
|
+
* Location helpers for Snowbridge V2 XCM
|
|
6
|
+
*/
|
|
7
|
+
export declare const etherLocation: (ethChainId: number) => {
|
|
8
|
+
parents: number;
|
|
9
|
+
interior: {
|
|
10
|
+
type: "X1";
|
|
11
|
+
value: XcmV5Junction;
|
|
12
|
+
} & {
|
|
13
|
+
type: "X1";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const erc20Location: (ethChainId: number, tokenAddress: string) => {
|
|
17
|
+
parents: number;
|
|
18
|
+
interior: {
|
|
19
|
+
type: "X2";
|
|
20
|
+
value: import("polkadot-api").FixedSizeArray<2, XcmV5Junction>;
|
|
21
|
+
} & {
|
|
22
|
+
type: "X2";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type SnowbridgeInboundXcmParams = {
|
|
26
|
+
ethChainId: number;
|
|
27
|
+
destinationParaId: number;
|
|
28
|
+
tokenAddress: string;
|
|
29
|
+
beneficiaryHex: string;
|
|
30
|
+
tokenAmount: bigint;
|
|
31
|
+
remoteEtherFeeAmount: bigint;
|
|
32
|
+
remoteDotFeeAmount?: bigint;
|
|
33
|
+
topic: SizedHex<32>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Builds the XCM V5 program passed to `v2_sendMessage` for
|
|
37
|
+
* transferring ERC20/ETH from Ethereum to a Polkadot parachain.
|
|
38
|
+
*
|
|
39
|
+
* If `remoteDotFeeAmount` is provided, an ExchangeAsset instruction
|
|
40
|
+
* is prepended to swap Ether for DOT on AssetHub (for parachains
|
|
41
|
+
* that require DOT as the fee asset).
|
|
42
|
+
*
|
|
43
|
+
* Flow:
|
|
44
|
+
* 1. (Optional) ExchangeAsset: swap Ether for DOT on AssetHub
|
|
45
|
+
* 2. InitiateTransfer to destination parachain
|
|
46
|
+
* - remote_fees: ReserveDeposit(ether or DOT) for destination execution
|
|
47
|
+
* - assets: ReserveDeposit(token) for the actual transfer
|
|
48
|
+
* - remote_xcm: RefundSurplus + DepositAsset to beneficiary
|
|
49
|
+
* 3. RefundSurplus (reclaim unused ether on Asset Hub)
|
|
50
|
+
* 4. DepositAsset remaining ether to beneficiary on Asset Hub
|
|
51
|
+
* 5. SetTopic for tracking
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildSnowbridgeInboundXcm(params: SnowbridgeInboundXcmParams): XcmV5Instruction[];
|
|
54
|
+
export type SnowbridgeOutboundXcmParams = {
|
|
55
|
+
tokenAddress: string;
|
|
56
|
+
senderPubKey: string;
|
|
57
|
+
beneficiaryHex: string;
|
|
58
|
+
tokenAmount: bigint;
|
|
59
|
+
sourceExecutionFee: bigint;
|
|
60
|
+
dotRemoteFee: bigint;
|
|
61
|
+
dotToEtherSwapAmount: bigint;
|
|
62
|
+
etherFeeAmount: bigint;
|
|
63
|
+
topic: SizedHex<32>;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Builds the V5 XCM program for `polkadotXcm.execute` to transfer
|
|
67
|
+
* ERC20/ETH from a Polkadot parachain to Ethereum via Snowbridge V2.
|
|
68
|
+
*
|
|
69
|
+
* 3-leg program:
|
|
70
|
+
*
|
|
71
|
+
* Leg 1 — Source parachain:
|
|
72
|
+
* WithdrawAsset, PayFees, SetAppendix (error recovery), InitiateTransfer → AssetHub
|
|
73
|
+
*
|
|
74
|
+
* Leg 2 — AssetHub (remote_xcm):
|
|
75
|
+
* SetAppendix (error recovery), ExchangeAsset (DOT→Ether), InitiateTransfer → Ethereum
|
|
76
|
+
*
|
|
77
|
+
* Leg 3 — Ethereum (innermost remote_xcm):
|
|
78
|
+
* DepositAsset to beneficiary, SetTopic
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildSnowbridgeOutboundXcm(params: SnowbridgeOutboundXcmParams): XcmV5Instruction[];
|
|
81
|
+
export declare function snowbridgeOutboundMessage(params: ExtrinsicConfigBuilderParams): {
|
|
82
|
+
type: "V5";
|
|
83
|
+
value: XcmV5Instruction[];
|
|
84
|
+
} & {
|
|
85
|
+
type: "V5";
|
|
86
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XcmV5Instruction } from '@galacticcouncil/descriptors';
|
|
2
|
+
import { Asset, Parachain } from '@galacticcouncil/xc-core';
|
|
3
|
+
/**
|
|
4
|
+
* Builds the V5 XCM program that InitiateTransfer generates on the
|
|
5
|
+
* destination parachain (e.g. Hydration). Used for weight/fee estimation.
|
|
6
|
+
*
|
|
7
|
+
* This matches what actually executes on the destination:
|
|
8
|
+
* 1. ReserveAssetDeposited(DOT)
|
|
9
|
+
* 2. PayFees(DOT)
|
|
10
|
+
* 3. ReserveAssetDeposited(token)
|
|
11
|
+
* 4. ClearOrigin
|
|
12
|
+
* 5. RefundSurplus
|
|
13
|
+
* 6. DepositAsset
|
|
14
|
+
* 7. SetTopic
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildParaERC20ReceivedV5(asset: Asset, chain: Parachain): XcmV5Instruction[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExtrinsicConfigBuilder } from '@galacticcouncil/xc-core';
|
|
1
|
+
import { ExtrinsicConfigBuilder, ExtrinsicConfigBuilderParams } from '@galacticcouncil/xc-core';
|
|
2
|
+
export type XcmMessageBuilder = (params: ExtrinsicConfigBuilderParams) => any;
|
|
2
3
|
import { XcmTransferType } from './types';
|
|
3
4
|
type TransferOpts = {
|
|
4
5
|
transferType: XcmTransferType;
|
|
@@ -6,12 +7,17 @@ type TransferOpts = {
|
|
|
6
7
|
type TransactOpts = {
|
|
7
8
|
fee: number;
|
|
8
9
|
};
|
|
10
|
+
declare function execute(messageBuilder: XcmMessageBuilder): ExtrinsicConfigBuilder;
|
|
11
|
+
declare function execute(): {
|
|
12
|
+
viaSnowbridge: () => ExtrinsicConfigBuilder;
|
|
13
|
+
};
|
|
9
14
|
export declare const polkadotXcm: () => {
|
|
10
15
|
limitedReserveTransferAssets: () => ExtrinsicConfigBuilder;
|
|
11
16
|
limitedTeleportAssets: () => ExtrinsicConfigBuilder;
|
|
12
17
|
reserveTransferAssets: () => ExtrinsicConfigBuilder;
|
|
13
18
|
transferAssets: () => ExtrinsicConfigBuilder;
|
|
14
19
|
transferAssetsUsingTypeAndThen: (opts: TransferOpts) => ExtrinsicConfigBuilder;
|
|
20
|
+
execute: typeof execute;
|
|
15
21
|
send: () => {
|
|
16
22
|
transact: (opts: TransactOpts) => ExtrinsicConfigBuilder;
|
|
17
23
|
transferAsset: (opts: TransactOpts) => ExtrinsicConfigBuilder;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AnyChain } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { arbitrum } from './arbitrum';
|
|
2
3
|
import { base } from './base';
|
|
3
4
|
import { ethereum } from './mainnet';
|
|
5
|
+
import { optimism } from './optimism';
|
|
4
6
|
export declare const evmChains: AnyChain[];
|
|
5
|
-
export { base, ethereum };
|
|
7
|
+
export { arbitrum, base, ethereum, optimism };
|
package/build/clients/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChainDefinition, TypedApi } from 'polkadot-api';
|
|
2
2
|
import { Asset, Parachain } from '@galacticcouncil/xc-core';
|
|
3
|
-
import { hub, XcmV4Instruction } from '@galacticcouncil/descriptors';
|
|
3
|
+
import { hub, XcmV4Instruction, XcmV5Instruction } from '@galacticcouncil/descriptors';
|
|
4
4
|
export declare class BaseClient<C extends ChainDefinition = typeof hub> {
|
|
5
5
|
readonly chain: Parachain;
|
|
6
6
|
protected descriptor: C;
|
|
@@ -10,4 +10,5 @@ export declare class BaseClient<C extends ChainDefinition = typeof hub> {
|
|
|
10
10
|
private get refApi();
|
|
11
11
|
getSystemAccountBalance(address: string): Promise<bigint>;
|
|
12
12
|
calculateDestinationFee(xcm: XcmV4Instruction[], asset: Asset): Promise<bigint>;
|
|
13
|
+
calculateDestinationFeeV5(xcm: XcmV5Instruction[], asset: Asset): Promise<bigint>;
|
|
13
14
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Asset, Parachain } from '@galacticcouncil/xc-core';
|
|
2
2
|
import { XcmV4Instruction, Hub } from '@galacticcouncil/descriptors';
|
|
3
|
+
type AssetLocation = {
|
|
4
|
+
parents: number;
|
|
5
|
+
interior: any;
|
|
6
|
+
};
|
|
3
7
|
import { BaseClient } from '../base';
|
|
4
8
|
export declare class AssethubClient extends BaseClient<Hub> {
|
|
5
9
|
constructor(chain: Parachain);
|
|
@@ -10,4 +14,8 @@ export declare class AssethubClient extends BaseClient<Hub> {
|
|
|
10
14
|
defaultFee: bigint;
|
|
11
15
|
}): Promise<bigint>;
|
|
12
16
|
calculateDeliveryFee(xcm: XcmV4Instruction[], destParachainId: number): Promise<bigint>;
|
|
17
|
+
quoteDotToEther(etherLocation: AssetLocation, dotAmount: bigint): Promise<bigint>;
|
|
18
|
+
quoteEtherForDot(etherLocation: AssetLocation, dotAmount: bigint): Promise<bigint>;
|
|
19
|
+
quoteDotForExactEther(etherLocation: AssetLocation, etherAmount: bigint): Promise<bigint>;
|
|
13
20
|
}
|
|
21
|
+
export {};
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
import { Asset, AssetRoute } from '@galacticcouncil/xc-core';
|
|
2
2
|
export declare function toHydrationViaWormholeTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
|
|
3
3
|
export declare function toHydrationViaBasejumpTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
|
|
4
|
+
/**
|
|
5
|
+
* Across V3 fast-fill on Ethereum → Snowbridge V2 inbound to AssetHub →
|
|
6
|
+
* XCM InitiateTransfer to Hydration. End-to-end via Snowfork's deployed
|
|
7
|
+
* `SnowbridgeL2Adaptor` on Base (0x07fe4e7340976fc873b74bafe3c3e5b0e01f3665).
|
|
8
|
+
*
|
|
9
|
+
* Phase 0 — fee uses the existing Snowbridge inbound fee builder. A proper
|
|
10
|
+
* Across-aware fee builder that adds the Across relayer fee (via
|
|
11
|
+
* `@snowbridge/api/across.estimateFees`) lands with the XCM construction
|
|
12
|
+
* follow-up referenced in `xc-cfg/builders/contracts/Across/Snowbridge.ts`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toHydrationViaAcrossSnowbridgeTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
|
|
15
|
+
/**
|
|
16
|
+
* Across V3 ETH/WETH path: identical to the ERC20 template but uses the
|
|
17
|
+
* L2 adaptor's `sendEtherAndCall` entrypoint — no Uniswap swap leg needed
|
|
18
|
+
* because the multicall on Ethereum unwraps WETH directly to fund the
|
|
19
|
+
* Snowbridge inbound fee.
|
|
20
|
+
*/
|
|
21
|
+
export declare function toHydrationViaAcrossSnowbridgeEtherTemplate(assetIn: Asset, assetOut: Asset): AssetRoute;
|