moneyos 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/chunk-RDIRDICH.mjs +408 -0
- package/dist/chunk-RDIRDICH.mjs.map +1 -0
- package/dist/cli/index.js +545 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +152 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/index.d.mts +131 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +437 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +21 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MoneyOS,
|
|
3
|
+
OdosProvider,
|
|
4
|
+
getChain
|
|
5
|
+
} from "../chunk-RDIRDICH.mjs";
|
|
6
|
+
|
|
7
|
+
// src/cli/index.ts
|
|
8
|
+
import { Command as Command5 } from "commander";
|
|
9
|
+
|
|
10
|
+
// src/cli/commands/init.ts
|
|
11
|
+
import { Command } from "commander";
|
|
12
|
+
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
13
|
+
|
|
14
|
+
// src/cli/config.ts
|
|
15
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
16
|
+
import { join } from "path";
|
|
17
|
+
import { homedir } from "os";
|
|
18
|
+
var CONFIG_DIR = join(homedir(), ".moneyos");
|
|
19
|
+
var CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
20
|
+
function loadConfig() {
|
|
21
|
+
if (!existsSync(CONFIG_FILE)) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const raw = readFileSync(CONFIG_FILE, "utf-8");
|
|
25
|
+
return JSON.parse(raw);
|
|
26
|
+
}
|
|
27
|
+
function saveConfig(config) {
|
|
28
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
29
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
30
|
+
}
|
|
31
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), {
|
|
32
|
+
mode: 384
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function getConfigPath() {
|
|
36
|
+
return CONFIG_FILE;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/cli/commands/init.ts
|
|
40
|
+
var initCommand = new Command("init").description("Initialize MoneyOS with a new or existing account").option("-k, --key <privateKey>", "Import an existing private key").option("--chain <chainId>", "Default chain ID (default: 42161 Arbitrum)").option("--rpc <url>", "Custom RPC URL").action(async (options) => {
|
|
41
|
+
const existing = loadConfig();
|
|
42
|
+
if (existing.privateKey && !options.key) {
|
|
43
|
+
const account2 = privateKeyToAccount(existing.privateKey);
|
|
44
|
+
console.log(`Already initialized.`);
|
|
45
|
+
console.log(`Address: ${account2.address}`);
|
|
46
|
+
console.log(`Config: ${getConfigPath()}`);
|
|
47
|
+
console.log(`
|
|
48
|
+
To reinitialize, run: moneyos init --key <privateKey>`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const privateKey = options.key ?? generatePrivateKey();
|
|
52
|
+
const account = privateKeyToAccount(privateKey);
|
|
53
|
+
const config = {
|
|
54
|
+
...existing,
|
|
55
|
+
privateKey,
|
|
56
|
+
chainId: options.chain ? parseInt(options.chain) : existing.chainId ?? 42161,
|
|
57
|
+
rpcUrl: options.rpc ?? existing.rpcUrl
|
|
58
|
+
};
|
|
59
|
+
saveConfig(config);
|
|
60
|
+
console.log(`MoneyOS initialized.`);
|
|
61
|
+
console.log(`Address: ${account.address}`);
|
|
62
|
+
console.log(`Config: ${getConfigPath()}`);
|
|
63
|
+
if (!options.key) {
|
|
64
|
+
console.log(`
|
|
65
|
+
This is a new account. Fund it before sending transactions.`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/cli/commands/balance.ts
|
|
70
|
+
import { Command as Command2 } from "commander";
|
|
71
|
+
var balanceCommand = new Command2("balance").description("Check token balance").argument("<token>", "Token symbol (e.g. USDC, ETH, RYZE)").option("-a, --address <address>", "Address to check (defaults to your own)").option("-c, --chain <chainId>", "Chain ID (default: 42161 Arbitrum)").action(async (token, options) => {
|
|
72
|
+
const config = loadConfig();
|
|
73
|
+
const chainId = options.chain ? parseInt(options.chain) : config.chainId;
|
|
74
|
+
const moneyos = new MoneyOS({
|
|
75
|
+
chainId: chainId ?? 42161,
|
|
76
|
+
rpcUrl: config.rpcUrl,
|
|
77
|
+
privateKey: options.address ? void 0 : config.privateKey
|
|
78
|
+
});
|
|
79
|
+
const address = options.address;
|
|
80
|
+
const result = await moneyos.balance(token, {
|
|
81
|
+
address,
|
|
82
|
+
chainId
|
|
83
|
+
});
|
|
84
|
+
console.log(`${result.amount} ${result.symbol}`);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// src/cli/commands/send.ts
|
|
88
|
+
import { Command as Command3 } from "commander";
|
|
89
|
+
var sendCommand = new Command3("send").description("Send tokens to an address").argument("<amount>", "Amount to send (e.g. 10)").argument("<token>", "Token symbol (e.g. USDC, ETH, RYZE)").argument("<to>", "Recipient address").option("-c, --chain <chainId>", "Chain ID (default: 42161 Arbitrum)").action(async (amount, token, to, options) => {
|
|
90
|
+
const config = loadConfig();
|
|
91
|
+
if (!config.privateKey) {
|
|
92
|
+
console.error(
|
|
93
|
+
"No private key configured. Run: moneyos init"
|
|
94
|
+
);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
const chainId = options.chain ? parseInt(options.chain) : config.chainId ?? 42161;
|
|
98
|
+
const moneyos = new MoneyOS({
|
|
99
|
+
chainId,
|
|
100
|
+
rpcUrl: config.rpcUrl,
|
|
101
|
+
privateKey: config.privateKey
|
|
102
|
+
});
|
|
103
|
+
const chain = getChain(chainId);
|
|
104
|
+
console.log(
|
|
105
|
+
`Sending ${amount} ${token.toUpperCase()} to ${to} on ${chain?.name ?? chainId}...`
|
|
106
|
+
);
|
|
107
|
+
const result = await moneyos.send(token, to, amount, {
|
|
108
|
+
chainId
|
|
109
|
+
});
|
|
110
|
+
console.log(`Sent. tx: ${result.hash}`);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// src/cli/commands/swap.ts
|
|
114
|
+
import { Command as Command4 } from "commander";
|
|
115
|
+
var swapCommand = new Command4("swap").description("Swap tokens").argument("<amount>", "Amount to swap (e.g. 100)").argument("<tokenIn>", "Token to sell (e.g. USDC)").argument("<tokenOut>", "Token to buy (e.g. RYZE)").option("-c, --chain <chainId>", "Chain ID (default: 42161 Arbitrum)").option("-s, --slippage <percent>", "Slippage tolerance in percent (default: 1)").action(async (amount, tokenIn, tokenOut, options) => {
|
|
116
|
+
const config = loadConfig();
|
|
117
|
+
if (!config.privateKey) {
|
|
118
|
+
console.error("No private key configured. Run: moneyos init");
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
const chainId = options.chain ? parseInt(options.chain) : config.chainId ?? 42161;
|
|
122
|
+
const moneyos = new MoneyOS({
|
|
123
|
+
chainId,
|
|
124
|
+
rpcUrl: config.rpcUrl,
|
|
125
|
+
privateKey: config.privateKey
|
|
126
|
+
});
|
|
127
|
+
const provider = new OdosProvider();
|
|
128
|
+
const chain = getChain(chainId);
|
|
129
|
+
const slippage = options.slippage ? parseFloat(options.slippage) : void 0;
|
|
130
|
+
console.log(
|
|
131
|
+
`Swapping ${amount} ${tokenIn.toUpperCase()} \u2192 ${tokenOut.toUpperCase()} on ${chain?.name ?? chainId}...`
|
|
132
|
+
);
|
|
133
|
+
const result = await moneyos.swap(tokenIn, tokenOut, amount, provider, {
|
|
134
|
+
chainId,
|
|
135
|
+
slippage
|
|
136
|
+
});
|
|
137
|
+
console.log(`Swapped. Expected: ~${result.amountOut} ${result.tokenOut}`);
|
|
138
|
+
console.log(`tx: ${result.hash}`);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// src/cli/version.ts
|
|
142
|
+
var version = "0.1.0";
|
|
143
|
+
|
|
144
|
+
// src/cli/index.ts
|
|
145
|
+
var program = new Command5();
|
|
146
|
+
program.name("moneyos").description("The operating system for money").version(version);
|
|
147
|
+
program.addCommand(initCommand);
|
|
148
|
+
program.addCommand(balanceCommand);
|
|
149
|
+
program.addCommand(sendCommand);
|
|
150
|
+
program.addCommand(swapCommand);
|
|
151
|
+
program.parse();
|
|
152
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/init.ts","../../src/cli/config.ts","../../src/cli/commands/balance.ts","../../src/cli/commands/send.ts","../../src/cli/commands/swap.ts","../../src/cli/version.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { initCommand } from \"./commands/init.js\";\nimport { balanceCommand } from \"./commands/balance.js\";\nimport { sendCommand } from \"./commands/send.js\";\nimport { swapCommand } from \"./commands/swap.js\";\nimport { version } from \"./version.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"moneyos\")\n .description(\"The operating system for money\")\n .version(version);\n\nprogram.addCommand(initCommand);\nprogram.addCommand(balanceCommand);\nprogram.addCommand(sendCommand);\nprogram.addCommand(swapCommand);\n\nprogram.parse();\n","import { Command } from \"commander\";\nimport { generatePrivateKey, privateKeyToAccount } from \"viem/accounts\";\nimport { loadConfig, saveConfig, getConfigPath } from \"../config.js\";\n\nexport const initCommand = new Command(\"init\")\n .description(\"Initialize MoneyOS with a new or existing account\")\n .option(\"-k, --key <privateKey>\", \"Import an existing private key\")\n .option(\"--chain <chainId>\", \"Default chain ID (default: 42161 Arbitrum)\")\n .option(\"--rpc <url>\", \"Custom RPC URL\")\n .action(async (options) => {\n const existing = loadConfig();\n\n if (existing.privateKey && !options.key) {\n const account = privateKeyToAccount(existing.privateKey);\n console.log(`Already initialized.`);\n console.log(`Address: ${account.address}`);\n console.log(`Config: ${getConfigPath()}`);\n console.log(`\\nTo reinitialize, run: moneyos init --key <privateKey>`);\n return;\n }\n\n const privateKey = options.key ?? generatePrivateKey();\n const account = privateKeyToAccount(privateKey);\n\n const config = {\n ...existing,\n privateKey,\n chainId: options.chain ? parseInt(options.chain) : existing.chainId ?? 42161,\n rpcUrl: options.rpc ?? existing.rpcUrl,\n };\n\n saveConfig(config);\n\n console.log(`MoneyOS initialized.`);\n console.log(`Address: ${account.address}`);\n console.log(`Config: ${getConfigPath()}`);\n\n if (!options.key) {\n console.log(`\\nThis is a new account. Fund it before sending transactions.`);\n }\n });\n","import { readFileSync, writeFileSync, existsSync, mkdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport type { Hex } from \"viem\";\n\nconst CONFIG_DIR = join(homedir(), \".moneyos\");\nconst CONFIG_FILE = join(CONFIG_DIR, \"config.json\");\n\nexport interface CLIConfig {\n chainId?: number;\n rpcUrl?: string;\n privateKey?: Hex;\n}\n\nexport function loadConfig(): CLIConfig {\n if (!existsSync(CONFIG_FILE)) {\n return {};\n }\n const raw = readFileSync(CONFIG_FILE, \"utf-8\");\n return JSON.parse(raw) as CLIConfig;\n}\n\nexport function saveConfig(config: CLIConfig): void {\n if (!existsSync(CONFIG_DIR)) {\n mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });\n }\n writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), {\n mode: 0o600,\n });\n}\n\nexport function getConfigPath(): string {\n return CONFIG_FILE;\n}\n","import { Command } from \"commander\";\nimport { MoneyOS } from \"../../core/client.js\";\nimport { loadConfig } from \"../config.js\";\nimport type { Address } from \"viem\";\n\nexport const balanceCommand = new Command(\"balance\")\n .description(\"Check token balance\")\n .argument(\"<token>\", \"Token symbol (e.g. USDC, ETH, RYZE)\")\n .option(\"-a, --address <address>\", \"Address to check (defaults to your own)\")\n .option(\"-c, --chain <chainId>\", \"Chain ID (default: 42161 Arbitrum)\")\n .action(async (token: string, options) => {\n const config = loadConfig();\n const chainId = options.chain ? parseInt(options.chain) : config.chainId;\n\n const moneyos = new MoneyOS({\n chainId: chainId ?? 42161,\n rpcUrl: config.rpcUrl,\n privateKey: options.address ? undefined : config.privateKey,\n });\n\n const address = options.address as Address | undefined;\n const result = await moneyos.balance(token, {\n address,\n chainId,\n });\n\n console.log(`${result.amount} ${result.symbol}`);\n });\n","import { Command } from \"commander\";\nimport { MoneyOS } from \"../../core/client.js\";\nimport { loadConfig } from \"../config.js\";\nimport { getChain } from \"../../core/chains.js\";\nimport type { Address } from \"viem\";\n\nexport const sendCommand = new Command(\"send\")\n .description(\"Send tokens to an address\")\n .argument(\"<amount>\", \"Amount to send (e.g. 10)\")\n .argument(\"<token>\", \"Token symbol (e.g. USDC, ETH, RYZE)\")\n .argument(\"<to>\", \"Recipient address\")\n .option(\"-c, --chain <chainId>\", \"Chain ID (default: 42161 Arbitrum)\")\n .action(async (amount: string, token: string, to: string, options) => {\n const config = loadConfig();\n\n if (!config.privateKey) {\n console.error(\n \"No private key configured. Run: moneyos init\",\n );\n process.exit(1);\n }\n\n const chainId = options.chain\n ? parseInt(options.chain)\n : config.chainId ?? 42161;\n\n const moneyos = new MoneyOS({\n chainId,\n rpcUrl: config.rpcUrl,\n privateKey: config.privateKey,\n });\n\n const chain = getChain(chainId);\n console.log(\n `Sending ${amount} ${token.toUpperCase()} to ${to} on ${chain?.name ?? chainId}...`,\n );\n\n const result = await moneyos.send(token, to as Address, amount, {\n chainId,\n });\n\n console.log(`Sent. tx: ${result.hash}`);\n });\n","import { Command } from \"commander\";\nimport { MoneyOS } from \"../../core/client.js\";\nimport { OdosProvider } from \"../../providers/odos.js\";\nimport { loadConfig } from \"../config.js\";\nimport { getChain } from \"../../core/chains.js\";\n\nexport const swapCommand = new Command(\"swap\")\n .description(\"Swap tokens\")\n .argument(\"<amount>\", \"Amount to swap (e.g. 100)\")\n .argument(\"<tokenIn>\", \"Token to sell (e.g. USDC)\")\n .argument(\"<tokenOut>\", \"Token to buy (e.g. RYZE)\")\n .option(\"-c, --chain <chainId>\", \"Chain ID (default: 42161 Arbitrum)\")\n .option(\"-s, --slippage <percent>\", \"Slippage tolerance in percent (default: 1)\")\n .action(async (amount: string, tokenIn: string, tokenOut: string, options) => {\n const config = loadConfig();\n\n if (!config.privateKey) {\n console.error(\"No private key configured. Run: moneyos init\");\n process.exit(1);\n }\n\n const chainId = options.chain\n ? parseInt(options.chain)\n : config.chainId ?? 42161;\n\n const moneyos = new MoneyOS({\n chainId,\n rpcUrl: config.rpcUrl,\n privateKey: config.privateKey,\n });\n\n const provider = new OdosProvider();\n const chain = getChain(chainId);\n const slippage = options.slippage ? parseFloat(options.slippage) : undefined;\n\n console.log(\n `Swapping ${amount} ${tokenIn.toUpperCase()} \\u2192 ${tokenOut.toUpperCase()} on ${chain?.name ?? chainId}...`,\n );\n\n const result = await moneyos.swap(tokenIn, tokenOut, amount, provider, {\n chainId,\n slippage,\n });\n\n console.log(`Swapped. Expected: ~${result.amountOut} ${result.tokenOut}`);\n console.log(`tx: ${result.hash}`);\n });\n","export const version = \"0.1.0\";\n"],"mappings":";;;;;;;AAAA,SAAS,WAAAA,gBAAe;;;ACAxB,SAAS,eAAe;AACxB,SAAS,oBAAoB,2BAA2B;;;ACDxD,SAAS,cAAc,eAAe,YAAY,iBAAiB;AACnE,SAAS,YAAY;AACrB,SAAS,eAAe;AAGxB,IAAM,aAAa,KAAK,QAAQ,GAAG,UAAU;AAC7C,IAAM,cAAc,KAAK,YAAY,aAAa;AAQ3C,SAAS,aAAwB;AACtC,MAAI,CAAC,WAAW,WAAW,GAAG;AAC5B,WAAO,CAAC;AAAA,EACV;AACA,QAAM,MAAM,aAAa,aAAa,OAAO;AAC7C,SAAO,KAAK,MAAM,GAAG;AACvB;AAEO,SAAS,WAAW,QAAyB;AAClD,MAAI,CAAC,WAAW,UAAU,GAAG;AAC3B,cAAU,YAAY,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAAA,EACxD;AACA,gBAAc,aAAa,KAAK,UAAU,QAAQ,MAA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AAC9B,QAAQ,WAAW,WAAW;AAE9B,QAAQ,MAAM;","names":["Command","account","Command","Command","Command","Command","Command","Command","Command"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
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 tokens: Record<string, Token>;
|
|
103
|
+
declare function getToken(symbol: string): Token | undefined;
|
|
104
|
+
declare function getTokenAddress(symbol: string, chainId: number): Address | undefined;
|
|
105
|
+
|
|
106
|
+
declare class OdosProvider implements SwapProvider {
|
|
107
|
+
name: string;
|
|
108
|
+
private apiKey?;
|
|
109
|
+
constructor(options?: {
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
});
|
|
112
|
+
getQuote(params: {
|
|
113
|
+
chainId: number;
|
|
114
|
+
tokenIn: Address;
|
|
115
|
+
tokenOut: Address;
|
|
116
|
+
amount: bigint;
|
|
117
|
+
sender: Address;
|
|
118
|
+
slippage?: number;
|
|
119
|
+
}): Promise<SwapQuote & {
|
|
120
|
+
pathId: string;
|
|
121
|
+
}>;
|
|
122
|
+
getCalldata(quote: SwapQuote & {
|
|
123
|
+
pathId: string;
|
|
124
|
+
}): Promise<{
|
|
125
|
+
to: Address;
|
|
126
|
+
data: Hex;
|
|
127
|
+
value: bigint;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { type Balance, type Chain, MoneyOS, type MoneyOSConfig, OdosProvider, type SendResult, type SwapProvider, type SwapQuote, type SwapResult, type Token, chains, defaultChain, getChain, getToken, getTokenAddress, tokens };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
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 tokens: Record<string, Token>;
|
|
103
|
+
declare function getToken(symbol: string): Token | undefined;
|
|
104
|
+
declare function getTokenAddress(symbol: string, chainId: number): Address | undefined;
|
|
105
|
+
|
|
106
|
+
declare class OdosProvider implements SwapProvider {
|
|
107
|
+
name: string;
|
|
108
|
+
private apiKey?;
|
|
109
|
+
constructor(options?: {
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
});
|
|
112
|
+
getQuote(params: {
|
|
113
|
+
chainId: number;
|
|
114
|
+
tokenIn: Address;
|
|
115
|
+
tokenOut: Address;
|
|
116
|
+
amount: bigint;
|
|
117
|
+
sender: Address;
|
|
118
|
+
slippage?: number;
|
|
119
|
+
}): Promise<SwapQuote & {
|
|
120
|
+
pathId: string;
|
|
121
|
+
}>;
|
|
122
|
+
getCalldata(quote: SwapQuote & {
|
|
123
|
+
pathId: string;
|
|
124
|
+
}): Promise<{
|
|
125
|
+
to: Address;
|
|
126
|
+
data: Hex;
|
|
127
|
+
value: bigint;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { type Balance, type Chain, MoneyOS, type MoneyOSConfig, OdosProvider, type SendResult, type SwapProvider, type SwapQuote, type SwapResult, type Token, chains, defaultChain, getChain, getToken, getTokenAddress, tokens };
|