@galacticcouncil/xc-cfg 1.2.0 → 1.3.0-pr297-5ef0efa
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/bridges/snowbridge/constants.d.ts +6 -0
- package/build/bridges/snowbridge/index.d.ts +2 -0
- package/build/bridges/snowbridge/volumeFee.d.ts +35 -0
- package/build/builders/ContractBuilder.d.ts +1 -1
- package/build/builders/ExtrinsicBuilder.d.ts +6 -0
- package/build/builders/FeeAmountBuilder.d.ts +5 -1
- 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 +93 -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/clients/base.d.ts +2 -1
- package/build/clients/chain/assethub.d.ts +8 -0
- package/build/configs/polkadot/hydration/templates.d.ts +3 -1
- package/build/index.cjs +1 -1
- package/build/index.mjs +1 -1
- package/build/tags.d.ts +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type SnowbridgeFast = boolean;
|
|
2
|
+
export declare const SNOWBRIDGE_BASE_DISPATCH_GAS = 80000n;
|
|
3
|
+
export declare const SNOWBRIDGE_BASE_VERIFICATION_GAS = 120000n;
|
|
4
|
+
export declare const SNOWBRIDGE_SUBMIT_GAS = 1000000n;
|
|
5
|
+
export declare const SNOWBRIDGE_FIAT_SHAMIR_GAS = 2000000n;
|
|
6
|
+
export declare const ASSETHUB_ETHER_ED = 15000000000000n;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Asset, Dex } from '@galacticcouncil/xc-core';
|
|
2
|
+
/**
|
|
3
|
+
* Snowbridge V2 volume-based relayer fee schedule.
|
|
4
|
+
* Direction:
|
|
5
|
+
* - Ethereum → Polkadot: add the result to `relayerFee` (5th arg of
|
|
6
|
+
* `v2_sendMessage`).
|
|
7
|
+
* - Polkadot → Ethereum: add the result to `etherFeeAmount`, which flows
|
|
8
|
+
* into the AH→Ethereum InitiateTransfer `remote_fees`.
|
|
9
|
+
*/
|
|
10
|
+
export type FeeBand = {
|
|
11
|
+
lowerUsd: bigint;
|
|
12
|
+
upperUsd: bigint;
|
|
13
|
+
numerator: bigint;
|
|
14
|
+
denominator: bigint;
|
|
15
|
+
};
|
|
16
|
+
export type VolumeFeeParams = {
|
|
17
|
+
txValueUsd: bigint;
|
|
18
|
+
ethToUsdNumerator: bigint;
|
|
19
|
+
ethToUsdDenominator: bigint;
|
|
20
|
+
};
|
|
21
|
+
export declare const FEE_SCHEDULE: FeeBand[];
|
|
22
|
+
export declare function lookupFeeRatio(txValueUsd: bigint): {
|
|
23
|
+
numerator: bigint;
|
|
24
|
+
denominator: bigint;
|
|
25
|
+
};
|
|
26
|
+
export declare function calculateVolumeTipInWei(params: VolumeFeeParams): bigint;
|
|
27
|
+
/**
|
|
28
|
+
* Compute the Snowbridge V2 volume tip for a transfer, sourcing all USD and
|
|
29
|
+
* ETH spot prices from the supplied Dex (typically Hydration's).
|
|
30
|
+
*
|
|
31
|
+
* Returns 0 when amount is missing or non-positive — the fee builder is
|
|
32
|
+
* called once at preview render with no amount, and we don't want to bill a
|
|
33
|
+
* tip for a phantom transfer.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getVolumeTipInWei(dex: Dex, transferAsset: Asset, transferAmount: bigint): Promise<bigint>;
|
|
@@ -11,7 +11,7 @@ export declare function ContractBuilder(): {
|
|
|
11
11
|
};
|
|
12
12
|
PolkadotXcm: typeof PolkadotXcm;
|
|
13
13
|
Snowbridge: () => {
|
|
14
|
-
|
|
14
|
+
v2SendMessage: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
|
|
15
15
|
};
|
|
16
16
|
Wormhole: typeof Wormhole;
|
|
17
17
|
};
|
|
@@ -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,5 @@
|
|
|
1
1
|
import { FeeAmountConfigBuilder, Parachain } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { SnowbridgeFast } from '../bridges/snowbridge';
|
|
2
3
|
declare function TokenRelayer(): {
|
|
3
4
|
calculateRelayerFee: () => FeeAmountConfigBuilder;
|
|
4
5
|
};
|
|
@@ -8,9 +9,12 @@ declare function Wormhole(): {
|
|
|
8
9
|
type SendFeeOpts = {
|
|
9
10
|
hub: Parachain;
|
|
10
11
|
};
|
|
12
|
+
type OutboundFeeOpts = SendFeeOpts & {
|
|
13
|
+
fast?: SnowbridgeFast;
|
|
14
|
+
};
|
|
11
15
|
declare function Snowbridge(): {
|
|
12
16
|
calculateInboundFee: (opts: SendFeeOpts) => FeeAmountConfigBuilder;
|
|
13
|
-
calculateOutboundFee: (opts:
|
|
17
|
+
calculateOutboundFee: (opts: OutboundFeeOpts) => FeeAmountConfigBuilder;
|
|
14
18
|
};
|
|
15
19
|
declare function XcmPaymentApi(): {
|
|
16
20
|
calculateDestFee: (opts?: {
|
|
@@ -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,93 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* Builds the complete XCM that AssetHub actually executes for a Snowbridge V2
|
|
27
|
+
* inbound transfer: BridgeHub's prelude (ReserveAssetDeposited + ExchangeAsset
|
|
28
|
+
* + PayFees) followed by the user XCM.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildSnowbridgeInboundDryRunXcm(ethChainId: number, destinationParaId: number): XcmV5Instruction[];
|
|
31
|
+
export type SnowbridgeInboundXcmParams = {
|
|
32
|
+
ethChainId: number;
|
|
33
|
+
destinationParaId: number;
|
|
34
|
+
tokenAddress: string;
|
|
35
|
+
beneficiaryHex: string;
|
|
36
|
+
tokenAmount: bigint;
|
|
37
|
+
hydrationDotFee: bigint;
|
|
38
|
+
topic: SizedHex<32>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Builds the XCM V5 program passed to `v2_sendMessage` for
|
|
42
|
+
* transferring ERC20/ETH from Ethereum to a Polkadot parachain.
|
|
43
|
+
*
|
|
44
|
+
* BridgeHub V2's inbound queue deposits ether + token into holding and
|
|
45
|
+
* pays for AH-side execution from its own prelude. We do NOT assume any
|
|
46
|
+
* DOT is left in holding for us — instead we explicitly swap leftover
|
|
47
|
+
* ether into the exact DOT amount needed for the destination's PayFees,
|
|
48
|
+
* then forward token + DOT downstream via InitiateTransfer.
|
|
49
|
+
*
|
|
50
|
+
* Flow:
|
|
51
|
+
* 1. SetAppendix — refund + deposit-to-beneficiary on error
|
|
52
|
+
* 2. ExchangeAsset — swap leftover ether → hydrationDotFee DOT
|
|
53
|
+
* 3. InitiateTransfer to destination parachain
|
|
54
|
+
* - remote_fees: ReserveDeposit(DOT) sized for destination PayFees
|
|
55
|
+
* - assets: ReserveDeposit(token) for the actual transfer
|
|
56
|
+
* - remote_xcm: RefundSurplus + DepositAsset to beneficiary
|
|
57
|
+
* 4. RefundSurplus + DepositAsset — sweep leftover assets to beneficiary on AH
|
|
58
|
+
* 5. SetTopic for tracking
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildSnowbridgeInboundXcm(params: SnowbridgeInboundXcmParams): XcmV5Instruction[];
|
|
61
|
+
export type SnowbridgeOutboundXcmParams = {
|
|
62
|
+
tokenAddress: string;
|
|
63
|
+
senderPubKey: string;
|
|
64
|
+
beneficiaryHex: string;
|
|
65
|
+
tokenAmount: bigint;
|
|
66
|
+
sourceExecutionFee: bigint;
|
|
67
|
+
dotRemoteFee: bigint;
|
|
68
|
+
dotToEtherSwapAmount: bigint;
|
|
69
|
+
etherFeeAmount: bigint;
|
|
70
|
+
topic: SizedHex<32>;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Builds the V5 XCM program for `polkadotXcm.execute` to transfer
|
|
74
|
+
* ERC20/ETH from a Polkadot parachain to Ethereum via Snowbridge V2.
|
|
75
|
+
*
|
|
76
|
+
* 3-leg program:
|
|
77
|
+
*
|
|
78
|
+
* Leg 1 — Source parachain:
|
|
79
|
+
* WithdrawAsset, PayFees, SetAppendix (error recovery), InitiateTransfer → AssetHub
|
|
80
|
+
*
|
|
81
|
+
* Leg 2 — AssetHub (remote_xcm):
|
|
82
|
+
* SetAppendix (error recovery), ExchangeAsset (DOT→Ether), InitiateTransfer → Ethereum
|
|
83
|
+
*
|
|
84
|
+
* Leg 3 — Ethereum (innermost remote_xcm):
|
|
85
|
+
* DepositAsset to beneficiary, SetTopic
|
|
86
|
+
*/
|
|
87
|
+
export declare function buildSnowbridgeOutboundXcm(params: SnowbridgeOutboundXcmParams): XcmV5Instruction[];
|
|
88
|
+
export declare function snowbridgeOutboundMessage(params: ExtrinsicConfigBuilderParams): {
|
|
89
|
+
type: "V5";
|
|
90
|
+
value: XcmV5Instruction[];
|
|
91
|
+
} & {
|
|
92
|
+
type: "V5";
|
|
93
|
+
};
|
|
@@ -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;
|
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 {};
|
|
@@ -10,4 +10,6 @@ export declare function toHubExtTemplate(asset: Asset): AssetRoute;
|
|
|
10
10
|
export declare function toParaErc20Template(asset: Asset, destination: Parachain, transferType?: XcmTransferType): AssetRoute;
|
|
11
11
|
export declare function toMoonbeamErc20Template(asset: Asset): AssetRoute;
|
|
12
12
|
export declare function viaWormholeBridgeTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;
|
|
13
|
-
export declare function viaSnowbridgeTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain
|
|
13
|
+
export declare function viaSnowbridgeTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain, opts?: {
|
|
14
|
+
fast?: boolean;
|
|
15
|
+
}): AssetRoute;
|