@anywalletkit/protocol-swap2-chainflip 0.0.0-stage → 0.2.1
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 +202 -0
- package/README.md +81 -2
- package/dist/activity.cjs +62 -0
- package/dist/activity.cjs.map +1 -0
- package/dist/activity.d.cts +12 -0
- package/dist/activity.d.ts +12 -0
- package/dist/activity.js +10 -0
- package/dist/activity.js.map +1 -0
- package/dist/chunk-GXHOO3CT.js +54 -0
- package/dist/chunk-GXHOO3CT.js.map +1 -0
- package/dist/chunk-H6GJVVWS.js +22 -0
- package/dist/chunk-H6GJVVWS.js.map +1 -0
- package/dist/chunk-R6EYDH5N.js +142 -0
- package/dist/chunk-R6EYDH5N.js.map +1 -0
- package/dist/chunk-XF7BEBET.js +27 -0
- package/dist/chunk-XF7BEBET.js.map +1 -0
- package/dist/chunk-ZFCYBCOT.js +223 -0
- package/dist/chunk-ZFCYBCOT.js.map +1 -0
- package/dist/codec.cjs +162 -0
- package/dist/codec.cjs.map +1 -0
- package/dist/codec.d.cts +60 -0
- package/dist/codec.d.ts +60 -0
- package/dist/codec.js +25 -0
- package/dist/codec.js.map +1 -0
- package/dist/config.cjs +74 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +46 -0
- package/dist/config.d.ts +46 -0
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -0
- package/dist/index.cjs +447 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.cjs +426 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +16 -0
- package/dist/protocol.d.ts +16 -0
- package/dist/protocol.js +11 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider.cjs +412 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +12 -0
- package/dist/provider.d.ts +12 -0
- package/dist/provider.js +10 -0
- package/dist/provider.js.map +1 -0
- package/module.json +20 -0
- package/package.json +90 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/codec.ts"],"sourcesContent":["/**\n * Decoders for what Chainflip's encoder returns, so a vault swap is checked byte by byte before anyone signs it:\n * - VersionedCfParameters (SCALE): retry window, refund address, minimum price (X128), oracle slippage, DCA, boost,\n * broker + its fee, affiliates — the EVM vault call's `cfParameters` and the tail of the Tron note;\n * - the Tron note: output asset id, encoded destination address, CCM option, then the length-prefixed parameters;\n * - the EVM vault calls xSwapNative / xSwapToken.\n * Layouts were decoded from live encoder outputs (2026-10-20) and match the state chain's types.\n */\nimport {base58} from \"@scure/base\";\nimport {sha256} from \"@noble/hashes/sha2.js\";\nimport {decodeFunctionData, parseAbi, type Hex} from \"viem\";\n\nexport interface CfParameters {\n version: number;\n retryDurationBlocks: number;\n /** raw refund address bytes (20 for EVM / Tron, 32 for Solana) as 0x-hex */\n refundAddress: Hex;\n /** minimum output price × 2^128, scaled by 10^(destDecimals − srcDecimals) */\n minPriceX128: bigint;\n refundCcm: boolean;\n maxOraclePriceSlippageBps: number | null;\n dca: {chunks: number; intervalBlocks: number} | null;\n boostFeeBps: number;\n broker: {account: Hex; feeBps: number};\n affiliates: {account: number; feeBps: number}[];\n}\n\nclass Reader {\n i = 0;\n constructor(readonly b: Uint8Array) {}\n need(n: number) { if (this.i + n > this.b.length) throw new Error(`chainflip codec: truncated at ${this.i} (+${n} of ${this.b.length})`); }\n u8() { this.need(1); return this.b[this.i++]!; }\n bytes(n: number) { this.need(n); const out = this.b.slice(this.i, this.i + n); this.i += n; return out; }\n uLE(n: number): bigint { const x = this.bytes(n); let v = 0n; for (let k = n - 1; k >= 0; k--) v = (v << 8n) | BigInt(x[k]!); return v; }\n /** SCALE compact integer */\n compact(): number {\n const first = this.u8();\n const mode = first & 3;\n if (mode === 0) return first >> 2;\n if (mode === 1) return ((this.u8() << 8) | first) >> 2;\n if (mode === 2) { const rest = Number(this.uLE(3)); return ((rest << 8) | first) >>> 2; }\n throw new Error(\"chainflip codec: big compact integers are not used here\");\n }\n done() { if (this.i !== this.b.length) throw new Error(`chainflip codec: ${this.b.length - this.i} trailing bytes`); }\n}\n\nexport const toHex = (b: Uint8Array): Hex => `0x${[...b].map((x) => x.toString(16).padStart(2, \"0\")).join(\"\")}` as Hex;\nexport function fromHex(h: string): Uint8Array {\n const s = h.startsWith(\"0x\") ? h.slice(2) : h;\n if (s.length % 2 || /[^0-9a-f]/i.test(s)) throw new Error(\"chainflip codec: not hex\");\n return Uint8Array.from(s.match(/../g) ?? [], (x) => Number.parseInt(x, 16));\n}\n\n/** VersionedCfParameters V1. `refundLen` = 20 for EVM / Tron sources, 32 for Solana. */\nexport function decodeCfParameters(bytes: Uint8Array, refundLen: 20 | 32): CfParameters {\n const r = new Reader(bytes);\n const p = readCfParameters(r, refundLen);\n r.done();\n return p;\n}\n\nfunction readCfParameters(r: Reader, refundLen: number): CfParameters {\n const version = r.u8();\n if (version !== 1) throw new Error(`chainflip codec: cf parameters version ${version}`);\n // ccm_additional_data is `()` for non-CCM swaps: zero bytes\n const retryDurationBlocks = Number(r.uLE(4));\n const refundAddress = toHex(r.bytes(refundLen));\n const minPriceX128 = r.uLE(32);\n const refundCcm = r.u8() !== 0;\n if (refundCcm) throw new Error(\"chainflip codec: refund CCM metadata is not expected\");\n const maxOraclePriceSlippageBps = r.u8() ? Number(r.uLE(2)) : null;\n const dca = r.u8() ? {chunks: Number(r.uLE(4)), intervalBlocks: Number(r.uLE(4))} : null;\n const boostFeeBps = r.u8();\n const broker = {account: toHex(r.bytes(32)), feeBps: Number(r.uLE(2))};\n const n = r.compact();\n const affiliates = Array.from({length: n}, () => ({account: r.u8(), feeBps: Number(r.uLE(2))}));\n return {version, retryDurationBlocks, refundAddress, minPriceX128, refundCcm, maxOraclePriceSlippageBps, dca, boostFeeBps, broker, affiliates};\n}\n\nexport interface TronNote {\n outputAsset: number;\n /** EncodedAddress variant of the destination (Eth 0, Dot 1, Btc 2, Arb 3, Sol 4, Hub 5, Tron 6) and its raw bytes */\n destTag: number;\n destAddress: Uint8Array;\n ccm: boolean;\n params: CfParameters;\n}\n\n/** Address byte length per encoded-address tag (EncodedAddress enum: Eth, Dot, Btc, Arb, Sol, Hub, Tron …). */\nconst TAG_LEN: Record<number, number | \"vec\"> = {0: 20, 1: 32, 2: \"vec\", 3: 20, 4: 32, 5: 32, 6: 20};\n\n/** The note a Tron vault swap carries in raw_data.data. */\nexport function decodeTronNote(note: string): TronNote {\n const r = new Reader(fromHex(note));\n const outputAsset = r.u8();\n const destTag = r.u8();\n const len = TAG_LEN[destTag];\n if (len === undefined) throw new Error(`chainflip codec: unknown address tag ${destTag}`);\n const destAddress = len === \"vec\" ? r.bytes(r.compact()) : r.bytes(len);\n const ccm = r.u8() !== 0;\n if (ccm) throw new Error(\"chainflip codec: CCM swaps are not expected\");\n const paramsLen = r.compact();\n const start = r.i;\n const params = readCfParameters(r, 20);\n if (r.i - start !== paramsLen) throw new Error(`chainflip codec: cf parameters length ${r.i - start} ≠ declared ${paramsLen}`);\n r.done();\n return {outputAsset, destTag, destAddress, ccm, params};\n}\n\nconst VAULT_ABI = parseAbi([\n \"function xSwapNative(uint32 dstChain, bytes dstAddress, uint32 dstToken, bytes cfParameters) payable\",\n \"function xSwapToken(uint32 dstChain, bytes dstAddress, uint32 dstToken, address srcToken, uint256 amount, bytes cfParameters)\",\n]);\n\nexport interface EvmVaultCall {\n native: boolean;\n dstChain: number;\n dstAddress: Uint8Array;\n dstToken: number;\n srcToken: string | null;\n amount: bigint | null;\n params: CfParameters;\n}\n\nexport function decodeEvmVaultCall(data: string): EvmVaultCall {\n const d = decodeFunctionData({abi: VAULT_ABI, data: data as Hex});\n if (d.functionName === \"xSwapNative\") {\n const [dstChain, dstAddress, dstToken, cf] = d.args;\n return {native: true, dstChain, dstAddress: fromHex(dstAddress), dstToken, srcToken: null, amount: null, params: decodeCfParameters(fromHex(cf), 20)};\n }\n const [dstChain, dstAddress, dstToken, srcToken, amount, cf] = d.args;\n return {native: false, dstChain, dstAddress: fromHex(dstAddress), dstToken, srcToken, amount, params: decodeCfParameters(fromHex(cf), 20)};\n}\n\n/** Tron base58check `T…` ↔ the 20 raw bytes Chainflip encodes (0x41 prefix dropped). */\nexport function tronToBytes(address: string): Uint8Array {\n const b = base58.decode(address);\n if (b.length !== 25 || b[0] !== 0x41) throw new Error(`not a Tron address: ${address}`);\n const check = sha256(sha256(b.subarray(0, 21))).subarray(0, 4);\n if (toHex(check) !== toHex(b.subarray(21))) throw new Error(`bad Tron checksum: ${address}`);\n return b.subarray(1, 21);\n}\n\n/** The raw bytes a destination address is encoded with, per destination chain (EVM / Tron 20, Solana 32, BTC ASCII). */\nexport function destAddressBytes(chain: string, address: string): Uint8Array {\n if (chain.startsWith(\"eip155:\")) return fromHex(address);\n if (chain.startsWith(\"tron:\")) return tronToBytes(address);\n if (chain.startsWith(\"solana:\")) { const b = base58.decode(address); if (b.length !== 32) throw new Error(`not a Solana address: ${address}`); return b; }\n if (chain.startsWith(\"bitcoin:\")) return new TextEncoder().encode(address);\n throw new Error(`chainflip: no address encoding for ${chain}`);\n}\n\nexport const sameBytes = (a: Uint8Array, b: Uint8Array) => a.length === b.length && a.every((x, i) => x === b[i]);\n\n/** minPriceX128 for a guaranteed output: ceil(minOut × 2^128 / amountIn) (base units on both sides carry the decimals). */\nexport function minPriceX128For(amountIn: bigint, minOut: bigint): bigint {\n return (minOut * 2n ** 128n + amountIn - 1n) / amountIn;\n}\n/** The output a min price guarantees for `amountIn` (floor). */\nexport function minOutOf(amountIn: bigint, minPriceX128: bigint): bigint {\n return (amountIn * minPriceX128) / 2n ** 128n;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,kBAAqB;AACrB,kBAAqB;AACrB,kBAAqD;AAiBr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AM,sCAAsC,KAAK,EAAE;AAC/D;AAEO,IAAM,YAAY,CAAC,GAAe,MAAkB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,MAAM,MAAM,EAAE,CAAC,CAAC;AAGzG,SAAS,gBAAgB,UAAkB,QAAwB;AACxE,UAAQ,SAAS,MAAM,OAAO,WAAW,MAAM;AACjD;AAEO,SAAS,SAAS,UAAkB,cAA8B;AACvE,SAAQ,WAAW,eAAgB,MAAM;AAC3C;","names":["dstChain","dstAddress","dstToken","cf"]}
|
package/dist/codec.d.cts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
|
+
|
|
3
|
+
interface CfParameters {
|
|
4
|
+
version: number;
|
|
5
|
+
retryDurationBlocks: number;
|
|
6
|
+
/** raw refund address bytes (20 for EVM / Tron, 32 for Solana) as 0x-hex */
|
|
7
|
+
refundAddress: Hex;
|
|
8
|
+
/** minimum output price × 2^128, scaled by 10^(destDecimals − srcDecimals) */
|
|
9
|
+
minPriceX128: bigint;
|
|
10
|
+
refundCcm: boolean;
|
|
11
|
+
maxOraclePriceSlippageBps: number | null;
|
|
12
|
+
dca: {
|
|
13
|
+
chunks: number;
|
|
14
|
+
intervalBlocks: number;
|
|
15
|
+
} | null;
|
|
16
|
+
boostFeeBps: number;
|
|
17
|
+
broker: {
|
|
18
|
+
account: Hex;
|
|
19
|
+
feeBps: number;
|
|
20
|
+
};
|
|
21
|
+
affiliates: {
|
|
22
|
+
account: number;
|
|
23
|
+
feeBps: number;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
declare const toHex: (b: Uint8Array) => Hex;
|
|
27
|
+
declare function fromHex(h: string): Uint8Array;
|
|
28
|
+
/** VersionedCfParameters V1. `refundLen` = 20 for EVM / Tron sources, 32 for Solana. */
|
|
29
|
+
declare function decodeCfParameters(bytes: Uint8Array, refundLen: 20 | 32): CfParameters;
|
|
30
|
+
interface TronNote {
|
|
31
|
+
outputAsset: number;
|
|
32
|
+
/** EncodedAddress variant of the destination (Eth 0, Dot 1, Btc 2, Arb 3, Sol 4, Hub 5, Tron 6) and its raw bytes */
|
|
33
|
+
destTag: number;
|
|
34
|
+
destAddress: Uint8Array;
|
|
35
|
+
ccm: boolean;
|
|
36
|
+
params: CfParameters;
|
|
37
|
+
}
|
|
38
|
+
/** The note a Tron vault swap carries in raw_data.data. */
|
|
39
|
+
declare function decodeTronNote(note: string): TronNote;
|
|
40
|
+
interface EvmVaultCall {
|
|
41
|
+
native: boolean;
|
|
42
|
+
dstChain: number;
|
|
43
|
+
dstAddress: Uint8Array;
|
|
44
|
+
dstToken: number;
|
|
45
|
+
srcToken: string | null;
|
|
46
|
+
amount: bigint | null;
|
|
47
|
+
params: CfParameters;
|
|
48
|
+
}
|
|
49
|
+
declare function decodeEvmVaultCall(data: string): EvmVaultCall;
|
|
50
|
+
/** Tron base58check `T…` ↔ the 20 raw bytes Chainflip encodes (0x41 prefix dropped). */
|
|
51
|
+
declare function tronToBytes(address: string): Uint8Array;
|
|
52
|
+
/** The raw bytes a destination address is encoded with, per destination chain (EVM / Tron 20, Solana 32, BTC ASCII). */
|
|
53
|
+
declare function destAddressBytes(chain: string, address: string): Uint8Array;
|
|
54
|
+
declare const sameBytes: (a: Uint8Array, b: Uint8Array) => boolean;
|
|
55
|
+
/** minPriceX128 for a guaranteed output: ceil(minOut × 2^128 / amountIn) (base units on both sides carry the decimals). */
|
|
56
|
+
declare function minPriceX128For(amountIn: bigint, minOut: bigint): bigint;
|
|
57
|
+
/** The output a min price guarantees for `amountIn` (floor). */
|
|
58
|
+
declare function minOutOf(amountIn: bigint, minPriceX128: bigint): bigint;
|
|
59
|
+
|
|
60
|
+
export { type CfParameters, type EvmVaultCall, type TronNote, decodeCfParameters, decodeEvmVaultCall, decodeTronNote, destAddressBytes, fromHex, minOutOf, minPriceX128For, sameBytes, toHex, tronToBytes };
|
package/dist/codec.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
|
+
|
|
3
|
+
interface CfParameters {
|
|
4
|
+
version: number;
|
|
5
|
+
retryDurationBlocks: number;
|
|
6
|
+
/** raw refund address bytes (20 for EVM / Tron, 32 for Solana) as 0x-hex */
|
|
7
|
+
refundAddress: Hex;
|
|
8
|
+
/** minimum output price × 2^128, scaled by 10^(destDecimals − srcDecimals) */
|
|
9
|
+
minPriceX128: bigint;
|
|
10
|
+
refundCcm: boolean;
|
|
11
|
+
maxOraclePriceSlippageBps: number | null;
|
|
12
|
+
dca: {
|
|
13
|
+
chunks: number;
|
|
14
|
+
intervalBlocks: number;
|
|
15
|
+
} | null;
|
|
16
|
+
boostFeeBps: number;
|
|
17
|
+
broker: {
|
|
18
|
+
account: Hex;
|
|
19
|
+
feeBps: number;
|
|
20
|
+
};
|
|
21
|
+
affiliates: {
|
|
22
|
+
account: number;
|
|
23
|
+
feeBps: number;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
declare const toHex: (b: Uint8Array) => Hex;
|
|
27
|
+
declare function fromHex(h: string): Uint8Array;
|
|
28
|
+
/** VersionedCfParameters V1. `refundLen` = 20 for EVM / Tron sources, 32 for Solana. */
|
|
29
|
+
declare function decodeCfParameters(bytes: Uint8Array, refundLen: 20 | 32): CfParameters;
|
|
30
|
+
interface TronNote {
|
|
31
|
+
outputAsset: number;
|
|
32
|
+
/** EncodedAddress variant of the destination (Eth 0, Dot 1, Btc 2, Arb 3, Sol 4, Hub 5, Tron 6) and its raw bytes */
|
|
33
|
+
destTag: number;
|
|
34
|
+
destAddress: Uint8Array;
|
|
35
|
+
ccm: boolean;
|
|
36
|
+
params: CfParameters;
|
|
37
|
+
}
|
|
38
|
+
/** The note a Tron vault swap carries in raw_data.data. */
|
|
39
|
+
declare function decodeTronNote(note: string): TronNote;
|
|
40
|
+
interface EvmVaultCall {
|
|
41
|
+
native: boolean;
|
|
42
|
+
dstChain: number;
|
|
43
|
+
dstAddress: Uint8Array;
|
|
44
|
+
dstToken: number;
|
|
45
|
+
srcToken: string | null;
|
|
46
|
+
amount: bigint | null;
|
|
47
|
+
params: CfParameters;
|
|
48
|
+
}
|
|
49
|
+
declare function decodeEvmVaultCall(data: string): EvmVaultCall;
|
|
50
|
+
/** Tron base58check `T…` ↔ the 20 raw bytes Chainflip encodes (0x41 prefix dropped). */
|
|
51
|
+
declare function tronToBytes(address: string): Uint8Array;
|
|
52
|
+
/** The raw bytes a destination address is encoded with, per destination chain (EVM / Tron 20, Solana 32, BTC ASCII). */
|
|
53
|
+
declare function destAddressBytes(chain: string, address: string): Uint8Array;
|
|
54
|
+
declare const sameBytes: (a: Uint8Array, b: Uint8Array) => boolean;
|
|
55
|
+
/** minPriceX128 for a guaranteed output: ceil(minOut × 2^128 / amountIn) (base units on both sides carry the decimals). */
|
|
56
|
+
declare function minPriceX128For(amountIn: bigint, minOut: bigint): bigint;
|
|
57
|
+
/** The output a min price guarantees for `amountIn` (floor). */
|
|
58
|
+
declare function minOutOf(amountIn: bigint, minPriceX128: bigint): bigint;
|
|
59
|
+
|
|
60
|
+
export { type CfParameters, type EvmVaultCall, type TronNote, decodeCfParameters, decodeEvmVaultCall, decodeTronNote, destAddressBytes, fromHex, minOutOf, minPriceX128For, sameBytes, toHex, tronToBytes };
|
package/dist/codec.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeCfParameters,
|
|
3
|
+
decodeEvmVaultCall,
|
|
4
|
+
decodeTronNote,
|
|
5
|
+
destAddressBytes,
|
|
6
|
+
fromHex,
|
|
7
|
+
minOutOf,
|
|
8
|
+
minPriceX128For,
|
|
9
|
+
sameBytes,
|
|
10
|
+
toHex,
|
|
11
|
+
tronToBytes
|
|
12
|
+
} from "./chunk-R6EYDH5N.js";
|
|
13
|
+
export {
|
|
14
|
+
decodeCfParameters,
|
|
15
|
+
decodeEvmVaultCall,
|
|
16
|
+
decodeTronNote,
|
|
17
|
+
destAddressBytes,
|
|
18
|
+
fromHex,
|
|
19
|
+
minOutOf,
|
|
20
|
+
minPriceX128For,
|
|
21
|
+
sameBytes,
|
|
22
|
+
toHex,
|
|
23
|
+
tronToBytes
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
CF_API_DEFAULT: () => CF_API_DEFAULT,
|
|
24
|
+
CF_ASSETS: () => CF_ASSETS,
|
|
25
|
+
CF_CHAINS: () => CF_CHAINS,
|
|
26
|
+
CF_SOURCE_CHAINS: () => CF_SOURCE_CHAINS,
|
|
27
|
+
CF_VAULTS: () => CF_VAULTS,
|
|
28
|
+
cfAsset: () => cfAsset,
|
|
29
|
+
chainflip: () => chainflip
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(config_exports);
|
|
32
|
+
var CF_CHAINS = {
|
|
33
|
+
"eip155:1": { name: "Ethereum", id: 1, addrTag: 0 },
|
|
34
|
+
"bitcoin:mainnet": { name: "Bitcoin", id: 3, addrTag: 2 },
|
|
35
|
+
"eip155:42161": { name: "Arbitrum", id: 4, addrTag: 3 },
|
|
36
|
+
"solana:mainnet": { name: "Solana", id: 5, addrTag: 4 },
|
|
37
|
+
"tron:728126428": { name: "Tron", id: 7, addrTag: 6 }
|
|
38
|
+
};
|
|
39
|
+
var CF_ASSETS = [
|
|
40
|
+
{ chain: "Ethereum", asset: "ETH", id: 1, decimals: 18, token: null, minDeposit: 10n ** 16n },
|
|
41
|
+
{ chain: "Ethereum", asset: "USDC", id: 3, decimals: 6, token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", minDeposit: 20000000n },
|
|
42
|
+
{ chain: "Ethereum", asset: "USDT", id: 8, decimals: 6, token: "0xdAC17F958D2ee523a2206206994597C13D831ec7", minDeposit: 20000000n },
|
|
43
|
+
{ chain: "Ethereum", asset: "WBTC", id: 14, decimals: 8, token: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", minDeposit: 40000n },
|
|
44
|
+
{ chain: "Bitcoin", asset: "BTC", id: 5, decimals: 8, token: null, minDeposit: 40000n },
|
|
45
|
+
{ chain: "Arbitrum", asset: "ETH", id: 6, decimals: 18, token: null, minDeposit: 3900000000000000n },
|
|
46
|
+
{ chain: "Arbitrum", asset: "USDC", id: 7, decimals: 6, token: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", minDeposit: 10000000n },
|
|
47
|
+
{ chain: "Arbitrum", asset: "USDT", id: 15, decimals: 6, token: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", minDeposit: 10000000n },
|
|
48
|
+
{ chain: "Solana", asset: "SOL", id: 9, decimals: 9, token: null, minDeposit: 68000000n },
|
|
49
|
+
{ chain: "Solana", asset: "USDC", id: 10, decimals: 6, token: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", minDeposit: 10000000n },
|
|
50
|
+
{ chain: "Solana", asset: "USDT", id: 16, decimals: 6, token: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", minDeposit: 10000000n },
|
|
51
|
+
{ chain: "Tron", asset: "TRX", id: 17, decimals: 6, token: null, minDeposit: 30000000n },
|
|
52
|
+
{ chain: "Tron", asset: "USDT", id: 18, decimals: 6, token: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", minDeposit: 10000000n }
|
|
53
|
+
];
|
|
54
|
+
var CF_VAULTS = {
|
|
55
|
+
"eip155:1": "0xF5e10380213880111522dd0efD3dbb45b9f62Bcc",
|
|
56
|
+
"eip155:42161": "0x79001a5e762f3bEFC8e5871b42F6734e00498920",
|
|
57
|
+
"tron:728126428": "TEcDijvKSXcfWT7S6rd44H5vNgufm7Y4XC"
|
|
58
|
+
};
|
|
59
|
+
var CF_SOURCE_CHAINS = /* @__PURE__ */ new Set(["eip155:1", "eip155:42161", "tron:728126428"]);
|
|
60
|
+
var CF_API_DEFAULT = "https://chainflip-swap.chainflip.io";
|
|
61
|
+
var sameToken = (chain, a, b) => chain.startsWith("eip155:") ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
62
|
+
var NATIVE = /* @__PURE__ */ new Set(["", "native", "0x0000000000000000000000000000000000000000"]);
|
|
63
|
+
function cfAsset(chain, token) {
|
|
64
|
+
const c = CF_CHAINS[chain];
|
|
65
|
+
if (!c) return void 0;
|
|
66
|
+
const on = CF_ASSETS.filter((a) => a.chain === c.name);
|
|
67
|
+
if (NATIVE.has(token.toLowerCase())) return on.find((a) => a.token === null);
|
|
68
|
+
return on.find((a) => a.token !== null && sameToken(chain, a.token, token) || a.asset === token.toUpperCase());
|
|
69
|
+
}
|
|
70
|
+
var chainflip = {
|
|
71
|
+
supportsChain: (chain) => !!CF_CHAINS[chain],
|
|
72
|
+
supports: (from, to) => CF_SOURCE_CHAINS.has(from) && !!CF_CHAINS[to] && from !== to
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["/**\n * Chainflip (JIT-AMM state chain) — chains, assets and contracts as the public backend and the vault encodings name them.\n * Asset ids, chain ids and decimals are the protocol's own (`cf_environment` / networkInfo, verified 2026-10-20); the\n * contract addresses are Chainflip's mainnet deployments (docs mainnet-addresses, confirmed by live encodings).\n *\n * Only VAULT SWAPS are offered: the donor signs a transaction whose every Chainflip parameter (destination, minimum price,\n * refund address) is decoded and checked locally before signing — no off-chain deposit channel to trust, and on Tron no\n * 3.4 USDT ingress fee. Sources: EVM (Ethereum, Arbitrum) and Tron in this release; Solana / Bitcoin vault swaps need an\n * instruction / OP_RETURN builder and come next. Destinations: every live chain.\n */\nexport type CfChain = \"Ethereum\" | \"Bitcoin\" | \"Arbitrum\" | \"Solana\" | \"Tron\";\n\nexport interface CfAsset {\n chain: CfChain;\n /** the API's asset symbol */\n asset: string;\n /** the u32 asset id inside vault encodings */\n id: number;\n decimals: number;\n /** token contract / mint on its chain, null for the native coin */\n token: string | null;\n /** smallest deposit the state chain accepts (base units) */\n minDeposit: bigint;\n}\n\n/**\n * CAIP-2 → Chainflip chain: `id` = the ForeignChain number an EVM vault call names (`dstChain`), `addrTag` = the\n * EncodedAddress variant a Tron note names (Eth 0, Dot 1, Btc 2, Arb 3, Sol 4, Hub 5, Tron 6) — two different enums.\n */\nexport const CF_CHAINS: Readonly<Record<string, {name: CfChain; id: number; addrTag: number}>> = {\n \"eip155:1\": {name: \"Ethereum\", id: 1, addrTag: 0},\n \"bitcoin:mainnet\": {name: \"Bitcoin\", id: 3, addrTag: 2},\n \"eip155:42161\": {name: \"Arbitrum\", id: 4, addrTag: 3},\n \"solana:mainnet\": {name: \"Solana\", id: 5, addrTag: 4},\n \"tron:728126428\": {name: \"Tron\", id: 7, addrTag: 6},\n};\n\nexport const CF_ASSETS: readonly CfAsset[] = [\n {chain: \"Ethereum\", asset: \"ETH\", id: 1, decimals: 18, token: null, minDeposit: 10n ** 16n},\n {chain: \"Ethereum\", asset: \"USDC\", id: 3, decimals: 6, token: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\", minDeposit: 20_000_000n},\n {chain: \"Ethereum\", asset: \"USDT\", id: 8, decimals: 6, token: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\", minDeposit: 20_000_000n},\n {chain: \"Ethereum\", asset: \"WBTC\", id: 14, decimals: 8, token: \"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599\", minDeposit: 40_000n},\n {chain: \"Bitcoin\", asset: \"BTC\", id: 5, decimals: 8, token: null, minDeposit: 40_000n},\n {chain: \"Arbitrum\", asset: \"ETH\", id: 6, decimals: 18, token: null, minDeposit: 3_900_000_000_000_000n},\n {chain: \"Arbitrum\", asset: \"USDC\", id: 7, decimals: 6, token: \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\", minDeposit: 10_000_000n},\n {chain: \"Arbitrum\", asset: \"USDT\", id: 15, decimals: 6, token: \"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9\", minDeposit: 10_000_000n},\n {chain: \"Solana\", asset: \"SOL\", id: 9, decimals: 9, token: null, minDeposit: 68_000_000n},\n {chain: \"Solana\", asset: \"USDC\", id: 10, decimals: 6, token: \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\", minDeposit: 10_000_000n},\n {chain: \"Solana\", asset: \"USDT\", id: 16, decimals: 6, token: \"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB\", minDeposit: 10_000_000n},\n {chain: \"Tron\", asset: \"TRX\", id: 17, decimals: 6, token: null, minDeposit: 30_000_000n},\n {chain: \"Tron\", asset: \"USDT\", id: 18, decimals: 6, token: \"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t\", minDeposit: 10_000_000n},\n];\n\n/** Vault contracts that receive vault swaps (the deposit transaction's target). */\nexport const CF_VAULTS: Readonly<Record<string, string>> = {\n \"eip155:1\": \"0xF5e10380213880111522dd0efD3dbb45b9f62Bcc\",\n \"eip155:42161\": \"0x79001a5e762f3bEFC8e5871b42F6734e00498920\",\n \"tron:728126428\": \"TEcDijvKSXcfWT7S6rd44H5vNgufm7Y4XC\",\n};\n\n/** Sources this release signs (vault swaps the engine can execute and the verifier can decode). */\nexport const CF_SOURCE_CHAINS = new Set([\"eip155:1\", \"eip155:42161\", \"tron:728126428\"]);\n\nexport const CF_API_DEFAULT = \"https://chainflip-swap.chainflip.io\";\n\nconst sameToken = (chain: string, a: string, b: string) => (chain.startsWith(\"eip155:\") ? a.toLowerCase() === b.toLowerCase() : a === b);\nconst NATIVE = new Set([\"\", \"native\", \"0x0000000000000000000000000000000000000000\"]);\n\n/** The Chainflip asset for a CAIP-2 chain + token (contract / mint, a native marker, or the asset symbol). */\nexport function cfAsset(chain: string, token: string): CfAsset | undefined {\n const c = CF_CHAINS[chain];\n if (!c) return undefined;\n const on = CF_ASSETS.filter((a) => a.chain === c.name);\n if (NATIVE.has(token.toLowerCase())) return on.find((a) => a.token === null);\n return on.find((a) => (a.token !== null && sameToken(chain, a.token, token)) || a.asset === token.toUpperCase());\n}\n\nexport const chainflip = {\n supportsChain: (chain: string) => !!CF_CHAINS[chain],\n supports: (from: string, to: string) => CF_SOURCE_CHAINS.has(from) && !!CF_CHAINS[to] && from !== to,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BO,IAAM,YAAoF;AAAA,EAC/F,YAAY,EAAC,MAAM,YAAY,IAAI,GAAG,SAAS,EAAC;AAAA,EAChD,mBAAmB,EAAC,MAAM,WAAW,IAAI,GAAG,SAAS,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them.
|
|
3
|
+
* Asset ids, chain ids and decimals are the protocol's own (`cf_environment` / networkInfo, verified 2026-10-20); the
|
|
4
|
+
* contract addresses are Chainflip's mainnet deployments (docs mainnet-addresses, confirmed by live encodings).
|
|
5
|
+
*
|
|
6
|
+
* Only VAULT SWAPS are offered: the donor signs a transaction whose every Chainflip parameter (destination, minimum price,
|
|
7
|
+
* refund address) is decoded and checked locally before signing — no off-chain deposit channel to trust, and on Tron no
|
|
8
|
+
* 3.4 USDT ingress fee. Sources: EVM (Ethereum, Arbitrum) and Tron in this release; Solana / Bitcoin vault swaps need an
|
|
9
|
+
* instruction / OP_RETURN builder and come next. Destinations: every live chain.
|
|
10
|
+
*/
|
|
11
|
+
type CfChain = "Ethereum" | "Bitcoin" | "Arbitrum" | "Solana" | "Tron";
|
|
12
|
+
interface CfAsset {
|
|
13
|
+
chain: CfChain;
|
|
14
|
+
/** the API's asset symbol */
|
|
15
|
+
asset: string;
|
|
16
|
+
/** the u32 asset id inside vault encodings */
|
|
17
|
+
id: number;
|
|
18
|
+
decimals: number;
|
|
19
|
+
/** token contract / mint on its chain, null for the native coin */
|
|
20
|
+
token: string | null;
|
|
21
|
+
/** smallest deposit the state chain accepts (base units) */
|
|
22
|
+
minDeposit: bigint;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* CAIP-2 → Chainflip chain: `id` = the ForeignChain number an EVM vault call names (`dstChain`), `addrTag` = the
|
|
26
|
+
* EncodedAddress variant a Tron note names (Eth 0, Dot 1, Btc 2, Arb 3, Sol 4, Hub 5, Tron 6) — two different enums.
|
|
27
|
+
*/
|
|
28
|
+
declare const CF_CHAINS: Readonly<Record<string, {
|
|
29
|
+
name: CfChain;
|
|
30
|
+
id: number;
|
|
31
|
+
addrTag: number;
|
|
32
|
+
}>>;
|
|
33
|
+
declare const CF_ASSETS: readonly CfAsset[];
|
|
34
|
+
/** Vault contracts that receive vault swaps (the deposit transaction's target). */
|
|
35
|
+
declare const CF_VAULTS: Readonly<Record<string, string>>;
|
|
36
|
+
/** Sources this release signs (vault swaps the engine can execute and the verifier can decode). */
|
|
37
|
+
declare const CF_SOURCE_CHAINS: Set<string>;
|
|
38
|
+
declare const CF_API_DEFAULT = "https://chainflip-swap.chainflip.io";
|
|
39
|
+
/** The Chainflip asset for a CAIP-2 chain + token (contract / mint, a native marker, or the asset symbol). */
|
|
40
|
+
declare function cfAsset(chain: string, token: string): CfAsset | undefined;
|
|
41
|
+
declare const chainflip: {
|
|
42
|
+
supportsChain: (chain: string) => boolean;
|
|
43
|
+
supports: (from: string, to: string) => boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { CF_API_DEFAULT, CF_ASSETS, CF_CHAINS, CF_SOURCE_CHAINS, CF_VAULTS, type CfAsset, type CfChain, cfAsset, chainflip };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chainflip (JIT-AMM state chain) — chains, assets and contracts as the public backend and the vault encodings name them.
|
|
3
|
+
* Asset ids, chain ids and decimals are the protocol's own (`cf_environment` / networkInfo, verified 2026-10-20); the
|
|
4
|
+
* contract addresses are Chainflip's mainnet deployments (docs mainnet-addresses, confirmed by live encodings).
|
|
5
|
+
*
|
|
6
|
+
* Only VAULT SWAPS are offered: the donor signs a transaction whose every Chainflip parameter (destination, minimum price,
|
|
7
|
+
* refund address) is decoded and checked locally before signing — no off-chain deposit channel to trust, and on Tron no
|
|
8
|
+
* 3.4 USDT ingress fee. Sources: EVM (Ethereum, Arbitrum) and Tron in this release; Solana / Bitcoin vault swaps need an
|
|
9
|
+
* instruction / OP_RETURN builder and come next. Destinations: every live chain.
|
|
10
|
+
*/
|
|
11
|
+
type CfChain = "Ethereum" | "Bitcoin" | "Arbitrum" | "Solana" | "Tron";
|
|
12
|
+
interface CfAsset {
|
|
13
|
+
chain: CfChain;
|
|
14
|
+
/** the API's asset symbol */
|
|
15
|
+
asset: string;
|
|
16
|
+
/** the u32 asset id inside vault encodings */
|
|
17
|
+
id: number;
|
|
18
|
+
decimals: number;
|
|
19
|
+
/** token contract / mint on its chain, null for the native coin */
|
|
20
|
+
token: string | null;
|
|
21
|
+
/** smallest deposit the state chain accepts (base units) */
|
|
22
|
+
minDeposit: bigint;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* CAIP-2 → Chainflip chain: `id` = the ForeignChain number an EVM vault call names (`dstChain`), `addrTag` = the
|
|
26
|
+
* EncodedAddress variant a Tron note names (Eth 0, Dot 1, Btc 2, Arb 3, Sol 4, Hub 5, Tron 6) — two different enums.
|
|
27
|
+
*/
|
|
28
|
+
declare const CF_CHAINS: Readonly<Record<string, {
|
|
29
|
+
name: CfChain;
|
|
30
|
+
id: number;
|
|
31
|
+
addrTag: number;
|
|
32
|
+
}>>;
|
|
33
|
+
declare const CF_ASSETS: readonly CfAsset[];
|
|
34
|
+
/** Vault contracts that receive vault swaps (the deposit transaction's target). */
|
|
35
|
+
declare const CF_VAULTS: Readonly<Record<string, string>>;
|
|
36
|
+
/** Sources this release signs (vault swaps the engine can execute and the verifier can decode). */
|
|
37
|
+
declare const CF_SOURCE_CHAINS: Set<string>;
|
|
38
|
+
declare const CF_API_DEFAULT = "https://chainflip-swap.chainflip.io";
|
|
39
|
+
/** The Chainflip asset for a CAIP-2 chain + token (contract / mint, a native marker, or the asset symbol). */
|
|
40
|
+
declare function cfAsset(chain: string, token: string): CfAsset | undefined;
|
|
41
|
+
declare const chainflip: {
|
|
42
|
+
supportsChain: (chain: string) => boolean;
|
|
43
|
+
supports: (from: string, to: string) => boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { CF_API_DEFAULT, CF_ASSETS, CF_CHAINS, CF_SOURCE_CHAINS, CF_VAULTS, type CfAsset, type CfChain, cfAsset, chainflip };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CF_API_DEFAULT,
|
|
3
|
+
CF_ASSETS,
|
|
4
|
+
CF_CHAINS,
|
|
5
|
+
CF_SOURCE_CHAINS,
|
|
6
|
+
CF_VAULTS,
|
|
7
|
+
cfAsset,
|
|
8
|
+
chainflip
|
|
9
|
+
} from "./chunk-GXHOO3CT.js";
|
|
10
|
+
export {
|
|
11
|
+
CF_API_DEFAULT,
|
|
12
|
+
CF_ASSETS,
|
|
13
|
+
CF_CHAINS,
|
|
14
|
+
CF_SOURCE_CHAINS,
|
|
15
|
+
CF_VAULTS,
|
|
16
|
+
cfAsset,
|
|
17
|
+
chainflip
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|