@velora-dex/sdk 8.0.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 +7 -0
- package/README.md +494 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/examples/customFetcher.d.ts +3 -0
- package/dist/examples/customFetcher.d.ts.map +1 -0
- package/dist/examples/delta.d.ts +2 -0
- package/dist/examples/delta.d.ts.map +1 -0
- package/dist/examples/ethersV6.d.ts +2 -0
- package/dist/examples/ethersV6.d.ts.map +1 -0
- package/dist/examples/limitOrders_all.d.ts +2 -0
- package/dist/examples/limitOrders_all.d.ts.map +1 -0
- package/dist/examples/limitOrders_partial.d.ts +2 -0
- package/dist/examples/limitOrders_partial.d.ts.map +1 -0
- package/dist/examples/limitOrders_postOrder.d.ts +2 -0
- package/dist/examples/limitOrders_postOrder.d.ts.map +1 -0
- package/dist/examples/partial.d.ts +2 -0
- package/dist/examples/partial.d.ts.map +1 -0
- package/dist/examples/quote.d.ts +2 -0
- package/dist/examples/quote.d.ts.map +1 -0
- package/dist/examples/sdk.d.ts +2 -0
- package/dist/examples/sdk.d.ts.map +1 -0
- package/dist/examples/simple.d.ts +2 -0
- package/dist/examples/simple.d.ts.map +1 -0
- package/dist/examples/simpleQuote.d.ts +2 -0
- package/dist/examples/simpleQuote.d.ts.map +1 -0
- package/dist/examples/viem.d.ts +2 -0
- package/dist/examples/viem.d.ts.map +1 -0
- package/dist/examples/wagmi.d.ts +43 -0
- package/dist/examples/wagmi.d.ts.map +1 -0
- package/dist/examples/web3.d.ts +2 -0
- package/dist/examples/web3.d.ts.map +1 -0
- package/dist/gas.d.ts +8 -0
- package/dist/gas.d.ts.map +1 -0
- package/dist/helpers/approve.d.ts +8 -0
- package/dist/helpers/approve.d.ts.map +1 -0
- package/dist/helpers/fetchers/axios.d.ts +5 -0
- package/dist/helpers/fetchers/axios.d.ts.map +1 -0
- package/dist/helpers/fetchers/fetch.d.ts +5 -0
- package/dist/helpers/fetchers/fetch.d.ts.map +1 -0
- package/dist/helpers/index.d.ts +13 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/misc.d.ts +48 -0
- package/dist/helpers/misc.d.ts.map +1 -0
- package/dist/helpers/providers/ethers.d.ts +10 -0
- package/dist/helpers/providers/ethers.d.ts.map +1 -0
- package/dist/helpers/providers/ethersV6.d.ts +8 -0
- package/dist/helpers/providers/ethersV6.d.ts.map +1 -0
- package/dist/helpers/providers/helpers.d.ts +3 -0
- package/dist/helpers/providers/helpers.d.ts.map +1 -0
- package/dist/helpers/providers/viem.d.ts +23 -0
- package/dist/helpers/providers/viem.d.ts.map +1 -0
- package/dist/helpers/providers/web3.d.ts +9 -0
- package/dist/helpers/providers/web3.d.ts.map +1 -0
- package/dist/helpers/token.d.ts +38 -0
- package/dist/helpers/token.d.ts.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/methods/common/orders/buildOrderData.d.ts +27 -0
- package/dist/methods/common/orders/buildOrderData.d.ts.map +1 -0
- package/dist/methods/common/orders/encoding.d.ts +23 -0
- package/dist/methods/common/orders/encoding.d.ts.map +1 -0
- package/dist/methods/common/orders/misc.d.ts +27 -0
- package/dist/methods/common/orders/misc.d.ts.map +1 -0
- package/dist/methods/common/orders/signature.d.ts +9 -0
- package/dist/methods/common/orders/signature.d.ts.map +1 -0
- package/dist/methods/common/orders/types.d.ts +8 -0
- package/dist/methods/common/orders/types.d.ts.map +1 -0
- package/dist/methods/delta/approveForDelta.d.ts +8 -0
- package/dist/methods/delta/approveForDelta.d.ts.map +1 -0
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts +23 -0
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts.map +1 -0
- package/dist/methods/delta/buildDeltaOrder.d.ts +49 -0
- package/dist/methods/delta/buildDeltaOrder.d.ts.map +1 -0
- package/dist/methods/delta/getBridgeInfo.d.ts +9 -0
- package/dist/methods/delta/getBridgeInfo.d.ts.map +1 -0
- package/dist/methods/delta/getDeltaContract.d.ts +9 -0
- package/dist/methods/delta/getDeltaContract.d.ts.map +1 -0
- package/dist/methods/delta/getDeltaOrders.d.ts +22 -0
- package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -0
- package/dist/methods/delta/getDeltaPrice.d.ts +58 -0
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -0
- package/dist/methods/delta/getMulticallHandlers.d.ts +9 -0
- package/dist/methods/delta/getMulticallHandlers.d.ts.map +1 -0
- package/dist/methods/delta/getPartnerFee.d.ts +16 -0
- package/dist/methods/delta/getPartnerFee.d.ts.map +1 -0
- package/dist/methods/delta/helpers/across.d.ts +22 -0
- package/dist/methods/delta/helpers/across.d.ts.map +1 -0
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts +35 -0
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts.map +1 -0
- package/dist/methods/delta/helpers/composePermit.d.ts +5 -0
- package/dist/methods/delta/helpers/composePermit.d.ts.map +1 -0
- package/dist/methods/delta/helpers/misc.d.ts +3 -0
- package/dist/methods/delta/helpers/misc.d.ts.map +1 -0
- package/dist/methods/delta/helpers/types.d.ts +96 -0
- package/dist/methods/delta/helpers/types.d.ts.map +1 -0
- package/dist/methods/delta/index.d.ts +28 -0
- package/dist/methods/delta/index.d.ts.map +1 -0
- package/dist/methods/delta/isTokenSupportedInDelta.d.ts +8 -0
- package/dist/methods/delta/isTokenSupportedInDelta.d.ts.map +1 -0
- package/dist/methods/delta/postDeltaOrder.d.ts +23 -0
- package/dist/methods/delta/postDeltaOrder.d.ts.map +1 -0
- package/dist/methods/delta/signDeltaOrder.d.ts +12 -0
- package/dist/methods/delta/signDeltaOrder.d.ts.map +1 -0
- package/dist/methods/limitOrders/approveForOrder.d.ts +12 -0
- package/dist/methods/limitOrders/approveForOrder.d.ts.map +1 -0
- package/dist/methods/limitOrders/buildOrder.d.ts +11 -0
- package/dist/methods/limitOrders/buildOrder.d.ts.map +1 -0
- package/dist/methods/limitOrders/cancelOrder.d.ts +9 -0
- package/dist/methods/limitOrders/cancelOrder.d.ts.map +1 -0
- package/dist/methods/limitOrders/fillOrderDirectly.d.ts +30 -0
- package/dist/methods/limitOrders/fillOrderDirectly.d.ts.map +1 -0
- package/dist/methods/limitOrders/getOrders.d.ts +39 -0
- package/dist/methods/limitOrders/getOrders.d.ts.map +1 -0
- package/dist/methods/limitOrders/getOrdersContract.d.ts +8 -0
- package/dist/methods/limitOrders/getOrdersContract.d.ts.map +1 -0
- package/dist/methods/limitOrders/helpers/buildOrderData.d.ts +43 -0
- package/dist/methods/limitOrders/helpers/buildOrderData.d.ts.map +1 -0
- package/dist/methods/limitOrders/helpers/misc.d.ts +9 -0
- package/dist/methods/limitOrders/helpers/misc.d.ts.map +1 -0
- package/dist/methods/limitOrders/helpers/types.d.ts +49 -0
- package/dist/methods/limitOrders/helpers/types.d.ts.map +1 -0
- package/dist/methods/limitOrders/index.d.ts +30 -0
- package/dist/methods/limitOrders/index.d.ts.map +1 -0
- package/dist/methods/limitOrders/postOrder.d.ts +10 -0
- package/dist/methods/limitOrders/postOrder.d.ts.map +1 -0
- package/dist/methods/limitOrders/signOrder.d.ts +7 -0
- package/dist/methods/limitOrders/signOrder.d.ts.map +1 -0
- package/dist/methods/limitOrders/transaction.d.ts +23 -0
- package/dist/methods/limitOrders/transaction.d.ts.map +1 -0
- package/dist/methods/nftOrders/approveForOrder.d.ts +12 -0
- package/dist/methods/nftOrders/approveForOrder.d.ts.map +1 -0
- package/dist/methods/nftOrders/buildOrder.d.ts +11 -0
- package/dist/methods/nftOrders/buildOrder.d.ts.map +1 -0
- package/dist/methods/nftOrders/cancelOrder.d.ts +8 -0
- package/dist/methods/nftOrders/cancelOrder.d.ts.map +1 -0
- package/dist/methods/nftOrders/getOrders.d.ts +18 -0
- package/dist/methods/nftOrders/getOrders.d.ts.map +1 -0
- package/dist/methods/nftOrders/getOrdersContract.d.ts +8 -0
- package/dist/methods/nftOrders/getOrdersContract.d.ts.map +1 -0
- package/dist/methods/nftOrders/helpers/buildOrderData.d.ts +52 -0
- package/dist/methods/nftOrders/helpers/buildOrderData.d.ts.map +1 -0
- package/dist/methods/nftOrders/helpers/misc.d.ts +13 -0
- package/dist/methods/nftOrders/helpers/misc.d.ts.map +1 -0
- package/dist/methods/nftOrders/helpers/types.d.ts +39 -0
- package/dist/methods/nftOrders/helpers/types.d.ts.map +1 -0
- package/dist/methods/nftOrders/index.d.ts +23 -0
- package/dist/methods/nftOrders/index.d.ts.map +1 -0
- package/dist/methods/nftOrders/postOrder.d.ts +10 -0
- package/dist/methods/nftOrders/postOrder.d.ts.map +1 -0
- package/dist/methods/nftOrders/signOrder.d.ts +7 -0
- package/dist/methods/nftOrders/signOrder.d.ts.map +1 -0
- package/dist/methods/nftOrders/transaction.d.ts +23 -0
- package/dist/methods/nftOrders/transaction.d.ts.map +1 -0
- package/dist/methods/quote/getQuote.d.ts +51 -0
- package/dist/methods/quote/getQuote.d.ts.map +1 -0
- package/dist/methods/swap/adapters.d.ts +8 -0
- package/dist/methods/swap/adapters.d.ts.map +1 -0
- package/dist/methods/swap/approve.d.ts +10 -0
- package/dist/methods/swap/approve.d.ts.map +1 -0
- package/dist/methods/swap/balance.d.ts +23 -0
- package/dist/methods/swap/balance.d.ts.map +1 -0
- package/dist/methods/swap/helpers/normalizeRateOptions.d.ts +12 -0
- package/dist/methods/swap/helpers/normalizeRateOptions.d.ts.map +1 -0
- package/dist/methods/swap/index.d.ts +13 -0
- package/dist/methods/swap/index.d.ts.map +1 -0
- package/dist/methods/swap/rates.d.ts +52 -0
- package/dist/methods/swap/rates.d.ts.map +1 -0
- package/dist/methods/swap/spender.d.ts +21 -0
- package/dist/methods/swap/spender.d.ts.map +1 -0
- package/dist/methods/swap/swapTx.d.ts +158 -0
- package/dist/methods/swap/swapTx.d.ts.map +1 -0
- package/dist/methods/swap/token.d.ts +8 -0
- package/dist/methods/swap/token.d.ts.map +1 -0
- package/dist/methods/swap/transaction.d.ts +115 -0
- package/dist/methods/swap/transaction.d.ts.map +1 -0
- package/dist/sdk/full.d.ts +17 -0
- package/dist/sdk/full.d.ts.map +1 -0
- package/dist/sdk/partial.d.ts +31 -0
- package/dist/sdk/partial.d.ts.map +1 -0
- package/dist/sdk/simple.d.ts +75 -0
- package/dist/sdk/simple.d.ts.map +1 -0
- package/dist/sdk.cjs.development.js +5182 -0
- package/dist/sdk.cjs.development.js.map +1 -0
- package/dist/sdk.cjs.production.min.js +2 -0
- package/dist/sdk.cjs.production.min.js.map +1 -0
- package/dist/sdk.esm.js +5102 -0
- package/dist/sdk.esm.js.map +1 -0
- package/dist/types.d.ts +161 -0
- package/dist/types.d.ts.map +1 -0
- package/docs/DELTA.md +207 -0
- package/package.json +126 -0
- package/src/constants.ts +16 -0
- package/src/examples/customFetcher.ts +44 -0
- package/src/examples/delta.ts +127 -0
- package/src/examples/ethersV6.ts +38 -0
- package/src/examples/limitOrders_all.ts +135 -0
- package/src/examples/limitOrders_partial.ts +171 -0
- package/src/examples/limitOrders_postOrder.ts +77 -0
- package/src/examples/partial.ts +34 -0
- package/src/examples/quote.ts +205 -0
- package/src/examples/sdk.ts +39 -0
- package/src/examples/simple.ts +44 -0
- package/src/examples/simpleQuote.ts +98 -0
- package/src/examples/viem.ts +120 -0
- package/src/examples/wagmi.ts +68 -0
- package/src/examples/web3.ts +32 -0
- package/src/gas.ts +7 -0
- package/src/helpers/approve.ts +60 -0
- package/src/helpers/fetchers/axios.ts +34 -0
- package/src/helpers/fetchers/fetch.ts +67 -0
- package/src/helpers/index.ts +27 -0
- package/src/helpers/misc.ts +160 -0
- package/src/helpers/providers/ethers.ts +192 -0
- package/src/helpers/providers/ethersV6.ts +121 -0
- package/src/helpers/providers/helpers.ts +36 -0
- package/src/helpers/providers/viem.ts +205 -0
- package/src/helpers/providers/web3.ts +154 -0
- package/src/helpers/token.ts +75 -0
- package/src/index.ts +425 -0
- package/src/methods/common/orders/buildOrderData.ts +29 -0
- package/src/methods/common/orders/encoding.ts +216 -0
- package/src/methods/common/orders/misc.ts +86 -0
- package/src/methods/common/orders/signature.ts +68 -0
- package/src/methods/common/orders/types.ts +13 -0
- package/src/methods/delta/approveForDelta.ts +38 -0
- package/src/methods/delta/buildCrosschainOrderBridge.ts +84 -0
- package/src/methods/delta/buildDeltaOrder.ts +192 -0
- package/src/methods/delta/getBridgeInfo.ts +38 -0
- package/src/methods/delta/getDeltaContract.ts +29 -0
- package/src/methods/delta/getDeltaOrders.ts +102 -0
- package/src/methods/delta/getDeltaPrice.ts +122 -0
- package/src/methods/delta/getMulticallHandlers.ts +44 -0
- package/src/methods/delta/getPartnerFee.ts +58 -0
- package/src/methods/delta/helpers/across.ts +255 -0
- package/src/methods/delta/helpers/buildDeltaOrderData.ts +153 -0
- package/src/methods/delta/helpers/composePermit.ts +76 -0
- package/src/methods/delta/helpers/misc.ts +32 -0
- package/src/methods/delta/helpers/types.ts +110 -0
- package/src/methods/delta/index.ts +146 -0
- package/src/methods/delta/isTokenSupportedInDelta.ts +54 -0
- package/src/methods/delta/postDeltaOrder.ts +50 -0
- package/src/methods/delta/signDeltaOrder.ts +41 -0
- package/src/methods/limitOrders/approveForOrder.ts +36 -0
- package/src/methods/limitOrders/buildOrder.ts +56 -0
- package/src/methods/limitOrders/cancelOrder.ts +111 -0
- package/src/methods/limitOrders/fillOrderDirectly.ts +277 -0
- package/src/methods/limitOrders/getOrders.ts +151 -0
- package/src/methods/limitOrders/getOrdersContract.ts +20 -0
- package/src/methods/limitOrders/helpers/buildOrderData.ts +121 -0
- package/src/methods/limitOrders/helpers/misc.ts +64 -0
- package/src/methods/limitOrders/helpers/types.ts +70 -0
- package/src/methods/limitOrders/index.ts +154 -0
- package/src/methods/limitOrders/postOrder.ts +74 -0
- package/src/methods/limitOrders/signOrder.ts +29 -0
- package/src/methods/limitOrders/transaction.ts +231 -0
- package/src/methods/nftOrders/approveForOrder.ts +79 -0
- package/src/methods/nftOrders/buildOrder.ts +52 -0
- package/src/methods/nftOrders/cancelOrder.ts +23 -0
- package/src/methods/nftOrders/getOrders.ts +84 -0
- package/src/methods/nftOrders/getOrdersContract.ts +24 -0
- package/src/methods/nftOrders/helpers/buildOrderData.ts +131 -0
- package/src/methods/nftOrders/helpers/misc.ts +92 -0
- package/src/methods/nftOrders/helpers/types.ts +50 -0
- package/src/methods/nftOrders/index.ts +139 -0
- package/src/methods/nftOrders/postOrder.ts +71 -0
- package/src/methods/nftOrders/signOrder.ts +29 -0
- package/src/methods/nftOrders/transaction.ts +234 -0
- package/src/methods/quote/getQuote.ts +131 -0
- package/src/methods/swap/adapters.ts +49 -0
- package/src/methods/swap/approve.ts +51 -0
- package/src/methods/swap/balance.ts +147 -0
- package/src/methods/swap/helpers/normalizeRateOptions.ts +55 -0
- package/src/methods/swap/index.ts +38 -0
- package/src/methods/swap/rates.ts +276 -0
- package/src/methods/swap/spender.ts +76 -0
- package/src/methods/swap/swapTx.ts +266 -0
- package/src/methods/swap/token.ts +35 -0
- package/src/methods/swap/transaction.ts +310 -0
- package/src/sdk/full.ts +54 -0
- package/src/sdk/partial.ts +107 -0
- package/src/sdk/simple.ts +429 -0
- package/src/types.ts +240 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import type {
|
|
3
|
+
Address,
|
|
4
|
+
ConstructFetchInput,
|
|
5
|
+
RequestParameters,
|
|
6
|
+
} from '../../types';
|
|
7
|
+
|
|
8
|
+
// srcChainId -> destChainId -> outputToken[]
|
|
9
|
+
// output Tokens that are supported for a srcChainId -> destChainId pair
|
|
10
|
+
export type BridgeInfo = Record<number, Record<number, Address[]>>;
|
|
11
|
+
type BridgeInfoResponse = { supportedTokens: BridgeInfo };
|
|
12
|
+
|
|
13
|
+
type GetBridgeInfo = (requestParams?: RequestParameters) => Promise<BridgeInfo>;
|
|
14
|
+
|
|
15
|
+
export type GetBridgeInfoFunctions = {
|
|
16
|
+
getBridgeInfo: GetBridgeInfo;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const constructGetBridgeInfo = ({
|
|
20
|
+
apiURL = API_URL,
|
|
21
|
+
fetcher,
|
|
22
|
+
}: ConstructFetchInput): GetBridgeInfoFunctions => {
|
|
23
|
+
const bridgeInfoUrl = `${apiURL}/delta/prices/bridge-info` as const;
|
|
24
|
+
|
|
25
|
+
const getBridgeInfo: GetBridgeInfo = async (requestParams) => {
|
|
26
|
+
const data = await fetcher<BridgeInfoResponse>({
|
|
27
|
+
url: bridgeInfoUrl,
|
|
28
|
+
method: 'GET',
|
|
29
|
+
requestParams,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return data.supportedTokens;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
getBridgeInfo,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address,
|
|
3
|
+
ConstructFetchInput,
|
|
4
|
+
RequestParameters,
|
|
5
|
+
} from '../../types';
|
|
6
|
+
import { constructGetSpender } from '../swap/spender';
|
|
7
|
+
|
|
8
|
+
type GetDeltaContract = (
|
|
9
|
+
requestParams?: RequestParameters
|
|
10
|
+
) => Promise<Address | null>;
|
|
11
|
+
export type GetDeltaContractFunctions = {
|
|
12
|
+
/** @description returns ParaswapDelta contract address when Delta is available on current chain */
|
|
13
|
+
getDeltaContract: GetDeltaContract;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const constructGetDeltaContract = (
|
|
17
|
+
options: ConstructFetchInput
|
|
18
|
+
): GetDeltaContractFunctions => {
|
|
19
|
+
// analogous to getSpender() but for Delta Orders Contract = ParaswapDelta
|
|
20
|
+
|
|
21
|
+
const { getContracts } = constructGetSpender(options);
|
|
22
|
+
|
|
23
|
+
const getDeltaContract: GetDeltaContract = async (requestParams) => {
|
|
24
|
+
const { ParaswapDelta } = await getContracts(requestParams);
|
|
25
|
+
return ParaswapDelta || null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return { getDeltaContract };
|
|
29
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type {
|
|
4
|
+
Address,
|
|
5
|
+
ConstructFetchInput,
|
|
6
|
+
RequestParameters,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
import type { DeltaAuction } from './helpers/types';
|
|
9
|
+
|
|
10
|
+
type OrderFromAPI = Omit<DeltaAuction, 'signature'>;
|
|
11
|
+
|
|
12
|
+
type GetDeltaOrderById = (
|
|
13
|
+
orderId: string,
|
|
14
|
+
requestParams?: RequestParameters
|
|
15
|
+
) => Promise<OrderFromAPI>;
|
|
16
|
+
|
|
17
|
+
type GetDeltaOrderByHash = (
|
|
18
|
+
orderHash: string,
|
|
19
|
+
requestParams?: RequestParameters
|
|
20
|
+
) => Promise<OrderFromAPI>;
|
|
21
|
+
|
|
22
|
+
type OrdersFilter = {
|
|
23
|
+
/** @description Order.owner to fetch Delta Order for */
|
|
24
|
+
userAddress: Address;
|
|
25
|
+
/** @description Pagination option, page. Default 1 */
|
|
26
|
+
page?: number;
|
|
27
|
+
/** @description Pagination option, limit. Default 100 */
|
|
28
|
+
limit?: number;
|
|
29
|
+
};
|
|
30
|
+
type OrderFiltersQuery = OrdersFilter;
|
|
31
|
+
|
|
32
|
+
type GetDeltaOrders = (
|
|
33
|
+
options: OrdersFilter,
|
|
34
|
+
requestParams?: RequestParameters
|
|
35
|
+
) => Promise<OrderFromAPI[]>;
|
|
36
|
+
|
|
37
|
+
export type GetDeltaOrdersFunctions = {
|
|
38
|
+
getDeltaOrderById: GetDeltaOrderById;
|
|
39
|
+
getDeltaOrderByHash: GetDeltaOrderByHash;
|
|
40
|
+
getDeltaOrders: GetDeltaOrders;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const constructGetDeltaOrders = ({
|
|
44
|
+
apiURL = API_URL,
|
|
45
|
+
fetcher,
|
|
46
|
+
}: ConstructFetchInput): GetDeltaOrdersFunctions => {
|
|
47
|
+
const baseUrl = `${apiURL}/delta/orders` as const;
|
|
48
|
+
|
|
49
|
+
const getDeltaOrderById: GetDeltaOrderById = async (
|
|
50
|
+
orderId,
|
|
51
|
+
requestParams
|
|
52
|
+
) => {
|
|
53
|
+
const fetchURL = `${baseUrl}/${orderId}` as const;
|
|
54
|
+
|
|
55
|
+
const order = await fetcher<OrderFromAPI>({
|
|
56
|
+
url: fetchURL,
|
|
57
|
+
method: 'GET',
|
|
58
|
+
requestParams,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return order;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const getDeltaOrderByHash: GetDeltaOrderByHash = async (
|
|
65
|
+
orderHash,
|
|
66
|
+
requestParams
|
|
67
|
+
) => {
|
|
68
|
+
const fetchURL = `${baseUrl}/hash/${orderHash}` as const;
|
|
69
|
+
|
|
70
|
+
const order = await fetcher<OrderFromAPI>({
|
|
71
|
+
url: fetchURL,
|
|
72
|
+
method: 'GET',
|
|
73
|
+
requestParams,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return order;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const getDeltaOrders: GetDeltaOrders = async (options, requestParams) => {
|
|
80
|
+
const search = constructSearchString<OrderFiltersQuery>({
|
|
81
|
+
userAddress: options.userAddress,
|
|
82
|
+
page: options.page,
|
|
83
|
+
limit: options.limit,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const fetchURL = `${baseUrl}${search}` as const;
|
|
87
|
+
|
|
88
|
+
const orders = await fetcher<OrderFromAPI[]>({
|
|
89
|
+
url: fetchURL,
|
|
90
|
+
method: 'GET',
|
|
91
|
+
requestParams,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return orders;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
getDeltaOrderById,
|
|
99
|
+
getDeltaOrderByHash,
|
|
100
|
+
getDeltaOrders,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { API_URL, SwapSide } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
4
|
+
|
|
5
|
+
export type DeltaPriceParams = {
|
|
6
|
+
/** @description Source Token Address. Not Native Token */
|
|
7
|
+
srcToken: string;
|
|
8
|
+
/** @description Destination Token Address */
|
|
9
|
+
destToken: string;
|
|
10
|
+
/** @description srcToken amount in wei */
|
|
11
|
+
amount: string;
|
|
12
|
+
/** @description Source Token Decimals */
|
|
13
|
+
srcDecimals: number;
|
|
14
|
+
/** @description Destination Token Decimals */
|
|
15
|
+
destDecimals: number;
|
|
16
|
+
// side?: SwapSide; // no BUY side for now
|
|
17
|
+
/** @description User's Wallet Address */
|
|
18
|
+
userAddress?: string;
|
|
19
|
+
/** @description Partner string. */
|
|
20
|
+
partner?: string;
|
|
21
|
+
/** @description Destination Chain ID for Crosschain Orders */
|
|
22
|
+
destChainId?: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type DeltaPriceQueryOptions = DeltaPriceParams & {
|
|
26
|
+
chainId: number; // will return error from API on unsupported chains
|
|
27
|
+
side: SwapSide.SELL;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type DeltaPrice = {
|
|
31
|
+
srcToken: string;
|
|
32
|
+
destToken: string;
|
|
33
|
+
srcAmount: string;
|
|
34
|
+
destAmount: string;
|
|
35
|
+
destAmountBeforeFee: string;
|
|
36
|
+
gasCost: string;
|
|
37
|
+
gasCostBeforeFee: string;
|
|
38
|
+
gasCostUSD: string;
|
|
39
|
+
gasCostUSDBeforeFee: string;
|
|
40
|
+
srcUSD: string;
|
|
41
|
+
destUSD: string;
|
|
42
|
+
destUSDBeforeFee: string;
|
|
43
|
+
partner: string;
|
|
44
|
+
partnerFee: number; // in %
|
|
45
|
+
hmac: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type BridgePrice = DeltaPrice & {
|
|
49
|
+
destAmountAfterBridge: string;
|
|
50
|
+
destUSDAfterBridge: string;
|
|
51
|
+
bridgeFee: string;
|
|
52
|
+
bridgeFeeUSD: string;
|
|
53
|
+
poolAddress: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
type DeltaPriceResponse = {
|
|
57
|
+
price: DeltaPrice | BridgePrice;
|
|
58
|
+
deltaAddress: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
interface GetDeltaPrice {
|
|
62
|
+
(
|
|
63
|
+
options: DeltaPriceParams & { destChainId: number },
|
|
64
|
+
requestParams?: RequestParameters
|
|
65
|
+
): Promise<BridgePrice>;
|
|
66
|
+
(
|
|
67
|
+
options: DeltaPriceParams & { destChainId?: undefined },
|
|
68
|
+
requestParams?: RequestParameters
|
|
69
|
+
): Promise<DeltaPrice>;
|
|
70
|
+
(options: DeltaPriceParams, requestParams?: RequestParameters): Promise<
|
|
71
|
+
DeltaPrice | BridgePrice
|
|
72
|
+
>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type GetDeltaPriceFunctions = {
|
|
76
|
+
getDeltaPrice: GetDeltaPrice;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const constructGetDeltaPrice = ({
|
|
80
|
+
apiURL = API_URL,
|
|
81
|
+
chainId,
|
|
82
|
+
fetcher,
|
|
83
|
+
}: ConstructFetchInput): GetDeltaPriceFunctions => {
|
|
84
|
+
const pricesUrl = `${apiURL}/delta/prices` as const;
|
|
85
|
+
|
|
86
|
+
async function getDeltaPrice(
|
|
87
|
+
options: DeltaPriceParams & { destChainId: number },
|
|
88
|
+
requestParams?: RequestParameters
|
|
89
|
+
): Promise<BridgePrice>;
|
|
90
|
+
async function getDeltaPrice(
|
|
91
|
+
options: DeltaPriceParams & { destChainId?: undefined },
|
|
92
|
+
requestParams?: RequestParameters
|
|
93
|
+
): Promise<DeltaPrice>;
|
|
94
|
+
async function getDeltaPrice(
|
|
95
|
+
options: DeltaPriceParams,
|
|
96
|
+
requestParams?: RequestParameters
|
|
97
|
+
): Promise<DeltaPrice | BridgePrice>;
|
|
98
|
+
async function getDeltaPrice(
|
|
99
|
+
options: DeltaPriceParams,
|
|
100
|
+
requestParams?: RequestParameters
|
|
101
|
+
): Promise<DeltaPrice | BridgePrice> {
|
|
102
|
+
const search = constructSearchString<DeltaPriceQueryOptions>({
|
|
103
|
+
...options,
|
|
104
|
+
chainId,
|
|
105
|
+
side: SwapSide.SELL, // so far SELL side only
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const fetchURL = `${pricesUrl}/${search}` as const;
|
|
109
|
+
|
|
110
|
+
const data = await fetcher<DeltaPriceResponse>({
|
|
111
|
+
url: fetchURL,
|
|
112
|
+
method: 'GET',
|
|
113
|
+
requestParams,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return data.price;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
getDeltaPrice,
|
|
121
|
+
};
|
|
122
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import { runOnceAndCache } from '../../helpers/misc';
|
|
3
|
+
import type {
|
|
4
|
+
Address,
|
|
5
|
+
ConstructFetchInput,
|
|
6
|
+
RequestParameters,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
|
|
9
|
+
// chainId -> multicallHandler
|
|
10
|
+
export type MulticallHandlersResponse = Record<number, Address>;
|
|
11
|
+
|
|
12
|
+
type GetMulticallHandlers = (
|
|
13
|
+
requestParams?: RequestParameters
|
|
14
|
+
) => Promise<MulticallHandlersResponse>;
|
|
15
|
+
|
|
16
|
+
export type GetMulticallHandlersFunctions = {
|
|
17
|
+
getMulticallHandlers: GetMulticallHandlers;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const constructGetMulticallHandlers = ({
|
|
21
|
+
apiURL = API_URL,
|
|
22
|
+
fetcher,
|
|
23
|
+
}: ConstructFetchInput): GetMulticallHandlersFunctions => {
|
|
24
|
+
const multicallHandlersUrl =
|
|
25
|
+
`${apiURL}/delta/prices/multicall-handlers` as const;
|
|
26
|
+
|
|
27
|
+
const _getMulticallHandlers: GetMulticallHandlers = async (requestParams) => {
|
|
28
|
+
const data = await fetcher<MulticallHandlersResponse>({
|
|
29
|
+
url: multicallHandlersUrl,
|
|
30
|
+
method: 'GET',
|
|
31
|
+
requestParams,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// cached for the same instance of `{getMulticallHandlers} = constructGetMulticallHandlers()`
|
|
38
|
+
// so should persist across same apiUrl & network (and response is even network agnostic)
|
|
39
|
+
const getMulticallHandlers = runOnceAndCache(_getMulticallHandlers);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
getMulticallHandlers,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
4
|
+
|
|
5
|
+
export type PartnerFeeResponse = {
|
|
6
|
+
partnerFee: number; // in %, e.g. 0.12
|
|
7
|
+
partnerAddress: string;
|
|
8
|
+
takeSurplus: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type PartnerFeeQueryParams = {
|
|
12
|
+
partner: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type GetPartnerFee = (
|
|
16
|
+
options: PartnerFeeQueryParams,
|
|
17
|
+
requestParams?: RequestParameters
|
|
18
|
+
) => Promise<PartnerFeeResponse>;
|
|
19
|
+
|
|
20
|
+
export type GetPartnerFeeFunctions = {
|
|
21
|
+
getPartnerFee: GetPartnerFee;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const constructGetPartnerFee = ({
|
|
25
|
+
apiURL = API_URL,
|
|
26
|
+
chainId,
|
|
27
|
+
fetcher,
|
|
28
|
+
}: ConstructFetchInput): GetPartnerFeeFunctions => {
|
|
29
|
+
const partnerFeeUrl = `${apiURL}/prices/partnerfee/${chainId}` as const;
|
|
30
|
+
|
|
31
|
+
// going on the assumption that one `partner` will correspond to one `partnerFee` during the lifetime of SDK instance,
|
|
32
|
+
// to avoid unnecessary network requests
|
|
33
|
+
const cachedPartnerFee = new Map<string, PartnerFeeResponse>();
|
|
34
|
+
|
|
35
|
+
const getPartnerFee: GetPartnerFee = async (options, requestParams) => {
|
|
36
|
+
if (cachedPartnerFee.has(options.partner)) {
|
|
37
|
+
return cachedPartnerFee.get(options.partner)!;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const search = constructSearchString<PartnerFeeQueryParams>(options);
|
|
41
|
+
|
|
42
|
+
const fetchURL = `${partnerFeeUrl}/${search}` as const;
|
|
43
|
+
|
|
44
|
+
const data = await fetcher<PartnerFeeResponse>({
|
|
45
|
+
url: fetchURL,
|
|
46
|
+
method: 'GET',
|
|
47
|
+
requestParams,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
cachedPartnerFee.set(options.partner, data);
|
|
51
|
+
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
getPartnerFee,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { assert } from 'ts-essentials';
|
|
2
|
+
import { ZERO_ADDRESS } from '../../common/orders/buildOrderData';
|
|
3
|
+
import { BeneficiaryType } from '../../common/orders/types';
|
|
4
|
+
import { Bridge, DeltaAuctionOrder } from './types';
|
|
5
|
+
|
|
6
|
+
export const ACROSS_WETH_ADDRESSES_MAP: Record<number, string> = {
|
|
7
|
+
// Mainnet
|
|
8
|
+
1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
9
|
+
// Sepolia
|
|
10
|
+
11155111: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
|
|
11
|
+
// Base
|
|
12
|
+
8453: '0x4200000000000000000000000000000000000006',
|
|
13
|
+
// Base Sepolia
|
|
14
|
+
84532: '0x4200000000000000000000000000000000000006',
|
|
15
|
+
// Optimism
|
|
16
|
+
10: '0x4200000000000000000000000000000000000006',
|
|
17
|
+
// Optimism Sepolia
|
|
18
|
+
11155420: '0x4200000000000000000000000000000000000006',
|
|
19
|
+
// Polygon
|
|
20
|
+
137: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
|
|
21
|
+
// Polygon Amoy
|
|
22
|
+
80002: '0x52eF3d68BaB452a294342DC3e5f464d7f610f72E',
|
|
23
|
+
// Aleph Zero
|
|
24
|
+
41455: '0xB3f0eE446723f4258862D949B4c9688e7e7d35d3',
|
|
25
|
+
// Arbitrum
|
|
26
|
+
42161: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
27
|
+
// Arbitrum Sepolia
|
|
28
|
+
421614: '0x980B62Da83eFf3D4576C647993b0c1D7faf17c73',
|
|
29
|
+
// Boba
|
|
30
|
+
288: '0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000',
|
|
31
|
+
// Blast
|
|
32
|
+
81457: '0x4300000000000000000000000000000000000004',
|
|
33
|
+
// Blast Sepolia
|
|
34
|
+
168587773: '0x4200000000000000000000000000000000000023',
|
|
35
|
+
// Ink
|
|
36
|
+
57073: '0x4200000000000000000000000000000000000006',
|
|
37
|
+
// Ink Sepolia
|
|
38
|
+
763373: '0x4200000000000000000000000000000000000006',
|
|
39
|
+
// Lens
|
|
40
|
+
232: '0xE5ecd226b3032910CEaa43ba92EE8232f8237553',
|
|
41
|
+
// Lens Sepolia
|
|
42
|
+
37111: '0xaA91D645D7a6C1aeaa5988e0547267B77d33fe16',
|
|
43
|
+
// Linea
|
|
44
|
+
59144: '0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f',
|
|
45
|
+
// Lisk
|
|
46
|
+
1135: '0x4200000000000000000000000000000000000006',
|
|
47
|
+
// Lisk Sepolia
|
|
48
|
+
4202: '0x4200000000000000000000000000000000000006',
|
|
49
|
+
// Mode
|
|
50
|
+
34443: '0x4200000000000000000000000000000000000006',
|
|
51
|
+
// Mode Sepolia
|
|
52
|
+
919: '0x4200000000000000000000000000000000000006',
|
|
53
|
+
// Redstone
|
|
54
|
+
690: '0x4200000000000000000000000000000000000006',
|
|
55
|
+
// Scroll
|
|
56
|
+
534352: '0x5300000000000000000000000000000000000004',
|
|
57
|
+
// Scroll Sepolia
|
|
58
|
+
534351: '0x5300000000000000000000000000000000000004',
|
|
59
|
+
// Soneium
|
|
60
|
+
1868: '0x4200000000000000000000000000000000000006',
|
|
61
|
+
// Tatara
|
|
62
|
+
129399: '0x17B8Ee96E3bcB3b04b3e8334de4524520C51caB4',
|
|
63
|
+
// Unichain
|
|
64
|
+
130: '0x4200000000000000000000000000000000000006',
|
|
65
|
+
// Unichain Sepolia
|
|
66
|
+
1301: '0x4200000000000000000000000000000000000006',
|
|
67
|
+
// World Chain
|
|
68
|
+
480: '0x4200000000000000000000000000000000000006',
|
|
69
|
+
// ZK Sync
|
|
70
|
+
324: '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91',
|
|
71
|
+
// ZK Sync Sepolia
|
|
72
|
+
300: '0x2D6Db36B3117802E996f13073A08A685D3FeF7eD',
|
|
73
|
+
// Zora
|
|
74
|
+
7777777: '0x4200000000000000000000000000000000000006',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export function isAcrossWETH(tokenAddress: string, chainId: number) {
|
|
78
|
+
return (
|
|
79
|
+
ACROSS_WETH_ADDRESSES_MAP[chainId]?.toLowerCase() ===
|
|
80
|
+
tokenAddress.toLowerCase()
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
85
|
+
|
|
86
|
+
const ETH_ADDRESS_LOWERCASE = ETH_ADDRESS.toLowerCase() as Lowercase<
|
|
87
|
+
typeof ETH_ADDRESS
|
|
88
|
+
>;
|
|
89
|
+
|
|
90
|
+
export function isETHaddress(tokenAddress: string): boolean {
|
|
91
|
+
return tokenAddress.toLowerCase() === ETH_ADDRESS_LOWERCASE;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// WETH > ETH Across logic
|
|
95
|
+
// https://docs.across.to/introduction/technical-faq#what-is-the-behavior-of-eth-weth-in-transfers
|
|
96
|
+
|
|
97
|
+
// Velora API ref
|
|
98
|
+
// https://developers.velora.xyz/api/velora-api/velora-delta-api/build-a-delta-order-to-sign
|
|
99
|
+
|
|
100
|
+
export type GetDeltaBridgeAndDestTokenInput = {
|
|
101
|
+
destTokenDestChain: string;
|
|
102
|
+
destChainId: number;
|
|
103
|
+
destTokenSrcChain: string;
|
|
104
|
+
srcChainId: number;
|
|
105
|
+
bridgeFee: string;
|
|
106
|
+
beneficiaryType: BeneficiaryType;
|
|
107
|
+
getMulticallHandler: (chainId: number) => Promise<string>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type GetDeltaBridgeAndDestTokenOutput = {
|
|
111
|
+
/** @description The bridge object to be used for Order.bridge */
|
|
112
|
+
bridge: Bridge;
|
|
113
|
+
/** @description The changes to be made to the Order */
|
|
114
|
+
orderChanges: Pick<DeltaAuctionOrder, 'destToken'>;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export async function getDeltaBridgeAndDestToken({
|
|
118
|
+
destTokenDestChain,
|
|
119
|
+
destChainId,
|
|
120
|
+
destTokenSrcChain,
|
|
121
|
+
srcChainId,
|
|
122
|
+
bridgeFee,
|
|
123
|
+
beneficiaryType,
|
|
124
|
+
getMulticallHandler,
|
|
125
|
+
}: GetDeltaBridgeAndDestTokenInput): Promise<GetDeltaBridgeAndDestTokenOutput> {
|
|
126
|
+
assert(
|
|
127
|
+
beneficiaryType === 'EOA' || beneficiaryType === 'SmartContract',
|
|
128
|
+
'beneficiaryType must be EOA or SmartContract'
|
|
129
|
+
);
|
|
130
|
+
const WETH_SRC_CHAIN = ACROSS_WETH_ADDRESSES_MAP[srcChainId];
|
|
131
|
+
|
|
132
|
+
const WETH_DEST_CHAIN = ACROSS_WETH_ADDRESSES_MAP[destChainId];
|
|
133
|
+
|
|
134
|
+
if (!WETH_SRC_CHAIN || !WETH_DEST_CHAIN) {
|
|
135
|
+
// this should never happen as we only expect crosschain Delta Orders for supported chains
|
|
136
|
+
const bridge: Bridge = {
|
|
137
|
+
maxRelayerFee: bridgeFee,
|
|
138
|
+
destinationChainId: destChainId,
|
|
139
|
+
outputToken: destTokenDestChain,
|
|
140
|
+
multiCallHandler: ZERO_ADDRESS,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
bridge,
|
|
145
|
+
orderChanges: {
|
|
146
|
+
destToken: destTokenSrcChain,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (beneficiaryType === 'EOA' && isETHaddress(destTokenDestChain)) {
|
|
152
|
+
/*
|
|
153
|
+
if beneficiary is an EOA and destToken on destChain = ETH
|
|
154
|
+
order.destToken=ETH
|
|
155
|
+
order.bridge.outputToken=WETH_DEST_CHAIN
|
|
156
|
+
order.bridge.multiCallHandler=NULL_ADDRESS
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
const bridge: Bridge = {
|
|
160
|
+
maxRelayerFee: bridgeFee,
|
|
161
|
+
destinationChainId: destChainId,
|
|
162
|
+
outputToken: WETH_DEST_CHAIN,
|
|
163
|
+
multiCallHandler: ZERO_ADDRESS,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
bridge,
|
|
168
|
+
orderChanges: {
|
|
169
|
+
destToken: ETH_ADDRESS,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (
|
|
174
|
+
beneficiaryType === 'EOA' &&
|
|
175
|
+
isAcrossWETH(destTokenDestChain, destChainId)
|
|
176
|
+
) {
|
|
177
|
+
/*
|
|
178
|
+
if beneficiary is an EOA and destToken on destChain = WETH
|
|
179
|
+
order.destToken=WETH
|
|
180
|
+
order.bridge.outputToken=WETH_DEST_CHAIN
|
|
181
|
+
order.bridge.multiCallHandler=MULTI_CALL_HANDLER
|
|
182
|
+
*/
|
|
183
|
+
const bridge: Bridge = {
|
|
184
|
+
maxRelayerFee: bridgeFee,
|
|
185
|
+
destinationChainId: destChainId,
|
|
186
|
+
outputToken: WETH_DEST_CHAIN,
|
|
187
|
+
multiCallHandler: await getMulticallHandler(destChainId),
|
|
188
|
+
};
|
|
189
|
+
return {
|
|
190
|
+
bridge,
|
|
191
|
+
orderChanges: {
|
|
192
|
+
destToken: WETH_SRC_CHAIN,
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (beneficiaryType === 'SmartContract' && isETHaddress(destTokenDestChain)) {
|
|
198
|
+
/*
|
|
199
|
+
if beneficiary is a contract and destToken on destChain = ETH
|
|
200
|
+
order.destToken=ETH
|
|
201
|
+
order.bridge.outputToken=WETH_DEST_CHAIN
|
|
202
|
+
order.bridge.multiCallHandler=MULTI_CALL_HANDLER
|
|
203
|
+
*/
|
|
204
|
+
const bridge: Bridge = {
|
|
205
|
+
maxRelayerFee: bridgeFee,
|
|
206
|
+
destinationChainId: destChainId,
|
|
207
|
+
outputToken: WETH_DEST_CHAIN,
|
|
208
|
+
multiCallHandler: await getMulticallHandler(destChainId),
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
bridge,
|
|
212
|
+
orderChanges: {
|
|
213
|
+
destToken: ETH_ADDRESS,
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (
|
|
219
|
+
beneficiaryType === 'SmartContract' &&
|
|
220
|
+
isAcrossWETH(destTokenDestChain, destChainId)
|
|
221
|
+
) {
|
|
222
|
+
/*
|
|
223
|
+
if beneficiary is a contract and destToken on destChain = WETH
|
|
224
|
+
order.destToken=WETH
|
|
225
|
+
order.bridge.outputToken=WETH_DEST_CHAIN
|
|
226
|
+
order.bridge.multiCallHandler=NULL_ADDRESS
|
|
227
|
+
*/
|
|
228
|
+
const bridge: Bridge = {
|
|
229
|
+
maxRelayerFee: bridgeFee,
|
|
230
|
+
destinationChainId: destChainId,
|
|
231
|
+
outputToken: WETH_DEST_CHAIN,
|
|
232
|
+
multiCallHandler: ZERO_ADDRESS,
|
|
233
|
+
};
|
|
234
|
+
return {
|
|
235
|
+
bridge,
|
|
236
|
+
orderChanges: {
|
|
237
|
+
destToken: WETH_SRC_CHAIN,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const bridge: Bridge = {
|
|
243
|
+
maxRelayerFee: bridgeFee,
|
|
244
|
+
destinationChainId: destChainId,
|
|
245
|
+
outputToken: destTokenDestChain,
|
|
246
|
+
multiCallHandler: ZERO_ADDRESS,
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
bridge,
|
|
251
|
+
orderChanges: {
|
|
252
|
+
destToken: destTokenSrcChain,
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
}
|