@1delta/bridge-configs 0.1.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 +674 -0
- package/dist/configs/across/config.d.ts +4 -0
- package/dist/configs/across/config.d.ts.map +1 -0
- package/dist/configs/across/config.js +317 -0
- package/dist/configs/axelar/abis/AxelarGasService.d.ts +103 -0
- package/dist/configs/axelar/abis/AxelarGasService.d.ts.map +1 -0
- package/dist/configs/axelar/abis/AxelarGasService.js +1073 -0
- package/dist/configs/axelar/abis/AxelarGateway.d.ts +51 -0
- package/dist/configs/axelar/abis/AxelarGateway.d.ts.map +1 -0
- package/dist/configs/axelar/abis/AxelarGateway.js +753 -0
- package/dist/configs/axelar/abis/SquidMulticall.d.ts +47 -0
- package/dist/configs/axelar/abis/SquidMulticall.d.ts.map +1 -0
- package/dist/configs/axelar/abis/SquidMulticall.js +104 -0
- package/dist/configs/axelar/abis/SquidRouter.d.ts +82 -0
- package/dist/configs/axelar/abis/SquidRouter.d.ts.map +1 -0
- package/dist/configs/axelar/abis/SquidRouter.js +837 -0
- package/dist/configs/axelar/calldata/buildTx.d.ts +3 -0
- package/dist/configs/axelar/calldata/buildTx.d.ts.map +1 -0
- package/dist/configs/axelar/calldata/buildTx.js +29 -0
- package/dist/configs/axelar/calldata/index.d.ts +3 -0
- package/dist/configs/axelar/calldata/index.d.ts.map +1 -0
- package/dist/configs/axelar/calldata/index.js +2 -0
- package/dist/configs/axelar/calldata/squid/createSquidMulticallPayload.d.ts +16 -0
- package/dist/configs/axelar/calldata/squid/createSquidMulticallPayload.d.ts.map +1 -0
- package/dist/configs/axelar/calldata/squid/createSquidMulticallPayload.js +76 -0
- package/dist/configs/axelar/calldata/squid/types.d.ts +15 -0
- package/dist/configs/axelar/calldata/squid/types.d.ts.map +1 -0
- package/dist/configs/axelar/calldata/squid/types.js +7 -0
- package/dist/configs/axelar/calldata/types.d.ts +18 -0
- package/dist/configs/axelar/calldata/types.d.ts.map +1 -0
- package/dist/configs/axelar/calldata/types.js +1 -0
- package/dist/configs/axelar/config.d.ts +4 -0
- package/dist/configs/axelar/config.d.ts.map +1 -0
- package/dist/configs/axelar/config.js +99 -0
- package/dist/configs/axelar/data/axelarConfig/index.d.ts +3 -0
- package/dist/configs/axelar/data/axelarConfig/index.d.ts.map +1 -0
- package/dist/configs/axelar/data/axelarConfig/index.js +33 -0
- package/dist/configs/axelar/data/axelarConfig/types.d.ts +181 -0
- package/dist/configs/axelar/data/axelarConfig/types.d.ts.map +1 -0
- package/dist/configs/axelar/data/axelarConfig/types.js +1 -0
- package/dist/configs/axelar/data/squidChains/index.d.ts +6 -0
- package/dist/configs/axelar/data/squidChains/index.d.ts.map +1 -0
- package/dist/configs/axelar/data/squidChains/index.js +61 -0
- package/dist/configs/axelar/data/squidChains/types.d.ts +23 -0
- package/dist/configs/axelar/data/squidChains/types.d.ts.map +1 -0
- package/dist/configs/axelar/data/squidChains/types.js +1 -0
- package/dist/configs/axelar/errors.d.ts +15 -0
- package/dist/configs/axelar/errors.d.ts.map +1 -0
- package/dist/configs/axelar/errors.js +8 -0
- package/dist/configs/axelar/gasEstimation/index.d.ts +7 -0
- package/dist/configs/axelar/gasEstimation/index.d.ts.map +1 -0
- package/dist/configs/axelar/gasEstimation/index.js +38 -0
- package/dist/configs/axelar/gasEstimation/types.d.ts +23 -0
- package/dist/configs/axelar/gasEstimation/types.d.ts.map +1 -0
- package/dist/configs/axelar/gasEstimation/types.js +1 -0
- package/dist/configs/axelar/route/fetchAxelarRoute.d.ts +3 -0
- package/dist/configs/axelar/route/fetchAxelarRoute.d.ts.map +1 -0
- package/dist/configs/axelar/route/fetchAxelarRoute.js +50 -0
- package/dist/configs/axelar/route/index.d.ts +3 -0
- package/dist/configs/axelar/route/index.d.ts.map +1 -0
- package/dist/configs/axelar/route/index.js +2 -0
- package/dist/configs/axelar/route/tokenIdentifier.d.ts +5 -0
- package/dist/configs/axelar/route/tokenIdentifier.d.ts.map +1 -0
- package/dist/configs/axelar/route/tokenIdentifier.js +32 -0
- package/dist/configs/axelar/route/types.d.ts +5 -0
- package/dist/configs/axelar/route/types.d.ts.map +1 -0
- package/dist/configs/axelar/route/types.js +1 -0
- package/dist/configs/butter/config.d.ts +9 -0
- package/dist/configs/butter/config.d.ts.map +1 -0
- package/dist/configs/butter/config.js +207 -0
- package/dist/configs/cowswap/config.d.ts +4 -0
- package/dist/configs/cowswap/config.d.ts.map +1 -0
- package/dist/configs/cowswap/config.js +106 -0
- package/dist/configs/cowswap/errors.d.ts +19 -0
- package/dist/configs/cowswap/errors.d.ts.map +1 -0
- package/dist/configs/cowswap/errors.js +12 -0
- package/dist/configs/cowswap/swap/quote.d.ts +5 -0
- package/dist/configs/cowswap/swap/quote.d.ts.map +1 -0
- package/dist/configs/cowswap/swap/quote.js +28 -0
- package/dist/configs/cowswap/swap/route.d.ts +5 -0
- package/dist/configs/cowswap/swap/route.d.ts.map +1 -0
- package/dist/configs/cowswap/swap/route.js +61 -0
- package/dist/configs/cowswap/track/index.d.ts +6 -0
- package/dist/configs/cowswap/track/index.d.ts.map +1 -0
- package/dist/configs/cowswap/track/index.js +27 -0
- package/dist/configs/cowswap/utils/getCowSwapSlippage.d.ts +4 -0
- package/dist/configs/cowswap/utils/getCowSwapSlippage.d.ts.map +1 -0
- package/dist/configs/cowswap/utils/getCowSwapSlippage.js +16 -0
- package/dist/configs/cowswap/utils/toSupportedChainId.d.ts +3 -0
- package/dist/configs/cowswap/utils/toSupportedChainId.d.ts.map +1 -0
- package/dist/configs/cowswap/utils/toSupportedChainId.js +11 -0
- package/dist/configs/crosscurve/config.d.ts +4 -0
- package/dist/configs/crosscurve/config.d.ts.map +1 -0
- package/dist/configs/crosscurve/config.js +185 -0
- package/dist/configs/gas-zip/chains/fetch.d.ts +10 -0
- package/dist/configs/gas-zip/chains/fetch.d.ts.map +1 -0
- package/dist/configs/gas-zip/chains/fetch.js +29 -0
- package/dist/configs/gas-zip/chains/types.d.ts +25 -0
- package/dist/configs/gas-zip/chains/types.d.ts.map +1 -0
- package/dist/configs/gas-zip/chains/types.js +1 -0
- package/dist/configs/gas-zip/config.d.ts +4 -0
- package/dist/configs/gas-zip/config.d.ts.map +1 -0
- package/dist/configs/gas-zip/config.js +121 -0
- package/dist/configs/index.d.ts +2 -0
- package/dist/configs/index.d.ts.map +1 -0
- package/dist/configs/index.js +41 -0
- package/dist/configs/layerswap/LayerswapNetworks.json +3656 -0
- package/dist/configs/layerswap/config.d.ts +4 -0
- package/dist/configs/layerswap/config.d.ts.map +1 -0
- package/dist/configs/layerswap/config.js +285 -0
- package/dist/configs/lifi/config.d.ts +4 -0
- package/dist/configs/lifi/config.d.ts.map +1 -0
- package/dist/configs/lifi/config.js +104 -0
- package/dist/configs/mayan/calldata/index.d.ts +14 -0
- package/dist/configs/mayan/calldata/index.d.ts.map +1 -0
- package/dist/configs/mayan/calldata/index.js +41 -0
- package/dist/configs/mayan/config.d.ts +4 -0
- package/dist/configs/mayan/config.d.ts.map +1 -0
- package/dist/configs/mayan/config.js +222 -0
- package/dist/configs/odos/config.d.ts +8 -0
- package/dist/configs/odos/config.d.ts.map +1 -0
- package/dist/configs/odos/config.js +127 -0
- package/dist/configs/orbiter/abis/ERC20.d.ts +172 -0
- package/dist/configs/orbiter/abis/ERC20.d.ts.map +1 -0
- package/dist/configs/orbiter/abis/ERC20.js +224 -0
- package/dist/configs/orbiter/abis/OrbiterRouterEVMV3.d.ts +85 -0
- package/dist/configs/orbiter/abis/OrbiterRouterEVMV3.d.ts.map +1 -0
- package/dist/configs/orbiter/abis/OrbiterRouterEVMV3.js +83 -0
- package/dist/configs/orbiter/calldata/index.d.ts +32 -0
- package/dist/configs/orbiter/calldata/index.d.ts.map +1 -0
- package/dist/configs/orbiter/calldata/index.js +59 -0
- package/dist/configs/orbiter/config.d.ts +4 -0
- package/dist/configs/orbiter/config.d.ts.map +1 -0
- package/dist/configs/orbiter/config.js +178 -0
- package/dist/configs/router/config.d.ts +4 -0
- package/dist/configs/router/config.d.ts.map +1 -0
- package/dist/configs/router/config.js +125 -0
- package/dist/configs/squid-v1/config.d.ts +4 -0
- package/dist/configs/squid-v1/config.d.ts.map +1 -0
- package/dist/configs/squid-v1/config.js +133 -0
- package/dist/configs/squid-v2/config.d.ts +4 -0
- package/dist/configs/squid-v2/config.d.ts.map +1 -0
- package/dist/configs/squid-v2/config.js +146 -0
- package/dist/configs/squid-v2/constants.d.ts +2 -0
- package/dist/configs/squid-v2/constants.d.ts.map +1 -0
- package/dist/configs/squid-v2/constants.js +1 -0
- package/dist/configs/stargate/abis/StargatePool.d.ts +41 -0
- package/dist/configs/stargate/abis/StargatePool.d.ts.map +1 -0
- package/dist/configs/stargate/abis/StargatePool.js +318 -0
- package/dist/configs/stargate/abis/TokenMessaging.d.ts +16 -0
- package/dist/configs/stargate/abis/TokenMessaging.d.ts.map +1 -0
- package/dist/configs/stargate/abis/TokenMessaging.js +21 -0
- package/dist/configs/stargate/calldata/constants.d.ts +249 -0
- package/dist/configs/stargate/calldata/constants.d.ts.map +1 -0
- package/dist/configs/stargate/calldata/constants.js +273 -0
- package/dist/configs/stargate/calldata/index.d.ts +6 -0
- package/dist/configs/stargate/calldata/index.d.ts.map +1 -0
- package/dist/configs/stargate/calldata/index.js +127 -0
- package/dist/configs/stargate/calldata/types.d.ts +51 -0
- package/dist/configs/stargate/calldata/types.d.ts.map +1 -0
- package/dist/configs/stargate/calldata/types.js +10 -0
- package/dist/configs/stargate/common/config.d.ts +88 -0
- package/dist/configs/stargate/common/config.d.ts.map +1 -0
- package/dist/configs/stargate/common/config.js +93 -0
- package/dist/configs/stargate/common/constants.d.ts +5 -0
- package/dist/configs/stargate/common/constants.d.ts.map +1 -0
- package/dist/configs/stargate/common/constants.js +7 -0
- package/dist/configs/stargate/common/index.d.ts +3 -0
- package/dist/configs/stargate/common/index.d.ts.map +1 -0
- package/dist/configs/stargate/common/index.js +2 -0
- package/dist/configs/stargate/configs/bus/config.d.ts +4 -0
- package/dist/configs/stargate/configs/bus/config.d.ts.map +1 -0
- package/dist/configs/stargate/configs/bus/config.js +41 -0
- package/dist/configs/stargate/configs/taxi/config.d.ts +4 -0
- package/dist/configs/stargate/configs/taxi/config.d.ts.map +1 -0
- package/dist/configs/stargate/configs/taxi/config.js +58 -0
- package/dist/configs/stargate/types/index.d.ts +12 -0
- package/dist/configs/stargate/types/index.d.ts.map +1 -0
- package/dist/configs/stargate/types/index.js +15 -0
- package/dist/configs/symbiosis/config.d.ts +4 -0
- package/dist/configs/symbiosis/config.d.ts.map +1 -0
- package/dist/configs/symbiosis/config.js +119 -0
- package/dist/configs/utils/index.d.ts +2 -0
- package/dist/configs/utils/index.d.ts.map +1 -0
- package/dist/configs/utils/index.js +3 -0
- package/dist/configs/xy/config.d.ts +4 -0
- package/dist/configs/xy/config.d.ts.map +1 -0
- package/dist/configs/xy/config.js +176 -0
- package/dist/configs/zenlink/calldata/aggregationRouterV2ABI.d.ts +49 -0
- package/dist/configs/zenlink/calldata/aggregationRouterV2ABI.d.ts.map +1 -0
- package/dist/configs/zenlink/calldata/aggregationRouterV2ABI.js +63 -0
- package/dist/configs/zenlink/calldata/index.d.ts +18 -0
- package/dist/configs/zenlink/calldata/index.d.ts.map +1 -0
- package/dist/configs/zenlink/calldata/index.js +35 -0
- package/dist/configs/zenlink/config.d.ts +4 -0
- package/dist/configs/zenlink/config.d.ts.map +1 -0
- package/dist/configs/zenlink/config.js +109 -0
- package/dist/configs/zenlink/errors.d.ts +15 -0
- package/dist/configs/zenlink/errors.d.ts.map +1 -0
- package/dist/configs/zenlink/errors.js +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +52 -0
- package/dist/walletClient.d.ts +4433 -0
- package/dist/walletClient.d.ts.map +1 -0
- package/dist/walletClient.js +7 -0
- package/package.json +27 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { CrossChainBusinessException, } from '@1delta/bridge-core';
|
|
2
|
+
import { SupportedChainId } from '@1delta/lib-utils';
|
|
3
|
+
import { addresses, getSdkVersion } from '@mayanfinance/swap-sdk';
|
|
4
|
+
import { AxiosError } from 'axios';
|
|
5
|
+
import lodashRound from 'lodash/round';
|
|
6
|
+
import { formatUnits, parseUnits, zeroAddress } from 'viem';
|
|
7
|
+
import { Bridge } from '../../types';
|
|
8
|
+
import { bridgeIcon } from '../utils';
|
|
9
|
+
import { MayanBridge } from './calldata';
|
|
10
|
+
const NAME = Bridge.MAYAN;
|
|
11
|
+
const errorCodes = {
|
|
12
|
+
ERROR: { code: 'ERROR', message: 'unknown error' },
|
|
13
|
+
NOT_SUPPORT: { code: 'NOT_SUPPORT', message: 'NOT SUPPORT' },
|
|
14
|
+
};
|
|
15
|
+
var Status;
|
|
16
|
+
(function (Status) {
|
|
17
|
+
Status["COMPLETED"] = "COMPLETED";
|
|
18
|
+
Status["INPROGRESS"] = "INPROGRESS";
|
|
19
|
+
Status["REFUNDED"] = "REFUNDED";
|
|
20
|
+
})(Status || (Status = {}));
|
|
21
|
+
const CHAINID_TO_NAME = {
|
|
22
|
+
[SupportedChainId.ETHEREUM_MAINNET]: 'ethereum',
|
|
23
|
+
[SupportedChainId.BNB_SMART_CHAIN_MAINNET]: 'bsc',
|
|
24
|
+
[SupportedChainId.POLYGON_MAINNET]: 'polygon',
|
|
25
|
+
[SupportedChainId.AVALANCHE_C_CHAIN]: 'avalanche',
|
|
26
|
+
[SupportedChainId.ARBITRUM_ONE]: 'arbitrum',
|
|
27
|
+
[SupportedChainId.OP_MAINNET]: 'optimism',
|
|
28
|
+
[SupportedChainId.BASE]: 'base',
|
|
29
|
+
[SupportedChainId.UNICHAIN]: 'unichain',
|
|
30
|
+
[SupportedChainId.LINEA]: 'linea',
|
|
31
|
+
[SupportedChainId.HYPEREVM]: 'hyperevm',
|
|
32
|
+
[SupportedChainId.SONIC_MAINNET]: 'sonic',
|
|
33
|
+
};
|
|
34
|
+
const APP_NATIVE_ASSET = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
35
|
+
export const mayanConfig = {
|
|
36
|
+
name: NAME,
|
|
37
|
+
icon: {
|
|
38
|
+
light: bridgeIcon(NAME),
|
|
39
|
+
dark: bridgeIcon(NAME),
|
|
40
|
+
},
|
|
41
|
+
apiInterface: {
|
|
42
|
+
route: {
|
|
43
|
+
url: `${addresses.PRICE_URL}/quote`,
|
|
44
|
+
method: 'get',
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
before: async (params) => {
|
|
49
|
+
if (!CHAINID_TO_NAME[params.fromChainId] ||
|
|
50
|
+
!CHAINID_TO_NAME[params.toChainId]) {
|
|
51
|
+
throw new CrossChainBusinessException(errorCodes.NOT_SUPPORT);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
requestMapping: {
|
|
55
|
+
swift: true,
|
|
56
|
+
mctp: true,
|
|
57
|
+
gasless: {
|
|
58
|
+
format: (params) => params.permitEnabled && params.canDirectlyPermit,
|
|
59
|
+
},
|
|
60
|
+
onlyDirect: false,
|
|
61
|
+
solanaProgram: addresses.MAYAN_PROGRAM_ID,
|
|
62
|
+
forwarderAddress: addresses.MAYAN_FORWARDER_CONTRACT,
|
|
63
|
+
amountIn: {
|
|
64
|
+
format: (params) => Number(formatUnits(params.fromAmount, params.fromTokenDecimals)),
|
|
65
|
+
},
|
|
66
|
+
fromToken: {
|
|
67
|
+
format: (params) => params.fromTokenAddress === APP_NATIVE_ASSET
|
|
68
|
+
? zeroAddress
|
|
69
|
+
: params.fromTokenAddress,
|
|
70
|
+
},
|
|
71
|
+
fromChain: {
|
|
72
|
+
format: (params) => CHAINID_TO_NAME[params.fromChainId],
|
|
73
|
+
},
|
|
74
|
+
toToken: {
|
|
75
|
+
format: (params) => params.toTokenAddress === APP_NATIVE_ASSET
|
|
76
|
+
? zeroAddress
|
|
77
|
+
: params.toTokenAddress,
|
|
78
|
+
},
|
|
79
|
+
toChain: {
|
|
80
|
+
format: (params) => CHAINID_TO_NAME[params.toChainId],
|
|
81
|
+
},
|
|
82
|
+
slippageBps: {
|
|
83
|
+
format: (params) => params.slippage * 100,
|
|
84
|
+
},
|
|
85
|
+
gasDrop: 0,
|
|
86
|
+
// referrer: "",
|
|
87
|
+
// referrerBps: undefined,
|
|
88
|
+
sdkVersion: getSdkVersion(),
|
|
89
|
+
},
|
|
90
|
+
requestAfter: async (res, _, crossChainParamsData) => {
|
|
91
|
+
if (!Array.isArray(res.quotes) || res.quotes.length === 0) {
|
|
92
|
+
throw new CrossChainBusinessException(errorCodes.ERROR);
|
|
93
|
+
}
|
|
94
|
+
const quote = res.quotes[0];
|
|
95
|
+
const isIntent = quote.type === 'SWIFT' && quote.gasless;
|
|
96
|
+
const userIsDefined = !!crossChainParamsData.fromAddress && !!crossChainParamsData.toAddress;
|
|
97
|
+
const order = userIsDefined && isIntent
|
|
98
|
+
? MayanBridge.createEVMIntent(quote, crossChainParamsData.fromAddress, crossChainParamsData.fromChainId, crossChainParamsData.toAddress)
|
|
99
|
+
: undefined;
|
|
100
|
+
const txn = userIsDefined && !isIntent
|
|
101
|
+
? MayanBridge.createEVMTransaction(quote, crossChainParamsData.fromAddress, crossChainParamsData.fromChainId, crossChainParamsData.toAddress)
|
|
102
|
+
: undefined;
|
|
103
|
+
return { ...quote, order, txn };
|
|
104
|
+
},
|
|
105
|
+
responseMapping: {
|
|
106
|
+
name: NAME,
|
|
107
|
+
depositContract: {
|
|
108
|
+
format: (result) => result.order
|
|
109
|
+
? result.swiftMayanContract
|
|
110
|
+
: addresses.MAYAN_FORWARDER_CONTRACT,
|
|
111
|
+
},
|
|
112
|
+
toAmount: {
|
|
113
|
+
format: (result) => parseUnits(
|
|
114
|
+
// use lodash rounding and crop decimals for `parseUnits` as this will error if there are too many decimal places
|
|
115
|
+
String(lodashRound(result.expectedAmountOut, result.toToken.decimals)?.toFixed(result.toToken.decimals)), result.toToken.decimals).toString(),
|
|
116
|
+
},
|
|
117
|
+
otherPayOut: {},
|
|
118
|
+
fee: {
|
|
119
|
+
// "bridgeFee" always seems to be 0
|
|
120
|
+
},
|
|
121
|
+
estimatedDuration: 'etaSeconds', // estimated time of arrival in seconds
|
|
122
|
+
transactionData: {
|
|
123
|
+
data: {
|
|
124
|
+
format: (result) => result?.txn?.data,
|
|
125
|
+
},
|
|
126
|
+
value: {
|
|
127
|
+
format: (result) => result?.txn?.value,
|
|
128
|
+
},
|
|
129
|
+
to: {
|
|
130
|
+
format: (result) => result?.txn?.to,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
orderData: {
|
|
134
|
+
typedData: {
|
|
135
|
+
format: (result) => result?.order?.typedData,
|
|
136
|
+
},
|
|
137
|
+
broadcastIntent: {
|
|
138
|
+
format: (result) => result?.order?.broadcastIntent,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
interfaceParamData: {
|
|
142
|
+
orderId: {
|
|
143
|
+
format: (result) => {
|
|
144
|
+
return result?.order?.orderId;
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
after: (err, res) => {
|
|
150
|
+
if (!err) {
|
|
151
|
+
return res;
|
|
152
|
+
}
|
|
153
|
+
if (err instanceof AxiosError && err.response?.status === 500)
|
|
154
|
+
throw new CrossChainBusinessException(errorCodes.NOT_SUPPORT);
|
|
155
|
+
throw err;
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
status: {
|
|
159
|
+
url: `${addresses.EXPLORER_URL}/swap/trx/:hash:orderId`,
|
|
160
|
+
method: 'get',
|
|
161
|
+
before: async (params) => {
|
|
162
|
+
if (params.orderId) {
|
|
163
|
+
params.fromHash = '';
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
params.orderId = '';
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
pathParams: {
|
|
170
|
+
hash: 'fromHash',
|
|
171
|
+
orderId: 'orderId',
|
|
172
|
+
},
|
|
173
|
+
requestMapping: {},
|
|
174
|
+
requestAfter: (res) => {
|
|
175
|
+
if (!res.id)
|
|
176
|
+
throw new CrossChainBusinessException(errorCodes.ERROR);
|
|
177
|
+
return res;
|
|
178
|
+
},
|
|
179
|
+
responseMapping: {
|
|
180
|
+
fromHash: {
|
|
181
|
+
format: (result) => result.createTxHash,
|
|
182
|
+
},
|
|
183
|
+
toHash: {
|
|
184
|
+
format: (result) => result.fulfillTxHash,
|
|
185
|
+
},
|
|
186
|
+
statusInfo: {
|
|
187
|
+
format: (result) => {
|
|
188
|
+
const data = {
|
|
189
|
+
status: 'PENDING',
|
|
190
|
+
bridgeResponseResult: result,
|
|
191
|
+
};
|
|
192
|
+
if (result.clientStatus == Status.COMPLETED)
|
|
193
|
+
data.status = 'DONE';
|
|
194
|
+
else if (result.clientStatus == Status.REFUNDED)
|
|
195
|
+
data.status = 'FAILED';
|
|
196
|
+
return data;
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
after: (err, res) => {
|
|
201
|
+
if (!err) {
|
|
202
|
+
return res;
|
|
203
|
+
}
|
|
204
|
+
if (err instanceof AxiosError) {
|
|
205
|
+
if (err.response?.status === 404) {
|
|
206
|
+
return {
|
|
207
|
+
toHash: '',
|
|
208
|
+
statusInfo: {
|
|
209
|
+
status: 'NOT_FOUND',
|
|
210
|
+
message: 'NOT_FOUND',
|
|
211
|
+
bridgeResponseResult: {},
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
throw err;
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
errorCodes,
|
|
221
|
+
};
|
|
222
|
+
export default mayanConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CrossChainConfig } from '@1delta/bridge-core';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches quotes cross-chain swaps using Odos. it utilizes the Across Protocol for bridging.
|
|
4
|
+
* Note that while this function provides a price quote, the transaction execution is not working for unknown reasons (destination swap is not executed).
|
|
5
|
+
*/
|
|
6
|
+
export declare const odosConfig: CrossChainConfig;
|
|
7
|
+
export default odosConfig;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/configs/odos/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAiB5B;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,gBAsHxB,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { CrossChainBusinessException, } from '@1delta/bridge-core';
|
|
2
|
+
import { NATIVE_PLACEHOLDER } from '@1delta/lib-utils';
|
|
3
|
+
import { AxiosError } from 'axios';
|
|
4
|
+
import { zeroAddress } from 'viem';
|
|
5
|
+
const NAME = 'Odos Cross-Chain';
|
|
6
|
+
const URL = 'https://api.odos.xyz/cross-chain';
|
|
7
|
+
const errorCodes = {
|
|
8
|
+
ERROR: { code: 'ERROR', message: 'unknown error' },
|
|
9
|
+
NOT_SUPPORT: { code: 'NOT_SUPPORT', message: 'NOT SUPPORT' },
|
|
10
|
+
};
|
|
11
|
+
const ODOS_ICON = 'https://raw.githubusercontent.com/1delta-DAO/protocol-icons/main/aggregator/odos.webp';
|
|
12
|
+
/**
|
|
13
|
+
* Fetches quotes cross-chain swaps using Odos. it utilizes the Across Protocol for bridging.
|
|
14
|
+
* Note that while this function provides a price quote, the transaction execution is not working for unknown reasons (destination swap is not executed).
|
|
15
|
+
*/
|
|
16
|
+
export const odosConfig = {
|
|
17
|
+
name: NAME,
|
|
18
|
+
icon: {
|
|
19
|
+
light: ODOS_ICON,
|
|
20
|
+
dark: ODOS_ICON,
|
|
21
|
+
},
|
|
22
|
+
apiInterface: {
|
|
23
|
+
route: {
|
|
24
|
+
url: `${URL}/quote`,
|
|
25
|
+
method: 'post',
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
},
|
|
29
|
+
requestMapping: {
|
|
30
|
+
sourceChain: 'fromChainId',
|
|
31
|
+
destinationChain: 'toChainId',
|
|
32
|
+
inputTokens: {
|
|
33
|
+
format: (params) => [
|
|
34
|
+
{
|
|
35
|
+
tokenAddress: params.fromTokenAddress === NATIVE_PLACEHOLDER
|
|
36
|
+
? zeroAddress
|
|
37
|
+
: params.fromTokenAddress,
|
|
38
|
+
amount: params.fromAmount,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
outputTokens: {
|
|
43
|
+
format: (params) => [
|
|
44
|
+
{
|
|
45
|
+
tokenAddress: params.toTokenAddress === NATIVE_PLACEHOLDER
|
|
46
|
+
? zeroAddress
|
|
47
|
+
: params.toTokenAddress,
|
|
48
|
+
proportion: 1,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
slippageLimitPercent: 'slippage',
|
|
53
|
+
userAddr: 'toAddress',
|
|
54
|
+
compact: {
|
|
55
|
+
format: () => true,
|
|
56
|
+
},
|
|
57
|
+
disableRFQs: {
|
|
58
|
+
format: () => false,
|
|
59
|
+
},
|
|
60
|
+
sourceBlacklist: {
|
|
61
|
+
format: () => [],
|
|
62
|
+
},
|
|
63
|
+
pathViz: {
|
|
64
|
+
format: () => false,
|
|
65
|
+
},
|
|
66
|
+
referralCode: {
|
|
67
|
+
format: () => 0,
|
|
68
|
+
},
|
|
69
|
+
likeAsset: {
|
|
70
|
+
format: () => false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
requestAfter: async (res, _, crossChainParamsData) => {
|
|
74
|
+
if (!res?.destinationQuote || !res?.transaction) {
|
|
75
|
+
throw new CrossChainBusinessException(errorCodes.ERROR);
|
|
76
|
+
}
|
|
77
|
+
const quote = res.destinationQuote;
|
|
78
|
+
const userIsDefined = !!crossChainParamsData.fromAddress && !!crossChainParamsData.toAddress;
|
|
79
|
+
const txn = userIsDefined ? res.transaction : undefined;
|
|
80
|
+
return { ...quote, txn };
|
|
81
|
+
},
|
|
82
|
+
responseMapping: {
|
|
83
|
+
name: NAME,
|
|
84
|
+
depositContract: 'txn.to',
|
|
85
|
+
toAmount: {
|
|
86
|
+
format: (result) => result?.outAmounts[0],
|
|
87
|
+
},
|
|
88
|
+
otherPayOut: {},
|
|
89
|
+
fee: {
|
|
90
|
+
// "bridgeFee" always seems to be 0
|
|
91
|
+
},
|
|
92
|
+
estimatedDuration: '60', // estimated time of arrival in seconds
|
|
93
|
+
transactionData: {
|
|
94
|
+
data: 'txn.data',
|
|
95
|
+
value: 'txn.value',
|
|
96
|
+
to: 'txn.to',
|
|
97
|
+
},
|
|
98
|
+
interfaceParamData: {},
|
|
99
|
+
},
|
|
100
|
+
after: (err, res) => {
|
|
101
|
+
if (!err) {
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
if (err instanceof AxiosError && err.response?.status === 500)
|
|
105
|
+
throw new CrossChainBusinessException(errorCodes.NOT_SUPPORT);
|
|
106
|
+
throw err;
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
status: {
|
|
110
|
+
url: `${URL}`,
|
|
111
|
+
method: 'get',
|
|
112
|
+
requestMapping: {},
|
|
113
|
+
requestAfter: () => { },
|
|
114
|
+
responseMapping: {
|
|
115
|
+
fromHash: '',
|
|
116
|
+
toHash: '',
|
|
117
|
+
statusInfo: {
|
|
118
|
+
status: 'DONE',
|
|
119
|
+
message: '',
|
|
120
|
+
bridgeResponseResult: '',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
errorCodes,
|
|
126
|
+
};
|
|
127
|
+
export default odosConfig;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
export declare const ERC20_ABI: readonly [{
|
|
2
|
+
readonly anonymous: false;
|
|
3
|
+
readonly inputs: readonly [{
|
|
4
|
+
readonly indexed: true;
|
|
5
|
+
readonly internalType: "address";
|
|
6
|
+
readonly name: "owner";
|
|
7
|
+
readonly type: "address";
|
|
8
|
+
}, {
|
|
9
|
+
readonly indexed: true;
|
|
10
|
+
readonly internalType: "address";
|
|
11
|
+
readonly name: "spender";
|
|
12
|
+
readonly type: "address";
|
|
13
|
+
}, {
|
|
14
|
+
readonly indexed: false;
|
|
15
|
+
readonly internalType: "uint256";
|
|
16
|
+
readonly name: "value";
|
|
17
|
+
readonly type: "uint256";
|
|
18
|
+
}];
|
|
19
|
+
readonly name: "Approval";
|
|
20
|
+
readonly type: "event";
|
|
21
|
+
}, {
|
|
22
|
+
readonly anonymous: false;
|
|
23
|
+
readonly inputs: readonly [{
|
|
24
|
+
readonly indexed: true;
|
|
25
|
+
readonly internalType: "address";
|
|
26
|
+
readonly name: "from";
|
|
27
|
+
readonly type: "address";
|
|
28
|
+
}, {
|
|
29
|
+
readonly indexed: true;
|
|
30
|
+
readonly internalType: "address";
|
|
31
|
+
readonly name: "to";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
}, {
|
|
34
|
+
readonly indexed: false;
|
|
35
|
+
readonly internalType: "uint256";
|
|
36
|
+
readonly name: "value";
|
|
37
|
+
readonly type: "uint256";
|
|
38
|
+
}];
|
|
39
|
+
readonly name: "Transfer";
|
|
40
|
+
readonly type: "event";
|
|
41
|
+
}, {
|
|
42
|
+
readonly inputs: readonly [{
|
|
43
|
+
readonly internalType: "address";
|
|
44
|
+
readonly name: "owner";
|
|
45
|
+
readonly type: "address";
|
|
46
|
+
}, {
|
|
47
|
+
readonly internalType: "address";
|
|
48
|
+
readonly name: "spender";
|
|
49
|
+
readonly type: "address";
|
|
50
|
+
}];
|
|
51
|
+
readonly name: "allowance";
|
|
52
|
+
readonly outputs: readonly [{
|
|
53
|
+
readonly internalType: "uint256";
|
|
54
|
+
readonly name: "";
|
|
55
|
+
readonly type: "uint256";
|
|
56
|
+
}];
|
|
57
|
+
readonly stateMutability: "view";
|
|
58
|
+
readonly type: "function";
|
|
59
|
+
}, {
|
|
60
|
+
readonly inputs: readonly [{
|
|
61
|
+
readonly internalType: "address";
|
|
62
|
+
readonly name: "spender";
|
|
63
|
+
readonly type: "address";
|
|
64
|
+
}, {
|
|
65
|
+
readonly internalType: "uint256";
|
|
66
|
+
readonly name: "amount";
|
|
67
|
+
readonly type: "uint256";
|
|
68
|
+
}];
|
|
69
|
+
readonly name: "approve";
|
|
70
|
+
readonly outputs: readonly [{
|
|
71
|
+
readonly internalType: "bool";
|
|
72
|
+
readonly name: "";
|
|
73
|
+
readonly type: "bool";
|
|
74
|
+
}];
|
|
75
|
+
readonly stateMutability: "nonpayable";
|
|
76
|
+
readonly type: "function";
|
|
77
|
+
}, {
|
|
78
|
+
readonly inputs: readonly [{
|
|
79
|
+
readonly internalType: "address";
|
|
80
|
+
readonly name: "account";
|
|
81
|
+
readonly type: "address";
|
|
82
|
+
}];
|
|
83
|
+
readonly name: "balanceOf";
|
|
84
|
+
readonly outputs: readonly [{
|
|
85
|
+
readonly internalType: "uint256";
|
|
86
|
+
readonly name: "";
|
|
87
|
+
readonly type: "uint256";
|
|
88
|
+
}];
|
|
89
|
+
readonly stateMutability: "view";
|
|
90
|
+
readonly type: "function";
|
|
91
|
+
}, {
|
|
92
|
+
readonly inputs: readonly [];
|
|
93
|
+
readonly name: "decimals";
|
|
94
|
+
readonly outputs: readonly [{
|
|
95
|
+
readonly internalType: "uint8";
|
|
96
|
+
readonly name: "";
|
|
97
|
+
readonly type: "uint8";
|
|
98
|
+
}];
|
|
99
|
+
readonly stateMutability: "view";
|
|
100
|
+
readonly type: "function";
|
|
101
|
+
}, {
|
|
102
|
+
readonly inputs: readonly [];
|
|
103
|
+
readonly name: "name";
|
|
104
|
+
readonly outputs: readonly [{
|
|
105
|
+
readonly internalType: "string";
|
|
106
|
+
readonly name: "";
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
}];
|
|
109
|
+
readonly stateMutability: "view";
|
|
110
|
+
readonly type: "function";
|
|
111
|
+
}, {
|
|
112
|
+
readonly inputs: readonly [];
|
|
113
|
+
readonly name: "symbol";
|
|
114
|
+
readonly outputs: readonly [{
|
|
115
|
+
readonly internalType: "string";
|
|
116
|
+
readonly name: "";
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
}];
|
|
119
|
+
readonly stateMutability: "view";
|
|
120
|
+
readonly type: "function";
|
|
121
|
+
}, {
|
|
122
|
+
readonly inputs: readonly [];
|
|
123
|
+
readonly name: "totalSupply";
|
|
124
|
+
readonly outputs: readonly [{
|
|
125
|
+
readonly internalType: "uint256";
|
|
126
|
+
readonly name: "";
|
|
127
|
+
readonly type: "uint256";
|
|
128
|
+
}];
|
|
129
|
+
readonly stateMutability: "view";
|
|
130
|
+
readonly type: "function";
|
|
131
|
+
}, {
|
|
132
|
+
readonly inputs: readonly [{
|
|
133
|
+
readonly internalType: "address";
|
|
134
|
+
readonly name: "recipient";
|
|
135
|
+
readonly type: "address";
|
|
136
|
+
}, {
|
|
137
|
+
readonly internalType: "uint256";
|
|
138
|
+
readonly name: "amount";
|
|
139
|
+
readonly type: "uint256";
|
|
140
|
+
}];
|
|
141
|
+
readonly name: "transfer";
|
|
142
|
+
readonly outputs: readonly [{
|
|
143
|
+
readonly internalType: "bool";
|
|
144
|
+
readonly name: "";
|
|
145
|
+
readonly type: "bool";
|
|
146
|
+
}];
|
|
147
|
+
readonly stateMutability: "nonpayable";
|
|
148
|
+
readonly type: "function";
|
|
149
|
+
}, {
|
|
150
|
+
readonly inputs: readonly [{
|
|
151
|
+
readonly internalType: "address";
|
|
152
|
+
readonly name: "sender";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
}, {
|
|
155
|
+
readonly internalType: "address";
|
|
156
|
+
readonly name: "recipient";
|
|
157
|
+
readonly type: "address";
|
|
158
|
+
}, {
|
|
159
|
+
readonly internalType: "uint256";
|
|
160
|
+
readonly name: "amount";
|
|
161
|
+
readonly type: "uint256";
|
|
162
|
+
}];
|
|
163
|
+
readonly name: "transferFrom";
|
|
164
|
+
readonly outputs: readonly [{
|
|
165
|
+
readonly internalType: "bool";
|
|
166
|
+
readonly name: "";
|
|
167
|
+
readonly type: "bool";
|
|
168
|
+
}];
|
|
169
|
+
readonly stateMutability: "nonpayable";
|
|
170
|
+
readonly type: "function";
|
|
171
|
+
}];
|
|
172
|
+
//# sourceMappingURL=ERC20.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20.d.ts","sourceRoot":"","sources":["../../../../src/configs/orbiter/abis/ERC20.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+NZ,CAAA"}
|