@0xmonaco/core 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/README.md +421 -0
- package/dist/api/auth/api.d.ts +198 -0
- package/dist/api/auth/api.d.ts.map +1 -0
- package/dist/api/auth/api.js +359 -0
- package/dist/api/auth/api.js.map +1 -0
- package/dist/api/auth/index.d.ts +6 -0
- package/dist/api/auth/index.d.ts.map +1 -0
- package/dist/api/auth/index.js +5 -0
- package/dist/api/auth/index.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/trading/api.d.ts +152 -0
- package/dist/api/trading/api.d.ts.map +1 -0
- package/dist/api/trading/api.js +229 -0
- package/dist/api/trading/api.js.map +1 -0
- package/dist/api/trading/index.d.ts +6 -0
- package/dist/api/trading/index.d.ts.map +1 -0
- package/dist/api/trading/index.js +5 -0
- package/dist/api/trading/index.js.map +1 -0
- package/dist/api/vault/api.d.ts +224 -0
- package/dist/api/vault/api.d.ts.map +1 -0
- package/dist/api/vault/api.js +514 -0
- package/dist/api/vault/api.js.map +1 -0
- package/dist/api/vault/index.d.ts +6 -0
- package/dist/api/vault/index.d.ts.map +1 -0
- package/dist/api/vault/index.js +5 -0
- package/dist/api/vault/index.js.map +1 -0
- package/dist/chains.d.ts +90 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +56 -0
- package/dist/chains.js.map +1 -0
- package/dist/errors.d.ts +132 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +165 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/networks.d.ts +8 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +16 -0
- package/dist/networks.js.map +1 -0
- package/dist/sdk.d.ts +76 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +203 -0
- package/dist/sdk.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault API Implementation
|
|
3
|
+
*
|
|
4
|
+
* Handles vault operations including deposits, withdrawals, and ERC20 approvals.
|
|
5
|
+
* Implements the signature flow for deposit/withdraw operations via API Gateway.
|
|
6
|
+
*
|
|
7
|
+
* This class provides a complete interface for interacting with the Monaco vault contract,
|
|
8
|
+
* including token approvals, deposits, withdrawals, and balance queries. All operations
|
|
9
|
+
* use EIP-712 signatures for security and go through the API Gateway for validation.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const vaultAPI = new VaultAPIImpl(
|
|
14
|
+
* publicClient,
|
|
15
|
+
* walletClient,
|
|
16
|
+
* vaultAddress,
|
|
17
|
+
* apiUrl,
|
|
18
|
+
* chain
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* // Check balance
|
|
22
|
+
* const balance = await vaultAPI.getBalance(tokenAddress);
|
|
23
|
+
* console.log(`Balance: ${balance.formatted} ${balance.symbol}`);
|
|
24
|
+
*
|
|
25
|
+
* // Deposit tokens
|
|
26
|
+
* const result = await vaultAPI.deposit(tokenAddress, parseEther("100"));
|
|
27
|
+
* console.log(`Deposit transaction: ${result.hash}`);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
import { erc20Abi, encodeFunctionData, getContract, formatUnits, } from "viem";
|
|
31
|
+
import { ContractError, APIError, TransactionError, InvalidConfigError } from "../../errors";
|
|
32
|
+
import { CONTRACT_ABIS } from "@0xmonaco/contracts";
|
|
33
|
+
export class VaultAPIImpl {
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new VaultAPI instance.
|
|
36
|
+
*
|
|
37
|
+
* @param publicClient - The viem public client for reading blockchain state
|
|
38
|
+
* @param walletClient - The viem wallet client for signing transactions
|
|
39
|
+
* @param vaultAddress - The address of the Monaco vault contract
|
|
40
|
+
* @param apiUrl - The base URL for the Monaco API Gateway
|
|
41
|
+
* @param chain - The blockchain network configuration
|
|
42
|
+
*/
|
|
43
|
+
constructor(publicClient, walletClient, vaultAddress, apiUrl, chain) {
|
|
44
|
+
this.publicClient = publicClient;
|
|
45
|
+
this.walletClient = walletClient;
|
|
46
|
+
this.vaultAddress = vaultAddress;
|
|
47
|
+
this.apiUrl = apiUrl;
|
|
48
|
+
this.chain = chain;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Set the access token for the VaultAPI
|
|
52
|
+
* @param token - The access token to set
|
|
53
|
+
*/
|
|
54
|
+
setAccessToken(token) {
|
|
55
|
+
this.accessToken = token;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Approves the vault contract to spend tokens on behalf of the user.
|
|
59
|
+
*
|
|
60
|
+
* This method creates and sends an ERC20 approve transaction to allow the vault
|
|
61
|
+
* to transfer tokens from the user's wallet. Approval is required before any
|
|
62
|
+
* deposit operations can be performed.
|
|
63
|
+
*
|
|
64
|
+
* @param token - The ERC20 token contract address to approve
|
|
65
|
+
* @param amount - The maximum amount of tokens the vault can spend (as bigint)
|
|
66
|
+
* @returns Promise resolving to TransactionResult with transaction details
|
|
67
|
+
* @throws {ContractError} When approval transaction fails
|
|
68
|
+
* @throws {InvalidConfigError} When wallet account is not available
|
|
69
|
+
* @throws {TransactionError} When transaction signing fails
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Approve vault to spend up to 1000 USDC
|
|
74
|
+
* const result = await vaultAPI.approve(
|
|
75
|
+
* usdcAddress,
|
|
76
|
+
* parseUnits("1000", 6)
|
|
77
|
+
* );
|
|
78
|
+
* console.log(`Approval transaction: ${result.hash}`);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
async approve(token, amount) {
|
|
82
|
+
try {
|
|
83
|
+
const account = this.walletClient.account;
|
|
84
|
+
if (!account) {
|
|
85
|
+
throw new InvalidConfigError("No account available in wallet client", "account");
|
|
86
|
+
}
|
|
87
|
+
// 1) Calldata for approve
|
|
88
|
+
const data = encodeFunctionData({
|
|
89
|
+
abi: erc20Abi,
|
|
90
|
+
functionName: "approve",
|
|
91
|
+
args: [this.vaultAddress, amount],
|
|
92
|
+
});
|
|
93
|
+
// 2) Nonce & gas price
|
|
94
|
+
const [nonce, gasPrice] = await Promise.all([
|
|
95
|
+
this.publicClient.getTransactionCount({ address: account.address }),
|
|
96
|
+
this.publicClient.getGasPrice(),
|
|
97
|
+
]);
|
|
98
|
+
// 3) Gas limit
|
|
99
|
+
const gasLimit = await this.publicClient.estimateGas({
|
|
100
|
+
account: account.address,
|
|
101
|
+
to: token,
|
|
102
|
+
data,
|
|
103
|
+
});
|
|
104
|
+
// 4) Use the most basic raw transaction approach
|
|
105
|
+
const transaction = {
|
|
106
|
+
chainId: this.chain.id,
|
|
107
|
+
nonce,
|
|
108
|
+
gasPrice,
|
|
109
|
+
gas: gasLimit,
|
|
110
|
+
to: token,
|
|
111
|
+
value: 0n,
|
|
112
|
+
data,
|
|
113
|
+
type: 'legacy',
|
|
114
|
+
};
|
|
115
|
+
// 5) Sign transaction with account
|
|
116
|
+
const signature = await account.signTransaction?.(transaction);
|
|
117
|
+
if (!signature) {
|
|
118
|
+
throw new TransactionError("Failed to sign transaction", undefined);
|
|
119
|
+
}
|
|
120
|
+
// 6) Send raw transaction
|
|
121
|
+
const hash = await this.publicClient.sendRawTransaction({
|
|
122
|
+
serializedTransaction: signature,
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
hash,
|
|
126
|
+
status: "pending",
|
|
127
|
+
nonce: BigInt(nonce),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
throw new ContractError(`Failed to approve token ${token}`, error instanceof Error ? error.message : "Unknown error", undefined);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Deposits tokens into the Monaco vault.
|
|
136
|
+
*
|
|
137
|
+
* Deposits the specified amount of tokens into the vault contract. The method
|
|
138
|
+
* first checks if sufficient approval exists, then obtains a signature from the
|
|
139
|
+
* API Gateway, and finally executes the deposit transaction on-chain.
|
|
140
|
+
*
|
|
141
|
+
* Note: This method requires prior approval via the approve() method.
|
|
142
|
+
*
|
|
143
|
+
* @param token - The ERC20 token contract address to deposit
|
|
144
|
+
* @param amount - The amount of tokens to deposit (as bigint)
|
|
145
|
+
* @returns Promise resolving to TransactionResult with transaction details
|
|
146
|
+
* @throws {ContractError} When deposit fails or approval is insufficient
|
|
147
|
+
* @throws {APIError} When signature retrieval fails
|
|
148
|
+
* @throws {InvalidConfigError} When wallet account is not available
|
|
149
|
+
* @throws {TransactionError} When transaction signing fails
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* // Deposit 100 USDC into the vault
|
|
154
|
+
* const result = await vaultAPI.deposit(
|
|
155
|
+
* usdcAddress,
|
|
156
|
+
* parseUnits("100", 6)
|
|
157
|
+
* );
|
|
158
|
+
* console.log(`Deposit transaction: ${result.hash}`);
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
async deposit(token, amount) {
|
|
162
|
+
try {
|
|
163
|
+
// Check if approval is needed before proceeding
|
|
164
|
+
const needsApproval = await this.needsApproval(token, amount);
|
|
165
|
+
if (needsApproval) {
|
|
166
|
+
throw new ContractError(`Approval required before deposit. Please invoke approve() first for token ${token}`, "APPROVAL_REQUIRED", undefined);
|
|
167
|
+
}
|
|
168
|
+
// Get account address
|
|
169
|
+
const [account] = await this.walletClient.getAddresses();
|
|
170
|
+
// Get signature from backend API
|
|
171
|
+
const { seed, signature } = await this.getDepositSignature(token, amount, account);
|
|
172
|
+
// Use the simplified approach: backend provides correct seed format directly
|
|
173
|
+
console.log("Using simplified approach: backend provides correct seed format");
|
|
174
|
+
console.log("Generated seed:", seed);
|
|
175
|
+
console.log("Token address:", token);
|
|
176
|
+
console.log("Vault address:", this.vaultAddress);
|
|
177
|
+
// Use raw transaction approach like we did for approval
|
|
178
|
+
const walletAccount = this.walletClient.account;
|
|
179
|
+
if (!walletAccount) {
|
|
180
|
+
throw new InvalidConfigError("No account available in wallet client", "account");
|
|
181
|
+
}
|
|
182
|
+
// Encode the deposit function call
|
|
183
|
+
const data = encodeFunctionData({
|
|
184
|
+
abi: CONTRACT_ABIS.vault,
|
|
185
|
+
functionName: "deposit",
|
|
186
|
+
args: [token, amount, seed, signature],
|
|
187
|
+
});
|
|
188
|
+
// Get nonce and gas price
|
|
189
|
+
const [nonce, gasPrice] = await Promise.all([
|
|
190
|
+
this.publicClient.getTransactionCount({ address: walletAccount.address }),
|
|
191
|
+
this.publicClient.getGasPrice(),
|
|
192
|
+
]);
|
|
193
|
+
// Estimate gas
|
|
194
|
+
const gasLimit = await this.publicClient.estimateGas({
|
|
195
|
+
account: walletAccount.address,
|
|
196
|
+
to: this.vaultAddress,
|
|
197
|
+
data,
|
|
198
|
+
});
|
|
199
|
+
// Sign transaction
|
|
200
|
+
const signed = await walletAccount.signTransaction?.({
|
|
201
|
+
chain: this.chain,
|
|
202
|
+
nonce,
|
|
203
|
+
gas: gasLimit,
|
|
204
|
+
gasPrice,
|
|
205
|
+
to: this.vaultAddress,
|
|
206
|
+
value: 0n,
|
|
207
|
+
data,
|
|
208
|
+
type: 'legacy',
|
|
209
|
+
});
|
|
210
|
+
if (!signed) {
|
|
211
|
+
throw new TransactionError("Failed to sign transaction", undefined);
|
|
212
|
+
}
|
|
213
|
+
// Send raw transaction
|
|
214
|
+
const hash = await this.publicClient.sendRawTransaction({
|
|
215
|
+
serializedTransaction: signed,
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
hash,
|
|
219
|
+
status: "pending",
|
|
220
|
+
nonce: BigInt(Date.now()),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
throw new ContractError(`Failed to deposit ${amount} of token ${token}`, error instanceof Error ? error.message : "Unknown error", undefined);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Withdraws tokens from the Monaco vault.
|
|
229
|
+
*
|
|
230
|
+
* Withdraws the specified amount of tokens from the vault contract back to the
|
|
231
|
+
* user's wallet. The method obtains a signature from the API Gateway and then
|
|
232
|
+
* executes the withdrawal transaction on-chain.
|
|
233
|
+
*
|
|
234
|
+
* @param token - The ERC20 token contract address to withdraw
|
|
235
|
+
* @param amount - The amount of tokens to withdraw (as bigint)
|
|
236
|
+
* @returns Promise resolving to TransactionResult with transaction details
|
|
237
|
+
* @throws {ContractError} When withdrawal fails
|
|
238
|
+
* @throws {APIError} When signature retrieval fails
|
|
239
|
+
* @throws {InvalidConfigError} When wallet account is not available
|
|
240
|
+
* @throws {TransactionError} When transaction signing fails
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* // Withdraw 50 USDC from the vault
|
|
245
|
+
* const result = await vaultAPI.withdraw(
|
|
246
|
+
* usdcAddress,
|
|
247
|
+
* parseUnits("50", 6)
|
|
248
|
+
* );
|
|
249
|
+
* console.log(`Withdrawal transaction: ${result.hash}`);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
async withdraw(token, amount) {
|
|
253
|
+
try {
|
|
254
|
+
const [account] = await this.walletClient.getAddresses();
|
|
255
|
+
// Get signature from backend API
|
|
256
|
+
const { seed, signature } = await this.getWithdrawSignature(token, amount, account);
|
|
257
|
+
// Use raw transaction approach like we did for deposit
|
|
258
|
+
const walletAccount = this.walletClient.account;
|
|
259
|
+
if (!walletAccount) {
|
|
260
|
+
throw new InvalidConfigError("No account available in wallet client", "account");
|
|
261
|
+
}
|
|
262
|
+
// Encode the withdraw function call
|
|
263
|
+
const data = encodeFunctionData({
|
|
264
|
+
abi: CONTRACT_ABIS.vault,
|
|
265
|
+
functionName: "withdraw",
|
|
266
|
+
args: [token, amount, seed, signature],
|
|
267
|
+
});
|
|
268
|
+
// Get nonce and gas price
|
|
269
|
+
const [nonce, gasPrice] = await Promise.all([
|
|
270
|
+
this.publicClient.getTransactionCount({ address: walletAccount.address }),
|
|
271
|
+
this.publicClient.getGasPrice(),
|
|
272
|
+
]);
|
|
273
|
+
// Estimate gas
|
|
274
|
+
const gasLimit = await this.publicClient.estimateGas({
|
|
275
|
+
account: walletAccount.address,
|
|
276
|
+
to: this.vaultAddress,
|
|
277
|
+
data,
|
|
278
|
+
});
|
|
279
|
+
// Sign transaction
|
|
280
|
+
const signed = await walletAccount.signTransaction?.({
|
|
281
|
+
chain: this.chain,
|
|
282
|
+
nonce,
|
|
283
|
+
gas: gasLimit,
|
|
284
|
+
gasPrice,
|
|
285
|
+
to: this.vaultAddress,
|
|
286
|
+
value: 0n,
|
|
287
|
+
data,
|
|
288
|
+
type: 'legacy',
|
|
289
|
+
});
|
|
290
|
+
if (!signed) {
|
|
291
|
+
throw new TransactionError("Failed to sign transaction", undefined);
|
|
292
|
+
}
|
|
293
|
+
// Send raw transaction
|
|
294
|
+
const hash = await this.publicClient.sendRawTransaction({
|
|
295
|
+
serializedTransaction: signed,
|
|
296
|
+
});
|
|
297
|
+
return {
|
|
298
|
+
hash,
|
|
299
|
+
status: "pending",
|
|
300
|
+
nonce: BigInt(nonce),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
throw new ContractError(`Failed to withdraw ${amount} of token ${token}`, error instanceof Error ? error.message : "Unknown error", undefined);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Retrieves the user's token balance in the vault.
|
|
309
|
+
*
|
|
310
|
+
* Queries the vault contract to get the current balance of a specific token
|
|
311
|
+
* for the connected wallet. Returns both raw amount and formatted display values.
|
|
312
|
+
*
|
|
313
|
+
* @param token - The ERC20 token contract address to check balance for
|
|
314
|
+
* @returns Promise resolving to Balance with token balance details
|
|
315
|
+
* @throws {ContractError} When balance retrieval fails
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* const balance = await vaultAPI.getBalance(usdcAddress);
|
|
320
|
+
* console.log(`Vault balance: ${balance.formatted} ${balance.symbol}`);
|
|
321
|
+
* console.log(`Raw amount: ${balance.amount}`);
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
async getBalance(token) {
|
|
325
|
+
try {
|
|
326
|
+
const [account] = await this.walletClient.getAddresses();
|
|
327
|
+
// Get balance from vault contract
|
|
328
|
+
const balance = await this.publicClient.readContract({
|
|
329
|
+
address: this.vaultAddress,
|
|
330
|
+
abi: CONTRACT_ABIS.vault,
|
|
331
|
+
functionName: "balanceOf",
|
|
332
|
+
args: [account, token],
|
|
333
|
+
});
|
|
334
|
+
// Get token metadata
|
|
335
|
+
const tokenContract = getContract({
|
|
336
|
+
address: token,
|
|
337
|
+
abi: erc20Abi,
|
|
338
|
+
client: this.publicClient,
|
|
339
|
+
});
|
|
340
|
+
const [symbol, decimals] = await Promise.all([
|
|
341
|
+
tokenContract.read.symbol(),
|
|
342
|
+
tokenContract.read.decimals(),
|
|
343
|
+
]);
|
|
344
|
+
return {
|
|
345
|
+
token,
|
|
346
|
+
amount: balance,
|
|
347
|
+
formatted: formatUnits(balance, decimals),
|
|
348
|
+
symbol: symbol,
|
|
349
|
+
decimals: decimals,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
throw new ContractError(`Failed to get balance for token ${token}`, error instanceof Error ? error.message : "Unknown error", undefined);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Retrieves the current allowance for a token.
|
|
358
|
+
*
|
|
359
|
+
* Queries the ERC20 token contract to get the current allowance granted to the
|
|
360
|
+
* vault contract for spending tokens on behalf of the user.
|
|
361
|
+
*
|
|
362
|
+
* @param token - The ERC20 token contract address to check allowance for
|
|
363
|
+
* @returns Promise resolving to the current allowance amount as bigint
|
|
364
|
+
* @throws {ContractError} When allowance retrieval fails
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const allowance = await vaultAPI.getAllowance(usdcAddress);
|
|
369
|
+
* console.log(`Current allowance: ${formatUnits(allowance, 6)} USDC`);
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
async getAllowance(token) {
|
|
373
|
+
try {
|
|
374
|
+
const [account] = await this.walletClient.getAddresses();
|
|
375
|
+
const allowance = await this.publicClient.readContract({
|
|
376
|
+
address: token,
|
|
377
|
+
abi: erc20Abi,
|
|
378
|
+
functionName: "allowance",
|
|
379
|
+
args: [account, this.vaultAddress],
|
|
380
|
+
});
|
|
381
|
+
return allowance;
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
throw new ContractError(`Failed to get allowance for token ${token}`, error instanceof Error ? error.message : "Unknown error", undefined);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Checks if approval is needed for a specific amount.
|
|
389
|
+
*
|
|
390
|
+
* Compares the current allowance with the requested amount to determine if
|
|
391
|
+
* the user needs to approve more tokens before performing operations.
|
|
392
|
+
*
|
|
393
|
+
* @param token - The ERC20 token contract address to check
|
|
394
|
+
* @param amount - The amount to check approval for (as bigint)
|
|
395
|
+
* @returns Promise resolving to true if approval is needed, false otherwise
|
|
396
|
+
* @throws {ContractError} When approval check fails
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* const needsApproval = await vaultAPI.needsApproval(
|
|
401
|
+
* usdcAddress,
|
|
402
|
+
* parseUnits("100", 6)
|
|
403
|
+
* );
|
|
404
|
+
*
|
|
405
|
+
* if (needsApproval) {
|
|
406
|
+
* console.log("Approval required before deposit");
|
|
407
|
+
* await vaultAPI.approve(usdcAddress, parseUnits("100", 6));
|
|
408
|
+
* }
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
async needsApproval(token, amount) {
|
|
412
|
+
try {
|
|
413
|
+
const allowance = await this.getAllowance(token);
|
|
414
|
+
return allowance < amount;
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
throw new ContractError(`Failed to check approval for token ${token}`, error instanceof Error ? error.message : "Unknown error", undefined);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Retrieves a deposit signature from the API Gateway.
|
|
422
|
+
*
|
|
423
|
+
* Internal method that communicates with the Monaco API Gateway to obtain
|
|
424
|
+
* the cryptographic signature required for deposit transactions. The signature
|
|
425
|
+
* validates the deposit request and ensures proper authorization.
|
|
426
|
+
*
|
|
427
|
+
* @param token - The ERC20 token contract address
|
|
428
|
+
* @param amount - The amount to deposit (as bigint)
|
|
429
|
+
* @param userAddress - The user's wallet address
|
|
430
|
+
* @returns Promise resolving to object containing seed and signature
|
|
431
|
+
* @throws {APIError} When signature retrieval fails
|
|
432
|
+
* @private
|
|
433
|
+
*/
|
|
434
|
+
async getDepositSignature(token, amount, userAddress) {
|
|
435
|
+
try {
|
|
436
|
+
// Generate a unique nonce and expiry for this transaction
|
|
437
|
+
const nonce = Math.floor(Date.now() / 1000); // Current timestamp as nonce
|
|
438
|
+
const expiry = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
|
|
439
|
+
const response = await fetch(`${this.apiUrl}/api/v1/deposit/signature`, {
|
|
440
|
+
method: "POST",
|
|
441
|
+
headers: {
|
|
442
|
+
"Content-Type": "application/json",
|
|
443
|
+
"Authorization": `Bearer ${this.accessToken}`,
|
|
444
|
+
},
|
|
445
|
+
body: JSON.stringify({
|
|
446
|
+
contract_address: this.vaultAddress, // Use vault address for seed validation
|
|
447
|
+
token_address: token, // Include token address separately
|
|
448
|
+
chain_id: this.chain.id,
|
|
449
|
+
amount: amount.toString(),
|
|
450
|
+
user_address: userAddress,
|
|
451
|
+
nonce,
|
|
452
|
+
expiry,
|
|
453
|
+
}),
|
|
454
|
+
});
|
|
455
|
+
if (!response.ok) {
|
|
456
|
+
throw new APIError(`API request failed: ${response.status}`, `${this.apiUrl}/api/v1/deposit/signature`, response.status);
|
|
457
|
+
}
|
|
458
|
+
const data = await response.json();
|
|
459
|
+
return {
|
|
460
|
+
seed: data.seed,
|
|
461
|
+
signature: data.signature,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
throw new APIError("Failed to get deposit signature from API", `${this.apiUrl}/api/v1/deposit/signature`, undefined);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Retrieves a withdrawal signature from the API Gateway.
|
|
470
|
+
*
|
|
471
|
+
* Internal method that communicates with the Monaco API Gateway to obtain
|
|
472
|
+
* the cryptographic signature required for withdrawal transactions. The signature
|
|
473
|
+
* validates the withdrawal request and ensures proper authorization.
|
|
474
|
+
*
|
|
475
|
+
* @param token - The ERC20 token contract address
|
|
476
|
+
* @param amount - The amount to withdraw (as bigint)
|
|
477
|
+
* @param userAddress - The user's wallet address
|
|
478
|
+
* @returns Promise resolving to object containing seed and signature
|
|
479
|
+
* @throws {APIError} When signature retrieval fails
|
|
480
|
+
* @private
|
|
481
|
+
*/
|
|
482
|
+
async getWithdrawSignature(token, amount, userAddress) {
|
|
483
|
+
try {
|
|
484
|
+
const response = await fetch(`${this.apiUrl}/api/v1/withdraw/signature`, {
|
|
485
|
+
method: "POST",
|
|
486
|
+
headers: {
|
|
487
|
+
"Content-Type": "application/json",
|
|
488
|
+
"Authorization": `Bearer ${this.accessToken}`,
|
|
489
|
+
},
|
|
490
|
+
body: JSON.stringify({
|
|
491
|
+
contract_address: this.vaultAddress, // Use vault address for seed validation
|
|
492
|
+
token_address: token, // Include token address separately
|
|
493
|
+
chain_id: this.chain.id,
|
|
494
|
+
amount: amount.toString(),
|
|
495
|
+
user_address: userAddress,
|
|
496
|
+
nonce: Math.floor(Date.now() / 1000),
|
|
497
|
+
expiry: Math.floor(Date.now() / 1000) + 3600,
|
|
498
|
+
}),
|
|
499
|
+
});
|
|
500
|
+
if (!response.ok) {
|
|
501
|
+
throw new APIError(`API request failed: ${response.status}`, `${this.apiUrl}/api/v1/withdraw/signature`, response.status);
|
|
502
|
+
}
|
|
503
|
+
const data = await response.json();
|
|
504
|
+
return {
|
|
505
|
+
seed: data.seed,
|
|
506
|
+
signature: data.signature,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
throw new APIError("Failed to get withdraw signature from API", `${this.apiUrl}/api/v1/withdraw/signature`, undefined);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/api/vault/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAML,QAAQ,EACR,kBAAkB,EAClB,WAAW,EACX,WAAW,GACZ,MAAM,MAAM,CAAC;AAMd,OAAO,EACL,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,OAAO,YAAY;IAGvB;;;;;;;;OAQG;IACH,YACmB,YAA0B,EAC1B,YAA0B,EAC1B,YAAqB,EACrB,MAAc,EACd,KAAY;QAJZ,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAAS;QACrB,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAO;IAC5B,CAAC;IAGJ;;;OAGG;IACH,cAAc,CAAC,KAAa;QAC1B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;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,EAAE,IAAI,CAAC,SAAS;aAC1B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,QAAQ,CAChB,2CAA2C,EAC3C,GAAG,IAAI,CAAC,MAAM,4BAA4B,EAC1C,SAAS,CACV,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/vault/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/vault/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines supported chains using viem's Chain type.
|
|
5
|
+
*/
|
|
6
|
+
export declare const seiMainnet: {
|
|
7
|
+
blockExplorers: {
|
|
8
|
+
readonly default: {
|
|
9
|
+
readonly name: "Seiscan";
|
|
10
|
+
readonly url: "https://seiscan.io";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
blockTime?: number | undefined | undefined;
|
|
14
|
+
contracts?: {
|
|
15
|
+
[x: string]: import("viem").ChainContract | {
|
|
16
|
+
[sourceId: number]: import("viem").ChainContract | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
ensRegistry?: import("viem").ChainContract | undefined;
|
|
19
|
+
ensUniversalResolver?: import("viem").ChainContract | undefined;
|
|
20
|
+
multicall3?: import("viem").ChainContract | undefined;
|
|
21
|
+
universalSignatureVerifier?: import("viem").ChainContract | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
ensTlds?: readonly string[] | undefined;
|
|
24
|
+
id: 1329;
|
|
25
|
+
name: "Sei Mainnet";
|
|
26
|
+
nativeCurrency: {
|
|
27
|
+
readonly name: "Sei";
|
|
28
|
+
readonly symbol: "SEI";
|
|
29
|
+
readonly decimals: 18;
|
|
30
|
+
};
|
|
31
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
32
|
+
rpcUrls: {
|
|
33
|
+
readonly default: {
|
|
34
|
+
readonly http: readonly ["https://evm-rpc.sei-apis.com"];
|
|
35
|
+
};
|
|
36
|
+
readonly public: {
|
|
37
|
+
readonly http: readonly ["https://evm-rpc.sei-apis.com"];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
sourceId?: number | undefined | undefined;
|
|
41
|
+
testnet?: boolean | undefined | undefined;
|
|
42
|
+
custom?: Record<string, unknown> | undefined;
|
|
43
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
44
|
+
formatters?: undefined;
|
|
45
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
46
|
+
readonly network: "sei-mainnet";
|
|
47
|
+
};
|
|
48
|
+
export declare const seiTestnet: {
|
|
49
|
+
blockExplorers: {
|
|
50
|
+
readonly default: {
|
|
51
|
+
readonly name: "Seiscan";
|
|
52
|
+
readonly url: "https://testnet.seiscan.io";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
blockTime?: number | undefined | undefined;
|
|
56
|
+
contracts?: {
|
|
57
|
+
[x: string]: import("viem").ChainContract | {
|
|
58
|
+
[sourceId: number]: import("viem").ChainContract | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
ensRegistry?: import("viem").ChainContract | undefined;
|
|
61
|
+
ensUniversalResolver?: import("viem").ChainContract | undefined;
|
|
62
|
+
multicall3?: import("viem").ChainContract | undefined;
|
|
63
|
+
universalSignatureVerifier?: import("viem").ChainContract | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
ensTlds?: readonly string[] | undefined;
|
|
66
|
+
id: 1328;
|
|
67
|
+
name: "Sei Testnet";
|
|
68
|
+
nativeCurrency: {
|
|
69
|
+
readonly name: "Sei";
|
|
70
|
+
readonly symbol: "SEI";
|
|
71
|
+
readonly decimals: 18;
|
|
72
|
+
};
|
|
73
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
74
|
+
rpcUrls: {
|
|
75
|
+
readonly default: {
|
|
76
|
+
readonly http: readonly ["https://evm-rpc-testnet.sei-apis.com"];
|
|
77
|
+
};
|
|
78
|
+
readonly public: {
|
|
79
|
+
readonly http: readonly ["https://evm-rpc-testnet.sei-apis.com"];
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
sourceId?: number | undefined | undefined;
|
|
83
|
+
testnet: true;
|
|
84
|
+
custom?: Record<string, unknown> | undefined;
|
|
85
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
86
|
+
formatters?: undefined;
|
|
87
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
88
|
+
readonly network: "sei-testnet";
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBrB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBrB,CAAC"}
|