@velora-dex/sdk 8.1.1-dev.2 → 9.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.
Files changed (48) hide show
  1. package/dist/index.d.ts +3 -5
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/methods/common/orders/types.d.ts +0 -2
  4. package/dist/methods/common/orders/types.d.ts.map +1 -1
  5. package/dist/methods/delta/buildDeltaOrder.d.ts +3 -5
  6. package/dist/methods/delta/buildDeltaOrder.d.ts.map +1 -1
  7. package/dist/methods/delta/cancelDeltaOrder.d.ts.map +1 -1
  8. package/dist/methods/delta/getDeltaOrders.d.ts +15 -4
  9. package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -1
  10. package/dist/methods/delta/getDeltaPrice.d.ts +15 -0
  11. package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
  12. package/dist/methods/delta/helpers/types.d.ts +1 -1
  13. package/dist/methods/delta/helpers/types.d.ts.map +1 -1
  14. package/dist/methods/delta/index.d.ts +1 -3
  15. package/dist/methods/delta/index.d.ts.map +1 -1
  16. package/dist/methods/limitOrders/helpers/types.d.ts +2 -4
  17. package/dist/methods/limitOrders/helpers/types.d.ts.map +1 -1
  18. package/dist/methods/nftOrders/helpers/types.d.ts +2 -4
  19. package/dist/methods/nftOrders/helpers/types.d.ts.map +1 -1
  20. package/dist/sdk/simple.d.ts +1 -3
  21. package/dist/sdk/simple.d.ts.map +1 -1
  22. package/dist/sdk.cjs.development.js +33 -115
  23. package/dist/sdk.cjs.development.js.map +1 -1
  24. package/dist/sdk.cjs.production.min.js +1 -1
  25. package/dist/sdk.cjs.production.min.js.map +1 -1
  26. package/dist/sdk.esm.js +34 -114
  27. package/dist/sdk.esm.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/index.ts +2 -18
  30. package/src/methods/common/orders/types.ts +0 -7
  31. package/src/methods/delta/buildDeltaOrder.ts +37 -23
  32. package/src/methods/delta/cancelDeltaOrder.ts +1 -1
  33. package/src/methods/delta/getDeltaOrders.ts +31 -6
  34. package/src/methods/delta/getDeltaPrice.ts +28 -0
  35. package/src/methods/delta/helpers/types.ts +12 -1
  36. package/src/methods/delta/index.ts +0 -16
  37. package/src/methods/limitOrders/helpers/types.ts +2 -4
  38. package/src/methods/nftOrders/helpers/types.ts +2 -4
  39. package/src/sdk/simple.ts +0 -12
  40. package/dist/methods/delta/buildCrosschainOrderBridge.d.ts +0 -23
  41. package/dist/methods/delta/buildCrosschainOrderBridge.d.ts.map +0 -1
  42. package/dist/methods/delta/getMulticallHandlers.d.ts +0 -9
  43. package/dist/methods/delta/getMulticallHandlers.d.ts.map +0 -1
  44. package/dist/methods/delta/helpers/across.d.ts +0 -19
  45. package/dist/methods/delta/helpers/across.d.ts.map +0 -1
  46. package/src/methods/delta/buildCrosschainOrderBridge.ts +0 -96
  47. package/src/methods/delta/getMulticallHandlers.ts +0 -44
  48. package/src/methods/delta/helpers/across.ts +0 -189
@@ -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
- }