@gibs/bridge-sdk 1.10.1 → 1.13.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/LICENSE +15 -0
- package/README.md +234 -432
- package/dist/abis.d.ts +1 -0
- package/dist/abis.js +3 -0
- package/dist/bridge-limits.d.ts +103 -0
- package/dist/bridge-limits.js +84 -0
- package/dist/{src/chain-info.d.ts → chain-info.d.ts} +66 -27
- package/dist/{src/chain-info.js → chain-info.js} +106 -46
- package/dist/chain-names.d.ts +160 -0
- package/dist/chain-names.js +200 -0
- package/dist/chains.d.ts +65 -0
- package/dist/chains.js +284 -0
- package/dist/config.d.ts +216 -0
- package/dist/{src/config.js → config.js} +151 -44
- package/dist/consolidated-quote.d.ts +554 -0
- package/dist/consolidated-quote.js +773 -0
- package/dist/destination-calldata.d.ts +118 -0
- package/dist/destination-calldata.js +152 -0
- package/dist/ecosystems.d.ts +217 -0
- package/dist/ecosystems.js +288 -0
- package/dist/hyperliquid-execution.d.ts +152 -0
- package/dist/hyperliquid-execution.js +168 -0
- package/dist/image-links.d.ts +117 -0
- package/dist/image-links.js +142 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/lifi-execution-guard.d.ts +199 -0
- package/dist/lifi-execution-guard.js +400 -0
- package/dist/near-intents-conformance.d.ts +85 -0
- package/dist/near-intents-conformance.js +329 -0
- package/dist/near-intents-route.d.ts +47 -0
- package/dist/near-intents-route.js +265 -0
- package/dist/near-intents.d.ts +524 -0
- package/dist/near-intents.js +1055 -0
- package/dist/origin-deposit.d.ts +326 -0
- package/dist/origin-deposit.js +68 -0
- package/dist/pre-quote.d.ts +198 -0
- package/dist/pre-quote.js +175 -0
- package/dist/prices.d.ts +107 -0
- package/dist/prices.js +162 -0
- package/dist/providers.d.ts +221 -0
- package/dist/providers.js +157 -0
- package/dist/quote-fees.d.ts +102 -0
- package/dist/quote-fees.js +195 -0
- package/dist/referral.d.ts +77 -0
- package/dist/referral.js +72 -0
- package/dist/relay-currencies.d.ts +47 -0
- package/dist/relay-currencies.js +89 -0
- package/dist/relay-quote.d.ts +301 -0
- package/dist/relay-quote.js +983 -0
- package/dist/route-steps.d.ts +138 -0
- package/dist/route-steps.js +305 -0
- package/dist/routing/amounts.d.ts +80 -0
- package/dist/routing/amounts.js +120 -0
- package/dist/routing/candidate-route.d.ts +43 -0
- package/dist/routing/candidate-route.js +45 -0
- package/dist/routing/candidate.d.ts +237 -0
- package/dist/routing/candidate.js +96 -0
- package/dist/routing/carriers/ask-answer.d.ts +58 -0
- package/dist/routing/carriers/omnibridge.d.ts +137 -0
- package/dist/routing/carriers/omnibridge.js +419 -0
- package/dist/routing/carriers/pulsex.d.ts +111 -0
- package/dist/routing/carriers/pulsex.js +404 -0
- package/dist/routing/carriers/wrap.d.ts +25 -0
- package/dist/routing/carriers/wrap.js +115 -0
- package/dist/routing/composed-route-quality.d.ts +103 -0
- package/dist/routing/composed-route-quality.js +108 -0
- package/dist/routing/entry-chain-anchor.d.ts +88 -0
- package/dist/routing/entry-chain-anchor.js +55 -0
- package/dist/routing/format.d.ts +31 -0
- package/dist/routing/format.js +58 -0
- package/dist/routing/index.d.ts +34 -0
- package/dist/routing/index.js +42 -0
- package/dist/routing/producers.d.ts +770 -0
- package/dist/routing/producers.js +1564 -0
- package/dist/routing/providers.d.ts +26 -0
- package/dist/routing/providers.js +38 -0
- package/dist/routing/route-data.d.ts +355 -0
- package/dist/routing/route-data.js +1 -0
- package/dist/routing/search/compose.d.ts +168 -0
- package/dist/routing/search/compose.js +98 -0
- package/dist/routing/search/graph.d.ts +639 -0
- package/dist/routing/search/graph.js +445 -0
- package/dist/routing/search/plan-route-data.d.ts +244 -0
- package/dist/routing/search/plan-route-data.js +767 -0
- package/dist/routing/search/score.d.ts +324 -0
- package/dist/routing/search/score.js +400 -0
- package/dist/routing/usd-value.d.ts +17 -0
- package/dist/routing/usd-value.js +25 -0
- package/dist/settings.d.ts +692 -0
- package/dist/{src/settings.js → settings.js} +338 -71
- package/dist/ton-execution.d.ts +117 -0
- package/dist/ton-execution.js +247 -0
- package/dist/tron-execution.d.ts +146 -0
- package/dist/tron-execution.js +239 -0
- package/dist/{src/types.d.ts → types.d.ts} +8 -1
- package/dist/types.js +1 -0
- package/package.json +210 -23
- package/dist/src/abis.d.ts +0 -384
- package/dist/src/abis.js +0 -68
- package/dist/src/chains.d.ts +0 -6
- package/dist/src/chains.js +0 -86
- package/dist/src/config.d.ts +0 -136
- package/dist/src/image-links.d.ts +0 -41
- package/dist/src/image-links.js +0 -45
- package/dist/src/index.d.ts +0 -8
- package/dist/src/index.js +0 -8
- package/dist/src/settings.d.ts +0 -357
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/abis.ts +0 -70
- package/src/chain-info.ts +0 -464
- package/src/chains.ts +0 -88
- package/src/config.ts +0 -480
- package/src/fee-type.ts +0 -14
- package/src/image-links.ts +0 -61
- package/src/index.ts +0 -8
- package/src/settings.ts +0 -898
- package/src/types.ts +0 -48
- package/tsconfig.json +0 -16
- /package/dist/{src/fee-type.d.ts → fee-type.d.ts} +0 -0
- /package/dist/{src/fee-type.js → fee-type.js} +0 -0
- /package/dist/{src/types.js → routing/carriers/ask-answer.js} +0 -0
package/dist/src/chains.d.ts
DELETED
package/dist/src/chains.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { mainnet, pulsechain, bsc, sepolia, pulsechainV4 } from '@reown/appkit/networks';
|
|
2
|
-
import { Chains } from '@gibs/bridge-sdk/config';
|
|
3
|
-
import * as imageLinks from '@gibs/bridge-sdk/image-links';
|
|
4
|
-
/**
|
|
5
|
-
* all of the chains that are enabled in this dapp
|
|
6
|
-
* and their corresponding useful metadata
|
|
7
|
-
*/
|
|
8
|
-
export const chainsMetadata = {
|
|
9
|
-
[Chains.PLS]: {
|
|
10
|
-
...pulsechain,
|
|
11
|
-
chainId: Chains.PLS,
|
|
12
|
-
logoURI: imageLinks.network(pulsechain.id),
|
|
13
|
-
alt: 'a pink blue and purple hexagon with an ekg line running horizontally',
|
|
14
|
-
rpcUrls: {
|
|
15
|
-
default: {
|
|
16
|
-
http: ['https://rpc.pulsechain.com'],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
contracts: {
|
|
20
|
-
...pulsechain.contracts,
|
|
21
|
-
ensRegistry: {
|
|
22
|
-
address: '0xbd5133993FCDED5945c5539D9f032261F0d13170',
|
|
23
|
-
},
|
|
24
|
-
ensUniversalResolver: {
|
|
25
|
-
address: '0x2FDBb906b4FE68e31D928C1ED0b6a3bD1f204374',
|
|
26
|
-
blockCreated: 19_400_610,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
[Chains.ETH]: {
|
|
31
|
-
...mainnet,
|
|
32
|
-
chainId: Chains.ETH,
|
|
33
|
-
logoURI: imageLinks.network(mainnet.id),
|
|
34
|
-
alt: 'two pyramids joined on one side',
|
|
35
|
-
rpcUrls: {
|
|
36
|
-
default: {
|
|
37
|
-
http: ['https://rpc-ethereum.g4mm4.io'],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
[Chains.BNB]: {
|
|
42
|
-
...bsc,
|
|
43
|
-
name: 'Binance Smart Chain',
|
|
44
|
-
chainId: Chains.BNB,
|
|
45
|
-
logoURI: imageLinks.network(bsc.id),
|
|
46
|
-
alt: 'a gold cube with slits in the middle of each side',
|
|
47
|
-
rpcUrls: {
|
|
48
|
-
default: {
|
|
49
|
-
http: ['https://bsc-rpc.publicnode.com'],
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
[Chains.SEP]: {
|
|
54
|
-
...sepolia,
|
|
55
|
-
name: 'Sepolia',
|
|
56
|
-
chainId: Chains.SEP,
|
|
57
|
-
logoURI: imageLinks.network(sepolia.id),
|
|
58
|
-
alt: 'two pyramids joined on one side',
|
|
59
|
-
rpcUrls: {
|
|
60
|
-
default: {
|
|
61
|
-
http: ['https://ethereum-sepolia-rpc.publicnode.com'],
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
[Chains.V4PLS]: {
|
|
66
|
-
...pulsechainV4,
|
|
67
|
-
name: 'Pulsechain V4',
|
|
68
|
-
chainId: Chains.V4PLS,
|
|
69
|
-
logoURI: imageLinks.network(pulsechainV4.id),
|
|
70
|
-
alt: 'a pink blue and purple hexagon with an ekg line running horizontally',
|
|
71
|
-
rpcUrls: {
|
|
72
|
-
default: {
|
|
73
|
-
http: ['https://rpc-testnet-pulsechain.g4mm4.io'],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
contracts: {
|
|
77
|
-
...pulsechainV4.contracts,
|
|
78
|
-
ensRegistry: {
|
|
79
|
-
address: '0xaDB38309aF7F85034FDC35bd6E6B45d1216CfB56',
|
|
80
|
-
},
|
|
81
|
-
ensUniversalResolver: {
|
|
82
|
-
address: '0xDDFde3fA938dE0cdff82645579d03Ed750DE2e69',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
package/dist/src/config.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { type Hex } from "viem";
|
|
2
|
-
import type { BridgeKey, Token, TokenOut } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Add here your chain id as hex, be sure to add your chain in the chainsMetadata object too
|
|
5
|
-
*/
|
|
6
|
-
export declare enum Chains {
|
|
7
|
-
PLS = "0x171",
|
|
8
|
-
ETH = "0x1",
|
|
9
|
-
BNB = "0x38",
|
|
10
|
-
SEP = "0xaa36a7",
|
|
11
|
-
V4PLS = "0x3af"
|
|
12
|
-
}
|
|
13
|
-
/** The key of a chain - human readable for query params */
|
|
14
|
-
export type ChainKey = keyof typeof Chains;
|
|
15
|
-
/** A map of chain ids to chain keys */
|
|
16
|
-
export declare const chainIdToKey: Map<Chains, "ETH" | "PLS" | "BNB" | "SEP" | "V4PLS">;
|
|
17
|
-
/**
|
|
18
|
-
* Converts a chain id to a chain key
|
|
19
|
-
* @param chainId - the chain id
|
|
20
|
-
* @returns the chain key
|
|
21
|
-
*/
|
|
22
|
-
export declare const toChain: (chainId: number | string) => Chains;
|
|
23
|
-
/**
|
|
24
|
-
* Converts a chain id to a chain key
|
|
25
|
-
* @param chainId - the chain id
|
|
26
|
-
* @returns the chain key
|
|
27
|
-
*/
|
|
28
|
-
export declare const toChainKey: (chainId: number | string) => "ETH" | "PLS" | "BNB" | "SEP" | "V4PLS" | undefined;
|
|
29
|
-
export declare const Providers: {
|
|
30
|
-
readonly PULSECHAIN: "pulsechain";
|
|
31
|
-
readonly TOKENSEX: "tokensex";
|
|
32
|
-
};
|
|
33
|
-
export type Provider = typeof Providers[keyof typeof Providers];
|
|
34
|
-
/** A map of chains to native asset out addresses */
|
|
35
|
-
export declare const nativeAssetOut: Record<Chains, Hex>;
|
|
36
|
-
/** A map of chains to deprecated native asset out addresses */
|
|
37
|
-
export declare const deprecatedNativeAssetOut: Partial<Record<Chains, Set<Hex>>>;
|
|
38
|
-
/** A map of chains to uni v2 router addresses */
|
|
39
|
-
export declare const uniV2Routers: Record<Chains, Hex[]>;
|
|
40
|
-
/** A map of chains to native token symbols */
|
|
41
|
-
export declare const nativeTokenSymbol: Record<Chains, string>;
|
|
42
|
-
/** A map of chains to native token names */
|
|
43
|
-
export declare const nativeTokenName: Record<Chains, string>;
|
|
44
|
-
/** The pathway of a bridge */
|
|
45
|
-
export type Pathway = {
|
|
46
|
-
from: Hex;
|
|
47
|
-
to: Hex;
|
|
48
|
-
destinationRouter: Hex | null;
|
|
49
|
-
nativeRouter: Hex;
|
|
50
|
-
validator: Hex;
|
|
51
|
-
usesExtraParam: boolean;
|
|
52
|
-
feeManager: 'from' | 'to';
|
|
53
|
-
toHome: boolean;
|
|
54
|
-
requiresDelivery: boolean;
|
|
55
|
-
bridgedNativeAssetOut: Hex;
|
|
56
|
-
settingOverrides?: Record<Hex, Partial<Pathway>>;
|
|
57
|
-
};
|
|
58
|
-
/** A map of providers to pathways */
|
|
59
|
-
export type DeepPathwayConfig = Record<Provider, Partial<Record<Chains, Partial<Record<Chains, Pathway>>>>>;
|
|
60
|
-
export declare const pathways: DeepPathwayConfig;
|
|
61
|
-
export declare const testnetPathways: DeepPathwayConfig;
|
|
62
|
-
/** Returns the valid bridge keys for the given is prod */
|
|
63
|
-
export declare const validBridgeKeys: (isProd: boolean) => BridgeKey[];
|
|
64
|
-
/**
|
|
65
|
-
* Infers the bridge key from the current key, provider, from chain, and to chain
|
|
66
|
-
* @param currentKey - the current bridge key
|
|
67
|
-
* @param provider - the provider
|
|
68
|
-
* @param fromChain - the from chain
|
|
69
|
-
* @param toChain - the to chain
|
|
70
|
-
* @returns the inferred bridge key
|
|
71
|
-
*/
|
|
72
|
-
export declare const inferBridgeKey: ({ currentKey, provider, fromChain, toChain, }: {
|
|
73
|
-
currentKey: BridgeKey;
|
|
74
|
-
provider: Provider;
|
|
75
|
-
fromChain?: Chains;
|
|
76
|
-
toChain?: Chains;
|
|
77
|
-
}) => BridgeKey;
|
|
78
|
-
/**
|
|
79
|
-
* Returns the pathway for the given bridge key, is prod, and asset in address
|
|
80
|
-
* @param bridgeKey - the bridge key
|
|
81
|
-
* @param isProd - whether to use the production pathway
|
|
82
|
-
* @param assetInAddress - the asset in address
|
|
83
|
-
* @returns the pathway
|
|
84
|
-
*/
|
|
85
|
-
export declare const pathway: (bridgeKey: BridgeKey | null, isProd: boolean, assetInAddress?: string | Hex | null | undefined) => Pathway | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* Returns the default asset in for the given bridge key and is prod
|
|
88
|
-
* @param bridgeKey - the bridge key
|
|
89
|
-
* @param isProd - whether to use the production pathway
|
|
90
|
-
* @returns the default asset in
|
|
91
|
-
*/
|
|
92
|
-
export declare const defaultAssetIn: ($bridgeKey: BridgeKey | null, isProd: boolean) => `0x${string}` | null | undefined;
|
|
93
|
-
/**
|
|
94
|
-
* Returns whether the given asset is the native asset for the given bridge key
|
|
95
|
-
* @param asset - the asset
|
|
96
|
-
* @param bridgeKey - the bridge key
|
|
97
|
-
* @returns whether the given asset is the native asset for the given bridge key
|
|
98
|
-
*/
|
|
99
|
-
export declare const isNative: (asset: Token | TokenOut | null, bridgeKey: BridgeKey | null) => boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Returns whether the given asset is unwrappable for the given bridge key
|
|
102
|
-
* @param bridgeKey - the bridge key
|
|
103
|
-
* @param assetIn - the asset in
|
|
104
|
-
* @returns whether the given asset is unwrappable for the given bridge key
|
|
105
|
-
*/
|
|
106
|
-
export declare const isUnwrappable: (bridgeKey: BridgeKey | null, assetIn: Pick<Token, "address"> | null) => boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Returns whether the given asset can be unwrapped for the given bridge key
|
|
109
|
-
* @param bridgeKey - the bridge key
|
|
110
|
-
* @param assetIn - the asset in
|
|
111
|
-
* @returns boolean
|
|
112
|
-
*/
|
|
113
|
-
export declare const canChangeUnwrap: (bridgeKey: BridgeKey, assetIn: Token | null) => boolean;
|
|
114
|
-
export declare const chains: {
|
|
115
|
-
readonly ethereum: 1;
|
|
116
|
-
readonly bsc: 56;
|
|
117
|
-
readonly pulsechain: 369;
|
|
118
|
-
readonly pulsechainV4: 943;
|
|
119
|
-
readonly sepolia: 11155111;
|
|
120
|
-
};
|
|
121
|
-
export declare const chainIds: (1 | 56 | 369 | 943 | 11155111)[];
|
|
122
|
-
export type ChainId = (typeof chainIds)[number];
|
|
123
|
-
export type Side = 'home' | 'foreign';
|
|
124
|
-
export type MinimalKey = `${ChainId}-${Hex}`;
|
|
125
|
-
export type PathwayInfo = {
|
|
126
|
-
pair: string;
|
|
127
|
-
key: string;
|
|
128
|
-
home: Hex;
|
|
129
|
-
foreign: Hex;
|
|
130
|
-
};
|
|
131
|
-
export type ProviderHomeChainEntry = Partial<Record<ChainId, PathwayInfo[]>>;
|
|
132
|
-
export type ProviderEntries = Partial<Record<ChainId, ProviderHomeChainEntry>>;
|
|
133
|
-
export type BridgeConfig = Record<Provider, ProviderEntries>;
|
|
134
|
-
export declare const bridgeConfigs: BridgeConfig;
|
|
135
|
-
export declare const HOME_TO_FOREIGN_FEE: `0x${string}`;
|
|
136
|
-
export declare const FOREIGN_TO_HOME_FEE: `0x${string}`;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sets the image root for the bridge
|
|
3
|
-
* @param root - the root
|
|
4
|
-
*/
|
|
5
|
-
export declare const setImageRoot: (root: string) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the image root for the bridge
|
|
8
|
-
* @returns the image root
|
|
9
|
-
*/
|
|
10
|
-
export declare const getImageRoot: () => string;
|
|
11
|
-
/** The minimal token info */
|
|
12
|
-
interface MinimalTokenInfo {
|
|
13
|
-
chainId: number;
|
|
14
|
-
address: string;
|
|
15
|
-
logoURI?: string | null;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Returns the list image for the given path
|
|
19
|
-
* @param path - the path
|
|
20
|
-
* @returns the list image
|
|
21
|
-
*/
|
|
22
|
-
export declare const list: (path: string) => string;
|
|
23
|
-
/**
|
|
24
|
-
* Returns the network image for the given chain id
|
|
25
|
-
* @param chainId - the chain id
|
|
26
|
-
* @returns the network image
|
|
27
|
-
*/
|
|
28
|
-
export declare const network: (chainId: number) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Returns the image url for the given token info
|
|
31
|
-
* @param t - the token info
|
|
32
|
-
* @returns the image url
|
|
33
|
-
*/
|
|
34
|
-
export declare const image: (t: MinimalTokenInfo) => string;
|
|
35
|
-
/**
|
|
36
|
-
* Returns a url that will lookup all sources for the given array
|
|
37
|
-
* @param sources - the sources
|
|
38
|
-
* @returns the images
|
|
39
|
-
*/
|
|
40
|
-
export declare const images: (sources: string[]) => string;
|
|
41
|
-
export {};
|
package/dist/src/image-links.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getAddress } from 'viem';
|
|
2
|
-
let imageRoot = 'https://gib.show';
|
|
3
|
-
/**
|
|
4
|
-
* Sets the image root for the bridge
|
|
5
|
-
* @param root - the root
|
|
6
|
-
*/
|
|
7
|
-
export const setImageRoot = (root) => {
|
|
8
|
-
imageRoot = root;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Returns the image root for the bridge
|
|
12
|
-
* @returns the image root
|
|
13
|
-
*/
|
|
14
|
-
export const getImageRoot = () => imageRoot;
|
|
15
|
-
/**
|
|
16
|
-
* Returns the list image for the given path
|
|
17
|
-
* @param path - the path
|
|
18
|
-
* @returns the list image
|
|
19
|
-
*/
|
|
20
|
-
export const list = (path) => {
|
|
21
|
-
return `${imageRoot}/list${path}`;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Returns the network image for the given chain id
|
|
25
|
-
* @param chainId - the chain id
|
|
26
|
-
* @returns the network image
|
|
27
|
-
*/
|
|
28
|
-
export const network = (chainId) => {
|
|
29
|
-
if (!chainId) {
|
|
30
|
-
console.trace('network image');
|
|
31
|
-
}
|
|
32
|
-
return `${imageRoot}/image/${Number(chainId)}`;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Returns the image url for the given token info
|
|
36
|
-
* @param t - the token info
|
|
37
|
-
* @returns the image url
|
|
38
|
-
*/
|
|
39
|
-
export const image = (t) => t.logoURI || `${network(t.chainId)}/${getAddress(t.address)}`;
|
|
40
|
-
/**
|
|
41
|
-
* Returns a url that will lookup all sources for the given array
|
|
42
|
-
* @param sources - the sources
|
|
43
|
-
* @returns the images
|
|
44
|
-
*/
|
|
45
|
-
export const images = (sources) => `${imageRoot}/image/?${sources.map((s) => `i=${s}`).join('&')}`;
|
package/dist/src/index.d.ts
DELETED
package/dist/src/index.js
DELETED
package/dist/src/settings.d.ts
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { type Hex } from "viem";
|
|
2
|
-
import { Chains, type Pathway } from "./config.js";
|
|
3
|
-
import { FeeType } from "./fee-type.js";
|
|
4
|
-
import type { BridgeKey, Token } from "./types.js";
|
|
5
|
-
import type { TokenBridgeInfo } from "./chain-info.js";
|
|
6
|
-
export declare const oneEther: bigint;
|
|
7
|
-
export declare const basisPoints = 10000n;
|
|
8
|
-
/**
|
|
9
|
-
* Returns the bridge pathway (configuration) for a given bridge key, asset in, and whether to use the production pathway
|
|
10
|
-
* @param bridgeKey - the bridge key to use
|
|
11
|
-
* @param isProd - whether to use the production pathway
|
|
12
|
-
* @param assetIn - the asset in to bridge
|
|
13
|
-
* @returns the bridge pathway
|
|
14
|
-
*/
|
|
15
|
-
export declare const bridgePathway: ({ bridgeKey, isProd, assetIn, }: {
|
|
16
|
-
bridgeKey: BridgeKey;
|
|
17
|
-
isProd: boolean;
|
|
18
|
-
assetIn: Token | null;
|
|
19
|
-
}) => Pathway | null;
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves the amount to bridge from the amount and asset in. If either of them is nil, returns 0n
|
|
22
|
-
* @param amountIn - the amount to bridge
|
|
23
|
-
* @param assetIn - the asset in to bridge
|
|
24
|
-
* @returns the amount to bridge
|
|
25
|
-
*/
|
|
26
|
-
export declare const amountToBridge: ({ amountIn, assetIn, }: {
|
|
27
|
-
amountIn: bigint | null;
|
|
28
|
-
assetIn: Token | null;
|
|
29
|
-
}) => bigint;
|
|
30
|
-
/**
|
|
31
|
-
* Calculates the bridge cost from the amount to bridge and bridge fee
|
|
32
|
-
* @param amountToBridge - the amount to bridge
|
|
33
|
-
* @param bridgeFee - the bridge fee
|
|
34
|
-
* @returns the bridge cost
|
|
35
|
-
*/
|
|
36
|
-
export declare const bridgeCost: ({ amountToBridge, bridgeFee, }: {
|
|
37
|
-
amountToBridge: bigint;
|
|
38
|
-
bridgeFee: bigint | null;
|
|
39
|
-
}) => bigint | null;
|
|
40
|
-
/**
|
|
41
|
-
* Calculates the amount after bridge fee from the amount to bridge and bridge cost
|
|
42
|
-
* @param amountToBridge - the amount to bridge
|
|
43
|
-
* @param bridgeCost - the bridge cost
|
|
44
|
-
* @returns the amount after bridge fee
|
|
45
|
-
*/
|
|
46
|
-
export declare const amountAfterBridgeFee: ({ amountToBridge, bridgeCost, }: {
|
|
47
|
-
amountToBridge: bigint;
|
|
48
|
-
bridgeCost: bigint | null;
|
|
49
|
-
}) => bigint | null;
|
|
50
|
-
/**
|
|
51
|
-
* Calculates the estimated amount out from the amount after bridge fee and fee
|
|
52
|
-
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
53
|
-
* @param fee - the fee
|
|
54
|
-
* @returns the estimated amount out
|
|
55
|
-
*/
|
|
56
|
-
export declare const estimatedAmountOut: ({ amountAfterBridgeFee, fee, }: {
|
|
57
|
-
amountAfterBridgeFee: bigint | null;
|
|
58
|
-
fee: bigint | null;
|
|
59
|
-
}) => bigint | null;
|
|
60
|
-
/**
|
|
61
|
-
* Calculates the estimated fee from the amount after bridge fee, fee, percent fee, fee type, limit, and whether to deliver the costs
|
|
62
|
-
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
63
|
-
* @param fee - the fee
|
|
64
|
-
* @param percentFee - the percent fee
|
|
65
|
-
* @param feeType - the fee type
|
|
66
|
-
* @param limit - the limit
|
|
67
|
-
* @param costsToDeliver - whether to deliver the costs
|
|
68
|
-
* @returns the estimated fee
|
|
69
|
-
*/
|
|
70
|
-
export declare const estimatedFee: ({ amountAfterBridgeFee, fee, percentFee, feeType, limit, costsToDeliver, }: {
|
|
71
|
-
amountAfterBridgeFee: bigint | null;
|
|
72
|
-
fee: bigint;
|
|
73
|
-
percentFee: bigint;
|
|
74
|
-
feeType: FeeType;
|
|
75
|
-
limit: bigint | null;
|
|
76
|
-
costsToDeliver: boolean;
|
|
77
|
-
}) => bigint | null;
|
|
78
|
-
/**
|
|
79
|
-
* Calculates the estimated native network cost from the estimated gas and latest base fee per gas
|
|
80
|
-
* @param estimatedGas - the estimated gas
|
|
81
|
-
* @param latestBaseFeePerGas - the latest base fee per gas
|
|
82
|
-
* @param requiresDelivery - whether to deliver the costs
|
|
83
|
-
* @returns the estimated native network cost
|
|
84
|
-
*/
|
|
85
|
-
export declare const estimatedNativeNetworkCost: ({ estimatedGas, latestBaseFeePerGas, requiresDelivery, }: {
|
|
86
|
-
estimatedGas: bigint | null;
|
|
87
|
-
latestBaseFeePerGas: bigint | null;
|
|
88
|
-
requiresDelivery: boolean;
|
|
89
|
-
}) => bigint | null;
|
|
90
|
-
/**
|
|
91
|
-
* Calculates the estimated token network cost from the estimated native
|
|
92
|
-
* network cost, price corrective, decimals, and one token int
|
|
93
|
-
* @param estimatedNativeNetworkCost - the estimated native network cost
|
|
94
|
-
* @param priceCorrective - the price corrective
|
|
95
|
-
* @param decimals - the decimals
|
|
96
|
-
* @param oneTokenInt - the one token int
|
|
97
|
-
* @returns the estimated token network cost
|
|
98
|
-
*/
|
|
99
|
-
export declare const estimatedTokenNetworkCost: ({ estimatedNativeNetworkCost, priceCorrective, decimals, oneTokenInt, }: {
|
|
100
|
-
estimatedNativeNetworkCost: bigint | null;
|
|
101
|
-
priceCorrective: bigint | null;
|
|
102
|
-
decimals: number | null;
|
|
103
|
-
oneTokenInt: bigint | null;
|
|
104
|
-
}) => bigint | null;
|
|
105
|
-
/**
|
|
106
|
-
* Calculates one token of the asset in as an int
|
|
107
|
-
* @param assetIn - the asset in to bridge
|
|
108
|
-
* @returns the one token int
|
|
109
|
-
*/
|
|
110
|
-
export declare const oneTokenInt: ({ assetIn, }: {
|
|
111
|
-
assetIn: Token | null;
|
|
112
|
-
}) => bigint;
|
|
113
|
-
/**
|
|
114
|
-
* Returns the limit as a bigint. Nil uses 0n
|
|
115
|
-
* @param lim - the limit
|
|
116
|
-
* @returns the limit
|
|
117
|
-
*/
|
|
118
|
-
export declare const limit: (lim: bigint | null) => bigint;
|
|
119
|
-
/**
|
|
120
|
-
* Returns the network switch asset out address from the asset out, unwrap, and to chain
|
|
121
|
-
* @param assetOut - the asset out
|
|
122
|
-
* @param unwrap - whether to unwrap
|
|
123
|
-
* @param toChain - the chain to switch to
|
|
124
|
-
* @returns the network switch asset out address
|
|
125
|
-
*/
|
|
126
|
-
export declare const networkSwitchAssetOutAddress: ({ assetOut, unwrap, toChain, }: {
|
|
127
|
-
assetOut: Token | null;
|
|
128
|
-
unwrap: boolean;
|
|
129
|
-
toChain: Chains;
|
|
130
|
-
}) => string | null;
|
|
131
|
-
/**
|
|
132
|
-
* Calculates the desired excess compensation basis points from the path, asset in, asset out, bridge key, fee type, list, and asset out address
|
|
133
|
-
* @param path - the path
|
|
134
|
-
* @param assetIn - the asset in to bridge
|
|
135
|
-
* @param assetOut - the asset out
|
|
136
|
-
* @param bridgeKey - the bridge key
|
|
137
|
-
* @param feeType - the fee type
|
|
138
|
-
* @param list - the list
|
|
139
|
-
* @param assetOutAddress - the asset out address
|
|
140
|
-
* @returns the desired excess compensation basis points
|
|
141
|
-
*/
|
|
142
|
-
export declare const desiredExcessCompensationBasisPoints: ({ path, assetIn, assetOut, bridgeKey, feeType, list, assetOutAddress, }: {
|
|
143
|
-
path: Pathway | null;
|
|
144
|
-
assetIn: Token | null;
|
|
145
|
-
assetOut: Token | null;
|
|
146
|
-
bridgeKey: BridgeKey;
|
|
147
|
-
feeType: FeeType;
|
|
148
|
-
list: Set<string>;
|
|
149
|
-
assetOutAddress: string | null;
|
|
150
|
-
}) => 0n | 10000n | 1000n | 5000n;
|
|
151
|
-
/**
|
|
152
|
-
* Calculates the estimated cost from the should deliver, amount after bridge fee, percent fee,
|
|
153
|
-
* estimated token network cost, reasonable percent on top of gas fee, and fee type
|
|
154
|
-
* @param shouldDeliver - whether to deliver the costs
|
|
155
|
-
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
156
|
-
* @param percentFee - the percent fee
|
|
157
|
-
* @param estimatedTokenNetworkCost - the estimated token network cost
|
|
158
|
-
* @param reasonablePercentOnTopOfGasFee - the reasonable percent on top of gas fee
|
|
159
|
-
* @param feeType - the fee type
|
|
160
|
-
* @returns the estimated cost
|
|
161
|
-
*/
|
|
162
|
-
export declare const estimatedCost: ({ shouldDeliver, amountAfterBridgeFee, percentFee, estimatedTokenNetworkCost, reasonablePercentOnTopOfGasFee, feeType, }: {
|
|
163
|
-
shouldDeliver: boolean;
|
|
164
|
-
amountAfterBridgeFee: bigint | null;
|
|
165
|
-
percentFee: bigint | null;
|
|
166
|
-
estimatedTokenNetworkCost: bigint | null;
|
|
167
|
-
reasonablePercentOnTopOfGasFee: bigint | null;
|
|
168
|
-
feeType: FeeType;
|
|
169
|
-
}) => bigint | null;
|
|
170
|
-
/**
|
|
171
|
-
* Calculates the reasonable fixed fee from the estimated token network cost and desired excess compensation basis points
|
|
172
|
-
* @param estimatedTokenNetworkCost - the estimated token network cost
|
|
173
|
-
* @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
|
|
174
|
-
* @returns the reasonable fixed fee
|
|
175
|
-
*/
|
|
176
|
-
export declare const reasonableFixedFee: ({ estimatedTokenNetworkCost, desiredExcessCompensationBasisPoints, }: {
|
|
177
|
-
estimatedTokenNetworkCost: bigint | null;
|
|
178
|
-
desiredExcessCompensationBasisPoints: bigint;
|
|
179
|
-
}) => bigint | null;
|
|
180
|
-
/**
|
|
181
|
-
* Calculates the reasonable percent on gas limit from the gas tip fee and estimated token network cost
|
|
182
|
-
* @param gasTipFee - the gas tip fee
|
|
183
|
-
* @param estimatedTokenNetworkCost - the estimated token network cost
|
|
184
|
-
* @returns the reasonable percent on gas limit
|
|
185
|
-
*/
|
|
186
|
-
export declare const reasonablePercentOnGasLimit: ({ gasTipFee, estimatedTokenNetworkCost, }: {
|
|
187
|
-
gasTipFee: bigint | null;
|
|
188
|
-
estimatedTokenNetworkCost: bigint | null;
|
|
189
|
-
}) => bigint;
|
|
190
|
-
/**
|
|
191
|
-
* Calculates the reasonable percent fee from the reasonable fixed fee and amount after bridge fee
|
|
192
|
-
* @param reasonableFixedFee - the reasonable fixed fee
|
|
193
|
-
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
194
|
-
* @returns the reasonable percent fee
|
|
195
|
-
*/
|
|
196
|
-
export declare const reasonablePercentFee: ({ reasonableFixedFee, amountAfterBridgeFee, }: {
|
|
197
|
-
reasonableFixedFee: bigint | null;
|
|
198
|
-
amountAfterBridgeFee: bigint | null;
|
|
199
|
-
}) => bigint | null;
|
|
200
|
-
/**
|
|
201
|
-
* Returns whether the asset in address is interacting with a bridge token
|
|
202
|
-
* @param assetLink - the asset link
|
|
203
|
-
* @param assetInAddress - the asset in address
|
|
204
|
-
* @returns whether the asset in address is interacting with a bridge token
|
|
205
|
-
*/
|
|
206
|
-
export declare const interactingWithBridgeToken: ({ assetLink, assetInAddress, }: {
|
|
207
|
-
assetLink: TokenBridgeInfo | null;
|
|
208
|
-
assetInAddress: string | null;
|
|
209
|
-
}) => boolean;
|
|
210
|
-
/**
|
|
211
|
-
* Calculates the fee director struct encoded from the recipient, bridge pathway, fee type, price corrective, gas tip fee, percent fee, fee type settings, limit, and asset out
|
|
212
|
-
* @param recipient - the recipient
|
|
213
|
-
* @param bridgePathway - the bridge pathway
|
|
214
|
-
* @param feeType - the fee type
|
|
215
|
-
* @param priceCorrective - the price corrective
|
|
216
|
-
* @param gasTipFee - the gas tip fee
|
|
217
|
-
* @param percentFee - the percent fee
|
|
218
|
-
* @param feeTypeSettings - the fee type settings
|
|
219
|
-
* @param limit - the limit
|
|
220
|
-
* @param assetOut - the asset out
|
|
221
|
-
* @returns the fee director struct encoded
|
|
222
|
-
*/
|
|
223
|
-
export declare const feeDirectorStructEncoded: ({ recipient, bridgePathway, feeType, priceCorrective, gasTipFee, percentFee, feeTypeSettings, limit, assetOut, }: {
|
|
224
|
-
recipient: Hex | null;
|
|
225
|
-
feeType: FeeType;
|
|
226
|
-
priceCorrective: bigint | null;
|
|
227
|
-
gasTipFee: bigint | null;
|
|
228
|
-
percentFee: bigint | null;
|
|
229
|
-
feeTypeSettings: bigint;
|
|
230
|
-
limit: bigint;
|
|
231
|
-
bridgePathway: Pathway | null;
|
|
232
|
-
assetOut: Token | null;
|
|
233
|
-
}) => `0x${string}` | null;
|
|
234
|
-
/**
|
|
235
|
-
* Calculates the destination data param from the recipient, bridge pathway, asset in, destination router, fee director struct encoded, asset link, should deliver, and unwrap
|
|
236
|
-
* @param recipient - the recipient
|
|
237
|
-
* @param bridgePathway - the bridge pathway
|
|
238
|
-
* @param assetIn - the asset in to bridge
|
|
239
|
-
* @param destinationRouter - the destination router
|
|
240
|
-
* @param feeDirectorStructEncoded - the fee director struct encoded
|
|
241
|
-
* @param assetLink - the asset link
|
|
242
|
-
* @param shouldDeliver - whether to deliver the costs
|
|
243
|
-
* @param unwrap - whether to unwrap
|
|
244
|
-
* @returns the destination data param
|
|
245
|
-
*/
|
|
246
|
-
export declare const destinationDataParam: ({ recipient, bridgePathway, assetIn, destinationRouter, feeDirectorStructEncoded, assetLink, shouldDeliver, unwrap, }: {
|
|
247
|
-
recipient: Hex | null;
|
|
248
|
-
bridgePathway: Pathway | null;
|
|
249
|
-
assetIn: Token | null;
|
|
250
|
-
destinationRouter: Hex | null;
|
|
251
|
-
feeDirectorStructEncoded: Hex | null;
|
|
252
|
-
assetLink: TokenBridgeInfo | null;
|
|
253
|
-
shouldDeliver: boolean;
|
|
254
|
-
unwrap: boolean;
|
|
255
|
-
}) => `0x${string}` | null;
|
|
256
|
-
/**
|
|
257
|
-
* Converts a desired excess compensation basis point value into a percentage as an integer, with the denominator assumed to be 1e18
|
|
258
|
-
* @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
|
|
259
|
-
* @returns the reasonable percent on top of gas fee
|
|
260
|
-
*/
|
|
261
|
-
export declare const reasonablePercentOnTopOfGasFee: ({ desiredExcessCompensationBasisPoints, }: {
|
|
262
|
-
desiredExcessCompensationBasisPoints: bigint;
|
|
263
|
-
}) => bigint;
|
|
264
|
-
/**
|
|
265
|
-
* Calculates the desired compensation ratio from the desired excess compensation basis points
|
|
266
|
-
* @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
|
|
267
|
-
* @returns the desired compensation ratio
|
|
268
|
-
*/
|
|
269
|
-
export declare const desiredCompensationRatio: ({ desiredExcessCompensationBasisPoints, }: {
|
|
270
|
-
desiredExcessCompensationBasisPoints: bigint;
|
|
271
|
-
}) => bigint;
|
|
272
|
-
/**
|
|
273
|
-
* Calculates the available compensation maximum from the amount after bridge fee, percent fee, fee type, fixed fee, and limit
|
|
274
|
-
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
275
|
-
* @param percentFee - the percent fee
|
|
276
|
-
* @param feeType - the fee type
|
|
277
|
-
* @param fixedFee - the fixed fee
|
|
278
|
-
* @param limit - the limit
|
|
279
|
-
* @returns the available compensation maximum
|
|
280
|
-
*/
|
|
281
|
-
export declare const availableCompensationMaximum: ({ amountAfterBridgeFee, percentFee, feeType, fixedFee, limit, }: {
|
|
282
|
-
amountAfterBridgeFee: bigint | null;
|
|
283
|
-
percentFee: bigint | null;
|
|
284
|
-
feeType: FeeType;
|
|
285
|
-
fixedFee: bigint | null;
|
|
286
|
-
limit: bigint;
|
|
287
|
-
}) => bigint | null;
|
|
288
|
-
/**
|
|
289
|
-
* Determines if the bridge is undercompensated based on network costs vs compensation limit using desired compensation rate
|
|
290
|
-
* @param estimatedTokenNetworkCost - the estimated token network cost
|
|
291
|
-
* @param feeType - the fee type
|
|
292
|
-
* @param limit - the maximum compensation limit
|
|
293
|
-
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
294
|
-
* @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
|
|
295
|
-
* @returns whether the bridge is undercompensated
|
|
296
|
-
*/
|
|
297
|
-
export declare const isUndercompensated: ({ estimatedTokenNetworkCost, feeType, limit, amountAfterBridgeFee, desiredExcessCompensationBasisPoints, }: {
|
|
298
|
-
estimatedTokenNetworkCost: bigint | null;
|
|
299
|
-
feeType: FeeType;
|
|
300
|
-
limit: bigint;
|
|
301
|
-
amountAfterBridgeFee: bigint | null;
|
|
302
|
-
desiredExcessCompensationBasisPoints: bigint;
|
|
303
|
-
}) => boolean;
|
|
304
|
-
/**
|
|
305
|
-
* Calculates the transaction inputs from the bridge pathway, asset in, recipient, account, asset link, destination data param, amount to bridge, fee director struct encoded, and should deliver
|
|
306
|
-
* @param bridgePathway - the bridge pathway to use
|
|
307
|
-
* @param assetIn - the asset in to bridge
|
|
308
|
-
* @param recipient - the recipient of the bridge
|
|
309
|
-
* @param account - the account to bridge from
|
|
310
|
-
* @param assetLink - the asset link to use
|
|
311
|
-
* @param destinationDataParam - the destination data param to use
|
|
312
|
-
* @param amountToBridge - the amount to bridge
|
|
313
|
-
* @param feeDirectorStructEncoded - the fee director struct encoded to use
|
|
314
|
-
* @param shouldDeliver - whether to deliver the tokens to the recipient
|
|
315
|
-
* @returns the transaction inputs
|
|
316
|
-
*/
|
|
317
|
-
export declare const transactionInputs: ({ bridgePathway, assetIn, recipient, account, assetLink, destinationDataParam, amountToBridge, feeDirectorStructEncoded, shouldDeliver, }: {
|
|
318
|
-
bridgePathway: Pathway | null;
|
|
319
|
-
assetIn: Token | null;
|
|
320
|
-
recipient: Hex | null;
|
|
321
|
-
account: Hex | null;
|
|
322
|
-
assetLink: TokenBridgeInfo | null;
|
|
323
|
-
destinationDataParam: Hex | null;
|
|
324
|
-
amountToBridge: bigint;
|
|
325
|
-
feeDirectorStructEncoded: Hex | null;
|
|
326
|
-
shouldDeliver: boolean;
|
|
327
|
-
}) => {
|
|
328
|
-
to: `0x${string}`;
|
|
329
|
-
value: bigint;
|
|
330
|
-
data: `0x${string}`;
|
|
331
|
-
} | null;
|
|
332
|
-
/**
|
|
333
|
-
* Calculates the asset out key from the bridge key path, asset in address, and unwrap
|
|
334
|
-
* @param bridgeKeyPath - the bridge key path
|
|
335
|
-
* @param assetInAddress - the asset in address
|
|
336
|
-
* @param unwrap - whether to unwrap
|
|
337
|
-
* @returns the asset out key
|
|
338
|
-
*/
|
|
339
|
-
export declare const assetOutKey: ({ bridgeKeyPath, assetInAddress, unwrap, }: {
|
|
340
|
-
bridgeKeyPath: string;
|
|
341
|
-
assetInAddress?: Hex | null;
|
|
342
|
-
unwrap: boolean;
|
|
343
|
-
}) => string | null;
|
|
344
|
-
/**
|
|
345
|
-
* Returns the asset out from the asset in address, assets out, bridge key path, and unwrap
|
|
346
|
-
* @param assetInAddress - the asset in address
|
|
347
|
-
* @param assetsOut - the assets out
|
|
348
|
-
* @param bridgeKeyPath - the bridge key path
|
|
349
|
-
* @param unwrap - whether to unwrap
|
|
350
|
-
* @returns the asset out
|
|
351
|
-
*/
|
|
352
|
-
export declare const assetOut: ({ assetInAddress, assetsOut, bridgeKeyPath, unwrap, }: {
|
|
353
|
-
assetInAddress: Hex | null;
|
|
354
|
-
assetsOut: Map<string, Token>;
|
|
355
|
-
bridgeKeyPath: string;
|
|
356
|
-
unwrap: boolean;
|
|
357
|
-
}) => Token | null;
|