@velora-dex/sdk 9.0.0 → 9.2.0-dev.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/dist/examples/wagmi.d.ts +121 -10
- package/dist/examples/wagmi.d.ts.map +1 -1
- package/dist/helpers/providers/helpers.d.ts +1 -1
- package/dist/helpers/providers/helpers.d.ts.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/common/orders/types.d.ts +0 -2
- package/dist/methods/common/orders/types.d.ts.map +1 -1
- package/dist/methods/delta/buildDeltaOrder.d.ts +3 -5
- package/dist/methods/delta/buildDeltaOrder.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaOrders.d.ts +15 -4
- package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +15 -0
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts +6 -0
- package/dist/methods/delta/helpers/buildDeltaOrderData.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +3 -2
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/delta/index.d.ts +2 -3
- package/dist/methods/delta/index.d.ts.map +1 -1
- package/dist/methods/delta/preSignDeltaOrder.d.ts +17 -0
- package/dist/methods/delta/preSignDeltaOrder.d.ts.map +1 -0
- package/dist/methods/delta/signDeltaOrder.d.ts +0 -3
- package/dist/methods/delta/signDeltaOrder.d.ts.map +1 -1
- package/dist/methods/limitOrders/helpers/types.d.ts +2 -4
- package/dist/methods/limitOrders/helpers/types.d.ts.map +1 -1
- package/dist/methods/nftOrders/helpers/types.d.ts +2 -4
- package/dist/methods/nftOrders/helpers/types.d.ts.map +1 -1
- package/dist/sdk/partial.d.ts +3 -1
- package/dist/sdk/partial.d.ts.map +1 -1
- package/dist/sdk/simple.d.ts +1 -3
- package/dist/sdk/simple.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +184 -115
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +184 -114
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +5 -4
- package/src/helpers/providers/helpers.ts +5 -5
- package/src/index.ts +8 -18
- package/src/methods/common/orders/types.ts +0 -7
- package/src/methods/delta/buildDeltaOrder.ts +37 -23
- package/src/methods/delta/getDeltaOrders.ts +31 -6
- package/src/methods/delta/getDeltaPrice.ts +28 -0
- package/src/methods/delta/helpers/buildDeltaOrderData.ts +1 -1
- package/src/methods/delta/helpers/types.ts +14 -1
- package/src/methods/delta/index.ts +8 -16
- package/src/methods/delta/preSignDeltaOrder.ts +157 -0
- package/src/methods/delta/signDeltaOrder.ts +0 -6
- package/src/methods/limitOrders/helpers/types.ts +2 -4
- package/src/methods/nftOrders/helpers/types.ts +2 -4
- package/src/sdk/partial.ts +3 -1
- package/src/sdk/simple.ts +0 -12
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts +0 -23
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts.map +0 -1
- package/dist/methods/delta/getMulticallHandlers.d.ts +0 -9
- package/dist/methods/delta/getMulticallHandlers.d.ts.map +0 -1
- package/dist/methods/delta/helpers/across.d.ts +0 -19
- package/dist/methods/delta/helpers/across.d.ts.map +0 -1
- package/src/methods/delta/buildCrosschainOrderBridge.ts +0 -96
- package/src/methods/delta/getMulticallHandlers.ts +0 -44
- package/src/methods/delta/helpers/across.ts +0 -189
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OrderTransaction } from '../../common/orders/types';
|
|
1
2
|
import type { OrderData } from './buildOrderData';
|
|
2
3
|
|
|
3
4
|
export type LimitOrderType = 'LIMIT' | 'P2P';
|
|
@@ -36,10 +37,7 @@ export type LimitOrderState =
|
|
|
36
37
|
|
|
37
38
|
export type LimitOrderEvent = '';
|
|
38
39
|
|
|
39
|
-
export type LimitOrderTransaction =
|
|
40
|
-
hash: string;
|
|
41
|
-
event_type: 'OrderFilled' | 'OrderCancelled';
|
|
42
|
-
};
|
|
40
|
+
export type LimitOrderTransaction = OrderTransaction;
|
|
43
41
|
|
|
44
42
|
export type LimitOrderFromApi = {
|
|
45
43
|
chainId: number;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { Address } from '../../../types';
|
|
2
|
+
import { OrderTransaction } from '../../common/orders/types';
|
|
2
3
|
import type { NFTOrderData } from './buildOrderData';
|
|
3
4
|
import type { AssetType } from './misc';
|
|
4
5
|
|
|
5
|
-
export type NFTOrderTransaction =
|
|
6
|
-
hash: string;
|
|
7
|
-
event_type: 'OrderFilled' | 'OrderCancelled';
|
|
8
|
-
};
|
|
6
|
+
export type NFTOrderTransaction = OrderTransaction;
|
|
9
7
|
|
|
10
8
|
export type NFTOrderType = 'LIMIT' | 'P2P';
|
|
11
9
|
|
package/src/sdk/partial.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { CancelNFTOrderFunctions } from '../methods/nftOrders/cancelOrder';
|
|
|
12
12
|
import type { ApproveTokenForNFTOrderFunctions } from '../methods/nftOrders/approveForOrder';
|
|
13
13
|
import type { FillOrderDirectlyFunctions } from '../methods/limitOrders/fillOrderDirectly';
|
|
14
14
|
import type { ApproveTokenForDeltaFunctions } from '../methods/delta/approveForDelta';
|
|
15
|
+
import type { PreSignDeltaOrderFunctions } from '../methods/delta/preSignDeltaOrder';
|
|
15
16
|
import { API_URL, DEFAULT_VERSION } from '../constants';
|
|
16
17
|
|
|
17
18
|
export type SDKConfig<TxResponse = any> = ConstructProviderFetchInput<
|
|
@@ -50,7 +51,8 @@ type InferWithTxResponse<
|
|
|
50
51
|
ApproveTokenForLimitOrderFunctions<TxResponse>,
|
|
51
52
|
CancelNFTOrderFunctions<TxResponse>,
|
|
52
53
|
ApproveTokenForNFTOrderFunctions<TxResponse>,
|
|
53
|
-
ApproveTokenForDeltaFunctions<TxResponse
|
|
54
|
+
ApproveTokenForDeltaFunctions<TxResponse>,
|
|
55
|
+
PreSignDeltaOrderFunctions<TxResponse>
|
|
54
56
|
]
|
|
55
57
|
// then merge IntersectionOfReturns<Funcs> with them recursively
|
|
56
58
|
>
|
package/src/sdk/simple.ts
CHANGED
|
@@ -132,18 +132,10 @@ import {
|
|
|
132
132
|
constructGetBridgeInfo,
|
|
133
133
|
GetBridgeInfoFunctions,
|
|
134
134
|
} from '../methods/delta/getBridgeInfo';
|
|
135
|
-
import {
|
|
136
|
-
constructGetMulticallHandlers,
|
|
137
|
-
GetMulticallHandlersFunctions,
|
|
138
|
-
} from '../methods/delta/getMulticallHandlers';
|
|
139
135
|
import {
|
|
140
136
|
constructIsTokenSupportedInDelta,
|
|
141
137
|
IsTokenSupportedInDeltaFunctions,
|
|
142
138
|
} from '../methods/delta/isTokenSupportedInDelta';
|
|
143
|
-
import {
|
|
144
|
-
BuildCrosschainOrderBridgeFunctions,
|
|
145
|
-
constructBuildCrosschainOrderBridge,
|
|
146
|
-
} from '../methods/delta/buildCrosschainOrderBridge';
|
|
147
139
|
|
|
148
140
|
export type SwapFetchMethods = GetBalancesFunctions &
|
|
149
141
|
GetTokensFunctions &
|
|
@@ -166,12 +158,10 @@ export type NFTOrdersFetchMethods = GetNFTOrdersContractFunctions &
|
|
|
166
158
|
BuildNFTOrdersTxFunctions;
|
|
167
159
|
|
|
168
160
|
export type DeltaFetchMethods = BuildDeltaOrderFunctions &
|
|
169
|
-
BuildCrosschainOrderBridgeFunctions &
|
|
170
161
|
GetDeltaOrdersFunctions &
|
|
171
162
|
GetDeltaPriceFunctions &
|
|
172
163
|
GetDeltaContractFunctions &
|
|
173
164
|
GetPartnerFeeFunctions &
|
|
174
|
-
GetMulticallHandlersFunctions &
|
|
175
165
|
GetBridgeInfoFunctions &
|
|
176
166
|
IsTokenSupportedInDeltaFunctions &
|
|
177
167
|
PostDeltaOrderFunctions;
|
|
@@ -288,13 +278,11 @@ export function constructSimpleSDK(
|
|
|
288
278
|
const delta = constructPartialSDK(
|
|
289
279
|
config,
|
|
290
280
|
constructBuildDeltaOrder,
|
|
291
|
-
constructBuildCrosschainOrderBridge,
|
|
292
281
|
constructPostDeltaOrder,
|
|
293
282
|
constructGetDeltaOrders,
|
|
294
283
|
constructGetDeltaPrice,
|
|
295
284
|
constructGetDeltaContract,
|
|
296
285
|
constructGetPartnerFee,
|
|
297
|
-
constructGetMulticallHandlers,
|
|
298
286
|
constructGetBridgeInfo,
|
|
299
287
|
constructIsTokenSupportedInDelta
|
|
300
288
|
);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
2
|
-
import { BridgePrice } from './getDeltaPrice';
|
|
3
|
-
import { GetDeltaBridgeAndDestTokenOutput } from './helpers/across';
|
|
4
|
-
import { BeneficiaryType } from '../common/orders/types';
|
|
5
|
-
export type { SignableDeltaOrderData } from './helpers/buildDeltaOrderData';
|
|
6
|
-
export type BuildCrosschainOrderBridgeParams = {
|
|
7
|
-
/** @description The address of the destination token on the destination chain */
|
|
8
|
-
destToken: string;
|
|
9
|
-
/** @description Destination Chain ID for Crosschain Orders */
|
|
10
|
-
destChainId: number;
|
|
11
|
-
/** @description Whether the beneficiary is a contract. Needed to automatically fill in crosschain Bridge */
|
|
12
|
-
beneficiaryType: BeneficiaryType;
|
|
13
|
-
/** @description price response received from /delta/prices (getDeltaPrice method) */
|
|
14
|
-
deltaPrice: BridgePrice;
|
|
15
|
-
};
|
|
16
|
-
type BuildCrosschainOrderBridge = (buildOrderParams: BuildCrosschainOrderBridgeParams, requestParams?: RequestParameters) => Promise<GetDeltaBridgeAndDestTokenOutput>;
|
|
17
|
-
export { GetDeltaBridgeAndDestTokenOutput as CrosschainOrderBridgeAndChanges };
|
|
18
|
-
export type BuildCrosschainOrderBridgeFunctions = {
|
|
19
|
-
/** @description Build Orders to be posted to Delta API for execution */
|
|
20
|
-
buildCrosschainOrderBridge: BuildCrosschainOrderBridge;
|
|
21
|
-
};
|
|
22
|
-
export declare const constructBuildCrosschainOrderBridge: (options: ConstructFetchInput) => BuildCrosschainOrderBridgeFunctions;
|
|
23
|
-
//# sourceMappingURL=buildCrosschainOrderBridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildCrosschainOrderBridge.d.ts","sourceRoot":"","sources":["../../../src/methods/delta/buildCrosschainOrderBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAEL,gCAAgC,EACjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,4GAA4G;IAC5G,eAAe,EAAE,eAAe,CAAC;IAEjC,qFAAqF;IACrF,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,KAAK,0BAA0B,GAAG,CAChC,gBAAgB,EAAE,gCAAgC,EAClD,aAAa,CAAC,EAAE,iBAAiB,KAC9B,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAE/C,OAAO,EAAE,gCAAgC,IAAI,+BAA+B,EAAE,CAAC;AAE/E,MAAM,MAAM,mCAAmC,GAAG;IAChD,wEAAwE;IACxE,0BAA0B,EAAE,0BAA0B,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,mCAAmC,YACrC,mBAAmB,KAC3B,mCA0DF,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Address, ConstructFetchInput, RequestParameters } from '../../types';
|
|
2
|
-
export type MulticallHandlersResponse = Record<number, Address>;
|
|
3
|
-
type GetMulticallHandlers = (requestParams?: RequestParameters) => Promise<MulticallHandlersResponse>;
|
|
4
|
-
export type GetMulticallHandlersFunctions = {
|
|
5
|
-
getMulticallHandlers: GetMulticallHandlers;
|
|
6
|
-
};
|
|
7
|
-
export declare const constructGetMulticallHandlers: ({ apiURL, fetcher, }: ConstructFetchInput) => GetMulticallHandlersFunctions;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=getMulticallHandlers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMulticallHandlers.d.ts","sourceRoot":"","sources":["../../../src/methods/delta/getMulticallHandlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhE,KAAK,oBAAoB,GAAG,CAC1B,aAAa,CAAC,EAAE,iBAAiB,KAC9B,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAExC,MAAM,MAAM,6BAA6B,GAAG;IAC1C,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,6BAA6B,yBAGvC,mBAAmB,KAAG,6BAqBxB,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BeneficiaryType } from '../../common/orders/types';
|
|
2
|
-
import { Bridge } from './types';
|
|
3
|
-
export declare const ACROSS_WETH_ADDRESSES_MAP: Record<number, string>;
|
|
4
|
-
export declare function isAcrossWETH(tokenAddress: string, chainId: number): boolean;
|
|
5
|
-
export declare function isETHaddress(tokenAddress: string): boolean;
|
|
6
|
-
export type GetDeltaBridgeAndDestTokenInput = {
|
|
7
|
-
destTokenDestChain: string;
|
|
8
|
-
destChainId: number;
|
|
9
|
-
bridgeFee: string;
|
|
10
|
-
bridgeOutputToken: string;
|
|
11
|
-
beneficiaryType: BeneficiaryType;
|
|
12
|
-
getMulticallHandler: (chainId: number) => Promise<string>;
|
|
13
|
-
};
|
|
14
|
-
export type GetDeltaBridgeAndDestTokenOutput = {
|
|
15
|
-
/** @description The bridge object to be used for Order.bridge */
|
|
16
|
-
bridge: Bridge;
|
|
17
|
-
};
|
|
18
|
-
export declare function getDeltaBridge({ destTokenDestChain, destChainId, bridgeFee, bridgeOutputToken, beneficiaryType, getMulticallHandler, }: GetDeltaBridgeAndDestTokenInput): Promise<GetDeltaBridgeAndDestTokenOutput>;
|
|
19
|
-
//# sourceMappingURL=across.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"across.d.ts","sourceRoot":"","sources":["../../../../src/methods/delta/helpers/across.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuE5D,CAAC;AAEF,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAKjE;AAQD,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE1D;AAQD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,eAAe,CAAC;IACjC,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,cAAc,CAAC,EACnC,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,EAAE,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAkE7E"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { assert } from 'ts-essentials';
|
|
2
|
-
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
-
import { BridgePrice } from './getDeltaPrice';
|
|
4
|
-
// import { constructGetMulticallHandlers } from './getMulticallHandlers';
|
|
5
|
-
import {
|
|
6
|
-
// getDeltaBridge,
|
|
7
|
-
GetDeltaBridgeAndDestTokenOutput,
|
|
8
|
-
} from './helpers/across';
|
|
9
|
-
import { BeneficiaryType } from '../common/orders/types';
|
|
10
|
-
export type { SignableDeltaOrderData } from './helpers/buildDeltaOrderData';
|
|
11
|
-
|
|
12
|
-
export type BuildCrosschainOrderBridgeParams = {
|
|
13
|
-
/** @description The address of the destination token on the destination chain */
|
|
14
|
-
destToken: string; // lowercase
|
|
15
|
-
/** @description Destination Chain ID for Crosschain Orders */
|
|
16
|
-
destChainId: number;
|
|
17
|
-
/** @description Whether the beneficiary is a contract. Needed to automatically fill in crosschain Bridge */
|
|
18
|
-
beneficiaryType: BeneficiaryType;
|
|
19
|
-
|
|
20
|
-
/** @description price response received from /delta/prices (getDeltaPrice method) */
|
|
21
|
-
deltaPrice: BridgePrice;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type BuildCrosschainOrderBridge = (
|
|
25
|
-
buildOrderParams: BuildCrosschainOrderBridgeParams,
|
|
26
|
-
requestParams?: RequestParameters
|
|
27
|
-
) => Promise<GetDeltaBridgeAndDestTokenOutput>;
|
|
28
|
-
|
|
29
|
-
export { GetDeltaBridgeAndDestTokenOutput as CrosschainOrderBridgeAndChanges };
|
|
30
|
-
|
|
31
|
-
export type BuildCrosschainOrderBridgeFunctions = {
|
|
32
|
-
/** @description Build Orders to be posted to Delta API for execution */
|
|
33
|
-
buildCrosschainOrderBridge: BuildCrosschainOrderBridge;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const constructBuildCrosschainOrderBridge = (
|
|
37
|
-
options: ConstructFetchInput
|
|
38
|
-
): BuildCrosschainOrderBridgeFunctions => {
|
|
39
|
-
const { chainId } = options;
|
|
40
|
-
|
|
41
|
-
// cached internally for `multicall` contracts
|
|
42
|
-
// const { getMulticallHandlers } = constructGetMulticallHandlers(options);
|
|
43
|
-
|
|
44
|
-
const buildCrosschainOrderBridge: BuildCrosschainOrderBridge = async (
|
|
45
|
-
{ destToken, destChainId, beneficiaryType, deltaPrice },
|
|
46
|
-
requestParams
|
|
47
|
-
) => {
|
|
48
|
-
assert(
|
|
49
|
-
chainId !== deltaPrice.bridge.destinationChainId,
|
|
50
|
-
'`deltaPrice.bridge.destinationChainId` must be different from `chainId` for crosschain Order.bridge'
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
assert(
|
|
54
|
-
destChainId === deltaPrice.bridge.destinationChainId,
|
|
55
|
-
'`destChainId` must match `deltaPrice.bridge.destinationChainId` for crosschain Order.bridge'
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
/* const getMulticallHandler = async (chainId: number) => {
|
|
59
|
-
const multicallHandlersMap = await getMulticallHandlers(requestParams);
|
|
60
|
-
const multicallHandler = multicallHandlersMap[chainId];
|
|
61
|
-
|
|
62
|
-
assert(
|
|
63
|
-
multicallHandler,
|
|
64
|
-
`Multicall handler not found for chain ${chainId}`
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return multicallHandler;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const { bridge } = await getDeltaBridge({
|
|
71
|
-
destTokenDestChain: destToken,
|
|
72
|
-
destChainId,
|
|
73
|
-
bridgeFee: deltaPrice.bridgeFee,
|
|
74
|
-
bridgeOutputToken: deltaPrice.bridge.outputToken,
|
|
75
|
-
beneficiaryType,
|
|
76
|
-
getMulticallHandler,
|
|
77
|
-
}); */
|
|
78
|
-
|
|
79
|
-
// @TODO remove the whole buildCrosschainOrderBridge() when API provides BridgePrice.bridge = whole Bridge object
|
|
80
|
-
const bridge = {
|
|
81
|
-
protocolSelector: '0x00000000',
|
|
82
|
-
scalingFactor: 0,
|
|
83
|
-
protocolData: '0x',
|
|
84
|
-
destinationChainId: deltaPrice.bridge.destinationChainId,
|
|
85
|
-
outputToken: deltaPrice.bridge.outputToken,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
bridge,
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
buildCrosschainOrderBridge,
|
|
95
|
-
};
|
|
96
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { assert } from 'ts-essentials';
|
|
2
|
-
import { ZERO_ADDRESS } from '../../common/orders/buildOrderData';
|
|
3
|
-
import { BeneficiaryType } from '../../common/orders/types';
|
|
4
|
-
import { Bridge } 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
|
-
// BSC
|
|
36
|
-
56: '0x2170Ed0880ac9A755fd29B2688956BD959F933F8',
|
|
37
|
-
// Ink
|
|
38
|
-
57073: '0x4200000000000000000000000000000000000006',
|
|
39
|
-
// Ink Sepolia
|
|
40
|
-
763373: '0x4200000000000000000000000000000000000006',
|
|
41
|
-
// Lens
|
|
42
|
-
232: '0xE5ecd226b3032910CEaa43ba92EE8232f8237553',
|
|
43
|
-
// Lens Sepolia
|
|
44
|
-
37111: '0xaA91D645D7a6C1aeaa5988e0547267B77d33fe16',
|
|
45
|
-
// Linea
|
|
46
|
-
59144: '0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f',
|
|
47
|
-
// Lisk
|
|
48
|
-
1135: '0x4200000000000000000000000000000000000006',
|
|
49
|
-
// Lisk Sepolia
|
|
50
|
-
4202: '0x4200000000000000000000000000000000000006',
|
|
51
|
-
// Mode
|
|
52
|
-
34443: '0x4200000000000000000000000000000000000006',
|
|
53
|
-
// Mode Sepolia
|
|
54
|
-
919: '0x4200000000000000000000000000000000000006',
|
|
55
|
-
// Redstone
|
|
56
|
-
690: '0x4200000000000000000000000000000000000006',
|
|
57
|
-
// Scroll
|
|
58
|
-
534352: '0x5300000000000000000000000000000000000004',
|
|
59
|
-
// Scroll Sepolia
|
|
60
|
-
534351: '0x5300000000000000000000000000000000000004',
|
|
61
|
-
// Soneium
|
|
62
|
-
1868: '0x4200000000000000000000000000000000000006',
|
|
63
|
-
// Tatara
|
|
64
|
-
129399: '0x17B8Ee96E3bcB3b04b3e8334de4524520C51caB4',
|
|
65
|
-
// Unichain
|
|
66
|
-
130: '0x4200000000000000000000000000000000000006',
|
|
67
|
-
// Unichain Sepolia
|
|
68
|
-
1301: '0x4200000000000000000000000000000000000006',
|
|
69
|
-
// World Chain
|
|
70
|
-
480: '0x4200000000000000000000000000000000000006',
|
|
71
|
-
// ZK Sync
|
|
72
|
-
324: '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91',
|
|
73
|
-
// ZK Sync Sepolia
|
|
74
|
-
300: '0x2D6Db36B3117802E996f13073A08A685D3FeF7eD',
|
|
75
|
-
// Zora
|
|
76
|
-
7777777: '0x4200000000000000000000000000000000000006',
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export function isAcrossWETH(tokenAddress: string, chainId: number) {
|
|
80
|
-
return (
|
|
81
|
-
ACROSS_WETH_ADDRESSES_MAP[chainId]?.toLowerCase() ===
|
|
82
|
-
tokenAddress.toLowerCase()
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
87
|
-
|
|
88
|
-
const ETH_ADDRESS_LOWERCASE = ETH_ADDRESS.toLowerCase() as Lowercase<
|
|
89
|
-
typeof ETH_ADDRESS
|
|
90
|
-
>;
|
|
91
|
-
|
|
92
|
-
export function isETHaddress(tokenAddress: string): boolean {
|
|
93
|
-
return tokenAddress.toLowerCase() === ETH_ADDRESS_LOWERCASE;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// WETH > ETH Across logic
|
|
97
|
-
// https://docs.across.to/introduction/technical-faq#what-is-the-behavior-of-eth-weth-in-transfers
|
|
98
|
-
|
|
99
|
-
// Velora API ref
|
|
100
|
-
// https://developers.velora.xyz/api/velora-api/velora-delta-api/build-a-delta-order-to-sign
|
|
101
|
-
|
|
102
|
-
export type GetDeltaBridgeAndDestTokenInput = {
|
|
103
|
-
destTokenDestChain: string; // the token user wants to ultimately receive
|
|
104
|
-
destChainId: number;
|
|
105
|
-
bridgeFee: string;
|
|
106
|
-
bridgeOutputToken: string; // the token on the destination chain, in case of WETH -> ETH, will be different from destTokenDestChain and unwrapped
|
|
107
|
-
beneficiaryType: BeneficiaryType;
|
|
108
|
-
getMulticallHandler: (chainId: number) => Promise<string>;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export type GetDeltaBridgeAndDestTokenOutput = {
|
|
112
|
-
/** @description The bridge object to be used for Order.bridge */
|
|
113
|
-
bridge: Bridge;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export async function getDeltaBridge({
|
|
117
|
-
destTokenDestChain,
|
|
118
|
-
destChainId,
|
|
119
|
-
bridgeFee,
|
|
120
|
-
bridgeOutputToken,
|
|
121
|
-
beneficiaryType,
|
|
122
|
-
getMulticallHandler,
|
|
123
|
-
}: GetDeltaBridgeAndDestTokenInput): Promise<GetDeltaBridgeAndDestTokenOutput> {
|
|
124
|
-
assert(
|
|
125
|
-
beneficiaryType === 'EOA' || beneficiaryType === 'SmartContract',
|
|
126
|
-
'beneficiaryType must be EOA or SmartContract'
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const outputToken = bridgeOutputToken.toLowerCase(); // for uniformity
|
|
130
|
-
|
|
131
|
-
let multiCallHandler: string = ZERO_ADDRESS;
|
|
132
|
-
|
|
133
|
-
if (beneficiaryType === 'EOA' && isETHaddress(destTokenDestChain)) {
|
|
134
|
-
/*
|
|
135
|
-
if beneficiary is an EOA and destToken on destChain = ETH
|
|
136
|
-
order.destToken=ETH (deltaPrice already contains correct destToken)
|
|
137
|
-
order.bridge.outputToken=WETH_DEST_CHAIN (deltaPrice already contains correct bridge.outputToken)
|
|
138
|
-
order.bridge.multiCallHandler=NULL_ADDRESS
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
multiCallHandler = ZERO_ADDRESS;
|
|
142
|
-
}
|
|
143
|
-
if (
|
|
144
|
-
beneficiaryType === 'EOA' &&
|
|
145
|
-
isAcrossWETH(destTokenDestChain, destChainId)
|
|
146
|
-
) {
|
|
147
|
-
/*
|
|
148
|
-
if beneficiary is an EOA and destToken on destChain = WETH
|
|
149
|
-
order.destToken=WETH (deltaPrice already contains correct destToken)
|
|
150
|
-
order.bridge.outputToken=WETH_DEST_CHAIN (deltaPrice already contains correct bridge.outputToken)
|
|
151
|
-
order.bridge.multiCallHandler=MULTI_CALL_HANDLER
|
|
152
|
-
*/
|
|
153
|
-
multiCallHandler = await getMulticallHandler(destChainId);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (beneficiaryType === 'SmartContract' && isETHaddress(destTokenDestChain)) {
|
|
157
|
-
/*
|
|
158
|
-
if beneficiary is a contract and destToken on destChain = ETH
|
|
159
|
-
order.destToken=ETH (deltaPrice already contains correct destToken)
|
|
160
|
-
order.bridge.outputToken=WETH_DEST_CHAIN (deltaPrice already contains correct bridge.outputToken)
|
|
161
|
-
order.bridge.multiCallHandler=MULTI_CALL_HANDLER
|
|
162
|
-
*/
|
|
163
|
-
multiCallHandler = await getMulticallHandler(destChainId);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (
|
|
167
|
-
beneficiaryType === 'SmartContract' &&
|
|
168
|
-
isAcrossWETH(destTokenDestChain, destChainId)
|
|
169
|
-
) {
|
|
170
|
-
/*
|
|
171
|
-
if beneficiary is a contract and destToken on destChain = WETH
|
|
172
|
-
order.destToken=WETH (deltaPrice already contains correct destToken)
|
|
173
|
-
order.bridge.outputToken=WETH_DEST_CHAIN (deltaPrice already contains correct bridge.outputToken)
|
|
174
|
-
order.bridge.multiCallHandler=NULL_ADDRESS
|
|
175
|
-
*/
|
|
176
|
-
multiCallHandler = ZERO_ADDRESS;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const bridge: Bridge = {
|
|
180
|
-
maxRelayerFee: bridgeFee,
|
|
181
|
-
destinationChainId: destChainId,
|
|
182
|
-
outputToken,
|
|
183
|
-
multiCallHandler,
|
|
184
|
-
} as any; // @TODO remove the whole getDeltaBridge() when API provides BridgePrice.bridge = whole Bridge object
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
bridge,
|
|
188
|
-
};
|
|
189
|
-
}
|