@dzapio/sdk 2.0.6 → 2.0.7

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 (216) hide show
  1. package/dist/examples/chain-utils.d.ts +1 -0
  2. package/dist/examples/chain-utils.js +20 -0
  3. package/dist/examples/permit-utils.d.ts +1 -0
  4. package/dist/examples/permit-utils.js +90 -0
  5. package/dist/examples/token-utils.d.ts +1 -0
  6. package/dist/examples/token-utils.js +41 -0
  7. package/dist/examples/trade-operations.d.ts +1 -0
  8. package/dist/examples/trade-operations.js +89 -0
  9. package/dist/examples/zap-operations.d.ts +1 -0
  10. package/dist/examples/zap-operations.js +69 -0
  11. package/dist/src/api/index.d.ts +27 -0
  12. package/dist/src/api/index.js +146 -0
  13. package/dist/src/artifacts/ERC20Permit.d.ts +374 -0
  14. package/dist/src/artifacts/ERC20Permit.js +469 -0
  15. package/dist/src/artifacts/Permit2.d.ts +700 -0
  16. package/dist/src/artifacts/Permit2.js +904 -0
  17. package/dist/src/artifacts/Permit2Proxy.d.ts +416 -0
  18. package/dist/src/artifacts/Permit2Proxy.js +206 -0
  19. package/dist/src/artifacts/default/DZapCoreAbi.d.ts +2 -0
  20. package/dist/src/artifacts/default/DZapCoreAbi.js +3079 -0
  21. package/dist/src/artifacts/default/DZapCoreV2Abi.d.ts +2 -0
  22. package/dist/src/artifacts/default/DZapCoreV2Abi.js +3719 -0
  23. package/dist/src/artifacts/default/DZapDcaAbi.d.ts +2 -0
  24. package/dist/src/artifacts/default/DZapDcaAbi.js +1829 -0
  25. package/dist/src/artifacts/default/Permit2Abi.d.ts +700 -0
  26. package/dist/src/artifacts/default/Permit2Abi.js +904 -0
  27. package/dist/src/artifacts/default/erc20Abi.d.ts +165 -0
  28. package/dist/src/artifacts/default/erc20Abi.js +220 -0
  29. package/dist/src/artifacts/default/index.d.ts +6 -0
  30. package/dist/src/artifacts/default/index.js +13 -0
  31. package/dist/src/artifacts/index.d.ts +2 -0
  32. package/dist/src/artifacts/index.js +9 -0
  33. package/dist/src/artifacts/staging/DZapCoreSwapAbi.d.ts +2 -0
  34. package/dist/src/artifacts/staging/DZapCoreSwapAbi.js +3079 -0
  35. package/dist/src/artifacts/staging/index.d.ts +2 -0
  36. package/dist/src/artifacts/staging/index.js +5 -0
  37. package/dist/src/axios/baseClient.d.ts +2 -0
  38. package/dist/src/axios/baseClient.js +7 -0
  39. package/dist/src/axios/index.d.ts +8 -0
  40. package/dist/src/axios/index.js +34 -0
  41. package/dist/src/chains/definitions/arthera.d.ts +35 -0
  42. package/dist/src/chains/definitions/arthera.js +28 -0
  43. package/dist/src/chains/definitions/fiveIre.d.ts +35 -0
  44. package/dist/src/chains/definitions/fiveIre.js +28 -0
  45. package/dist/src/chains/definitions/hyperEvm.d.ts +35 -0
  46. package/dist/src/chains/definitions/hyperEvm.js +26 -0
  47. package/dist/src/chains/definitions/hyperliquid.d.ts +35 -0
  48. package/dist/src/chains/definitions/hyperliquid.js +26 -0
  49. package/dist/src/chains/definitions/stable.d.ts +36 -0
  50. package/dist/src/chains/definitions/stable.js +31 -0
  51. package/dist/src/chains/index.d.ts +179 -0
  52. package/dist/src/chains/index.js +24 -0
  53. package/dist/src/config/index.d.ts +36 -0
  54. package/dist/src/config/index.js +59 -0
  55. package/dist/src/constants/address.d.ts +13 -0
  56. package/dist/src/constants/address.js +29 -0
  57. package/dist/src/constants/approval.d.ts +7 -0
  58. package/dist/src/constants/approval.js +17 -0
  59. package/dist/src/constants/axios.d.ts +2 -0
  60. package/dist/src/constants/axios.js +5 -0
  61. package/dist/src/constants/chains.d.ts +31 -0
  62. package/dist/src/constants/chains.js +34 -0
  63. package/dist/src/constants/contract.d.ts +6 -0
  64. package/dist/src/constants/contract.js +18 -0
  65. package/dist/src/constants/erc20.d.ts +25 -0
  66. package/dist/src/constants/erc20.js +28 -0
  67. package/dist/src/constants/httpMethods.d.ts +2 -0
  68. package/dist/src/constants/httpMethods.js +5 -0
  69. package/dist/src/constants/index.d.ts +48 -0
  70. package/dist/src/constants/index.js +53 -0
  71. package/dist/src/constants/permit.d.ts +29 -0
  72. package/dist/src/constants/permit.js +33 -0
  73. package/dist/src/constants/permit2.d.ts +2 -0
  74. package/dist/src/constants/permit2.js +5 -0
  75. package/dist/src/constants/rpc.d.ts +2 -0
  76. package/dist/src/constants/rpc.js +5 -0
  77. package/dist/src/constants/urlConstants.d.ts +15 -0
  78. package/dist/src/constants/urlConstants.js +18 -0
  79. package/dist/src/dZapClient/index.d.ts +1015 -0
  80. package/dist/src/dZapClient/index.js +255 -0
  81. package/dist/src/enums/index.d.ts +46 -0
  82. package/dist/src/enums/index.js +57 -0
  83. package/dist/src/index.d.ts +17 -0
  84. package/dist/src/index.js +48 -0
  85. package/dist/src/service/cache/cacheProvider.d.ts +10 -0
  86. package/dist/src/service/cache/cacheProvider.js +72 -0
  87. package/dist/src/service/cache/constant.d.ts +2 -0
  88. package/dist/src/service/cache/constant.js +6 -0
  89. package/dist/src/service/price/index.d.ts +16 -0
  90. package/dist/src/service/price/index.js +80 -0
  91. package/dist/src/service/price/provider/coingecko/config.d.ts +6 -0
  92. package/dist/src/service/price/provider/coingecko/config.js +9 -0
  93. package/dist/src/service/price/provider/coingecko/index.d.ts +9 -0
  94. package/dist/src/service/price/provider/coingecko/index.js +66 -0
  95. package/dist/src/service/price/provider/defiLlama/config.d.ts +3 -0
  96. package/dist/src/service/price/provider/defiLlama/config.js +6 -0
  97. package/dist/src/service/price/provider/defiLlama/index.d.ts +9 -0
  98. package/dist/src/service/price/provider/defiLlama/index.js +60 -0
  99. package/dist/src/service/price/provider/defiLlama/types.d.ts +11 -0
  100. package/dist/src/service/price/provider/defiLlama/types.js +2 -0
  101. package/dist/src/service/price/provider/dzap/index.d.ts +6 -0
  102. package/dist/src/service/price/provider/dzap/index.js +22 -0
  103. package/dist/src/service/price/types/IPriceProvider.d.ts +14 -0
  104. package/dist/src/service/price/types/IPriceProvider.js +8 -0
  105. package/dist/src/transactionHandlers/generic.d.ts +24 -0
  106. package/dist/src/transactionHandlers/generic.js +48 -0
  107. package/dist/src/transactionHandlers/permit.d.ts +61 -0
  108. package/dist/src/transactionHandlers/permit.js +177 -0
  109. package/dist/src/transactionHandlers/trade.d.ts +24 -0
  110. package/dist/src/transactionHandlers/trade.js +263 -0
  111. package/dist/src/transactionHandlers/zap.d.ts +37 -0
  112. package/dist/src/transactionHandlers/zap.js +135 -0
  113. package/dist/src/types/axiosClient.d.ts +6 -0
  114. package/dist/src/types/axiosClient.js +2 -0
  115. package/dist/src/types/btc.d.ts +45 -0
  116. package/dist/src/types/btc.js +2 -0
  117. package/dist/src/types/chains.d.ts +3 -0
  118. package/dist/src/types/chains.js +2 -0
  119. package/dist/src/types/contract.d.ts +14 -0
  120. package/dist/src/types/contract.js +2 -0
  121. package/dist/src/types/eip-2612.d.ts +24 -0
  122. package/dist/src/types/eip-2612.js +58 -0
  123. package/dist/src/types/index.d.ts +489 -0
  124. package/dist/src/types/index.js +8 -0
  125. package/dist/src/types/permit.d.ts +191 -0
  126. package/dist/src/types/permit.js +54 -0
  127. package/dist/src/types/wallet.d.ts +2 -0
  128. package/dist/src/types/wallet.js +2 -0
  129. package/dist/src/types/zap/build.d.ts +44 -0
  130. package/dist/src/types/zap/build.js +2 -0
  131. package/dist/src/types/zap/index.d.ts +34 -0
  132. package/dist/src/types/zap/index.js +23 -0
  133. package/dist/src/types/zap/path.d.ts +33 -0
  134. package/dist/src/types/zap/path.js +2 -0
  135. package/dist/src/types/zap/pool.d.ts +39 -0
  136. package/dist/src/types/zap/pool.js +2 -0
  137. package/dist/src/types/zap/position.d.ts +27 -0
  138. package/dist/src/types/zap/position.js +2 -0
  139. package/dist/src/types/zap/quote.d.ts +7 -0
  140. package/dist/src/types/zap/quote.js +2 -0
  141. package/dist/src/types/zap/status.d.ts +28 -0
  142. package/dist/src/types/zap/status.js +2 -0
  143. package/dist/src/types/zap/step.d.ts +23 -0
  144. package/dist/src/types/zap/step.js +2 -0
  145. package/dist/src/utils/amount.d.ts +82 -0
  146. package/dist/src/utils/amount.js +71 -0
  147. package/dist/src/utils/axios.d.ts +13 -0
  148. package/dist/src/utils/axios.js +42 -0
  149. package/dist/src/utils/date.d.ts +1 -0
  150. package/dist/src/utils/date.js +8 -0
  151. package/dist/src/utils/decoder/swap/abis.d.ts +643 -0
  152. package/dist/src/utils/decoder/swap/abis.js +831 -0
  153. package/dist/src/utils/decoder/swap/inputDataDecoder.d.ts +14 -0
  154. package/dist/src/utils/decoder/swap/inputDataDecoder.js +124 -0
  155. package/dist/src/utils/eip-2612/eip2612Permit.d.ts +23 -0
  156. package/dist/src/utils/eip-2612/eip2612Permit.js +121 -0
  157. package/dist/src/utils/eip-5792/batchApproveTokens.d.ts +21 -0
  158. package/dist/src/utils/eip-5792/batchApproveTokens.js +49 -0
  159. package/dist/src/utils/eip-5792/index.d.ts +3 -0
  160. package/dist/src/utils/eip-5792/index.js +9 -0
  161. package/dist/src/utils/eip-5792/isBatchTxnSupportedByWallet.d.ts +6 -0
  162. package/dist/src/utils/eip-5792/isBatchTxnSupportedByWallet.js +22 -0
  163. package/dist/src/utils/eip-5792/sendBatchCalls.d.ts +10 -0
  164. package/dist/src/utils/eip-5792/sendBatchCalls.js +25 -0
  165. package/dist/src/utils/eip-5792/waitForBatchTransactionReceipt.d.ts +4 -0
  166. package/dist/src/utils/eip-5792/waitForBatchTransactionReceipt.js +26 -0
  167. package/dist/src/utils/encodeApproveCall.d.ts +6 -0
  168. package/dist/src/utils/encodeApproveCall.js +13 -0
  169. package/dist/src/utils/erc20.d.ts +65 -0
  170. package/dist/src/utils/erc20.js +153 -0
  171. package/dist/src/utils/errors.d.ts +17 -0
  172. package/dist/src/utils/errors.js +78 -0
  173. package/dist/src/utils/index.d.ts +4566 -0
  174. package/dist/src/utils/index.js +196 -0
  175. package/dist/src/utils/multicall.d.ts +14 -0
  176. package/dist/src/utils/multicall.js +25 -0
  177. package/dist/src/utils/permit2/domain.d.ts +2 -0
  178. package/dist/src/utils/permit2/domain.js +11 -0
  179. package/dist/src/utils/permit2/index.d.ts +4 -0
  180. package/dist/src/utils/permit2/index.js +97 -0
  181. package/dist/src/utils/permit2/nonce.d.ts +15 -0
  182. package/dist/src/utils/permit2/nonce.js +61 -0
  183. package/dist/src/utils/permit2/permitData.d.ts +23 -0
  184. package/dist/src/utils/permit2/permitData.js +85 -0
  185. package/dist/src/utils/permit2/values.d.ts +54 -0
  186. package/dist/src/utils/permit2/values.js +88 -0
  187. package/dist/src/utils/permit2/witnessData.d.ts +4 -0
  188. package/dist/src/utils/permit2/witnessData.js +48 -0
  189. package/dist/src/utils/signIntent/custom.d.ts +11 -0
  190. package/dist/src/utils/signIntent/custom.js +31 -0
  191. package/dist/src/utils/signIntent/gasless.d.ts +12 -0
  192. package/dist/src/utils/signIntent/gasless.js +101 -0
  193. package/dist/src/utils/signTypedData.d.ts +11 -0
  194. package/dist/src/utils/signTypedData.js +21 -0
  195. package/dist/src/utils/tokens.d.ts +8 -0
  196. package/dist/src/utils/tokens.js +73 -0
  197. package/dist/src/utils/updateQuotes.d.ts +3 -0
  198. package/dist/src/utils/updateQuotes.js +69 -0
  199. package/dist/src/zap/constants/index.d.ts +2 -0
  200. package/dist/src/zap/constants/index.js +18 -0
  201. package/dist/src/zap/constants/path.d.ts +8 -0
  202. package/dist/src/zap/constants/path.js +11 -0
  203. package/dist/src/zap/constants/step.d.ts +3 -0
  204. package/dist/src/zap/constants/step.js +6 -0
  205. package/dist/src/zap/constants/urls.d.ts +13 -0
  206. package/dist/src/zap/constants/urls.js +16 -0
  207. package/dist/test/build.test.d.ts +1 -0
  208. package/dist/test/build.test.js +65 -0
  209. package/dist/test/permit/permit2Nonce.test.d.ts +2 -0
  210. package/dist/test/permit/permit2Nonce.test.js +96 -0
  211. package/dist/test/quotes.test.d.ts +1 -0
  212. package/dist/test/quotes.test.js +59 -0
  213. package/dist/test/status.test.d.ts +1 -0
  214. package/dist/test/status.test.js +37 -0
  215. package/dist/tsconfig.tsbuildinfo +1 -0
  216. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatchPermitAbiParams = exports.bridgeGaslessWitnessType = exports.swapGaslessWitnessType = exports.defaultWitnessType = void 0;
4
+ exports.defaultWitnessType = {
5
+ typeName: 'DZapTransferWitness',
6
+ type: {
7
+ DZapTransferWitness: [
8
+ { name: 'owner', type: 'address' },
9
+ { name: 'recipient', type: 'address' },
10
+ ],
11
+ },
12
+ };
13
+ exports.swapGaslessWitnessType = {
14
+ typeName: 'DZapSwapWitness',
15
+ type: {
16
+ DZapSwapWitness: [
17
+ { name: 'txId', type: 'bytes32' },
18
+ { name: 'user', type: 'address' },
19
+ { name: 'executorFeesHash', type: 'bytes32' },
20
+ { name: 'swapDataHash', type: 'bytes32' },
21
+ ],
22
+ },
23
+ };
24
+ exports.bridgeGaslessWitnessType = {
25
+ typeName: 'DZapBridgeWitness',
26
+ type: {
27
+ DZapBridgeWitness: [
28
+ { name: 'txId', type: 'bytes32' },
29
+ { name: 'user', type: 'address' },
30
+ { name: 'executorFeesHash', type: 'bytes32' },
31
+ { name: 'swapDataHash', type: 'bytes32' },
32
+ { name: 'adapterDataHash', type: 'bytes32' },
33
+ ],
34
+ },
35
+ };
36
+ exports.BatchPermitAbiParams = [
37
+ {
38
+ name: 'permit',
39
+ type: 'tuple',
40
+ components: [
41
+ {
42
+ name: 'permitted',
43
+ type: 'tuple[]',
44
+ components: [
45
+ { name: 'token', type: 'address' },
46
+ { name: 'amount', type: 'uint256' },
47
+ ],
48
+ },
49
+ { name: 'nonce', type: 'uint256' },
50
+ { name: 'deadline', type: 'uint256' },
51
+ ],
52
+ },
53
+ { name: 'permitSignature', type: 'bytes' },
54
+ ];
@@ -0,0 +1,2 @@
1
+ import { type WalletCallReceipt as _WalletCallReceipt } from 'viem';
2
+ export type WalletCallReceipt = _WalletCallReceipt<bigint, 'success' | 'reverted'>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,44 @@
1
+ import { HexString } from '..';
2
+ import { ZapPath } from './path';
3
+ import { ZapStep } from './step';
4
+ export type ZapRouteRequestPositionDetails = {
5
+ nftId: string;
6
+ };
7
+ export type ZapRouteRequestPoolDetails = {
8
+ lowerTick: number;
9
+ upperTick: number;
10
+ metadata?: unknown;
11
+ };
12
+ export type ZapIntegratorConfig = {
13
+ id: string;
14
+ feeBps: number;
15
+ wallet: string;
16
+ };
17
+ export type ZapBuildTxnResponse = {
18
+ amountOut: string;
19
+ approvalData: {
20
+ callTo: HexString;
21
+ approveTo: HexString;
22
+ amount: string;
23
+ } | null;
24
+ steps: ZapStep[];
25
+ path: ZapPath[];
26
+ };
27
+ export type ZapBuildTxnRequest = {
28
+ srcToken: string;
29
+ srcChainId: number;
30
+ destToken: string;
31
+ destChainId: number;
32
+ recipient: string;
33
+ refundee: string;
34
+ slippage: number;
35
+ account: string;
36
+ integrator?: ZapIntegratorConfig;
37
+ permitData?: string;
38
+ amount?: string;
39
+ estimateGas?: boolean;
40
+ positionDetails?: ZapRouteRequestPositionDetails;
41
+ poolDetails?: ZapRouteRequestPoolDetails;
42
+ allowedBridges?: string[];
43
+ allowedDexes?: string[];
44
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ import { HexString, ProviderDetails } from '../';
2
+ import { ZapPathAsset } from './path';
3
+ export type ZapProviders = Record<string, ProviderDetails>;
4
+ export type ZapChains = {
5
+ [key: string]: {
6
+ name: string;
7
+ supportedProviders: string[];
8
+ };
9
+ };
10
+ export type ZapFee = {
11
+ amount: string;
12
+ amountUSD: string;
13
+ asset: ZapPathAsset;
14
+ included: boolean;
15
+ };
16
+ export type ZapUnderlyingToken = {
17
+ chainId: number;
18
+ address: HexString;
19
+ name?: string;
20
+ symbol: string;
21
+ decimals: number;
22
+ logo?: string | null;
23
+ };
24
+ export type ZapUnderlyingTokenWithAmount = ZapUnderlyingToken & {
25
+ amount: string;
26
+ amountUSD: string;
27
+ };
28
+ export * from './build';
29
+ export * from './path';
30
+ export * from './pool';
31
+ export * from './position';
32
+ export * from './quote';
33
+ export * from './status';
34
+ export * from './step';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./build"), exports);
18
+ __exportStar(require("./path"), exports);
19
+ __exportStar(require("./pool"), exports);
20
+ __exportStar(require("./position"), exports);
21
+ __exportStar(require("./quote"), exports);
22
+ __exportStar(require("./status"), exports);
23
+ __exportStar(require("./step"), exports);
@@ -0,0 +1,33 @@
1
+ import { ZapFee, ZapUnderlyingToken } from '.';
2
+ import { HexString, ProviderDetails } from '../..';
3
+ import { zapPathAction } from '../../zap/constants/path';
4
+ export type ZapPathAction = keyof typeof zapPathAction;
5
+ export type ZapPathAsset = {
6
+ chainId: number;
7
+ address: HexString;
8
+ symbol: string;
9
+ logo: string;
10
+ decimals: number;
11
+ price: string;
12
+ type: string;
13
+ name: string;
14
+ provider?: ProviderDetails;
15
+ underlyingTokens?: ZapUnderlyingToken[];
16
+ };
17
+ export type ZapPath = {
18
+ action: ZapPathAction;
19
+ protocol: ProviderDetails;
20
+ fee: ZapFee[];
21
+ estimatedDuration: number;
22
+ input: {
23
+ asset: ZapPathAsset;
24
+ amount: string;
25
+ amountUSD: string;
26
+ }[];
27
+ output: {
28
+ asset: ZapPathAsset;
29
+ amount: string;
30
+ amountUSD: string;
31
+ dust?: boolean;
32
+ }[];
33
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,39 @@
1
+ import { ZapUnderlyingToken } from '.';
2
+ import { HexString } from '..';
3
+ export type ZapPoolDetailsRequest = {
4
+ address: HexString;
5
+ chainId: number;
6
+ provider: string;
7
+ };
8
+ export type ZapPoolsRequest = {
9
+ chainId: number;
10
+ provider: string;
11
+ limit?: number;
12
+ offset?: number;
13
+ };
14
+ export type ZapPoolsResponse = {
15
+ pools: ZapPool[];
16
+ pages: number;
17
+ limit: number;
18
+ offset: number;
19
+ };
20
+ export type ZapPool = {
21
+ address: string;
22
+ chainId: number;
23
+ name: string;
24
+ provider: string;
25
+ underlyingAssets: ZapUnderlyingToken[];
26
+ tvl: string;
27
+ apr: number;
28
+ metadata?: unknown;
29
+ symbol: string;
30
+ decimals: number;
31
+ };
32
+ export type ZapPoolDetails = {
33
+ address: string;
34
+ slot0: {
35
+ sqrtPriceX96: string;
36
+ tick: number;
37
+ tickSpacing: number;
38
+ };
39
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ import { ZapUnderlyingTokenWithAmount } from '.';
2
+ import { HexString } from '..';
3
+ export type ZapPositionsRequest = {
4
+ account: HexString;
5
+ chainId: number;
6
+ provider: string;
7
+ };
8
+ export type ZapPosition = {
9
+ underlyingAssets: ZapUnderlyingTokenWithAmount[];
10
+ address: string;
11
+ apr: number;
12
+ name: string;
13
+ chainId: number;
14
+ provider: string;
15
+ amount: string;
16
+ amountUSD: string;
17
+ nftDetails?: {
18
+ id: string;
19
+ manager: HexString;
20
+ };
21
+ metadata?: unknown;
22
+ decimals: number;
23
+ };
24
+ export type ZapPositionsResponse = {
25
+ positions: ZapPosition[];
26
+ count: number;
27
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { ZapBuildTxnResponse, ZapBuildTxnRequest } from './build';
2
+ export type ZapQuoteResponse = Omit<ZapBuildTxnResponse, 'steps'>;
3
+ export type ZapQuoteRequest = Omit<ZapBuildTxnRequest, 'refundee' | 'recipient' | 'account'> & Partial<{
4
+ refundee: string;
5
+ recipient: string;
6
+ account: string;
7
+ }>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,28 @@
1
+ import { ProviderDetails } from '..';
2
+ import { ZapPathAsset } from './path';
3
+ export type ZapStatus = 'PENDING' | 'COMPLETED' | 'FAILED';
4
+ export type ZapStatusAsset = {
5
+ asset: ZapPathAsset;
6
+ amount: string;
7
+ amountUSD: string;
8
+ };
9
+ export type ZapStatusStep = {
10
+ chainId: number;
11
+ hash?: string;
12
+ status: ZapStatus;
13
+ action: string;
14
+ protocol: ProviderDetails;
15
+ input: ZapStatusAsset[];
16
+ output: ZapStatusAsset[];
17
+ };
18
+ export type ZapStatusResponse = {
19
+ status: ZapStatus;
20
+ steps: ZapStatusStep[];
21
+ recipient: string;
22
+ timestamp: number;
23
+ completedAt: number;
24
+ };
25
+ export type ZapStatusRequest = {
26
+ chainId: number;
27
+ txnHash: string;
28
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { HexString } from '..';
2
+ import { chainTypes } from '../../constants/chains';
3
+ import { zapStepAction } from '../../zap/constants/step';
4
+ export type StepAction = keyof typeof zapStepAction;
5
+ export type ZapEvmTxnDetails = {
6
+ type: typeof chainTypes.evm;
7
+ txnId: HexString;
8
+ callData: HexString;
9
+ callTo: HexString;
10
+ value: string;
11
+ estimatedGas: string;
12
+ };
13
+ export type ZapBvmTxnDetails = {
14
+ type: typeof chainTypes.bvm;
15
+ txnId: HexString;
16
+ data: string;
17
+ };
18
+ export type ZapTxnDetails = ZapEvmTxnDetails | ZapBvmTxnDetails;
19
+ export type ZapTransactionStep<T extends ZapTxnDetails = ZapTxnDetails> = {
20
+ action: StepAction;
21
+ data: T;
22
+ };
23
+ export type ZapStep = ZapTransactionStep;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,82 @@
1
+ import { Fee, TradeQuote } from '../types';
2
+ export declare const calculateAmountUSD: (amountInWei: string, decimals: number, price: string) => string;
3
+ export declare const calculateNetGasFeeUsd: (item: TradeQuote) => string;
4
+ export declare const calculateNetAmountUsd: (item: TradeQuote) => string;
5
+ export declare const calculateNetGasFee: (item: TradeQuote) => bigint;
6
+ export declare const updateFee: (fee: Fee, tokensPrice: Record<number, Record<string, string | null>>) => {
7
+ isUpdated: boolean;
8
+ fee: {
9
+ gasFee: {
10
+ amountUSD: string;
11
+ address: string;
12
+ decimals: number;
13
+ chainId: number;
14
+ symbol: string;
15
+ logo?: string;
16
+ amount: string;
17
+ included: boolean;
18
+ }[];
19
+ providerFee: {
20
+ amountUSD: string;
21
+ address: string;
22
+ decimals: number;
23
+ chainId: number;
24
+ symbol: string;
25
+ logo?: string;
26
+ amount: string;
27
+ included: boolean;
28
+ }[];
29
+ protocolFee: {
30
+ amountUSD: string;
31
+ address: string;
32
+ decimals: number;
33
+ chainId: number;
34
+ symbol: string;
35
+ logo?: string;
36
+ amount: string;
37
+ included: boolean;
38
+ }[];
39
+ };
40
+ };
41
+ export declare const updatePath: (data: TradeQuote, tokensPrice: Record<number, Record<string, string | null>>) => {
42
+ fee: {
43
+ gasFee: {
44
+ amountUSD: string;
45
+ address: string;
46
+ decimals: number;
47
+ chainId: number;
48
+ symbol: string;
49
+ logo?: string;
50
+ amount: string;
51
+ included: boolean;
52
+ }[];
53
+ providerFee: {
54
+ amountUSD: string;
55
+ address: string;
56
+ decimals: number;
57
+ chainId: number;
58
+ symbol: string;
59
+ logo?: string;
60
+ amount: string;
61
+ included: boolean;
62
+ }[];
63
+ protocolFee: {
64
+ amountUSD: string;
65
+ address: string;
66
+ decimals: number;
67
+ chainId: number;
68
+ symbol: string;
69
+ logo?: string;
70
+ amount: string;
71
+ included: boolean;
72
+ }[];
73
+ };
74
+ srcAmountUSD: string;
75
+ destAmountUSD: string;
76
+ type: string;
77
+ exchange: import("../types").ProviderDetails;
78
+ srcToken: import("../types").Token;
79
+ srcAmount: string;
80
+ destToken: import("../types").Token;
81
+ destAmount: string;
82
+ }[];
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updatePath = exports.updateFee = exports.calculateNetGasFee = exports.calculateNetAmountUsd = exports.calculateNetGasFeeUsd = exports.calculateAmountUSD = void 0;
4
+ const decimal_js_1 = require("decimal.js");
5
+ const viem_1 = require("viem");
6
+ const calculateAmountUSD = (amountInWei, decimals, price) => {
7
+ return decimals ? new decimal_js_1.default((0, viem_1.formatUnits)(BigInt(amountInWei), decimals)).mul(price || 0).toFixed(5) : '0';
8
+ };
9
+ exports.calculateAmountUSD = calculateAmountUSD;
10
+ const calculateNetGasFeeUsd = (item) => {
11
+ const totalGas = item.fee.gasFee.reduce((acc, fee) => {
12
+ if (!fee.included) {
13
+ const feeAmount = fee.amountUSD || '0';
14
+ return acc.plus(feeAmount);
15
+ }
16
+ return acc;
17
+ }, new decimal_js_1.default(0));
18
+ return totalGas.toFixed(5);
19
+ };
20
+ exports.calculateNetGasFeeUsd = calculateNetGasFeeUsd;
21
+ const calculateNetAmountUsd = (item) => {
22
+ let feeUSD = new decimal_js_1.default((0, exports.calculateNetGasFeeUsd)(item));
23
+ item.fee.providerFee.forEach((fee) => {
24
+ if (!fee.included) {
25
+ feeUSD = feeUSD.plus(new decimal_js_1.default(fee.amountUSD || '0'));
26
+ }
27
+ });
28
+ return new decimal_js_1.default(item.destAmountUSD || '0').minus(feeUSD).toFixed(5);
29
+ };
30
+ exports.calculateNetAmountUsd = calculateNetAmountUsd;
31
+ const calculateNetGasFee = (item) => {
32
+ const totalGas = item.fee.gasFee.reduce((acc, fee) => {
33
+ if (!fee.included) {
34
+ const feeAmount = BigInt(fee.amount || '0');
35
+ return acc + feeAmount;
36
+ }
37
+ return acc;
38
+ }, BigInt(0));
39
+ return totalGas;
40
+ };
41
+ exports.calculateNetGasFee = calculateNetGasFee;
42
+ const updateFee = (fee, tokensPrice) => {
43
+ let isUpdated = false;
44
+ const updateAmountUSD = (feeItem, chainId, address, amount, decimals) => {
45
+ var _a;
46
+ const price = ((_a = tokensPrice[chainId]) === null || _a === void 0 ? void 0 : _a[address]) || '0';
47
+ if (!feeItem.amountUSD || parseFloat(feeItem.amountUSD) === 0) {
48
+ isUpdated = feeItem.included === false;
49
+ return (0, exports.calculateAmountUSD)(amount, decimals, price);
50
+ }
51
+ return feeItem.amountUSD;
52
+ };
53
+ const updateFeeItems = (feeItems) => feeItems.map((feeItem) => (Object.assign(Object.assign({}, feeItem), { amountUSD: updateAmountUSD(feeItem, feeItem.chainId, feeItem.address, feeItem.amount, feeItem.decimals) })));
54
+ const updateFees = {
55
+ gasFee: updateFeeItems(fee.gasFee),
56
+ providerFee: updateFeeItems(fee.providerFee),
57
+ protocolFee: updateFeeItems(fee.protocolFee),
58
+ };
59
+ return {
60
+ isUpdated: isUpdated,
61
+ fee: updateFees,
62
+ };
63
+ };
64
+ exports.updateFee = updateFee;
65
+ const updatePath = (data, tokensPrice) => {
66
+ return data.path.map((path) => {
67
+ const { fee } = (0, exports.updateFee)(path.fee, tokensPrice);
68
+ return Object.assign(Object.assign({}, path), { fee, srcAmountUSD: data.srcAmountUSD, destAmountUSD: data.destAmountUSD });
69
+ });
70
+ };
71
+ exports.updatePath = updatePath;
@@ -0,0 +1,13 @@
1
+ import { CancelToken, Method } from 'axios';
2
+ import AxiosClient from '../axios';
3
+ type Invoke = {
4
+ endpoint: string;
5
+ data?: any;
6
+ method?: Method;
7
+ cancelToken?: CancelToken;
8
+ shouldRetry?: boolean;
9
+ baseClient?: AxiosClient;
10
+ };
11
+ export declare const invoke: ({ endpoint, data, method, cancelToken, shouldRetry }: Invoke) => Promise<any>;
12
+ export declare const invokeZap: ({ endpoint, data, method, cancelToken, shouldRetry }: Invoke) => Promise<any>;
13
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invokeZap = exports.invoke = void 0;
4
+ const baseClient_1 = require("../axios/baseClient");
5
+ const httpMethods_1 = require("../constants/httpMethods");
6
+ const config_1 = require("../config");
7
+ const invoke = async ({ endpoint, data, method = httpMethods_1.POST, cancelToken, shouldRetry = false }) => {
8
+ const apiKey = config_1.config.getApiKey();
9
+ const axiosConfig = {
10
+ method,
11
+ url: endpoint,
12
+ data: method === httpMethods_1.GET ? undefined : data,
13
+ params: method === httpMethods_1.GET ? data : undefined,
14
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (apiKey ? { 'x-api-key': apiKey } : {})),
15
+ cancelToken,
16
+ shouldRetry,
17
+ };
18
+ return (0, baseClient_1.baseApiClient)(axiosConfig)
19
+ .then((res) => res.data)
20
+ .catch((error) => {
21
+ return Promise.reject(error);
22
+ });
23
+ };
24
+ exports.invoke = invoke;
25
+ const invokeZap = async ({ endpoint, data, method = httpMethods_1.POST, cancelToken, shouldRetry = false }) => {
26
+ const apiKey = config_1.config.getApiKey();
27
+ const axiosConfig = {
28
+ method,
29
+ url: endpoint,
30
+ data: method === httpMethods_1.GET ? undefined : data,
31
+ params: method === httpMethods_1.GET ? data : undefined,
32
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (apiKey ? { 'x-api-key': apiKey } : {})),
33
+ cancelToken,
34
+ shouldRetry,
35
+ };
36
+ return (0, baseClient_1.baseZapApiClient)(axiosConfig)
37
+ .then((res) => res.data)
38
+ .catch((error) => {
39
+ return Promise.reject(error);
40
+ });
41
+ };
42
+ exports.invokeZap = invokeZap;
@@ -0,0 +1 @@
1
+ export declare const generateDeadline: (expiryInSecs: number) => bigint;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateDeadline = void 0;
4
+ const generateDeadline = (expiryInSecs) => {
5
+ const currentTime = Math.floor(Date.now() / 1000);
6
+ return BigInt(currentTime + expiryInSecs);
7
+ };
8
+ exports.generateDeadline = generateDeadline;