@swapkit/helpers 4.0.0-beta.33 → 4.0.0-beta.35

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 (251) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/api/index.js.map +1 -1
  3. package/dist/{chunk-ganzk321.js → chunk-hm14bfyg.js} +3 -3
  4. package/dist/{chunk-fazw0jvt.js.map → chunk-hm14bfyg.js.map} +1 -1
  5. package/dist/chunk-vb4wtm2w.js +4 -0
  6. package/dist/{chunk-ganzk321.js.map → chunk-vb4wtm2w.js.map} +1 -1
  7. package/dist/contracts.cjs +4 -0
  8. package/dist/contracts.cjs.map +10 -0
  9. package/dist/contracts.js +4 -0
  10. package/dist/contracts.js.map +10 -0
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.cjs.map +9 -9
  13. package/dist/index.js +3 -3
  14. package/dist/index.js.map +9 -9
  15. package/dist/tokens.cjs +4 -0
  16. package/dist/tokens.cjs.map +10 -0
  17. package/dist/tokens.js +4 -0
  18. package/dist/tokens.js.map +10 -0
  19. package/dist/types/api/index.d.ts +238 -0
  20. package/dist/types/api/index.d.ts.map +1 -0
  21. package/dist/types/api/microgard/endpoints.d.ts +25 -0
  22. package/dist/types/api/microgard/endpoints.d.ts.map +1 -0
  23. package/dist/types/api/microgard/types.d.ts +56 -0
  24. package/dist/types/api/microgard/types.d.ts.map +1 -0
  25. package/dist/types/api/midgard/endpoints.d.ts +35 -0
  26. package/dist/types/api/midgard/endpoints.d.ts.map +1 -0
  27. package/dist/types/api/midgard/types.d.ts +102 -0
  28. package/dist/types/api/midgard/types.d.ts.map +1 -0
  29. package/dist/types/api/swapkitApi/endpoints.d.ts +194 -0
  30. package/dist/types/api/swapkitApi/endpoints.d.ts.map +1 -0
  31. package/dist/types/api/swapkitApi/types.d.ts +7238 -0
  32. package/dist/types/api/swapkitApi/types.d.ts.map +1 -0
  33. package/dist/types/api/thornode/endpoints.d.ts +31 -0
  34. package/dist/types/api/thornode/endpoints.d.ts.map +1 -0
  35. package/dist/types/api/thornode/types.d.ts +264 -0
  36. package/dist/types/api/thornode/types.d.ts.map +1 -0
  37. package/dist/types/api/thorswapStatic/endpoints.d.ts +7 -0
  38. package/dist/types/api/thorswapStatic/endpoints.d.ts.map +1 -0
  39. package/dist/types/api/thorswapStatic/types.d.ts +22 -0
  40. package/dist/types/api/thorswapStatic/types.d.ts.map +1 -0
  41. package/dist/types/contracts.d.ts +2 -0
  42. package/dist/types/contracts.d.ts.map +1 -0
  43. package/{src/index.ts → dist/types/index.d.ts} +3 -4
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/dist/types/modules/assetValue.d.ts +71 -0
  46. package/dist/types/modules/assetValue.d.ts.map +1 -0
  47. package/dist/types/modules/bigIntArithmetics.d.ts +56 -0
  48. package/dist/types/modules/bigIntArithmetics.d.ts.map +1 -0
  49. package/dist/types/modules/feeMultiplier.d.ts +45 -0
  50. package/dist/types/modules/feeMultiplier.d.ts.map +1 -0
  51. package/dist/types/modules/requestClient.d.ts +22 -0
  52. package/dist/types/modules/requestClient.d.ts.map +1 -0
  53. package/dist/types/modules/swapKitConfig.d.ts +98 -0
  54. package/dist/types/modules/swapKitConfig.d.ts.map +1 -0
  55. package/dist/types/modules/swapKitError.d.ts +829 -0
  56. package/dist/types/modules/swapKitError.d.ts.map +1 -0
  57. package/dist/types/modules/swapKitNumber.d.ts +7 -0
  58. package/dist/types/modules/swapKitNumber.d.ts.map +1 -0
  59. package/dist/types/tokens.d.ts +2 -0
  60. package/dist/types/tokens.d.ts.map +1 -0
  61. package/dist/types/types/chains.d.ts +187 -0
  62. package/dist/types/types/chains.d.ts.map +1 -0
  63. package/dist/types/types/commonTypes.d.ts +37 -0
  64. package/dist/types/types/commonTypes.d.ts.map +1 -0
  65. package/dist/types/types/derivationPath.d.ts +17 -0
  66. package/dist/types/types/derivationPath.d.ts.map +1 -0
  67. package/dist/types/types/errors/apiV1.d.ts +2 -0
  68. package/dist/types/types/errors/apiV1.d.ts.map +1 -0
  69. package/{src/types/index.ts → dist/types/types/index.d.ts} +1 -1
  70. package/dist/types/types/index.d.ts.map +1 -0
  71. package/dist/types/types/quotes.d.ts +170 -0
  72. package/dist/types/types/quotes.d.ts.map +1 -0
  73. package/dist/types/types/radix.d.ts +15 -0
  74. package/dist/types/types/radix.d.ts.map +1 -0
  75. package/dist/types/types/sdk.d.ts +35 -0
  76. package/dist/types/types/sdk.d.ts.map +1 -0
  77. package/dist/types/types/wallet.d.ts +122 -0
  78. package/dist/types/types/wallet.d.ts.map +1 -0
  79. package/dist/types/utils/asset.d.ts +40 -0
  80. package/dist/types/utils/asset.d.ts.map +1 -0
  81. package/dist/types/utils/derivationPath.d.ts +19 -0
  82. package/dist/types/utils/derivationPath.d.ts.map +1 -0
  83. package/dist/types/utils/explorerUrls.d.ts +10 -0
  84. package/dist/types/utils/explorerUrls.d.ts.map +1 -0
  85. package/dist/types/utils/liquidity.d.ts +59 -0
  86. package/dist/types/utils/liquidity.d.ts.map +1 -0
  87. package/dist/types/utils/memo.d.ts +65 -0
  88. package/dist/types/utils/memo.d.ts.map +1 -0
  89. package/dist/types/utils/others.d.ts +9 -0
  90. package/dist/types/utils/others.d.ts.map +1 -0
  91. package/dist/types/utils/validators.d.ts +3 -0
  92. package/dist/types/utils/validators.d.ts.map +1 -0
  93. package/dist/types/utils/wallets.d.ts +32 -0
  94. package/dist/types/utils/wallets.d.ts.map +1 -0
  95. package/package.json +14 -15
  96. package/dist/chunk-06q78xy3.js +0 -4
  97. package/dist/chunk-06q78xy3.js.map +0 -10
  98. package/dist/chunk-0q5vvg5c.js +0 -5
  99. package/dist/chunk-0q5vvg5c.js.map +0 -10
  100. package/dist/chunk-18bxh1n7.js +0 -5
  101. package/dist/chunk-18bxh1n7.js.map +0 -10
  102. package/dist/chunk-3qya5ng9.js +0 -4
  103. package/dist/chunk-3qya5ng9.js.map +0 -10
  104. package/dist/chunk-4yqymkbp.js +0 -5
  105. package/dist/chunk-4yqymkbp.js.map +0 -10
  106. package/dist/chunk-50gpwcq9.js +0 -4
  107. package/dist/chunk-50gpwcq9.js.map +0 -10
  108. package/dist/chunk-6atq9cs7.js +0 -4
  109. package/dist/chunk-6atq9cs7.js.map +0 -10
  110. package/dist/chunk-6m0d5pv4.js +0 -5
  111. package/dist/chunk-6m0d5pv4.js.map +0 -10
  112. package/dist/chunk-8x46g3wq.js +0 -5
  113. package/dist/chunk-8x46g3wq.js.map +0 -10
  114. package/dist/chunk-92sk0g47.js +0 -5
  115. package/dist/chunk-92sk0g47.js.map +0 -10
  116. package/dist/chunk-9f2b3enk.js +0 -5
  117. package/dist/chunk-9f2b3enk.js.map +0 -10
  118. package/dist/chunk-adrafsdk.js +0 -5
  119. package/dist/chunk-adrafsdk.js.map +0 -10
  120. package/dist/chunk-b1hang9z.js +0 -5
  121. package/dist/chunk-b1hang9z.js.map +0 -10
  122. package/dist/chunk-becdmywt.js +0 -4
  123. package/dist/chunk-becdmywt.js.map +0 -10
  124. package/dist/chunk-ehz0t9d1.js +0 -4
  125. package/dist/chunk-ehz0t9d1.js.map +0 -10
  126. package/dist/chunk-fazw0jvt.js +0 -4
  127. package/dist/chunk-fm9ycn0h.js +0 -5
  128. package/dist/chunk-fm9ycn0h.js.map +0 -10
  129. package/dist/chunk-g67e2r57.js +0 -4
  130. package/dist/chunk-g67e2r57.js.map +0 -10
  131. package/dist/chunk-he3vy8gt.js +0 -4
  132. package/dist/chunk-he3vy8gt.js.map +0 -10
  133. package/dist/chunk-jjayk2y5.js +0 -4
  134. package/dist/chunk-jjayk2y5.js.map +0 -10
  135. package/dist/chunk-mmyv2vsv.js +0 -5
  136. package/dist/chunk-mmyv2vsv.js.map +0 -10
  137. package/dist/chunk-phev7aw7.js +0 -4
  138. package/dist/chunk-phev7aw7.js.map +0 -10
  139. package/dist/chunk-rhqk87p2.js +0 -5
  140. package/dist/chunk-rhqk87p2.js.map +0 -10
  141. package/dist/chunk-rnv7fdjk.js +0 -4
  142. package/dist/chunk-rnv7fdjk.js.map +0 -10
  143. package/dist/chunk-rwh98p1c.js +0 -4
  144. package/dist/chunk-rwh98p1c.js.map +0 -10
  145. package/dist/chunk-v9zj2gsj.js +0 -5
  146. package/dist/chunk-v9zj2gsj.js.map +0 -10
  147. package/dist/chunk-vv5bgsn8.js +0 -4
  148. package/dist/chunk-vv5bgsn8.js.map +0 -10
  149. package/dist/chunk-vwh9jfxn.js +0 -5
  150. package/dist/chunk-vwh9jfxn.js.map +0 -10
  151. package/dist/chunk-x0rqy75t.js +0 -4
  152. package/dist/chunk-x0rqy75t.js.map +0 -10
  153. package/dist/contracts/index.cjs +0 -4
  154. package/dist/contracts/index.cjs.map +0 -38
  155. package/dist/contracts/index.js +0 -4
  156. package/dist/contracts/index.js.map +0 -38
  157. package/dist/tokens/index.cjs +0 -4
  158. package/dist/tokens/index.cjs.map +0 -10
  159. package/dist/tokens/index.js +0 -4
  160. package/dist/tokens/index.js.map +0 -10
  161. package/src/api/index.ts +0 -19
  162. package/src/api/microgard/endpoints.ts +0 -83
  163. package/src/api/microgard/types.ts +0 -57
  164. package/src/api/midgard/endpoints.ts +0 -90
  165. package/src/api/midgard/types.ts +0 -106
  166. package/src/api/swapkitApi/endpoints.ts +0 -193
  167. package/src/api/swapkitApi/types.ts +0 -635
  168. package/src/api/thornode/endpoints.ts +0 -116
  169. package/src/api/thornode/types.ts +0 -276
  170. package/src/api/thorswapStatic/endpoints.ts +0 -46
  171. package/src/api/thorswapStatic/types.ts +0 -18
  172. package/src/contracts/abis/avaxGeneric.ts +0 -92
  173. package/src/contracts/abis/avaxWoofi.ts +0 -145
  174. package/src/contracts/abis/bscGeneric.ts +0 -106
  175. package/src/contracts/abis/chainflipGateway.ts +0 -330
  176. package/src/contracts/abis/erc20.ts +0 -99
  177. package/src/contracts/abis/ethGeneric.ts +0 -92
  178. package/src/contracts/abis/mayaEvmVaults.ts +0 -331
  179. package/src/contracts/abis/pancakeV2.ts +0 -145
  180. package/src/contracts/abis/pangolin.ts +0 -120
  181. package/src/contracts/abis/sushiswap.ts +0 -120
  182. package/src/contracts/abis/tcEthVault.ts +0 -650
  183. package/src/contracts/abis/traderJoe.ts +0 -120
  184. package/src/contracts/abis/uniswapV2.ts +0 -120
  185. package/src/contracts/abis/uniswapV2Leg.ts +0 -128
  186. package/src/contracts/abis/uniswapV3_100.ts +0 -128
  187. package/src/contracts/abis/uniswapV3_10000.ts +0 -128
  188. package/src/contracts/abis/uniswapV3_3000.ts +0 -128
  189. package/src/contracts/abis/uniswapV3_500.ts +0 -128
  190. package/src/contracts/index.ts +0 -95
  191. package/src/contracts/routers/index.ts +0 -58
  192. package/src/contracts/routers/kyber.ts +0 -402
  193. package/src/contracts/routers/oneinch.ts +0 -2188
  194. package/src/contracts/routers/pancakeswap.ts +0 -340
  195. package/src/contracts/routers/pangolin.ts +0 -340
  196. package/src/contracts/routers/sushiswap.ts +0 -340
  197. package/src/contracts/routers/traderJoe.ts +0 -340
  198. package/src/contracts/routers/uniswapv2.ts +0 -340
  199. package/src/contracts/routers/uniswapv3.ts +0 -254
  200. package/src/contracts/routers/woofi.ts +0 -171
  201. package/src/modules/__tests__/assetValue.test.ts +0 -877
  202. package/src/modules/__tests__/bigIntArithmetics.test.ts +0 -30
  203. package/src/modules/__tests__/swapKitConfig.test.ts +0 -37
  204. package/src/modules/__tests__/swapKitNumber.test.ts +0 -560
  205. package/src/modules/assetValue.ts +0 -387
  206. package/src/modules/bigIntArithmetics.ts +0 -436
  207. package/src/modules/feeMultiplier.ts +0 -87
  208. package/src/modules/requestClient.ts +0 -83
  209. package/src/modules/swapKitConfig.ts +0 -143
  210. package/src/modules/swapKitError.ts +0 -442
  211. package/src/modules/swapKitNumber.ts +0 -16
  212. package/src/tokens/index.ts +0 -15
  213. package/src/tokens/lists/camelot_v3.ts +0 -16060
  214. package/src/tokens/lists/caviar_v1.ts +0 -1704
  215. package/src/tokens/lists/chainflip.ts +0 -104
  216. package/src/tokens/lists/index.ts +0 -14
  217. package/src/tokens/lists/jupiter.ts +0 -33563
  218. package/src/tokens/lists/mayachain.ts +0 -509
  219. package/src/tokens/lists/near.ts +0 -458
  220. package/src/tokens/lists/oneinch.ts +0 -15006
  221. package/src/tokens/lists/openocean_v2.ts +0 -12434
  222. package/src/tokens/lists/pancakeswap.ts +0 -6136
  223. package/src/tokens/lists/pangolin_v1.ts +0 -75
  224. package/src/tokens/lists/sushiswap_v2.ts +0 -595
  225. package/src/tokens/lists/thorchain.ts +0 -748
  226. package/src/tokens/lists/traderjoe_v2.ts +0 -594
  227. package/src/tokens/lists/uniswap_v2.ts +0 -11484
  228. package/src/tokens/lists/uniswap_v3.ts +0 -19424
  229. package/src/types/chains.ts +0 -555
  230. package/src/types/commonTypes.ts +0 -58
  231. package/src/types/derivationPath.ts +0 -58
  232. package/src/types/errors/apiV1.ts +0 -0
  233. package/src/types/quotes.ts +0 -172
  234. package/src/types/radix.ts +0 -14
  235. package/src/types/sdk.ts +0 -42
  236. package/src/types/tokens.ts +0 -17
  237. package/src/types/wallet.ts +0 -166
  238. package/src/utils/__tests__/asset.test.ts +0 -193
  239. package/src/utils/__tests__/derivationPath.test.ts +0 -16
  240. package/src/utils/__tests__/memo.test.ts +0 -103
  241. package/src/utils/__tests__/others.test.ts +0 -88
  242. package/src/utils/__tests__/validators.test.ts +0 -24
  243. package/src/utils/asset.ts +0 -231
  244. package/src/utils/derivationPath.ts +0 -98
  245. package/src/utils/liquidity.ts +0 -179
  246. package/src/utils/memo.ts +0 -143
  247. package/src/utils/others.ts +0 -86
  248. package/src/utils/plugin.ts +0 -13
  249. package/src/utils/tokens.ts +0 -73
  250. package/src/utils/validators.ts +0 -32
  251. package/src/utils/wallets.ts +0 -276
@@ -1,635 +0,0 @@
1
- import {
2
- type AssetValue,
3
- Chain,
4
- ChainId,
5
- ErrorCode,
6
- FeeTypeEnum,
7
- ProviderName,
8
- WarningCodeEnum,
9
- } from "@swapkit/helpers";
10
- import {
11
- type ZodType,
12
- array,
13
- boolean,
14
- coerce,
15
- nativeEnum,
16
- number,
17
- object,
18
- optional,
19
- string,
20
- union,
21
- unknown,
22
- type z,
23
- } from "zod";
24
-
25
- export enum PriorityLabel {
26
- CHEAPEST = "CHEAPEST",
27
- FASTEST = "FASTEST",
28
- RECOMMENDED = "RECOMMENDED",
29
- }
30
-
31
- export enum RouteQuoteTxType {
32
- PSBT = "PSBT",
33
- EVM = "EVM",
34
- COSMOS = "COSMOS",
35
- RADIX = "RADIX",
36
- }
37
-
38
- export enum TxnType {
39
- native_send = "native_send",
40
- token_transfer = "token_transfer",
41
- native_contract_call = "native_contract_call",
42
- token_contract_call = "token_contract_call",
43
- approve = "approve",
44
- deposit = "deposit",
45
- thorname_action = "thorname_action",
46
- lp_action = "lp_action",
47
- swap = "swap",
48
- streaming_swap = "streaming_swap",
49
- stake = "stake",
50
- claim = "claim",
51
- lending = "lending",
52
- unknown = "unknown",
53
- }
54
-
55
- export enum TxnStatus {
56
- unknown = "unknown",
57
- not_started = "not_started",
58
- pending = "pending",
59
- swapping = "swapping",
60
- completed = "completed",
61
- }
62
-
63
- export enum TrackingStatus {
64
- not_started = "not_started",
65
- starting = "starting",
66
- broadcasted = "broadcasted",
67
- mempool = "mempool",
68
- inbound = "inbound",
69
- outbound = "outbound",
70
- swapping = "swapping",
71
- completed = "completed",
72
- refunded = "refunded",
73
- partially_refunded = "partially_refunded",
74
- dropped = "dropped",
75
- reverted = "reverted",
76
- replaced = "replaced",
77
- retries_exceeded = "retries_exceeded",
78
- parsing_error = "parsing_error",
79
- }
80
-
81
- type TokenProviderVersion = {
82
- major: number;
83
- minor: number;
84
- patch: number;
85
- };
86
-
87
- export type TokenListProvidersResponse = Array<{
88
- provider: ProviderName;
89
- name: string;
90
- timestamp: string;
91
- version: TokenProviderVersion;
92
- keywords: string[];
93
- count: number;
94
- url: string;
95
- }>;
96
-
97
- export type TokensResponseV2 = {
98
- chainId: ChainId;
99
- count: number;
100
- keywords: string[];
101
- name: string;
102
- provider: ProviderName;
103
- timestamp: string;
104
- tokens: TokenV2[];
105
- version: TokenProviderVersion;
106
- };
107
-
108
- export type TokenV2 = {
109
- address?: string;
110
- chain: string;
111
- shortCode?: string;
112
- chainId: string;
113
- decimals: number;
114
- extensions?: {};
115
- identifier: string;
116
- logoURI: string;
117
- name?: string;
118
- symbol: string;
119
- ticker: string;
120
- };
121
-
122
- export interface TransactionProps {
123
- chainId: ChainId;
124
- hash: string;
125
- block: number;
126
- type?: TxnType;
127
- status?: TxnStatus;
128
- trackingStatus?: TrackingStatus;
129
- fromAsset: AssetValue | null;
130
- fromAddress: string;
131
- toAsset: AssetValue | null;
132
- toAddress: string;
133
- finalisedAt?: number;
134
- meta?: Partial<TxnMeta>;
135
- payload?: Partial<TxnPayload>;
136
- }
137
-
138
- export type TrackerParams = {
139
- chainId: ChainId;
140
- hash: string;
141
- block?: number;
142
- };
143
-
144
- export type TrackerResponse = TransactionProps & {
145
- legs: TransactionLegDTO[];
146
- transient?: TxnTransient;
147
- };
148
-
149
- export const ApiV2ErrorSchema = object({
150
- error: string(),
151
- message: string(),
152
- });
153
-
154
- export const AssetValueSchema = object({
155
- chain: nativeEnum(Chain),
156
- symbol: string(),
157
- ticker: string(),
158
- decimal: optional(number()),
159
- address: optional(string()),
160
- isGasAsset: boolean(),
161
- isSynthetic: boolean(),
162
- tax: optional(object({ buy: number(), sell: number() })),
163
- });
164
-
165
- export const TokenDetailsMetadataSchema = object({
166
- id: string(),
167
- market_cap: number(),
168
- name: string(),
169
- price_change_24h_usd: number(),
170
- price_change_percentage_24h_usd: number(),
171
- sparkline_in_7d: array(number()),
172
- timestamp: string(),
173
- total_volume: number(),
174
- });
175
-
176
- export const PriceResponseSchema = array(
177
- object({
178
- identifier: string(),
179
- provider: string(),
180
- cg: TokenDetailsMetadataSchema.optional(),
181
- price_usd: number(),
182
- timestamp: number(),
183
- }).partial(),
184
- );
185
-
186
- export type PriceResponse = z.infer<typeof PriceResponseSchema>;
187
-
188
- export const QuoteRequestSchema = object({
189
- sellAsset: string({ description: "Asset to sell" }),
190
- buyAsset: string({ description: "Asset to buy" }),
191
- sellAmount: string({ description: "Amount of asset to sell" }).refine((amount) => +amount > 0, {
192
- message: "sellAmount must be greater than 0",
193
- path: ["sellAmount"],
194
- }),
195
- providers: optional(
196
- array(
197
- string({ description: "List of providers to use" }).refine(
198
- (provider) => ProviderName[provider as ProviderName] !== undefined,
199
- { message: "Invalid provider", path: ["providers"] },
200
- ),
201
- ),
202
- ),
203
- sourceAddress: optional(string({ description: "Address to send asset from" })),
204
- destinationAddress: optional(string({ description: "Address to send asset to" })),
205
- slippage: optional(number({ description: "Slippage tolerance as a percentage. Default is 3%." })),
206
- affiliate: optional(string({ description: "Affiliate thorname" })),
207
- affiliateFee: optional(
208
- number({ description: "Affiliate fee in basis points" }).refine(
209
- (fee) => fee === Math.floor(fee) && fee >= 0,
210
- { message: "affiliateFee must be a positive integer", path: ["affiliateFee"] },
211
- ),
212
- ),
213
- allowSmartContractSender: optional(boolean({ description: "Allow smart contract as sender" })),
214
- allowSmartContractReceiver: optional(
215
- boolean({ description: "Allow smart contract as recipient" }),
216
- ),
217
- disableSecurityChecks: optional(boolean({ description: "Disable security checks" })),
218
- includeTx: optional(
219
- boolean({ description: "Set to true to include an transaction object (EVM only)" }),
220
- ),
221
- cfBoost: optional(
222
- boolean({
223
- description: "Set to true to enable CF boost to speed up Chainflip swaps. BTC only.",
224
- }),
225
- ),
226
- referrer: optional(string({ description: "Referrer address (referral program)" })),
227
- }).refine((data) => data.sellAsset !== data.buyAsset, {
228
- message: "Must be different",
229
- path: ["sellAsset", "buyAsset"],
230
- });
231
-
232
- export type QuoteRequest = z.infer<typeof QuoteRequestSchema>;
233
-
234
- export const PriceRequestSchema = object({
235
- tokens: array(
236
- object({
237
- identifier: string(),
238
- }),
239
- ),
240
- metadata: boolean(),
241
- });
242
-
243
- export type PriceRequest = z.infer<typeof PriceRequestSchema>;
244
-
245
- export const DepositChannelParamsSchema = object({
246
- destinationAddress: string(),
247
- });
248
-
249
- export const BrokerDepositChannelParamsSchema = DepositChannelParamsSchema.extend({
250
- sellAsset: object({
251
- chain: string(),
252
- asset: string(),
253
- }),
254
- buyAsset: object({
255
- chain: string(),
256
- asset: string(),
257
- }),
258
- channelMetadata: object({
259
- cfParameters: string().optional(),
260
- gasBudget: string().optional(),
261
- message: string().optional(),
262
- }).optional(),
263
- affiliateFees: array(
264
- object({
265
- brokerAddress: string(),
266
- feeBps: number(),
267
- }),
268
- ).optional(),
269
- refundParameters: object({
270
- minPrice: string().optional(),
271
- refundAddress: string().optional(),
272
- retryDuration: number().optional(),
273
- }).optional(),
274
- dcaParameters: object({
275
- chunkInterval: number().optional(),
276
- numberOfChunks: number().optional(),
277
- }).optional(),
278
- brokerCommissionBps: number().optional(),
279
- maxBoostFeeBps: number().optional(),
280
- });
281
-
282
- export type BrokerDepositChannelParams = z.infer<typeof BrokerDepositChannelParamsSchema>;
283
-
284
- export const DepositChannelResponseSchema = object({
285
- channelId: string(),
286
- depositAddress: string(),
287
- });
288
-
289
- export const NearDepositChannelParamsSchema = DepositChannelParamsSchema.extend({
290
- sellAsset: string(),
291
- buyAsset: string(),
292
- sourceAddress: string(),
293
- sellAmount: string(),
294
- affiliateFees: object({
295
- nearId: string(),
296
- feeBps: number(),
297
- }).optional(),
298
- slippage: coerce.number(),
299
- });
300
-
301
- export type NearDepositChannelParams = z.infer<typeof NearDepositChannelParamsSchema>;
302
-
303
- const NearQuoteResponseSchema = object({
304
- amountIn: string(),
305
- amountInFormatted: string(),
306
- amountInUsd: string(),
307
- minAmountIn: string(),
308
- amountOut: string(),
309
- amountOutFormatted: string(),
310
- amountOutUsd: string(),
311
- minAmountOut: string(),
312
- deadline: string().optional(),
313
- timeWhenInactive: string().optional(),
314
- timeEstimate: number().optional(),
315
- });
316
-
317
- export const NearDepositChannelResultSchema = NearQuoteResponseSchema.extend({
318
- timestamp: string(),
319
- signature: string(),
320
- quote: NearQuoteResponseSchema,
321
- tx: unknown(),
322
- depositAddress: string(),
323
- });
324
-
325
- export type NearDepositChannelResult = z.infer<typeof NearDepositChannelResultSchema>;
326
-
327
- export const NearSwapResponseSchema = object({
328
- depositAddress: string(),
329
- depositAsset: string(),
330
- depositAmount: string(),
331
- buyAsset: string(),
332
- buyAssetAmount: string(),
333
- buyAssetAmountMaxSlippage: string(),
334
- tx: unknown(),
335
- deadline: string().optional(),
336
- });
337
-
338
- export type NearSwapResponse = z.infer<typeof NearSwapResponseSchema>;
339
-
340
- export type DepositChannelResponse = z.infer<typeof DepositChannelResponseSchema>;
341
-
342
- const TxnPayloadSchema = object({
343
- evmCalldata: optional(string()),
344
- logs: optional(unknown()),
345
- memo: optional(string()),
346
- spender: optional(string()), // used in evm approve transactions
347
- });
348
-
349
- export type TxnPayload = z.infer<typeof TxnPayloadSchema>;
350
-
351
- // props that are most important while the transaction is live
352
- const TxnTransientSchema = object({
353
- estimatedFinalisedAt: number(),
354
- estimatedTimeToComplete: number(),
355
- updatedAt: number(),
356
- currentLegIndex: optional(number()),
357
- providerDetails: optional(unknown()), // see ProviderTransientDetails
358
- });
359
-
360
- export type TxnTransient = z.infer<typeof TxnTransientSchema>;
361
-
362
- const TransactionFeesSchema = object({
363
- network: optional(AssetValueSchema), // gas on ethereum, network fee on thorchain, etc.
364
- affiliate: optional(AssetValueSchema), // e.g. affiliate in memo, other affiliate mechanisms
365
- liquidity: optional(AssetValueSchema), // fee paid to pool
366
- protocol: optional(AssetValueSchema), // extra protocol fees (TS dex aggregation contracts, stargate fees, etc.)
367
- tax: optional(AssetValueSchema), // taxed tokens
368
- });
369
-
370
- export type TransactionFees = z.infer<typeof TransactionFeesSchema>;
371
-
372
- const TxnMetaSchema = object({
373
- broadcastedAt: optional(number()),
374
- wallet: optional(string()),
375
- quoteId: optional(string()),
376
- explorerUrl: optional(string()),
377
- affiliate: optional(string()),
378
- fees: optional(TransactionFeesSchema),
379
- provider: optional(nativeEnum(ProviderName)),
380
- images: optional(
381
- object({
382
- from: optional(string()),
383
- to: optional(string()),
384
- provider: optional(string()),
385
- chain: optional(string()),
386
- }),
387
- ),
388
- });
389
-
390
- export type TxnMeta = z.infer<typeof TxnMetaSchema>;
391
-
392
- const TransactionLegDTOSchema = object({
393
- chainId: nativeEnum(ChainId),
394
- hash: string(),
395
- block: number(),
396
- type: nativeEnum(TxnType),
397
- status: nativeEnum(TxnStatus),
398
- trackingStatus: optional(nativeEnum(TrackingStatus)),
399
-
400
- fromAsset: string(),
401
- fromAmount: string(),
402
- fromAddress: string(),
403
- toAsset: string(),
404
- toAmount: string(),
405
- toAddress: string(),
406
- finalAsset: optional(AssetValueSchema),
407
- finalAddress: optional(string()),
408
-
409
- finalisedAt: number(),
410
-
411
- transient: optional(TxnTransientSchema),
412
- meta: optional(TxnMetaSchema),
413
- payload: optional(TxnPayloadSchema),
414
- });
415
-
416
- export type TransactionLegDTO = z.infer<typeof TransactionLegDTOSchema>;
417
-
418
- export const TransactionSchema = TransactionLegDTOSchema.extend({
419
- legs: array(TransactionLegDTOSchema),
420
- });
421
-
422
- export type TransactionDTO = z.infer<typeof TransactionLegDTOSchema> & {
423
- legs: TransactionLegDTO[];
424
- };
425
-
426
- export const TransactionDTOSchema: ZodType<TransactionDTO> = TransactionLegDTOSchema.extend({
427
- legs: array(TransactionLegDTOSchema),
428
- });
429
-
430
- export const FeesSchema = array(
431
- object({
432
- type: nativeEnum(FeeTypeEnum),
433
- amount: string(),
434
- asset: string(),
435
- chain: string(),
436
- protocol: nativeEnum(ProviderName),
437
- }),
438
- );
439
-
440
- export type Fees = z.infer<typeof FeesSchema>;
441
-
442
- export const EstimatedTimeSchema = object({
443
- inbound: optional(number({ description: "Time to receive inbound asset in seconds" })),
444
- swap: optional(number({ description: "Time to swap assets in seconds" })),
445
- outbound: optional(number({ description: "Time to receive outbound asset in seconds" })),
446
- total: number({ description: "Total time in seconds" }),
447
- });
448
-
449
- export type EstimatedTime = z.infer<typeof EstimatedTimeSchema>;
450
-
451
- export const EVMTransactionSchema = object({
452
- to: string({ description: "Address of the recipient" }),
453
- from: string({ description: "Address of the sender" }),
454
- value: string({ description: "Value to send" }),
455
- data: string({ description: "Data to send" }),
456
- });
457
-
458
- export type EVMTransaction = z.infer<typeof EVMTransactionSchema>;
459
-
460
- export const EVMTransactionDetailsParamsSchema = array(
461
- union([
462
- string(),
463
- number(),
464
- array(string()),
465
- object({ from: string(), value: string() }).describe(
466
- "Parameters to pass to the contract method",
467
- ),
468
- ]),
469
- );
470
-
471
- export type EVMTransactionDetailsParams = z.infer<typeof EVMTransactionDetailsParamsSchema>;
472
-
473
- export const EVMTransactionDetailsSchema = object({
474
- contractAddress: string({ description: "Address of the contract to interact with" }),
475
- contractMethod: string({ description: "Name of the method to call" }),
476
- contractParams: EVMTransactionDetailsParamsSchema,
477
- contractParamNames: array(
478
- string({ description: "Names of the parameters to pass to the contract method" }),
479
- ),
480
- approvalToken: optional(string({ description: "Address of the token to approve spending of" })),
481
- approvalSpender: optional(string({ description: "Address of the spender to approve" })),
482
- });
483
-
484
- export type EVMTransactionDetails = z.infer<typeof EVMTransactionDetailsSchema>;
485
-
486
- const EncodeObjectSchema = object({
487
- typeUrl: string(),
488
- value: unknown(),
489
- });
490
-
491
- const FeeSchema = object({
492
- amount: array(object({ denom: string(), amount: string() })),
493
- gas: string(),
494
- });
495
-
496
- export const CosmosTransactionSchema = object({
497
- memo: string(),
498
- accountNumber: number(),
499
- sequence: number(),
500
- chainId: nativeEnum(ChainId),
501
- msgs: array(EncodeObjectSchema),
502
- fee: FeeSchema,
503
- });
504
-
505
- export type CosmosTransaction = z.infer<typeof CosmosTransactionSchema>;
506
-
507
- export const RouteLegSchema = object({
508
- sellAsset: string({ description: "Asset to sell" }),
509
- buyAsset: string({ description: "Asset to buy" }),
510
- provider: nativeEnum(ProviderName),
511
- sourceAddress: string({ description: "Source address" }),
512
- destinationAddress: string({ description: "Destination address" }),
513
- estimatedTime: EstimatedTimeSchema.optional(),
514
- affiliate: string({ description: "Affiliate address" }).optional(),
515
- affiliateFee: number({ description: "Affiliate fee" }).optional(),
516
- slipPercentage: number({ description: "Slippage as a percentage" }),
517
- });
518
-
519
- export type RouteLeg = z.infer<typeof RouteLegSchema>;
520
-
521
- export const RouteLegWithoutAddressesSchema = RouteLegSchema.omit({
522
- sourceAddress: true,
523
- destinationAddress: true,
524
- slipPercentage: true,
525
- });
526
-
527
- export type RouteLegWithoutAddresses = z.infer<typeof RouteLegWithoutAddressesSchema>;
528
-
529
- export const RouteQuoteMetadataAssetSchema = object({
530
- asset: string({ description: "Asset name" }),
531
- price: number({ description: "Price in USD" }),
532
- image: string({ description: "Asset image" }),
533
- });
534
-
535
- export type RouteQuoteMetadataAsset = z.infer<typeof RouteQuoteMetadataAssetSchema>;
536
-
537
- export const ChainflipMetadataSchema = BrokerDepositChannelParamsSchema;
538
-
539
- export type ChainflipMetadata = z.infer<typeof ChainflipMetadataSchema>;
540
-
541
- export const RouteQuoteMetadataSchema = object({
542
- assets: optional(array(RouteQuoteMetadataAssetSchema)),
543
- tags: array(nativeEnum(PriorityLabel)),
544
- streamingInterval: number().optional(),
545
- maxStreamingQuantity: number().optional(),
546
- referrer: string().optional(),
547
- });
548
-
549
- export const RouteQuoteMetadataV2Schema = RouteQuoteMetadataSchema.extend({
550
- priceImpact: optional(number({ description: "Price impact" })),
551
- approvalAddress: optional(string({ description: "Approval address for swap" })),
552
- affiliate: optional(string()),
553
- affiliateFee: optional(string()),
554
- txType: optional(nativeEnum(RouteQuoteTxType)),
555
- chainflip: ChainflipMetadataSchema.optional(),
556
- near: NearDepositChannelParamsSchema.optional(),
557
- referrer: optional(string()),
558
- });
559
-
560
- export const RouteQuoteWarningSchema = array(
561
- object({ code: nativeEnum(WarningCodeEnum), display: string(), tooltip: string().optional() }),
562
- );
563
-
564
- export type RouteQuoteWarning = z.infer<typeof RouteQuoteWarningSchema>;
565
-
566
- const QuoteResponseRouteLegItem = object({
567
- provider: nativeEnum(ProviderName),
568
- sellAsset: string({ description: "Asset to sell" }),
569
- sellAmount: string({ description: "Sell amount" }),
570
- buyAsset: string({ description: "Asset to buy" }),
571
- buyAmount: string({ description: "Buy amount" }),
572
- buyAmountMaxSlippage: string({ description: "Buy amount max slippage" }),
573
- fees: optional(FeesSchema),
574
- });
575
-
576
- const QuoteResponseRouteItem = object({
577
- providers: array(nativeEnum(ProviderName)),
578
- sellAsset: string({ description: "Asset to sell" }),
579
- sellAmount: string({ description: "Sell amount" }),
580
- buyAsset: string({ description: "Asset to buy" }),
581
- expectedBuyAmount: string({ description: "Expected Buy amount" }),
582
- expectedBuyAmountMaxSlippage: string({ description: "Expected Buy amount max slippage" }),
583
- sourceAddress: string({ description: "Source address" }),
584
- destinationAddress: string({ description: "Destination address" }),
585
- targetAddress: optional(string({ description: "Target address" })),
586
- inboundAddress: optional(string({ description: "Inbound address" })),
587
- expiration: optional(string({ description: "Expiration" })),
588
- memo: optional(string({ description: "Memo" })),
589
- fees: FeesSchema,
590
- txType: optional(nativeEnum(RouteQuoteTxType)),
591
- tx: optional(union([EVMTransactionSchema, CosmosTransactionSchema, string()])),
592
- estimatedTime: optional(EstimatedTimeSchema),
593
- totalSlippageBps: number({ description: "Total slippage in bps" }),
594
- legs: array(QuoteResponseRouteLegItem),
595
- warnings: RouteQuoteWarningSchema,
596
- meta: RouteQuoteMetadataV2Schema,
597
- });
598
-
599
- export const QuoteResponseSchema = object({
600
- quoteId: string({ description: "Quote ID" }),
601
- routes: array(QuoteResponseRouteItem),
602
- error: optional(string({ description: "Error message" })),
603
- providerErrors: optional(
604
- array(
605
- object({
606
- provider: nativeEnum(ProviderName).optional(),
607
- errorCode: optional(nativeEnum(ErrorCode)),
608
- message: optional(string()),
609
- }),
610
- ),
611
- ),
612
- });
613
-
614
- export type QuoteResponse = z.infer<typeof QuoteResponseSchema>;
615
- export type QuoteResponseRoute = z.infer<typeof QuoteResponseRouteItem>;
616
- export type QuoteResponseRouteLeg = z.infer<typeof QuoteResponseRouteLegItem>;
617
-
618
- export const GasResponseSchema = array(
619
- object({ id: number(), chainId: string(), value: string(), unit: string(), createdAt: string() }),
620
- );
621
-
622
- export type GasResponse = z.infer<typeof GasResponseSchema>;
623
-
624
- const BalanceResponseSchema = array(
625
- object({
626
- chain: nativeEnum(Chain),
627
- decimal: number(),
628
- ticker: string(),
629
- symbol: string(),
630
- value: string(),
631
- identifier: string(),
632
- }),
633
- );
634
-
635
- export type BalanceResponse = z.infer<typeof BalanceResponseSchema>;