moneyos 0.2.1 → 0.3.2

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/index.d.mts DELETED
@@ -1,135 +0,0 @@
1
- import { Hex, Address } from 'viem';
2
-
3
- interface MoneyOSConfig {
4
- /** Default chain ID (e.g. 42161 for Arbitrum) */
5
- chainId: number;
6
- /** RPC URL override. Uses public RPC if not set. */
7
- rpcUrl?: string;
8
- /** Private key for signing transactions (hex string) */
9
- privateKey?: Hex;
10
- }
11
- interface Balance {
12
- token: string;
13
- symbol: string;
14
- amount: string;
15
- rawAmount: bigint;
16
- decimals: number;
17
- chainId: number;
18
- }
19
- interface SendResult {
20
- hash: Hex;
21
- from: Address;
22
- to: Address;
23
- amount: string;
24
- token: string;
25
- chainId: number;
26
- }
27
- interface SwapQuote {
28
- tokenIn: string;
29
- tokenOut: string;
30
- amountIn: string;
31
- expectedOut: string;
32
- router: Address;
33
- chainId: number;
34
- }
35
- interface SwapResult {
36
- hash: Hex;
37
- tokenIn: string;
38
- tokenOut: string;
39
- amountIn: string;
40
- amountOut: string;
41
- chainId: number;
42
- }
43
- interface SwapProvider {
44
- name: string;
45
- getQuote(params: {
46
- chainId: number;
47
- tokenIn: Address;
48
- tokenOut: Address;
49
- amount: bigint;
50
- sender: Address;
51
- slippage?: number;
52
- }): Promise<SwapQuote>;
53
- getCalldata(quote: SwapQuote): Promise<{
54
- to: Address;
55
- data: Hex;
56
- value: bigint;
57
- }>;
58
- }
59
- interface Chain {
60
- id: number;
61
- name: string;
62
- rpcUrl: string;
63
- nativeCurrency: {
64
- name: string;
65
- symbol: string;
66
- decimals: number;
67
- };
68
- blockExplorer: string;
69
- }
70
-
71
- declare class MoneyOS {
72
- private config;
73
- private publicClients;
74
- private walletClient;
75
- constructor(config: MoneyOSConfig);
76
- private getPublicClient;
77
- private getWalletClient;
78
- get address(): Address;
79
- balance(token: string, options?: {
80
- address?: Address;
81
- chainId?: number;
82
- }): Promise<Balance>;
83
- send(token: string, to: Address, amount: string, options?: {
84
- chainId?: number;
85
- }): Promise<SendResult>;
86
- swap(tokenIn: string, tokenOut: string, amount: string, provider: SwapProvider, options?: {
87
- chainId?: number;
88
- slippage?: number;
89
- }): Promise<SwapResult>;
90
- }
91
-
92
- declare const chains: Record<string, Chain>;
93
- declare const defaultChain: Chain;
94
- declare function getChain(idOrName: number | string): Chain | undefined;
95
-
96
- interface Token {
97
- symbol: string;
98
- name: string;
99
- decimals: number;
100
- addresses: Record<number, Address>;
101
- }
102
- declare const NATIVE_TOKEN_ADDRESS: Address;
103
- declare const tokens: Record<string, Token>;
104
- declare function getToken(symbol: string): Token | undefined;
105
- declare function getTokenAddress(symbol: string, chainId: number): Address | undefined;
106
-
107
- declare class OdosProvider implements SwapProvider {
108
- name: string;
109
- private apiKey?;
110
- constructor(options?: {
111
- apiKey?: string;
112
- });
113
- private toOdosAddress;
114
- getQuote(params: {
115
- chainId: number;
116
- tokenIn: Address;
117
- tokenOut: Address;
118
- amount: bigint;
119
- sender: Address;
120
- slippage?: number;
121
- }): Promise<SwapQuote & {
122
- pathId: string;
123
- sender: Address;
124
- }>;
125
- getCalldata(quote: SwapQuote & {
126
- pathId: string;
127
- sender: Address;
128
- }): Promise<{
129
- to: Address;
130
- data: Hex;
131
- value: bigint;
132
- }>;
133
- }
134
-
135
- export { type Balance, type Chain, MoneyOS, type MoneyOSConfig, NATIVE_TOKEN_ADDRESS, OdosProvider, type SendResult, type SwapProvider, type SwapQuote, type SwapResult, type Token, chains, defaultChain, getChain, getToken, getTokenAddress, tokens };
package/dist/index.mjs DELETED
@@ -1,429 +0,0 @@
1
- // src/core/client.ts
2
- import {
3
- createPublicClient,
4
- createWalletClient,
5
- http,
6
- formatUnits,
7
- parseUnits
8
- } from "viem";
9
- import { privateKeyToAccount } from "viem/accounts";
10
- import { arbitrum, mainnet, polygon } from "viem/chains";
11
-
12
- // src/core/chains.ts
13
- var chains = {
14
- arbitrum: {
15
- id: 42161,
16
- name: "Arbitrum One",
17
- rpcUrl: "https://arb1.arbitrum.io/rpc",
18
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
19
- blockExplorer: "https://arbiscan.io"
20
- },
21
- ethereum: {
22
- id: 1,
23
- name: "Ethereum",
24
- rpcUrl: "https://eth.public-rpc.com",
25
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
26
- blockExplorer: "https://etherscan.io"
27
- },
28
- polygon: {
29
- id: 137,
30
- name: "Polygon",
31
- rpcUrl: "https://polygon-rpc.com",
32
- nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
33
- blockExplorer: "https://polygonscan.com"
34
- }
35
- };
36
- var defaultChain = chains.arbitrum;
37
- function getChain(idOrName) {
38
- if (typeof idOrName === "number") {
39
- return Object.values(chains).find((c) => c.id === idOrName);
40
- }
41
- return chains[idOrName.toLowerCase()];
42
- }
43
-
44
- // src/core/tokens.ts
45
- var NATIVE_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
46
- var tokens = {
47
- ETH: {
48
- symbol: "ETH",
49
- name: "Ether",
50
- decimals: 18,
51
- addresses: {
52
- 42161: NATIVE_TOKEN_ADDRESS,
53
- 1: NATIVE_TOKEN_ADDRESS,
54
- 137: NATIVE_TOKEN_ADDRESS
55
- }
56
- },
57
- USDC: {
58
- symbol: "USDC",
59
- name: "USD Coin",
60
- decimals: 6,
61
- addresses: {
62
- 42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
63
- 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
64
- 137: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
65
- }
66
- },
67
- USDT: {
68
- symbol: "USDT",
69
- name: "Tether USD",
70
- decimals: 6,
71
- addresses: {
72
- 42161: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
73
- 1: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
74
- 137: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
75
- }
76
- },
77
- RYZE: {
78
- symbol: "RYZE",
79
- name: "RYZE",
80
- decimals: 18,
81
- addresses: {
82
- 42161: "0x7712da72127d5dD213B621497D6E4899d5989e5C"
83
- }
84
- }
85
- };
86
- function getToken(symbol) {
87
- return tokens[symbol.toUpperCase()];
88
- }
89
- function getTokenAddress(symbol, chainId) {
90
- return getToken(symbol)?.addresses[chainId];
91
- }
92
-
93
- // src/core/client.ts
94
- var ERC20_ABI = [
95
- {
96
- name: "balanceOf",
97
- type: "function",
98
- stateMutability: "view",
99
- inputs: [{ name: "account", type: "address" }],
100
- outputs: [{ name: "", type: "uint256" }]
101
- },
102
- {
103
- name: "transfer",
104
- type: "function",
105
- stateMutability: "nonpayable",
106
- inputs: [
107
- { name: "to", type: "address" },
108
- { name: "amount", type: "uint256" }
109
- ],
110
- outputs: [{ name: "", type: "bool" }]
111
- },
112
- {
113
- name: "decimals",
114
- type: "function",
115
- stateMutability: "view",
116
- inputs: [],
117
- outputs: [{ name: "", type: "uint8" }]
118
- },
119
- {
120
- name: "symbol",
121
- type: "function",
122
- stateMutability: "view",
123
- inputs: [],
124
- outputs: [{ name: "", type: "string" }]
125
- },
126
- {
127
- name: "approve",
128
- type: "function",
129
- stateMutability: "nonpayable",
130
- inputs: [
131
- { name: "spender", type: "address" },
132
- { name: "amount", type: "uint256" }
133
- ],
134
- outputs: [{ name: "", type: "bool" }]
135
- },
136
- {
137
- name: "allowance",
138
- type: "function",
139
- stateMutability: "view",
140
- inputs: [
141
- { name: "owner", type: "address" },
142
- { name: "spender", type: "address" }
143
- ],
144
- outputs: [{ name: "", type: "uint256" }]
145
- }
146
- ];
147
- var viemChains = {
148
- 42161: arbitrum,
149
- 1: mainnet,
150
- 137: polygon
151
- };
152
- var MoneyOS = class {
153
- config;
154
- publicClients = /* @__PURE__ */ new Map();
155
- walletClient;
156
- constructor(config) {
157
- this.config = {
158
- ...config,
159
- chainId: config.chainId ?? defaultChain.id
160
- };
161
- }
162
- getPublicClient(chainId) {
163
- const id = chainId ?? this.config.chainId;
164
- let client = this.publicClients.get(id);
165
- if (!client) {
166
- const chain = viemChains[id];
167
- const chainInfo = getChain(id);
168
- const rpcUrl = id === this.config.chainId ? this.config.rpcUrl : void 0;
169
- client = createPublicClient({
170
- chain,
171
- transport: http(rpcUrl ?? chainInfo?.rpcUrl)
172
- });
173
- this.publicClients.set(id, client);
174
- }
175
- return client;
176
- }
177
- getWalletClient() {
178
- if (!this.walletClient) {
179
- if (!this.config.privateKey) {
180
- throw new Error(
181
- "No private key configured. Set privateKey in MoneyOS config."
182
- );
183
- }
184
- const account = privateKeyToAccount(this.config.privateKey);
185
- const chain = viemChains[this.config.chainId];
186
- const chainInfo = getChain(this.config.chainId);
187
- this.walletClient = createWalletClient({
188
- account,
189
- chain,
190
- transport: http(this.config.rpcUrl ?? chainInfo?.rpcUrl)
191
- });
192
- }
193
- return this.walletClient;
194
- }
195
- get address() {
196
- if (!this.config.privateKey) {
197
- throw new Error("No private key configured.");
198
- }
199
- return privateKeyToAccount(this.config.privateKey).address;
200
- }
201
- async balance(token, options) {
202
- const chainId = options?.chainId ?? this.config.chainId;
203
- const account = options?.address ?? this.address;
204
- const client = this.getPublicClient(chainId);
205
- if (token.toUpperCase() === "ETH") {
206
- const raw2 = await client.getBalance({ address: account });
207
- return {
208
- token: "ETH",
209
- symbol: "ETH",
210
- amount: formatUnits(raw2, 18),
211
- rawAmount: raw2,
212
- decimals: 18,
213
- chainId
214
- };
215
- }
216
- const tokenAddress = getTokenAddress(token, chainId);
217
- if (!tokenAddress) {
218
- throw new Error(`Token ${token} not found on chain ${chainId}`);
219
- }
220
- const tokenInfo = getToken(token);
221
- const raw = await client.readContract({
222
- address: tokenAddress,
223
- abi: ERC20_ABI,
224
- functionName: "balanceOf",
225
- args: [account]
226
- });
227
- return {
228
- token: tokenInfo.name,
229
- symbol: tokenInfo.symbol,
230
- amount: formatUnits(raw, tokenInfo.decimals),
231
- rawAmount: raw,
232
- decimals: tokenInfo.decimals,
233
- chainId
234
- };
235
- }
236
- async send(token, to, amount, options) {
237
- const chainId = options?.chainId ?? this.config.chainId;
238
- const walletClient = this.getWalletClient();
239
- const from = this.address;
240
- if (token.toUpperCase() === "ETH") {
241
- const value2 = parseUnits(amount, 18);
242
- const account = privateKeyToAccount(this.config.privateKey);
243
- const hash2 = await walletClient.sendTransaction({
244
- account,
245
- to,
246
- value: value2,
247
- chain: viemChains[chainId]
248
- });
249
- return { hash: hash2, from, to, amount, token: "ETH", chainId };
250
- }
251
- const tokenAddress = getTokenAddress(token, chainId);
252
- if (!tokenAddress) {
253
- throw new Error(`Token ${token} not found on chain ${chainId}`);
254
- }
255
- const tokenInfo = getToken(token);
256
- const value = parseUnits(amount, tokenInfo.decimals);
257
- const client = this.getPublicClient(chainId);
258
- const { request } = await client.simulateContract({
259
- address: tokenAddress,
260
- abi: ERC20_ABI,
261
- functionName: "transfer",
262
- args: [to, value],
263
- account: privateKeyToAccount(this.config.privateKey)
264
- });
265
- const hash = await walletClient.writeContract(request);
266
- return { hash, from, to, amount, token: tokenInfo.symbol, chainId };
267
- }
268
- async swap(tokenIn, tokenOut, amount, provider, options) {
269
- const chainId = options?.chainId ?? this.config.chainId;
270
- const walletClient = this.getWalletClient();
271
- const client = this.getPublicClient(chainId);
272
- const sender = this.address;
273
- const tokenInAddress = getTokenAddress(tokenIn, chainId);
274
- const tokenOutAddress = getTokenAddress(tokenOut, chainId);
275
- if (!tokenInAddress) {
276
- throw new Error(`Token ${tokenIn} not found on chain ${chainId}`);
277
- }
278
- if (!tokenOutAddress) {
279
- throw new Error(`Token ${tokenOut} not found on chain ${chainId}`);
280
- }
281
- const tokenInInfo = getToken(tokenIn);
282
- const amountWei = parseUnits(amount, tokenInInfo.decimals);
283
- const quote = await provider.getQuote({
284
- chainId,
285
- tokenIn: tokenInAddress,
286
- tokenOut: tokenOutAddress,
287
- amount: amountWei,
288
- sender,
289
- slippage: options?.slippage
290
- });
291
- const calldata = await provider.getCalldata(quote);
292
- const isNativeIn = tokenInAddress === NATIVE_TOKEN_ADDRESS;
293
- if (!isNativeIn) {
294
- const currentAllowance = await client.readContract({
295
- address: tokenInAddress,
296
- abi: ERC20_ABI,
297
- functionName: "allowance",
298
- args: [sender, calldata.to]
299
- });
300
- if (currentAllowance < amountWei) {
301
- const account2 = privateKeyToAccount(this.config.privateKey);
302
- const { request: approveRequest } = await client.simulateContract({
303
- address: tokenInAddress,
304
- abi: ERC20_ABI,
305
- functionName: "approve",
306
- args: [calldata.to, amountWei],
307
- account: account2
308
- });
309
- await walletClient.writeContract(approveRequest);
310
- }
311
- }
312
- const account = privateKeyToAccount(this.config.privateKey);
313
- const hash = await walletClient.sendTransaction({
314
- account,
315
- to: calldata.to,
316
- data: calldata.data,
317
- value: isNativeIn ? amountWei : calldata.value,
318
- chain: viemChains[chainId]
319
- });
320
- const tokenOutInfo = getToken(tokenOut);
321
- return {
322
- hash,
323
- tokenIn: tokenInInfo.symbol,
324
- tokenOut: tokenOutInfo.symbol,
325
- amountIn: amount,
326
- amountOut: formatUnits(BigInt(quote.expectedOut), tokenOutInfo.decimals),
327
- chainId
328
- };
329
- }
330
- };
331
-
332
- // src/providers/odos.ts
333
- var ODOS_API = "https://api.odos.xyz";
334
- var ODOS_NATIVE_ADDRESS = "0x0000000000000000000000000000000000000000";
335
- var OdosProvider = class {
336
- name = "odos";
337
- apiKey;
338
- constructor(options) {
339
- this.apiKey = options?.apiKey;
340
- }
341
- toOdosAddress(address) {
342
- return address === NATIVE_TOKEN_ADDRESS ? ODOS_NATIVE_ADDRESS : address;
343
- }
344
- async getQuote(params) {
345
- const headers = {
346
- "Content-Type": "application/json"
347
- };
348
- if (this.apiKey) {
349
- headers["Authorization"] = `Bearer ${this.apiKey}`;
350
- }
351
- const response = await fetch(`${ODOS_API}/sor/quote/v2`, {
352
- method: "POST",
353
- headers,
354
- body: JSON.stringify({
355
- chainId: params.chainId,
356
- inputTokens: [
357
- {
358
- tokenAddress: this.toOdosAddress(params.tokenIn),
359
- amount: params.amount.toString()
360
- }
361
- ],
362
- outputTokens: [
363
- {
364
- tokenAddress: this.toOdosAddress(params.tokenOut),
365
- proportion: 1
366
- }
367
- ],
368
- userAddr: params.sender,
369
- slippageLimitPercent: params.slippage ?? 1,
370
- referralCode: 0,
371
- compact: true
372
- })
373
- });
374
- if (!response.ok) {
375
- const text = await response.text();
376
- throw new Error(`Odos quote failed: ${response.status} ${text}`);
377
- }
378
- const data = await response.json();
379
- return {
380
- tokenIn: params.tokenIn,
381
- tokenOut: params.tokenOut,
382
- amountIn: params.amount.toString(),
383
- expectedOut: data.outAmounts[0],
384
- router: "",
385
- chainId: params.chainId,
386
- pathId: data.pathId,
387
- sender: params.sender
388
- };
389
- }
390
- async getCalldata(quote) {
391
- const headers = {
392
- "Content-Type": "application/json"
393
- };
394
- if (this.apiKey) {
395
- headers["Authorization"] = `Bearer ${this.apiKey}`;
396
- }
397
- const response = await fetch(`${ODOS_API}/sor/assemble`, {
398
- method: "POST",
399
- headers,
400
- body: JSON.stringify({
401
- userAddr: quote.sender,
402
- pathId: quote.pathId,
403
- simulate: false
404
- })
405
- });
406
- if (!response.ok) {
407
- const text = await response.text();
408
- throw new Error(`Odos assemble failed: ${response.status} ${text}`);
409
- }
410
- const data = await response.json();
411
- return {
412
- to: data.transaction.to,
413
- data: data.transaction.data,
414
- value: BigInt(data.transaction.value)
415
- };
416
- }
417
- };
418
- export {
419
- MoneyOS,
420
- NATIVE_TOKEN_ADDRESS,
421
- OdosProvider,
422
- chains,
423
- defaultChain,
424
- getChain,
425
- getToken,
426
- getTokenAddress,
427
- tokens
428
- };
429
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/client.ts","../src/core/chains.ts","../src/core/tokens.ts","../src/providers/odos.ts"],"sourcesContent":["import {\n createPublicClient,\n createWalletClient,\n http,\n formatUnits,\n parseUnits,\n type Address,\n type Chain as ViemChain,\n type Hex,\n type PublicClient,\n type WalletClient,\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { arbitrum, mainnet, polygon } from \"viem/chains\";\nimport type {\n MoneyOSConfig,\n Balance,\n SendResult,\n SwapProvider,\n SwapResult,\n} from \"./types.js\";\nimport { getChain, defaultChain } from \"./chains.js\";\nimport { getToken, getTokenAddress, NATIVE_TOKEN_ADDRESS } from \"./tokens.js\";\n\nconst ERC20_ABI = [\n {\n name: \"balanceOf\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [{ name: \"account\", type: \"address\" }],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n {\n name: \"transfer\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"decimals\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint8\" }],\n },\n {\n name: \"symbol\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\" }],\n },\n {\n name: \"approve\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"allowance\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n] as const;\n\nconst viemChains: Record<number, ViemChain> = {\n 42161: arbitrum,\n 1: mainnet,\n 137: polygon,\n};\n\nexport class MoneyOS {\n private config: MoneyOSConfig;\n private publicClients: Map<number, PublicClient> = new Map();\n private walletClient: WalletClient | undefined;\n\n constructor(config: MoneyOSConfig) {\n this.config = {\n ...config,\n chainId: config.chainId ?? defaultChain.id,\n };\n }\n\n private getPublicClient(chainId?: number): PublicClient {\n const id = chainId ?? this.config.chainId;\n let client = this.publicClients.get(id);\n if (!client) {\n const chain = viemChains[id];\n const chainInfo = getChain(id);\n const rpcUrl =\n id === this.config.chainId ? this.config.rpcUrl : undefined;\n\n client = createPublicClient({\n chain,\n transport: http(rpcUrl ?? chainInfo?.rpcUrl),\n });\n this.publicClients.set(id, client);\n }\n return client;\n }\n\n private getWalletClient(): WalletClient {\n if (!this.walletClient) {\n if (!this.config.privateKey) {\n throw new Error(\n \"No private key configured. Set privateKey in MoneyOS config.\",\n );\n }\n const account = privateKeyToAccount(this.config.privateKey);\n const chain = viemChains[this.config.chainId];\n const chainInfo = getChain(this.config.chainId);\n this.walletClient = createWalletClient({\n account,\n chain,\n transport: http(this.config.rpcUrl ?? chainInfo?.rpcUrl),\n });\n }\n return this.walletClient;\n }\n\n get address(): Address {\n if (!this.config.privateKey) {\n throw new Error(\"No private key configured.\");\n }\n return privateKeyToAccount(this.config.privateKey).address;\n }\n\n async balance(\n token: string,\n options?: { address?: Address; chainId?: number },\n ): Promise<Balance> {\n const chainId = options?.chainId ?? this.config.chainId;\n const account = options?.address ?? this.address;\n const client = this.getPublicClient(chainId);\n\n if (token.toUpperCase() === \"ETH\") {\n const raw = await client.getBalance({ address: account });\n return {\n token: \"ETH\",\n symbol: \"ETH\",\n amount: formatUnits(raw, 18),\n rawAmount: raw,\n decimals: 18,\n chainId,\n };\n }\n\n const tokenAddress = getTokenAddress(token, chainId);\n if (!tokenAddress) {\n throw new Error(`Token ${token} not found on chain ${chainId}`);\n }\n\n const tokenInfo = getToken(token)!;\n const raw = await client.readContract({\n address: tokenAddress,\n abi: ERC20_ABI,\n functionName: \"balanceOf\",\n args: [account],\n });\n\n return {\n token: tokenInfo.name,\n symbol: tokenInfo.symbol,\n amount: formatUnits(raw, tokenInfo.decimals),\n rawAmount: raw,\n decimals: tokenInfo.decimals,\n chainId,\n };\n }\n\n async send(\n token: string,\n to: Address,\n amount: string,\n options?: { chainId?: number },\n ): Promise<SendResult> {\n const chainId = options?.chainId ?? this.config.chainId;\n const walletClient = this.getWalletClient();\n const from = this.address;\n\n if (token.toUpperCase() === \"ETH\") {\n const value = parseUnits(amount, 18);\n const account = privateKeyToAccount(this.config.privateKey!);\n const hash = await walletClient.sendTransaction({\n account,\n to,\n value,\n chain: viemChains[chainId],\n });\n return { hash, from, to, amount, token: \"ETH\", chainId };\n }\n\n const tokenAddress = getTokenAddress(token, chainId);\n if (!tokenAddress) {\n throw new Error(`Token ${token} not found on chain ${chainId}`);\n }\n\n const tokenInfo = getToken(token)!;\n const value = parseUnits(amount, tokenInfo.decimals);\n const client = this.getPublicClient(chainId);\n\n const { request } = await client.simulateContract({\n address: tokenAddress,\n abi: ERC20_ABI,\n functionName: \"transfer\",\n args: [to, value],\n account: privateKeyToAccount(this.config.privateKey!),\n });\n\n const hash = await walletClient.writeContract(request);\n return { hash, from, to, amount, token: tokenInfo.symbol, chainId };\n }\n\n async swap(\n tokenIn: string,\n tokenOut: string,\n amount: string,\n provider: SwapProvider,\n options?: { chainId?: number; slippage?: number },\n ): Promise<SwapResult> {\n const chainId = options?.chainId ?? this.config.chainId;\n const walletClient = this.getWalletClient();\n const client = this.getPublicClient(chainId);\n const sender = this.address;\n\n const tokenInAddress = getTokenAddress(tokenIn, chainId);\n const tokenOutAddress = getTokenAddress(tokenOut, chainId);\n if (!tokenInAddress) {\n throw new Error(`Token ${tokenIn} not found on chain ${chainId}`);\n }\n if (!tokenOutAddress) {\n throw new Error(`Token ${tokenOut} not found on chain ${chainId}`);\n }\n\n const tokenInInfo = getToken(tokenIn)!;\n const amountWei = parseUnits(amount, tokenInInfo.decimals);\n\n const quote = await provider.getQuote({\n chainId,\n tokenIn: tokenInAddress,\n tokenOut: tokenOutAddress,\n amount: amountWei,\n sender,\n slippage: options?.slippage,\n });\n\n const calldata = await provider.getCalldata(quote);\n\n const isNativeIn = tokenInAddress === NATIVE_TOKEN_ADDRESS;\n\n if (!isNativeIn) {\n const currentAllowance = await client.readContract({\n address: tokenInAddress,\n abi: ERC20_ABI,\n functionName: \"allowance\",\n args: [sender, calldata.to],\n });\n\n if (currentAllowance < amountWei) {\n const account = privateKeyToAccount(this.config.privateKey!);\n const { request: approveRequest } = await client.simulateContract({\n address: tokenInAddress,\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [calldata.to, amountWei],\n account,\n });\n await walletClient.writeContract(approveRequest);\n }\n }\n\n const account = privateKeyToAccount(this.config.privateKey!);\n const hash = await walletClient.sendTransaction({\n account,\n to: calldata.to,\n data: calldata.data,\n value: isNativeIn ? amountWei : calldata.value,\n chain: viemChains[chainId],\n });\n\n const tokenOutInfo = getToken(tokenOut)!;\n return {\n hash,\n tokenIn: tokenInInfo.symbol,\n tokenOut: tokenOutInfo.symbol,\n amountIn: amount,\n amountOut: formatUnits(BigInt(quote.expectedOut), tokenOutInfo.decimals),\n chainId,\n };\n }\n}\n","import type { Chain } from \"./types.js\";\n\nexport const chains: Record<string, Chain> = {\n arbitrum: {\n id: 42161,\n name: \"Arbitrum One\",\n rpcUrl: \"https://arb1.arbitrum.io/rpc\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n blockExplorer: \"https://arbiscan.io\",\n },\n ethereum: {\n id: 1,\n name: \"Ethereum\",\n rpcUrl: \"https://eth.public-rpc.com\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n blockExplorer: \"https://etherscan.io\",\n },\n polygon: {\n id: 137,\n name: \"Polygon\",\n rpcUrl: \"https://polygon-rpc.com\",\n nativeCurrency: { name: \"POL\", symbol: \"POL\", decimals: 18 },\n blockExplorer: \"https://polygonscan.com\",\n },\n};\n\nexport const defaultChain = chains.arbitrum;\n\nexport function getChain(idOrName: number | string): Chain | undefined {\n if (typeof idOrName === \"number\") {\n return Object.values(chains).find((c) => c.id === idOrName);\n }\n return chains[idOrName.toLowerCase()];\n}\n","import type { Address } from \"viem\";\n\nexport interface Token {\n symbol: string;\n name: string;\n decimals: number;\n addresses: Record<number, Address>;\n}\n\nexport const NATIVE_TOKEN_ADDRESS =\n \"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\" as Address;\n\nexport const tokens: Record<string, Token> = {\n ETH: {\n symbol: \"ETH\",\n name: \"Ether\",\n decimals: 18,\n addresses: {\n 42161: NATIVE_TOKEN_ADDRESS,\n 1: NATIVE_TOKEN_ADDRESS,\n 137: NATIVE_TOKEN_ADDRESS,\n },\n },\n USDC: {\n symbol: \"USDC\",\n name: \"USD Coin\",\n decimals: 6,\n addresses: {\n 42161: \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\",\n 1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n 137: \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\",\n },\n },\n USDT: {\n symbol: \"USDT\",\n name: \"Tether USD\",\n decimals: 6,\n addresses: {\n 42161: \"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9\",\n 1: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n 137: \"0xc2132D05D31c914a87C6611C10748AEb04B58e8F\",\n },\n },\n RYZE: {\n symbol: \"RYZE\",\n name: \"RYZE\",\n decimals: 18,\n addresses: {\n 42161: \"0x7712da72127d5dD213B621497D6E4899d5989e5C\",\n },\n },\n};\n\nexport function getToken(symbol: string): Token | undefined {\n return tokens[symbol.toUpperCase()];\n}\n\nexport function getTokenAddress(\n symbol: string,\n chainId: number,\n): Address | undefined {\n return getToken(symbol)?.addresses[chainId];\n}\n","import type { Address, Hex } from \"viem\";\nimport type { SwapProvider, SwapQuote } from \"../core/types.js\";\nimport { NATIVE_TOKEN_ADDRESS } from \"../core/tokens.js\";\n\nconst ODOS_API = \"https://api.odos.xyz\";\nconst ODOS_NATIVE_ADDRESS = \"0x0000000000000000000000000000000000000000\" as Address;\n\ninterface OdosQuoteResponse {\n pathId: string;\n outAmounts: string[];\n outValues: number[];\n}\n\ninterface OdosAssembleResponse {\n transaction: {\n to: string;\n data: string;\n value: string;\n };\n}\n\nexport class OdosProvider implements SwapProvider {\n name = \"odos\";\n private apiKey?: string;\n\n constructor(options?: { apiKey?: string }) {\n this.apiKey = options?.apiKey;\n }\n\n private toOdosAddress(address: Address): Address {\n return address === NATIVE_TOKEN_ADDRESS ? ODOS_NATIVE_ADDRESS : address;\n }\n\n async getQuote(params: {\n chainId: number;\n tokenIn: Address;\n tokenOut: Address;\n amount: bigint;\n sender: Address;\n slippage?: number;\n }): Promise<SwapQuote & { pathId: string; sender: Address }> {\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n if (this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n const response = await fetch(`${ODOS_API}/sor/quote/v2`, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n chainId: params.chainId,\n inputTokens: [\n {\n tokenAddress: this.toOdosAddress(params.tokenIn),\n amount: params.amount.toString(),\n },\n ],\n outputTokens: [\n {\n tokenAddress: this.toOdosAddress(params.tokenOut),\n proportion: 1,\n },\n ],\n userAddr: params.sender,\n slippageLimitPercent: params.slippage ?? 1,\n referralCode: 0,\n compact: true,\n }),\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Odos quote failed: ${response.status} ${text}`);\n }\n\n const data = (await response.json()) as OdosQuoteResponse;\n\n return {\n tokenIn: params.tokenIn,\n tokenOut: params.tokenOut,\n amountIn: params.amount.toString(),\n expectedOut: data.outAmounts[0],\n router: \"\" as Address,\n chainId: params.chainId,\n pathId: data.pathId,\n sender: params.sender,\n };\n }\n\n async getCalldata(\n quote: SwapQuote & { pathId: string; sender: Address },\n ): Promise<{ to: Address; data: Hex; value: bigint }> {\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n if (this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n const response = await fetch(`${ODOS_API}/sor/assemble`, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n userAddr: quote.sender,\n pathId: quote.pathId,\n simulate: false,\n }),\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Odos assemble failed: ${response.status} ${text}`);\n }\n\n const data = (await response.json()) as OdosAssembleResponse;\n\n return {\n to: data.transaction.to as Address,\n data: data.transaction.data as Hex,\n value: BigInt(data.transaction.value),\n };\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,SAAS,2BAA2B;AACpC,SAAS,UAAU,SAAS,eAAe;;;ACXpC,IAAM,SAAgC;AAAA,EAC3C,UAAU;AAAA,IACR,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,gBAAgB,EAAE,MAAM,SAAS,QAAQ,OAAO,UAAU,GAAG;AAAA,IAC7D,eAAe;AAAA,EACjB;AAAA,EACA,UAAU;AAAA,IACR,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,gBAAgB,EAAE,MAAM,SAAS,QAAQ,OAAO,UAAU,GAAG;AAAA,IAC7D,eAAe;AAAA,EACjB;AAAA,EACA,SAAS;AAAA,IACP,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,gBAAgB,EAAE,MAAM,OAAO,QAAQ,OAAO,UAAU,GAAG;AAAA,IAC3D,eAAe;AAAA,EACjB;AACF;AAEO,IAAM,eAAe,OAAO;AAE5B,SAAS,SAAS,UAA8C;AACrE,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO,OAAO,OAAO,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,QAAQ;AAAA,EAC5D;AACA,SAAO,OAAO,SAAS,YAAY,CAAC;AACtC;;;ACxBO,IAAM,uBACX;AAEK,IAAM,SAAgC;AAAA,EAC3C,KAAK;AAAA,IACH,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,MACT,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