@rabby-wallet/rabby-bridge 0.0.13 → 0.0.14-alpha.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/README.md +163 -1
- package/dist/calldata/abi.d.ts +29 -0
- package/dist/calldata/abi.js +160 -0
- package/dist/calldata/across/deposit.d.ts +2 -0
- package/dist/calldata/across/deposit.js +36 -0
- package/dist/calldata/across/depositNative.d.ts +2 -0
- package/dist/calldata/across/depositNative.js +45 -0
- package/dist/calldata/across/depositNow.d.ts +2 -0
- package/dist/calldata/across/depositNow.js +35 -0
- package/dist/calldata/across/depositV3.d.ts +2 -0
- package/dist/calldata/across/depositV3.js +35 -0
- package/dist/calldata/across/depositV3Now.d.ts +2 -0
- package/dist/calldata/across/depositV3Now.js +34 -0
- package/dist/calldata/across/index.d.ts +4 -0
- package/dist/calldata/across/index.js +31 -0
- package/dist/calldata/across/swapAndBridge.d.ts +2 -0
- package/dist/calldata/across/swapAndBridge.js +70 -0
- package/dist/calldata/across/validate.d.ts +3 -0
- package/dist/calldata/across/validate.js +34 -0
- package/dist/calldata/chains.d.ts +2 -0
- package/dist/calldata/chains.js +36 -0
- package/dist/calldata/destination.d.ts +6 -0
- package/dist/calldata/destination.js +227 -0
- package/dist/calldata/destinationSwap.d.ts +14 -0
- package/dist/calldata/destinationSwap.js +83 -0
- package/dist/calldata/destinationUniswap.d.ts +7 -0
- package/dist/calldata/destinationUniswap.js +57 -0
- package/dist/calldata/diagnostics.d.ts +4 -0
- package/dist/calldata/diagnostics.js +18 -0
- package/dist/calldata/expect.d.ts +29 -0
- package/dist/calldata/expect.js +157 -0
- package/dist/calldata/hex.d.ts +6 -0
- package/dist/calldata/hex.js +46 -0
- package/dist/calldata/index.d.ts +20 -0
- package/dist/calldata/index.js +88 -0
- package/dist/calldata/lifi/across/acrossV4Erc20Min.d.ts +2 -0
- package/dist/calldata/lifi/across/acrossV4Erc20Min.js +27 -0
- package/dist/calldata/lifi/across/acrossV4NativeMin.d.ts +2 -0
- package/dist/calldata/lifi/across/acrossV4NativeMin.js +23 -0
- package/dist/calldata/lifi/across/index.d.ts +6 -0
- package/dist/calldata/lifi/across/index.js +19 -0
- package/dist/calldata/lifi/allbridge/index.d.ts +3 -0
- package/dist/calldata/lifi/allbridge/index.js +26 -0
- package/dist/calldata/lifi/celer/index.d.ts +4 -0
- package/dist/calldata/lifi/celer/index.js +10 -0
- package/dist/calldata/lifi/centrifuge/index.d.ts +3 -0
- package/dist/calldata/lifi/centrifuge/index.js +22 -0
- package/dist/calldata/lifi/destination.d.ts +5 -0
- package/dist/calldata/lifi/destination.js +40 -0
- package/dist/calldata/lifi/frax/index.d.ts +4 -0
- package/dist/calldata/lifi/frax/index.js +29 -0
- package/dist/calldata/lifi/garden/index.d.ts +3 -0
- package/dist/calldata/lifi/garden/index.js +22 -0
- package/dist/calldata/lifi/gaszip/index.d.ts +6 -0
- package/dist/calldata/lifi/gaszip/index.js +15 -0
- package/dist/calldata/lifi/index.d.ts +4 -0
- package/dist/calldata/lifi/index.js +62 -0
- package/dist/calldata/lifi/intents/index.d.ts +4 -0
- package/dist/calldata/lifi/intents/index.js +10 -0
- package/dist/calldata/lifi/layerswap/index.d.ts +4 -0
- package/dist/calldata/lifi/layerswap/index.js +10 -0
- package/dist/calldata/lifi/m0/index.d.ts +3 -0
- package/dist/calldata/lifi/m0/index.js +33 -0
- package/dist/calldata/lifi/mayan/index.d.ts +4 -0
- package/dist/calldata/lifi/mayan/index.js +10 -0
- package/dist/calldata/lifi/method.d.ts +6 -0
- package/dist/calldata/lifi/method.js +16 -0
- package/dist/calldata/lifi/native/index.d.ts +4 -0
- package/dist/calldata/lifi/native/index.js +80 -0
- package/dist/calldata/lifi/params.d.ts +28 -0
- package/dist/calldata/lifi/params.js +349 -0
- package/dist/calldata/lifi/paxos/index.d.ts +4 -0
- package/dist/calldata/lifi/paxos/index.js +10 -0
- package/dist/calldata/lifi/polymer/index.d.ts +4 -0
- package/dist/calldata/lifi/polymer/index.js +10 -0
- package/dist/calldata/lifi/relay/index.d.ts +6 -0
- package/dist/calldata/lifi/relay/index.js +15 -0
- package/dist/calldata/lifi/shape.d.ts +4 -0
- package/dist/calldata/lifi/shape.js +31 -0
- package/dist/calldata/lifi/squid/index.d.ts +6 -0
- package/dist/calldata/lifi/squid/index.js +15 -0
- package/dist/calldata/lifi/stargate/index.d.ts +5 -0
- package/dist/calldata/lifi/stargate/index.js +15 -0
- package/dist/calldata/lifi/swap/index.d.ts +5 -0
- package/dist/calldata/lifi/swap/index.js +18 -0
- package/dist/calldata/lifi/swap/swapMethod.d.ts +2 -0
- package/dist/calldata/lifi/swap/swapMethod.js +40 -0
- package/dist/calldata/lifi/swapData.d.ts +5 -0
- package/dist/calldata/lifi/swapData.js +33 -0
- package/dist/calldata/match.d.ts +3 -0
- package/dist/calldata/match.js +21 -0
- package/dist/calldata/mayan/destination.d.ts +2 -0
- package/dist/calldata/mayan/destination.js +13 -0
- package/dist/calldata/mayan/fastMctpBridge.d.ts +3 -0
- package/dist/calldata/mayan/fastMctpBridge.js +48 -0
- package/dist/calldata/mayan/fastMctpCreateOrder.d.ts +3 -0
- package/dist/calldata/mayan/fastMctpCreateOrder.js +39 -0
- package/dist/calldata/mayan/forward.d.ts +8 -0
- package/dist/calldata/mayan/forward.js +35 -0
- package/dist/calldata/mayan/forwardERC20.d.ts +2 -0
- package/dist/calldata/mayan/forwardERC20.js +19 -0
- package/dist/calldata/mayan/forwardEth.d.ts +2 -0
- package/dist/calldata/mayan/forwardEth.js +16 -0
- package/dist/calldata/mayan/index.d.ts +4 -0
- package/dist/calldata/mayan/index.js +21 -0
- package/dist/calldata/mayan/mctp.d.ts +5 -0
- package/dist/calldata/mayan/mctp.js +41 -0
- package/dist/calldata/mayan/readProtocol.d.ts +2 -0
- package/dist/calldata/mayan/readProtocol.js +29 -0
- package/dist/calldata/mayan/swapAndForwardERC20.d.ts +2 -0
- package/dist/calldata/mayan/swapAndForwardERC20.js +24 -0
- package/dist/calldata/mayan/swapAndForwardEth.d.ts +2 -0
- package/dist/calldata/mayan/swapAndForwardEth.js +23 -0
- package/dist/calldata/mayan/swiftCreateOrder.d.ts +3 -0
- package/dist/calldata/mayan/swiftCreateOrder.js +49 -0
- package/dist/calldata/mayan/validate.d.ts +3 -0
- package/dist/calldata/mayan/validate.js +20 -0
- package/dist/calldata/protocols.d.ts +9 -0
- package/dist/calldata/protocols.js +58 -0
- package/dist/calldata/relay/calls.d.ts +13 -0
- package/dist/calldata/relay/calls.js +58 -0
- package/dist/calldata/relay/depositErc20.d.ts +2 -0
- package/dist/calldata/relay/depositErc20.js +22 -0
- package/dist/calldata/relay/depositErc20Allowance.d.ts +2 -0
- package/dist/calldata/relay/depositErc20Allowance.js +20 -0
- package/dist/calldata/relay/depositNative.d.ts +2 -0
- package/dist/calldata/relay/depositNative.js +20 -0
- package/dist/calldata/relay/index.d.ts +4 -0
- package/dist/calldata/relay/index.js +45 -0
- package/dist/calldata/relay/multicall.d.ts +2 -0
- package/dist/calldata/relay/multicall.js +15 -0
- package/dist/calldata/relay/nestedDeposit.d.ts +8 -0
- package/dist/calldata/relay/nestedDeposit.js +107 -0
- package/dist/calldata/relay/permit2TransferAndMulticall.d.ts +2 -0
- package/dist/calldata/relay/permit2TransferAndMulticall.js +42 -0
- package/dist/calldata/relay/permit3009TransferAndMulticall.d.ts +2 -0
- package/dist/calldata/relay/permit3009TransferAndMulticall.js +41 -0
- package/dist/calldata/relay/permit3009TransferAndMulticallSigned.d.ts +2 -0
- package/dist/calldata/relay/permit3009TransferAndMulticallSigned.js +40 -0
- package/dist/calldata/relay/permitTransferAndMulticall.d.ts +2 -0
- package/dist/calldata/relay/permitTransferAndMulticall.js +34 -0
- package/dist/calldata/relay/permitTransferAndMulticallLegacy.d.ts +2 -0
- package/dist/calldata/relay/permitTransferAndMulticallLegacy.js +35 -0
- package/dist/calldata/relay/transferAndMulticall.d.ts +2 -0
- package/dist/calldata/relay/transferAndMulticall.js +26 -0
- package/dist/calldata/relay/validate.d.ts +3 -0
- package/dist/calldata/relay/validate.js +18 -0
- package/dist/calldata/resolve.d.ts +2 -0
- package/dist/calldata/resolve.js +28 -0
- package/dist/calldata/socket/addresses.d.ts +9 -0
- package/dist/calldata/socket/addresses.js +9 -0
- package/dist/calldata/socket/bridge.d.ts +2 -0
- package/dist/calldata/socket/bridge.js +28 -0
- package/dist/calldata/socket/exec.d.ts +2 -0
- package/dist/calldata/socket/exec.js +71 -0
- package/dist/calldata/socket/index.d.ts +4 -0
- package/dist/calldata/socket/index.js +13 -0
- package/dist/calldata/socket/params.d.ts +5 -0
- package/dist/calldata/socket/params.js +14 -0
- package/dist/calldata/socket/protocols/ccip.d.ts +2 -0
- package/dist/calldata/socket/protocols/ccip.js +32 -0
- package/dist/calldata/socket/protocols/cctp.d.ts +2 -0
- package/dist/calldata/socket/protocols/cctp.js +25 -0
- package/dist/calldata/socket/protocols/eco.d.ts +2 -0
- package/dist/calldata/socket/protocols/eco.js +49 -0
- package/dist/calldata/socket/protocols/index.d.ts +3 -0
- package/dist/calldata/socket/protocols/index.js +87 -0
- package/dist/calldata/socket/protocols/native.d.ts +2 -0
- package/dist/calldata/socket/protocols/native.js +71 -0
- package/dist/calldata/socket/protocols/oft.d.ts +2 -0
- package/dist/calldata/socket/protocols/oft.js +33 -0
- package/dist/calldata/socket/protocols/swapsXYZ.d.ts +2 -0
- package/dist/calldata/socket/protocols/swapsXYZ.js +62 -0
- package/dist/calldata/socket/swapAndBridge.d.ts +2 -0
- package/dist/calldata/socket/swapAndBridge.js +41 -0
- package/dist/calldata/socket/validate.d.ts +3 -0
- package/dist/calldata/socket/validate.js +24 -0
- package/dist/calldata/types.d.ts +86 -0
- package/dist/calldata/types.js +20 -0
- package/dist/errors/constants.d.ts +906 -0
- package/dist/errors/constants.js +913 -0
- package/dist/errors/index.d.ts +65 -0
- package/dist/errors/index.js +53 -0
- package/dist/errors/sanitize.d.ts +3 -0
- package/dist/errors/sanitize.js +74 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -0
- package/dist/providers/data.d.ts +23 -0
- package/dist/providers/data.js +116 -0
- package/dist/providers/errors.d.ts +7 -0
- package/dist/providers/errors.js +10 -0
- package/dist/providers/layerswap.d.ts +9 -0
- package/dist/providers/layerswap.js +95 -0
- package/dist/providers/relay.d.ts +62 -0
- package/dist/providers/relay.js +237 -0
- package/dist/providers/socket.d.ts +5 -0
- package/dist/providers/socket.js +58 -0
- package/dist/quote.d.ts +30 -3
- package/dist/quote.js +236 -66
- package/package.json +13 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BRIDGE_ERRORS, bridgeFailure } from '../../errors/index.js';
|
|
2
|
+
import { finishCheck } from '../expect.js';
|
|
3
|
+
import { matchMethod } from '../match.js';
|
|
4
|
+
import * as across from './across/index.js';
|
|
5
|
+
import * as allbridge from './allbridge/index.js';
|
|
6
|
+
import * as celer from './celer/index.js';
|
|
7
|
+
import * as centrifuge from './centrifuge/index.js';
|
|
8
|
+
import * as frax from './frax/index.js';
|
|
9
|
+
import * as gaszip from './gaszip/index.js';
|
|
10
|
+
import * as garden from './garden/index.js';
|
|
11
|
+
import * as intents from './intents/index.js';
|
|
12
|
+
import * as layerswap from './layerswap/index.js';
|
|
13
|
+
import * as mayan from './mayan/index.js';
|
|
14
|
+
import * as m0 from './m0/index.js';
|
|
15
|
+
import * as native from './native/index.js';
|
|
16
|
+
import * as paxos from './paxos/index.js';
|
|
17
|
+
import * as polymer from './polymer/index.js';
|
|
18
|
+
import * as relay from './relay/index.js';
|
|
19
|
+
import * as squid from './squid/index.js';
|
|
20
|
+
import * as stargate from './stargate/index.js';
|
|
21
|
+
import * as swap from './swap/index.js';
|
|
22
|
+
import { isNative } from '../protocols.js';
|
|
23
|
+
const ROUTES = [
|
|
24
|
+
across,
|
|
25
|
+
allbridge,
|
|
26
|
+
centrifuge,
|
|
27
|
+
garden,
|
|
28
|
+
m0,
|
|
29
|
+
native,
|
|
30
|
+
frax,
|
|
31
|
+
stargate,
|
|
32
|
+
intents,
|
|
33
|
+
polymer,
|
|
34
|
+
layerswap,
|
|
35
|
+
mayan,
|
|
36
|
+
celer,
|
|
37
|
+
paxos,
|
|
38
|
+
relay,
|
|
39
|
+
gaszip,
|
|
40
|
+
squid,
|
|
41
|
+
swap,
|
|
42
|
+
];
|
|
43
|
+
const METHODS = ROUTES.flatMap((route) => route.methods);
|
|
44
|
+
const routeFor = (method) => ROUTES.find((route) => route.methods.some((item) => item.name === method));
|
|
45
|
+
export const decodeLifi = (data, value) => matchMethod(METHODS, data, value);
|
|
46
|
+
export const validateLifi = (data, value, expectation, chainId = '') => {
|
|
47
|
+
const hit = decodeLifi(data, value);
|
|
48
|
+
if (!hit.ok) {
|
|
49
|
+
return { ...hit, aggregatorId: 'lifi' };
|
|
50
|
+
}
|
|
51
|
+
const route = routeFor(hit.parsed.method);
|
|
52
|
+
if (!route) {
|
|
53
|
+
return {
|
|
54
|
+
...bridgeFailure([BRIDGE_ERRORS.UNSUPPORTED_METHOD]),
|
|
55
|
+
aggregatorId: 'lifi',
|
|
56
|
+
method: hit.parsed.method,
|
|
57
|
+
parsed: hit.parsed,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return finishCheck('lifi', hit.parsed, hit.parsed.method.endsWith('ViaLayerSwap') && value !== (isNative(hit.parsed.sourceToken ?? '') ? hit.parsed.sourceAmount : 0n)
|
|
61
|
+
? BRIDGE_ERRORS.LAYERSWAP_SOURCE_VALUE_MISMATCH : route.check(hit.parsed), expectation, chainId, route.compare(hit.parsed));
|
|
62
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CalldataMethod } from '../../abi.js';
|
|
2
|
+
export declare const methods: CalldataMethod[];
|
|
3
|
+
export declare const compare: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../expect.js").CompareMask;
|
|
4
|
+
export declare const check: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../../index.js").BridgeErrorDefinition | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { knownCompare } from '../../expect.js';
|
|
2
|
+
import { bridgeShape } from '../shape.js';
|
|
3
|
+
import { lifiBridgeMethod } from '../method.js';
|
|
4
|
+
import { applyLifiIntentData, lifiIntentDataParam } from '../params.js';
|
|
5
|
+
export const methods = [
|
|
6
|
+
lifiBridgeMethod('startBridgeTokensViaLiFiIntentEscrowV2', '0x7dbcf1d9', [lifiIntentDataParam], false, (parsed, args) => applyLifiIntentData(parsed, args.lifiIntentData)),
|
|
7
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaLiFiIntentEscrowV2', '0x6d21c5df', [lifiIntentDataParam], true, (parsed, args) => applyLifiIntentData(parsed, args.lifiIntentData)),
|
|
8
|
+
];
|
|
9
|
+
export const compare = knownCompare;
|
|
10
|
+
export const check = bridgeShape;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CalldataMethod } from '../../abi.js';
|
|
2
|
+
export declare const methods: CalldataMethod[];
|
|
3
|
+
export declare const compare: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../expect.js").CompareMask;
|
|
4
|
+
export declare const check: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../../index.js").BridgeErrorDefinition | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { knownCompare } from '../../expect.js';
|
|
2
|
+
import { bridgeShape } from '../shape.js';
|
|
3
|
+
import { lifiBridgeMethod } from '../method.js';
|
|
4
|
+
import { applyLayerSwapData, layerSwapDataParam } from '../params.js';
|
|
5
|
+
export const methods = [
|
|
6
|
+
lifiBridgeMethod('startBridgeTokensViaLayerSwap', '0xee9e98e0', [layerSwapDataParam], false, (parsed, args) => applyLayerSwapData(parsed, args.layerSwapData)),
|
|
7
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaLayerSwap', '0x4c279d6b', [layerSwapDataParam], true, (parsed, args) => applyLayerSwapData(parsed, args.layerSwapData)),
|
|
8
|
+
];
|
|
9
|
+
export const compare = knownCompare;
|
|
10
|
+
export const check = bridgeShape;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const methods: import("../../abi.js").CalldataMethod[];
|
|
2
|
+
export declare const compare: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../expect.js").CompareMask;
|
|
3
|
+
export declare const check: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../../errors/constants.js").BridgeErrorDefinition | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BRIDGE_ERRORS, BridgeError } from '../../../errors/index.js';
|
|
2
|
+
import { asBigint, asRecord, asString } from '../../abi.js';
|
|
3
|
+
import { accountFromBytes32 } from '../../hex.js';
|
|
4
|
+
import { knownCompare } from '../../expect.js';
|
|
5
|
+
import { lifiBridgeMethod } from '../method.js';
|
|
6
|
+
import { bridgeShape } from '../shape.js';
|
|
7
|
+
const m0Data = { name: 'm0Data', kind: 'tuple', components: [
|
|
8
|
+
{ name: 'receiverAddress', kind: 'bytes', size: 32 }, { name: 'refundRecipient', kind: 'address' },
|
|
9
|
+
{ name: 'orderOwner', kind: 'address' }, { name: 'tokenOut', kind: 'bytes', size: 32 },
|
|
10
|
+
{ name: 'solver', kind: 'bytes', size: 32 }, { name: 'amountOut', kind: 'uint' },
|
|
11
|
+
{ name: 'fillDeadline', kind: 'uint' },
|
|
12
|
+
] };
|
|
13
|
+
const fill = (parsed, args) => {
|
|
14
|
+
const data = asRecord(args.m0Data);
|
|
15
|
+
if ((parsed.destinationChainId ?? 0n) > 0xffffffffn)
|
|
16
|
+
throw new BridgeError(BRIDGE_ERRORS.UNSUPPORTED_NON_EVM_M0_DESTINATION);
|
|
17
|
+
const receiver = accountFromBytes32(asString(data.receiverAddress));
|
|
18
|
+
if (receiver !== parsed.receiver)
|
|
19
|
+
throw new BridgeError(BRIDGE_ERRORS.M0_RECEIVER_MISMATCH);
|
|
20
|
+
if (asString(data.refundRecipient) !== receiver || asString(data.orderOwner) !== receiver) {
|
|
21
|
+
throw new BridgeError(BRIDGE_ERRORS.M0_REFUND_RECIPIENT_MISMATCH);
|
|
22
|
+
}
|
|
23
|
+
parsed.receiver = receiver;
|
|
24
|
+
parsed.outputToken = accountFromBytes32(asString(data.tokenOut));
|
|
25
|
+
// Positive source-swap slippage scales amountOut up; the quoted amount remains its floor.
|
|
26
|
+
parsed.minOutputAmount = asBigint(data.amountOut);
|
|
27
|
+
};
|
|
28
|
+
export const methods = [
|
|
29
|
+
lifiBridgeMethod('startBridgeTokensViaM0', '0x65782c4b', [m0Data], false, fill),
|
|
30
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaM0', '0xb9eaf86d', [m0Data], true, fill),
|
|
31
|
+
];
|
|
32
|
+
export const compare = knownCompare;
|
|
33
|
+
export const check = bridgeShape;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CalldataMethod } from '../../abi.js';
|
|
2
|
+
export declare const methods: CalldataMethod[];
|
|
3
|
+
export declare const compare: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../expect.js").CompareMask;
|
|
4
|
+
export declare const check: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../../index.js").BridgeErrorDefinition | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { knownCompare } from '../../expect.js';
|
|
2
|
+
import { bridgeShape } from '../shape.js';
|
|
3
|
+
import { applyMayanData, mayanDataParam } from '../params.js';
|
|
4
|
+
import { lifiBridgeMethod } from '../method.js';
|
|
5
|
+
export const methods = [
|
|
6
|
+
lifiBridgeMethod('startBridgeTokensViaMayan', '0xb4875292', [mayanDataParam], false, (parsed, args) => applyMayanData(parsed, args.mayanData)),
|
|
7
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaMayan', '0x80c65808', [mayanDataParam], true, (parsed, args) => applyMayanData(parsed, args.mayanData)),
|
|
8
|
+
];
|
|
9
|
+
export const compare = knownCompare;
|
|
10
|
+
export const check = bridgeShape;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AbiParam, type AbiValue } from '../abi.js';
|
|
2
|
+
import type { CalldataMethod } from '../abi.js';
|
|
3
|
+
import type { ParsedBridgeCall } from '../types.js';
|
|
4
|
+
export declare const lifiBridgeMethod: (name: string, selector: string, tail: AbiParam[], withSwap: boolean, fill?: (parsed: ParsedBridgeCall, args: {
|
|
5
|
+
[key: string]: AbiValue;
|
|
6
|
+
}) => void) => CalldataMethod;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { decodeCall } from '../abi.js';
|
|
2
|
+
import { applyBridgeData, applyFirstSwap, bridgeDataParam, swapDataArrayParam } from './params.js';
|
|
3
|
+
export const lifiBridgeMethod = (name, selector, tail, withSwap, fill) => ({
|
|
4
|
+
name,
|
|
5
|
+
selector,
|
|
6
|
+
decode(data) {
|
|
7
|
+
const params = [bridgeDataParam, ...(withSwap ? [swapDataArrayParam] : []), ...tail];
|
|
8
|
+
const args = decodeCall(params, data);
|
|
9
|
+
const parsed = applyBridgeData(name, args.bridgeData);
|
|
10
|
+
if (withSwap) {
|
|
11
|
+
applyFirstSwap(parsed, args.swapData);
|
|
12
|
+
}
|
|
13
|
+
fill?.(parsed, args);
|
|
14
|
+
return parsed;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ParsedBridgeCall } from '../../types.js';
|
|
2
|
+
export declare const methods: import("../../abi.js").CalldataMethod[];
|
|
3
|
+
export declare const compare: (parsed: ParsedBridgeCall) => import("../../expect.js").CompareMask;
|
|
4
|
+
export declare const check: (parsed: ParsedBridgeCall) => import("../../../errors/constants.js").BridgeErrorDefinition | undefined;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BRIDGE_ERRORS, BridgeError } from '../../../errors/index.js';
|
|
2
|
+
import { asBigint, asRecord, asString } from '../../abi.js';
|
|
3
|
+
import { knownCompare } from '../../expect.js';
|
|
4
|
+
import { LAYERZERO_CHAINS, NATIVE_TOKEN, isNative } from '../../protocols.js';
|
|
5
|
+
import { lifiBridgeMethod } from '../method.js';
|
|
6
|
+
import { bridgeShape } from '../shape.js';
|
|
7
|
+
const polygon = (parsed) => {
|
|
8
|
+
parsed.destinationChainId = 137n;
|
|
9
|
+
parsed.minOutputAmount = parsed.bridgeAmount;
|
|
10
|
+
if (isNative(parsed.bridgeToken)) {
|
|
11
|
+
parsed.outputToken = '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619';
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
parsed.outputTokenReference = { protocol: 'polygon', token: parsed.bridgeToken, destinationChainId: 137n };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const gnosis = (parsed) => {
|
|
18
|
+
parsed.destinationChainId = 100n;
|
|
19
|
+
parsed.minOutputAmount = parsed.bridgeAmount;
|
|
20
|
+
if (['0x6b175474e89094c44da98b954eedeac495271d0f', '0xdc035d45d973e3ec169d2276ddab16f1e407384f'].includes(parsed.bridgeToken)) {
|
|
21
|
+
parsed.outputToken = NATIVE_TOKEN;
|
|
22
|
+
}
|
|
23
|
+
else if (isNative(parsed.bridgeToken)) {
|
|
24
|
+
parsed.outputToken = '0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1';
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
parsed.outputTokenReference = { protocol: 'gnosis', token: parsed.bridgeToken, destinationChainId: 100n };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const megaETHData = { name: 'megaETHData', kind: 'tuple', components: [
|
|
31
|
+
{ name: 'assetIdOnL2', kind: 'address' }, { name: 'l2Gas', kind: 'uint' },
|
|
32
|
+
{ name: 'requiresDepositTo', kind: 'bool' },
|
|
33
|
+
] };
|
|
34
|
+
const megaETH = (parsed, args) => {
|
|
35
|
+
const data = asRecord(args.megaETHData);
|
|
36
|
+
parsed.destinationChainId = 4326n;
|
|
37
|
+
parsed.minOutputAmount = parsed.bridgeAmount;
|
|
38
|
+
if (isNative(parsed.bridgeToken))
|
|
39
|
+
parsed.outputToken = NATIVE_TOKEN;
|
|
40
|
+
else if (data.requiresDepositTo === false) {
|
|
41
|
+
const token = asString(data.assetIdOnL2);
|
|
42
|
+
if (isNative(token))
|
|
43
|
+
throw new BridgeError(BRIDGE_ERRORS.MISSING_MEGAETH_DESTINATION_TOKEN);
|
|
44
|
+
parsed.outputToken = token;
|
|
45
|
+
}
|
|
46
|
+
// Custom depositTo bridges choose their remote token outside this calldata.
|
|
47
|
+
};
|
|
48
|
+
const supersetData = {
|
|
49
|
+
name: 'supersetData', kind: 'tuple', components: [
|
|
50
|
+
{ name: 'path', kind: 'bytes' }, { name: 'amountOutMin', kind: 'uint' },
|
|
51
|
+
{ name: 'refundAddress', kind: 'address' }, { name: 'fallbackEoA', kind: 'address' },
|
|
52
|
+
{ name: 'deadline', kind: 'uint' }, { name: 'toEid', kind: 'uint' },
|
|
53
|
+
{ name: 'options', kind: 'bytes' }, { name: 'lzFee', kind: 'uint' },
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
const superset = (parsed, args) => {
|
|
57
|
+
const data = asRecord(args.supersetData);
|
|
58
|
+
const path = asString(data.path).slice(2);
|
|
59
|
+
if (path.length < 64 || (path.length - 64) % 70 !== 0)
|
|
60
|
+
throw new BridgeError(BRIDGE_ERRORS.INVALID_SUPERSET_OMNI_TOKEN_PATH);
|
|
61
|
+
parsed.minOutputAmount = asBigint(data.amountOutMin);
|
|
62
|
+
parsed.destinationChainRef = `layerzero:${asBigint(data.toEid)}`;
|
|
63
|
+
parsed.destinationChainId = LAYERZERO_CHAINS[asBigint(data.toEid).toString()];
|
|
64
|
+
parsed.outputTokenReference = {
|
|
65
|
+
protocol: 'superset', tokenId: `0x${path.slice(-64)}`,
|
|
66
|
+
destinationChainId: parsed.destinationChainId, destinationChainRef: parsed.destinationChainRef,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export const methods = [
|
|
70
|
+
lifiBridgeMethod('startBridgeTokensViaPolygonBridge', '0xaf62c7d6', [], false, polygon),
|
|
71
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaPolygonBridge', '0xb4f37581', [], true, polygon),
|
|
72
|
+
lifiBridgeMethod('startBridgeTokensViaGnosisBridge', '0xf66fe519', [], false, gnosis),
|
|
73
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaGnosisBridge', '0x7bf96e0a', [], true, gnosis),
|
|
74
|
+
lifiBridgeMethod('startBridgeTokensViaMegaETHBridge', '0x4213dfff', [megaETHData], false, megaETH),
|
|
75
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaMegaETHBridge', '0x22256e89', [megaETHData], true, megaETH),
|
|
76
|
+
lifiBridgeMethod('startBridgeTokensViaSuperset', '0x0691ff78', [supersetData], false, superset),
|
|
77
|
+
lifiBridgeMethod('swapAndStartBridgeTokensViaSuperset', '0xf26e657f', [supersetData], true, superset),
|
|
78
|
+
];
|
|
79
|
+
export const compare = knownCompare;
|
|
80
|
+
export const check = bridgeShape;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AbiParam, type AbiValue } from '../abi.js';
|
|
2
|
+
import type { ParsedBridgeCall } from '../types.js';
|
|
3
|
+
export { applyFirstSwap, swapDataArrayParam, swapDataParam } from './swapData.js';
|
|
4
|
+
export declare const bridgeDataParam: AbiParam;
|
|
5
|
+
export declare const acrossDataParam: AbiParam;
|
|
6
|
+
export declare const stargateDataParam: AbiParam;
|
|
7
|
+
export declare const relayDepositoryDataParam: AbiParam;
|
|
8
|
+
export declare const mayanDataParam: AbiParam;
|
|
9
|
+
export declare const gasZipDataParam: AbiParam;
|
|
10
|
+
export declare const squidDataParam: AbiParam;
|
|
11
|
+
export declare const acrossPackedParam: AbiParam;
|
|
12
|
+
export declare const applyBridgeData: (method: string, raw: AbiValue) => ParsedBridgeCall;
|
|
13
|
+
export declare const applyAcrossData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
14
|
+
export declare const applyStargateData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
15
|
+
export declare const applyRelayDepositoryData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
16
|
+
export declare const applyMayanData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
17
|
+
export declare const applyGasZipData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
18
|
+
export declare const applySquidData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
19
|
+
export declare const polymerDataParam: AbiParam;
|
|
20
|
+
export declare const lifiIntentDataParam: AbiParam;
|
|
21
|
+
export declare const layerSwapDataParam: AbiParam;
|
|
22
|
+
export declare const applyPolymerData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
23
|
+
export declare const applyLifiIntentData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
24
|
+
export declare const celerCircleDataParam: AbiParam;
|
|
25
|
+
export declare const paxosDataParam: AbiParam;
|
|
26
|
+
export declare const applyPaxosData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
27
|
+
export declare const applyLayerSwapData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
28
|
+
export declare const applyCelerCircleData: (parsed: ParsedBridgeCall, raw: AbiValue) => void;
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { BRIDGE_ERRORS, BridgeError } from '../../errors/index.js';
|
|
2
|
+
import { innerCallDiagnostics } from '../diagnostics.js';
|
|
3
|
+
import { asArray, asBigint, asRecord, asString, } from '../abi.js';
|
|
4
|
+
import { accountFromBytes32 } from '../hex.js';
|
|
5
|
+
import { readMayanProtocol } from '../mayan/readProtocol.js';
|
|
6
|
+
import { LAYERZERO_CHAINS, subtractFees } from '../protocols.js';
|
|
7
|
+
import { readLifiDestination } from './destination.js';
|
|
8
|
+
import { swapDataParam } from './swapData.js';
|
|
9
|
+
export { applyFirstSwap, swapDataArrayParam, swapDataParam } from './swapData.js';
|
|
10
|
+
export const bridgeDataParam = {
|
|
11
|
+
name: 'bridgeData',
|
|
12
|
+
kind: 'tuple',
|
|
13
|
+
components: [
|
|
14
|
+
{ name: 'transactionId', kind: 'bytes', size: 32 },
|
|
15
|
+
{ name: 'bridge', kind: 'string' },
|
|
16
|
+
{ name: 'integrator', kind: 'string' },
|
|
17
|
+
{ name: 'referrer', kind: 'address' },
|
|
18
|
+
{ name: 'sendingAssetId', kind: 'address' },
|
|
19
|
+
{ name: 'receiver', kind: 'address' },
|
|
20
|
+
{ name: 'minAmount', kind: 'uint' },
|
|
21
|
+
{ name: 'destinationChainId', kind: 'uint' },
|
|
22
|
+
{ name: 'hasSourceSwaps', kind: 'bool' },
|
|
23
|
+
{ name: 'hasDestinationCall', kind: 'bool' },
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
export const acrossDataParam = {
|
|
27
|
+
name: 'acrossData',
|
|
28
|
+
kind: 'tuple',
|
|
29
|
+
components: [
|
|
30
|
+
{ name: 'receiverAddress', kind: 'bytes', size: 32 },
|
|
31
|
+
{ name: 'refundAddress', kind: 'bytes', size: 32 },
|
|
32
|
+
{ name: 'sendingAssetId', kind: 'bytes', size: 32 },
|
|
33
|
+
{ name: 'receivingAssetId', kind: 'bytes', size: 32 },
|
|
34
|
+
{ name: 'outputAmount', kind: 'uint' },
|
|
35
|
+
{ name: 'outputAmountMultiplier', kind: 'uint' },
|
|
36
|
+
{ name: 'exclusiveRelayer', kind: 'bytes', size: 32 },
|
|
37
|
+
{ name: 'quoteTimestamp', kind: 'uint' },
|
|
38
|
+
{ name: 'fillDeadline', kind: 'uint' },
|
|
39
|
+
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
40
|
+
{ name: 'message', kind: 'bytes' },
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
export const stargateDataParam = {
|
|
44
|
+
name: 'stargateData',
|
|
45
|
+
kind: 'tuple',
|
|
46
|
+
components: [
|
|
47
|
+
{ name: 'assetId', kind: 'uint' },
|
|
48
|
+
{
|
|
49
|
+
name: 'sendParams',
|
|
50
|
+
kind: 'tuple',
|
|
51
|
+
components: [
|
|
52
|
+
{ name: 'dstEid', kind: 'uint' },
|
|
53
|
+
{ name: 'to', kind: 'bytes', size: 32 },
|
|
54
|
+
{ name: 'amountLD', kind: 'uint' },
|
|
55
|
+
{ name: 'minAmountLD', kind: 'uint' },
|
|
56
|
+
{ name: 'extraOptions', kind: 'bytes' },
|
|
57
|
+
{ name: 'composeMsg', kind: 'bytes' },
|
|
58
|
+
{ name: 'oftCmd', kind: 'bytes' },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'fee',
|
|
63
|
+
kind: 'tuple',
|
|
64
|
+
components: [
|
|
65
|
+
{ name: 'nativeFee', kind: 'uint' },
|
|
66
|
+
{ name: 'lzTokenFee', kind: 'uint' },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{ name: 'refundAddress', kind: 'address' },
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
export const relayDepositoryDataParam = {
|
|
73
|
+
name: 'relayDepositoryData',
|
|
74
|
+
kind: 'tuple',
|
|
75
|
+
components: [
|
|
76
|
+
{ name: 'orderId', kind: 'bytes', size: 32 },
|
|
77
|
+
{ name: 'depositorAddress', kind: 'address' },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
export const mayanDataParam = {
|
|
81
|
+
name: 'mayanData',
|
|
82
|
+
kind: 'tuple',
|
|
83
|
+
components: [
|
|
84
|
+
{ name: 'nonEVMReceiver', kind: 'bytes', size: 32 },
|
|
85
|
+
{ name: 'mayanProtocol', kind: 'address' },
|
|
86
|
+
{ name: 'protocolData', kind: 'bytes' },
|
|
87
|
+
{ name: 'swapProtocol', kind: 'address' },
|
|
88
|
+
{ name: 'swapData', kind: 'bytes' },
|
|
89
|
+
{ name: 'middleToken', kind: 'address' },
|
|
90
|
+
{ name: 'minMiddleAmount', kind: 'uint' },
|
|
91
|
+
{ name: 'refundRecipient', kind: 'address' },
|
|
92
|
+
{ name: 'mayanAmountIn', kind: 'uint' },
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
export const gasZipDataParam = {
|
|
96
|
+
name: 'gasZipData',
|
|
97
|
+
kind: 'tuple',
|
|
98
|
+
components: [
|
|
99
|
+
{ name: 'receiverAddress', kind: 'bytes', size: 32 },
|
|
100
|
+
{ name: 'destinationChains', kind: 'uint' },
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
export const squidDataParam = {
|
|
104
|
+
name: 'squidData',
|
|
105
|
+
kind: 'tuple',
|
|
106
|
+
components: [
|
|
107
|
+
{ name: 'routeType', kind: 'uint' },
|
|
108
|
+
{ name: 'destinationChain', kind: 'string' },
|
|
109
|
+
{ name: 'destinationAddress', kind: 'string' },
|
|
110
|
+
{ name: 'bridgedTokenSymbol', kind: 'string' },
|
|
111
|
+
{ name: 'depositAssetId', kind: 'address' },
|
|
112
|
+
{
|
|
113
|
+
name: 'sourceCalls',
|
|
114
|
+
kind: 'array',
|
|
115
|
+
item: {
|
|
116
|
+
name: 'call',
|
|
117
|
+
kind: 'tuple',
|
|
118
|
+
components: [
|
|
119
|
+
{ name: 'callType', kind: 'uint' },
|
|
120
|
+
{ name: 'target', kind: 'address' },
|
|
121
|
+
{ name: 'value', kind: 'uint' },
|
|
122
|
+
{ name: 'callData', kind: 'bytes' },
|
|
123
|
+
{ name: 'payload', kind: 'bytes' },
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{ name: 'payload', kind: 'bytes' },
|
|
128
|
+
{ name: 'fee', kind: 'uint' },
|
|
129
|
+
{ name: 'enableExpress', kind: 'bool' },
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
export const acrossPackedParam = {
|
|
133
|
+
name: 'parameters',
|
|
134
|
+
kind: 'tuple',
|
|
135
|
+
components: [
|
|
136
|
+
{ name: 'transactionId', kind: 'bytes', size: 8 },
|
|
137
|
+
{ name: 'receiver', kind: 'bytes', size: 32 },
|
|
138
|
+
{ name: 'depositor', kind: 'bytes', size: 32 },
|
|
139
|
+
{ name: 'destinationChainId', kind: 'uint' },
|
|
140
|
+
{ name: 'receivingAssetId', kind: 'bytes', size: 32 },
|
|
141
|
+
{ name: 'outputAmount', kind: 'uint' },
|
|
142
|
+
{ name: 'exclusiveRelayer', kind: 'bytes', size: 32 },
|
|
143
|
+
{ name: 'quoteTimestamp', kind: 'uint' },
|
|
144
|
+
{ name: 'fillDeadline', kind: 'uint' },
|
|
145
|
+
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
146
|
+
{ name: 'message', kind: 'bytes' },
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
export const applyBridgeData = (method, raw) => {
|
|
150
|
+
const data = asRecord(raw);
|
|
151
|
+
return {
|
|
152
|
+
aggregatorId: 'lifi',
|
|
153
|
+
method,
|
|
154
|
+
kind: 'bridge',
|
|
155
|
+
sourceToken: asString(data.sendingAssetId),
|
|
156
|
+
sourceAmount: asBigint(data.minAmount),
|
|
157
|
+
bridgeToken: asString(data.sendingAssetId),
|
|
158
|
+
bridgeAmount: asBigint(data.minAmount),
|
|
159
|
+
destinationChainId: asBigint(data.destinationChainId),
|
|
160
|
+
receiver: asString(data.receiver),
|
|
161
|
+
bridgeReceiver: asString(data.receiver),
|
|
162
|
+
referrer: asString(data.referrer),
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export const applyAcrossData = (parsed, raw) => {
|
|
166
|
+
const data = asRecord(raw);
|
|
167
|
+
parsed.refundRecipients = [accountFromBytes32(asString(data.refundAddress))];
|
|
168
|
+
parsed.receiver = accountFromBytes32(asString(data.receiverAddress));
|
|
169
|
+
parsed.outputToken = accountFromBytes32(asString(data.receivingAssetId));
|
|
170
|
+
parsed.minOutputAmount = asBigint(data.outputAmount);
|
|
171
|
+
};
|
|
172
|
+
export const applyStargateData = (parsed, raw) => {
|
|
173
|
+
const send = asRecord(asRecord(raw).sendParams);
|
|
174
|
+
parsed.receiver = accountFromBytes32(asString(send.to));
|
|
175
|
+
parsed.minOutputAmount = asBigint(send.minAmountLD);
|
|
176
|
+
};
|
|
177
|
+
export const applyRelayDepositoryData = (parsed, raw) => {
|
|
178
|
+
parsed.orderId = asString(asRecord(raw).orderId);
|
|
179
|
+
};
|
|
180
|
+
export const applyMayanData = (parsed, raw) => {
|
|
181
|
+
const data = asRecord(raw);
|
|
182
|
+
const receiver = accountFromBytes32(asString(data.nonEVMReceiver));
|
|
183
|
+
if (!/^0x0*$/.test(receiver)) {
|
|
184
|
+
parsed.receiver = receiver;
|
|
185
|
+
}
|
|
186
|
+
parsed.innerTarget = asString(data.mayanProtocol);
|
|
187
|
+
parsed.diagnostics = innerCallDiagnostics(asString(data.protocolData), 'protocol');
|
|
188
|
+
const protocol = readMayanProtocol(asString(data.protocolData), asBigint(data.minMiddleAmount) > 0n ? asBigint(data.minMiddleAmount) : parsed.bridgeAmount);
|
|
189
|
+
if (!protocol)
|
|
190
|
+
throw new BridgeError(BRIDGE_ERRORS.UNSUPPORTED_MAYAN_PROTOCOL_CALLDATA, parsed.diagnostics);
|
|
191
|
+
const { sourceToken, sourceAmount, aggregatorId, method, kind, ...destination } = protocol;
|
|
192
|
+
Object.assign(parsed, destination);
|
|
193
|
+
};
|
|
194
|
+
export const applyGasZipData = (parsed, raw) => {
|
|
195
|
+
const data = asRecord(raw);
|
|
196
|
+
parsed.receiver = accountFromBytes32(asString(data.receiverAddress));
|
|
197
|
+
parsed.destinationChainRef = asBigint(data.destinationChains).toString();
|
|
198
|
+
};
|
|
199
|
+
export const applySquidData = (parsed, raw) => {
|
|
200
|
+
const data = asRecord(raw);
|
|
201
|
+
parsed.destinationChainRef = asString(data.destinationChain);
|
|
202
|
+
parsed.receiver = asString(data.destinationAddress);
|
|
203
|
+
parsed.sourceToken = asString(data.depositAssetId);
|
|
204
|
+
};
|
|
205
|
+
export const polymerDataParam = {
|
|
206
|
+
name: 'polymerData',
|
|
207
|
+
kind: 'tuple',
|
|
208
|
+
components: [
|
|
209
|
+
{ name: 'polymerTokenFee', kind: 'uint' },
|
|
210
|
+
{ name: 'maxCCTPFee', kind: 'uint' },
|
|
211
|
+
{ name: 'nonEVMReceiver', kind: 'bytes', size: 32 },
|
|
212
|
+
{ name: 'solanaReceiverATA', kind: 'bytes', size: 32 },
|
|
213
|
+
{ name: 'minFinalityThreshold', kind: 'uint' },
|
|
214
|
+
{ name: 'refundRecipient', kind: 'address' },
|
|
215
|
+
{ name: 'hookData', kind: 'bytes' },
|
|
216
|
+
],
|
|
217
|
+
};
|
|
218
|
+
export const lifiIntentDataParam = {
|
|
219
|
+
name: 'lifiIntentData',
|
|
220
|
+
kind: 'tuple',
|
|
221
|
+
components: [
|
|
222
|
+
{ name: 'dstCallReceiver', kind: 'bytes', size: 32 },
|
|
223
|
+
{ name: 'recipient', kind: 'bytes', size: 32 },
|
|
224
|
+
{ name: 'depositAndRefundAddress', kind: 'address' },
|
|
225
|
+
{ name: 'nonce', kind: 'uint' },
|
|
226
|
+
{ name: 'expires', kind: 'uint' },
|
|
227
|
+
{ name: 'fillDeadline', kind: 'uint' },
|
|
228
|
+
{ name: 'inputOracle', kind: 'address' },
|
|
229
|
+
{ name: 'outputOracle', kind: 'bytes', size: 32 },
|
|
230
|
+
{ name: 'outputSettler', kind: 'bytes', size: 32 },
|
|
231
|
+
{ name: 'outputToken', kind: 'bytes', size: 32 },
|
|
232
|
+
{ name: 'outputAmountMultiplier', kind: 'uint' },
|
|
233
|
+
{ name: 'dstCallSwapData', kind: 'array', item: swapDataParam },
|
|
234
|
+
{ name: 'outputContext', kind: 'bytes' },
|
|
235
|
+
],
|
|
236
|
+
};
|
|
237
|
+
export const layerSwapDataParam = {
|
|
238
|
+
name: 'layerSwapData',
|
|
239
|
+
kind: 'tuple',
|
|
240
|
+
components: [
|
|
241
|
+
{ name: 'requestId', kind: 'bytes', size: 32 },
|
|
242
|
+
{ name: 'depositoryReceiver', kind: 'address' },
|
|
243
|
+
{ name: 'refundRecipient', kind: 'address' },
|
|
244
|
+
{ name: 'nonEVMReceiver', kind: 'bytes', size: 32 },
|
|
245
|
+
{ name: 'signature', kind: 'bytes' },
|
|
246
|
+
{ name: 'deadline', kind: 'uint' },
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
export const applyPolymerData = (parsed, raw) => {
|
|
250
|
+
const data = asRecord(raw);
|
|
251
|
+
parsed.outputTokenReference = { protocol: 'cctp', destinationChainId: parsed.destinationChainId };
|
|
252
|
+
parsed.minOutputAmount = subtractFees(parsed.bridgeAmount ?? 0n, asBigint(data.polymerTokenFee), asBigint(data.maxCCTPFee));
|
|
253
|
+
if (asString(data.hookData) !== '0x') {
|
|
254
|
+
parsed.destinationCallData = asString(data.hookData);
|
|
255
|
+
delete parsed.receiver;
|
|
256
|
+
delete parsed.outputTokenReference;
|
|
257
|
+
delete parsed.minOutputAmount;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
export const applyLifiIntentData = (parsed, raw) => {
|
|
261
|
+
const data = asRecord(raw);
|
|
262
|
+
parsed.refundRecipients = [asString(data.depositAndRefundAddress)];
|
|
263
|
+
parsed.receiver = accountFromBytes32(asString(data.recipient));
|
|
264
|
+
parsed.outputToken = accountFromBytes32(asString(data.outputToken));
|
|
265
|
+
parsed.minOutputAmount = (parsed.bridgeAmount ?? 0n) * asBigint(data.outputAmountMultiplier) / 10n ** 18n;
|
|
266
|
+
if (asArray(data.dstCallSwapData).length) {
|
|
267
|
+
const destination = readLifiDestination(parsed, data);
|
|
268
|
+
parsed.hasDestinationCall = true;
|
|
269
|
+
parsed.bridgeReceiver = accountFromBytes32(asString(data.dstCallReceiver));
|
|
270
|
+
parsed.bridgeOutputToken = parsed.outputToken;
|
|
271
|
+
parsed.bridgeOutputAmount = parsed.minOutputAmount;
|
|
272
|
+
delete parsed.receiver;
|
|
273
|
+
delete parsed.outputToken;
|
|
274
|
+
delete parsed.minOutputAmount;
|
|
275
|
+
// Unknown deployments and arbitrary calls remain unverified.
|
|
276
|
+
if (destination)
|
|
277
|
+
Object.assign(parsed, destination);
|
|
278
|
+
}
|
|
279
|
+
parsed.orderId = asBigint(data.nonce).toString(16).padStart(64, '0');
|
|
280
|
+
parsed.orderId = `0x${parsed.orderId}`;
|
|
281
|
+
};
|
|
282
|
+
export const celerCircleDataParam = {
|
|
283
|
+
name: 'celerCircleData',
|
|
284
|
+
kind: 'tuple',
|
|
285
|
+
components: [
|
|
286
|
+
{ name: 'maxFee', kind: 'uint' },
|
|
287
|
+
{ name: 'minFinalityThreshold', kind: 'uint' },
|
|
288
|
+
],
|
|
289
|
+
};
|
|
290
|
+
const paxosRouteParam = {
|
|
291
|
+
name: 'route',
|
|
292
|
+
kind: 'tuple',
|
|
293
|
+
components: [
|
|
294
|
+
{ name: 'destEID', kind: 'uint' },
|
|
295
|
+
{ name: 'offerAsset', kind: 'address' },
|
|
296
|
+
{ name: 'wantAsset', kind: 'address' },
|
|
297
|
+
],
|
|
298
|
+
};
|
|
299
|
+
export const paxosDataParam = {
|
|
300
|
+
name: 'paxosData',
|
|
301
|
+
kind: 'tuple',
|
|
302
|
+
components: [
|
|
303
|
+
{
|
|
304
|
+
name: 'quote',
|
|
305
|
+
kind: 'tuple',
|
|
306
|
+
components: [
|
|
307
|
+
paxosRouteParam,
|
|
308
|
+
{ name: 'offerAmount', kind: 'uint' },
|
|
309
|
+
{ name: 'receiver', kind: 'address' },
|
|
310
|
+
{ name: 'protocolFee', kind: 'uint' },
|
|
311
|
+
{ name: 'integratorFee', kind: 'uint' },
|
|
312
|
+
{ name: 'integratorFeeReceiver', kind: 'address' },
|
|
313
|
+
{ name: 'distributorCode', kind: 'bytes', size: 32 },
|
|
314
|
+
{ name: 'deadline', kind: 'uint' },
|
|
315
|
+
{ name: 'salt', kind: 'bytes', size: 32 },
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
{ name: 'signature', kind: 'bytes' },
|
|
319
|
+
{ name: 'nativeFee', kind: 'uint' },
|
|
320
|
+
{ name: 'refundRecipient', kind: 'address' },
|
|
321
|
+
],
|
|
322
|
+
};
|
|
323
|
+
export const applyPaxosData = (parsed, raw) => {
|
|
324
|
+
const quote = asRecord(asRecord(raw).quote);
|
|
325
|
+
const route = asRecord(quote.route);
|
|
326
|
+
parsed.destinationChainRef = `layerzero:${asBigint(route.destEID)}`;
|
|
327
|
+
parsed.destinationChainId = LAYERZERO_CHAINS[asBigint(route.destEID).toString()];
|
|
328
|
+
parsed.outputToken = asString(route.wantAsset);
|
|
329
|
+
const offerAmount = asBigint(quote.offerAmount);
|
|
330
|
+
parsed.minOutputAmount = subtractFees(offerAmount, asBigint(quote.protocolFee), asBigint(quote.integratorFee));
|
|
331
|
+
const receiver = asString(quote.receiver);
|
|
332
|
+
parsed.receiver = receiver;
|
|
333
|
+
};
|
|
334
|
+
export const applyLayerSwapData = (parsed, raw) => {
|
|
335
|
+
const data = asRecord(raw);
|
|
336
|
+
if (asString(data.refundRecipient) !== parsed.receiver)
|
|
337
|
+
throw new BridgeError(BRIDGE_ERRORS.LAYERSWAP_REFUND_RECIPIENT_MISMATCH);
|
|
338
|
+
if (!/^0x0*$/.test(asString(data.nonEVMReceiver)))
|
|
339
|
+
throw new BridgeError(BRIDGE_ERRORS.UNSUPPORTED_LAYERSWAP_NON_EVM_RECEIVER);
|
|
340
|
+
parsed.orderId = asString(data.requestId);
|
|
341
|
+
// The LayerSwap signature binds bridgeData.receiver to this request ID.
|
|
342
|
+
};
|
|
343
|
+
export const applyCelerCircleData = (parsed, raw) => {
|
|
344
|
+
parsed.outputTokenReference = { protocol: 'cctp', destinationChainId: parsed.destinationChainId };
|
|
345
|
+
parsed.outputAmountReference = {
|
|
346
|
+
kind: 'fees', amount: parsed.bridgeAmount ?? 0n,
|
|
347
|
+
token: parsed.outputTokenReference, maxFee: asBigint(asRecord(raw).maxFee),
|
|
348
|
+
};
|
|
349
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CalldataMethod } from '../../abi.js';
|
|
2
|
+
export declare const methods: CalldataMethod[];
|
|
3
|
+
export declare const compare: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../expect.js").CompareMask;
|
|
4
|
+
export declare const check: (parsed: import("../../types.js").ParsedBridgeCall) => import("../../../index.js").BridgeErrorDefinition | undefined;
|