@ember-finance/sdk 1.2.3 → 1.3.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/dist/src/abis/EmberETHVault.json +2985 -0
- package/dist/src/abis/index.d.ts +9 -0
- package/dist/src/abis/index.js +22 -0
- package/dist/src/evm-vaults/interfaces/index.d.ts +11 -0
- package/dist/src/evm-vaults/on-chain-calls/operator.d.ts +4 -4
- package/dist/src/evm-vaults/on-chain-calls/operator.js +8 -8
- package/dist/src/evm-vaults/on-chain-calls/tx-builder.d.ts +56 -11
- package/dist/src/evm-vaults/on-chain-calls/tx-builder.js +93 -21
- package/dist/src/evm-vaults/on-chain-calls/user.d.ts +56 -7
- package/dist/src/evm-vaults/on-chain-calls/user.js +76 -14
- package/dist/src/evm-vaults/on-chain-calls/vault-reader.d.ts +62 -30
- package/dist/src/evm-vaults/on-chain-calls/vault-reader.js +103 -69
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import EmberVaultABI from "./EmberVault.json";
|
|
2
|
+
import EmberProtocolConfigABI from "./EmberProtocolConfig.json";
|
|
3
|
+
import ERC20TokenABI from "./ERC20Token.json";
|
|
4
|
+
import { Interface } from "ethers";
|
|
5
|
+
declare const EmberVault: Interface;
|
|
6
|
+
declare const EmberProtocolConfig: Interface;
|
|
7
|
+
declare const ERC20Token: Interface;
|
|
8
|
+
declare const EmberETHVault: Interface;
|
|
9
|
+
export { EmberVaultABI, EmberProtocolConfigABI, ERC20TokenABI, EmberVault, EmberProtocolConfig, ERC20Token, EmberETHVault };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EmberETHVault = exports.ERC20Token = exports.EmberProtocolConfig = exports.EmberVault = exports.ERC20TokenABI = exports.EmberProtocolConfigABI = exports.EmberVaultABI = void 0;
|
|
7
|
+
const EmberVault_json_1 = __importDefault(require("./EmberVault.json"));
|
|
8
|
+
exports.EmberVaultABI = EmberVault_json_1.default;
|
|
9
|
+
const EmberProtocolConfig_json_1 = __importDefault(require("./EmberProtocolConfig.json"));
|
|
10
|
+
exports.EmberProtocolConfigABI = EmberProtocolConfig_json_1.default;
|
|
11
|
+
const ERC20Token_json_1 = __importDefault(require("./ERC20Token.json"));
|
|
12
|
+
exports.ERC20TokenABI = ERC20Token_json_1.default;
|
|
13
|
+
const EmberETHVault_json_1 = __importDefault(require("./EmberETHVault.json"));
|
|
14
|
+
const ethers_1 = require("ethers");
|
|
15
|
+
const EmberVault = new ethers_1.Interface(EmberVault_json_1.default.abi);
|
|
16
|
+
exports.EmberVault = EmberVault;
|
|
17
|
+
const EmberProtocolConfig = new ethers_1.Interface(EmberProtocolConfig_json_1.default.abi);
|
|
18
|
+
exports.EmberProtocolConfig = EmberProtocolConfig;
|
|
19
|
+
const ERC20Token = new ethers_1.Interface(ERC20Token_json_1.default.abi);
|
|
20
|
+
exports.ERC20Token = ERC20Token;
|
|
21
|
+
const EmberETHVault = new ethers_1.Interface(EmberETHVault_json_1.default.abi);
|
|
22
|
+
exports.EmberETHVault = EmberETHVault;
|
|
@@ -85,6 +85,15 @@ export interface IEncodedTransaction {
|
|
|
85
85
|
* Vault pause operation types for EVM
|
|
86
86
|
*/
|
|
87
87
|
export type VaultPauseOperation = "deposits" | "withdrawals" | "privilegedOperations";
|
|
88
|
+
/**
|
|
89
|
+
* Options for ETH deposit/mint operations
|
|
90
|
+
*/
|
|
91
|
+
export interface IETHDepositOptions extends IEvmCallOptions {
|
|
92
|
+
/** Receiver address for shares. Defaults to the caller's address if not provided */
|
|
93
|
+
receiver?: string;
|
|
94
|
+
/** Amount of ETH to send (in wei) */
|
|
95
|
+
value: bigint;
|
|
96
|
+
}
|
|
88
97
|
/**
|
|
89
98
|
* Represents a transaction call that can be encoded by ethers.js
|
|
90
99
|
*/
|
|
@@ -116,6 +125,8 @@ export interface IEvmCallOptions {
|
|
|
116
125
|
confirmations?: number;
|
|
117
126
|
/** Gas limit override */
|
|
118
127
|
gasLimit?: bigint;
|
|
128
|
+
/** If true, uses EmberETHVault ABI instead of EmberVault ABI */
|
|
129
|
+
isETHVault?: boolean;
|
|
119
130
|
}
|
|
120
131
|
/**
|
|
121
132
|
* Optional parameters for user deposit/mint/redeem calls
|
|
@@ -40,7 +40,7 @@ export declare class EVMOperatorCalls extends EVMOnChainCalls {
|
|
|
40
40
|
* Note: This requires the rate manager role, which may or may not be the operator
|
|
41
41
|
* @param vaultAddress The address of the vault
|
|
42
42
|
* @param rate The new rate to set for the vault
|
|
43
|
-
* @param options Optional tx execution params
|
|
43
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
44
44
|
* @returns EvmOnChainCallResponse
|
|
45
45
|
*/
|
|
46
46
|
updateVaultRate(vaultAddress: string, rate: NumStr, options?: IEvmCallOptions): Promise<EvmOnChainCallResponse>;
|
|
@@ -48,14 +48,14 @@ export declare class EVMOperatorCalls extends EVMOnChainCalls {
|
|
|
48
48
|
* Process withdrawal requests up to a maximum count
|
|
49
49
|
* @param vaultAddress The address of the vault
|
|
50
50
|
* @param maxRequestCount The maximum number of withdrawal requests to process
|
|
51
|
-
* @param options Optional tx execution params
|
|
51
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
52
52
|
* @returns EvmOnChainCallResponse
|
|
53
53
|
*/
|
|
54
54
|
processWithdrawalRequests(vaultAddress: string, maxRequestCount: NumStr, options?: IEvmCallOptions): Promise<EvmOnChainCallResponse>;
|
|
55
55
|
/**
|
|
56
56
|
* Collect accrued platform fees from a vault
|
|
57
57
|
* @param vaultAddress The address of the vault
|
|
58
|
-
* @param options Optional tx execution params
|
|
58
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
59
59
|
* @returns EvmOnChainCallResponse
|
|
60
60
|
*/
|
|
61
61
|
collectPlatformFee(vaultAddress: string, options?: IEvmCallOptions): Promise<EvmOnChainCallResponse>;
|
|
@@ -65,7 +65,7 @@ export declare class EVMOperatorCalls extends EVMOnChainCalls {
|
|
|
65
65
|
* @param vaultAddress The address of the vault
|
|
66
66
|
* @param subAccount The sub-account address to withdraw to
|
|
67
67
|
* @param amount The amount to withdraw
|
|
68
|
-
* @param options Optional tx execution params
|
|
68
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
69
69
|
* @returns EvmOnChainCallResponse
|
|
70
70
|
*/
|
|
71
71
|
withdrawFromVaultWithoutRedeemingShares(vaultAddress: string, subAccount: string, amount: NumStr, options?: IEvmCallOptions): Promise<EvmOnChainCallResponse>;
|
|
@@ -45,11 +45,11 @@ class EVMOperatorCalls extends onchain_calls_1.EVMOnChainCalls {
|
|
|
45
45
|
* Note: This requires the rate manager role, which may or may not be the operator
|
|
46
46
|
* @param vaultAddress The address of the vault
|
|
47
47
|
* @param rate The new rate to set for the vault
|
|
48
|
-
* @param options Optional tx execution params
|
|
48
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
49
49
|
* @returns EvmOnChainCallResponse
|
|
50
50
|
*/
|
|
51
51
|
async updateVaultRate(vaultAddress, rate, options) {
|
|
52
|
-
const txCall = this.txBuilder.updateVaultRate(vaultAddress, rate);
|
|
52
|
+
const txCall = this.txBuilder.updateVaultRate(vaultAddress, rate, options?.isETHVault);
|
|
53
53
|
return this.execCall(txCall, options);
|
|
54
54
|
}
|
|
55
55
|
// ============================================
|
|
@@ -59,11 +59,11 @@ class EVMOperatorCalls extends onchain_calls_1.EVMOnChainCalls {
|
|
|
59
59
|
* Process withdrawal requests up to a maximum count
|
|
60
60
|
* @param vaultAddress The address of the vault
|
|
61
61
|
* @param maxRequestCount The maximum number of withdrawal requests to process
|
|
62
|
-
* @param options Optional tx execution params
|
|
62
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
63
63
|
* @returns EvmOnChainCallResponse
|
|
64
64
|
*/
|
|
65
65
|
async processWithdrawalRequests(vaultAddress, maxRequestCount, options) {
|
|
66
|
-
const txCall = this.txBuilder.processWithdrawalRequests(vaultAddress, maxRequestCount);
|
|
66
|
+
const txCall = this.txBuilder.processWithdrawalRequests(vaultAddress, maxRequestCount, options?.isETHVault);
|
|
67
67
|
return this.execCall(txCall, options);
|
|
68
68
|
}
|
|
69
69
|
// ============================================
|
|
@@ -72,11 +72,11 @@ class EVMOperatorCalls extends onchain_calls_1.EVMOnChainCalls {
|
|
|
72
72
|
/**
|
|
73
73
|
* Collect accrued platform fees from a vault
|
|
74
74
|
* @param vaultAddress The address of the vault
|
|
75
|
-
* @param options Optional tx execution params
|
|
75
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
76
76
|
* @returns EvmOnChainCallResponse
|
|
77
77
|
*/
|
|
78
78
|
async collectPlatformFee(vaultAddress, options) {
|
|
79
|
-
const txCall = this.txBuilder.collectPlatformFee(vaultAddress);
|
|
79
|
+
const txCall = this.txBuilder.collectPlatformFee(vaultAddress, options?.isETHVault);
|
|
80
80
|
return this.execCall(txCall, options);
|
|
81
81
|
}
|
|
82
82
|
// ============================================
|
|
@@ -88,11 +88,11 @@ class EVMOperatorCalls extends onchain_calls_1.EVMOnChainCalls {
|
|
|
88
88
|
* @param vaultAddress The address of the vault
|
|
89
89
|
* @param subAccount The sub-account address to withdraw to
|
|
90
90
|
* @param amount The amount to withdraw
|
|
91
|
-
* @param options Optional tx execution params
|
|
91
|
+
* @param options Optional tx execution params (includes isETHVault flag)
|
|
92
92
|
* @returns EvmOnChainCallResponse
|
|
93
93
|
*/
|
|
94
94
|
async withdrawFromVaultWithoutRedeemingShares(vaultAddress, subAccount, amount, options) {
|
|
95
|
-
const txCall = this.txBuilder.withdrawFromVaultWithoutRedeemingShares(vaultAddress, subAccount, amount);
|
|
95
|
+
const txCall = this.txBuilder.withdrawFromVaultWithoutRedeemingShares(vaultAddress, subAccount, amount, options?.isETHVault);
|
|
96
96
|
return this.execCall(txCall, options);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -8,14 +8,22 @@ import { NumStr } from "../../common/types";
|
|
|
8
8
|
* on EVM-compatible chains. The vault contracts now implement ERC-4626 standard
|
|
9
9
|
* and are themselves ERC20 tokens representing shares.
|
|
10
10
|
*
|
|
11
|
+
* For ETH vaults (EmberETHVault), pass `isETHVault: true` to vault methods
|
|
12
|
+
* to use the correct ABI.
|
|
13
|
+
*
|
|
11
14
|
* @example
|
|
12
15
|
* ```typescript
|
|
13
16
|
* import { EVMTxBuilder } from "@ember-finance/sdk";
|
|
14
17
|
* import { encodeFunctionData } from "viem";
|
|
15
18
|
*
|
|
16
19
|
* const txBuilder = new EVMTxBuilder(deployment);
|
|
20
|
+
*
|
|
21
|
+
* // Standard ERC20 vault
|
|
17
22
|
* const txCall = txBuilder.deposit(vaultAddress, amount, receiver);
|
|
18
23
|
*
|
|
24
|
+
* // ETH vault - pass isETHVault flag
|
|
25
|
+
* const ethTxCall = txBuilder.deposit(vaultAddress, amount, receiver, true);
|
|
26
|
+
*
|
|
19
27
|
* // Encode with viem
|
|
20
28
|
* const data = encodeFunctionData({
|
|
21
29
|
* abi: txCall.abi,
|
|
@@ -40,6 +48,12 @@ export declare class EVMTxBuilder {
|
|
|
40
48
|
* Gets the chain ID from the deployment
|
|
41
49
|
*/
|
|
42
50
|
getChainId(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the appropriate vault ABI based on vault type
|
|
53
|
+
* @param isETHVault If true, returns EmberETHVault ABI; otherwise EmberVault ABI
|
|
54
|
+
* @returns The vault ABI array
|
|
55
|
+
*/
|
|
56
|
+
private getVaultAbiForType;
|
|
43
57
|
/**
|
|
44
58
|
* Pauses or unpauses non-admin operations at the protocol level
|
|
45
59
|
* @param pause True to pause, false to unpause
|
|
@@ -171,80 +185,107 @@ export declare class EVMTxBuilder {
|
|
|
171
185
|
* Updates the rate of a vault (rate manager only)
|
|
172
186
|
* @param vaultAddress Address of the vault
|
|
173
187
|
* @param newRate New rate value
|
|
188
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
174
189
|
* @returns Transaction call object
|
|
175
190
|
*/
|
|
176
|
-
updateVaultRate(vaultAddress: string, newRate: NumStr): ITransactionCall;
|
|
191
|
+
updateVaultRate(vaultAddress: string, newRate: NumStr, isETHVault?: boolean): ITransactionCall;
|
|
177
192
|
/**
|
|
178
193
|
* Processes a specified number of withdrawal requests (operator only)
|
|
179
194
|
* @param vaultAddress Address of the vault
|
|
180
195
|
* @param numRequests Maximum number of requests to process
|
|
196
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
181
197
|
* @returns Transaction call object
|
|
182
198
|
*/
|
|
183
|
-
processWithdrawalRequests(vaultAddress: string, numRequests: NumStr): ITransactionCall;
|
|
199
|
+
processWithdrawalRequests(vaultAddress: string, numRequests: NumStr, isETHVault?: boolean): ITransactionCall;
|
|
184
200
|
/**
|
|
185
201
|
* Collects accrued platform fees (operator only)
|
|
186
202
|
* @param vaultAddress Address of the vault
|
|
203
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
187
204
|
* @returns Transaction call object
|
|
188
205
|
*/
|
|
189
|
-
collectPlatformFee(vaultAddress: string): ITransactionCall;
|
|
206
|
+
collectPlatformFee(vaultAddress: string, isETHVault?: boolean): ITransactionCall;
|
|
190
207
|
/**
|
|
191
208
|
* Withdraws assets from the vault without redeeming shares (operator only)
|
|
192
209
|
* Used by operators to move funds to sub-accounts for strategy execution
|
|
193
210
|
* @param vaultAddress Address of the vault
|
|
194
211
|
* @param subAccount The sub-account address to withdraw to
|
|
195
212
|
* @param amount Amount to withdraw
|
|
213
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
196
214
|
* @returns Transaction call object
|
|
197
215
|
*/
|
|
198
|
-
withdrawFromVaultWithoutRedeemingShares(vaultAddress: string, subAccount: string, amount: NumStr): ITransactionCall;
|
|
216
|
+
withdrawFromVaultWithoutRedeemingShares(vaultAddress: string, subAccount: string, amount: NumStr, isETHVault?: boolean): ITransactionCall;
|
|
199
217
|
/**
|
|
200
218
|
* Deposits assets to a vault and mints shares (ERC-4626 standard)
|
|
201
219
|
* @param vaultAddress Address of the vault
|
|
202
220
|
* @param assets Amount of assets to deposit
|
|
203
221
|
* @param receiver Address to receive the shares
|
|
222
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
204
223
|
* @returns Transaction call object
|
|
205
224
|
*/
|
|
206
|
-
deposit(vaultAddress: string, assets: NumStr, receiver: string): ITransactionCall;
|
|
225
|
+
deposit(vaultAddress: string, assets: NumStr, receiver: string, isETHVault?: boolean): ITransactionCall;
|
|
207
226
|
/**
|
|
208
227
|
* Deposits assets to a vault using EIP-2612 permit (no separate approval needed)
|
|
209
228
|
* @param vaultAddress Address of the vault
|
|
210
229
|
* @param assets Amount of assets to deposit
|
|
211
230
|
* @param receiver Address to receive the shares
|
|
212
231
|
* @param permitSignature The EIP-2612 permit signature
|
|
232
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
213
233
|
* @returns Transaction call object
|
|
214
234
|
*/
|
|
215
|
-
depositWithPermit(vaultAddress: string, assets: NumStr, receiver: string, permitSignature: IPermitSignature): ITransactionCall;
|
|
235
|
+
depositWithPermit(vaultAddress: string, assets: NumStr, receiver: string, permitSignature: IPermitSignature, isETHVault?: boolean): ITransactionCall;
|
|
216
236
|
/**
|
|
217
237
|
* Mints a specific number of shares by depositing assets (ERC-4626 standard)
|
|
218
238
|
* @param vaultAddress Address of the vault
|
|
219
239
|
* @param shares Amount of shares to mint
|
|
220
240
|
* @param receiver Address to receive the shares
|
|
241
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
221
242
|
* @returns Transaction call object
|
|
222
243
|
*/
|
|
223
|
-
mint(vaultAddress: string, shares: NumStr, receiver: string): ITransactionCall;
|
|
244
|
+
mint(vaultAddress: string, shares: NumStr, receiver: string, isETHVault?: boolean): ITransactionCall;
|
|
224
245
|
/**
|
|
225
246
|
* Mints a specific number of shares using EIP-2612 permit (no separate approval needed)
|
|
226
247
|
* @param vaultAddress Address of the vault
|
|
227
248
|
* @param shares Amount of shares to mint
|
|
228
249
|
* @param receiver Address to receive the shares
|
|
229
250
|
* @param permitSignature The EIP-2612 permit signature
|
|
251
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
230
252
|
* @returns Transaction call object
|
|
231
253
|
*/
|
|
232
|
-
mintWithPermit(vaultAddress: string, shares: NumStr, receiver: string, permitSignature: IPermitSignature): ITransactionCall;
|
|
254
|
+
mintWithPermit(vaultAddress: string, shares: NumStr, receiver: string, permitSignature: IPermitSignature, isETHVault?: boolean): ITransactionCall;
|
|
233
255
|
/**
|
|
234
256
|
* Redeems shares to initiate a withdrawal request
|
|
235
257
|
* @param vaultAddress Address of the vault
|
|
236
258
|
* @param shares Amount of shares to redeem
|
|
237
259
|
* @param receiver Address to receive the withdrawn funds
|
|
260
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
261
|
+
* @returns Transaction call object
|
|
262
|
+
*/
|
|
263
|
+
redeemShares(vaultAddress: string, shares: NumStr, receiver: string, isETHVault?: boolean): ITransactionCall;
|
|
264
|
+
/**
|
|
265
|
+
* Deposits native ETH to an ETH vault and mints shares
|
|
266
|
+
* @param vaultAddress Address of the ETH vault
|
|
267
|
+
* @param receiver Address to receive the shares
|
|
268
|
+
* @param value Amount of ETH to deposit (in wei)
|
|
269
|
+
* @returns Transaction call object
|
|
270
|
+
*/
|
|
271
|
+
depositETH(vaultAddress: string, receiver: string, value: bigint): ITransactionCall;
|
|
272
|
+
/**
|
|
273
|
+
* Mints a specific number of shares by depositing native ETH
|
|
274
|
+
* @param vaultAddress Address of the ETH vault
|
|
275
|
+
* @param shares Amount of shares to mint
|
|
276
|
+
* @param receiver Address to receive the shares
|
|
277
|
+
* @param value Amount of ETH to send (must cover the required assets for shares)
|
|
238
278
|
* @returns Transaction call object
|
|
239
279
|
*/
|
|
240
|
-
|
|
280
|
+
mintWithETH(vaultAddress: string, shares: NumStr, receiver: string, value: bigint): ITransactionCall;
|
|
241
281
|
/**
|
|
242
282
|
* Cancels a pending withdrawal request
|
|
243
283
|
* @param vaultAddress Address of the vault
|
|
244
284
|
* @param requestSequenceNumber Sequence number of the withdrawal request to cancel
|
|
285
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
245
286
|
* @returns Transaction call object
|
|
246
287
|
*/
|
|
247
|
-
cancelPendingWithdrawalRequest(vaultAddress: string, requestSequenceNumber: NumStr): ITransactionCall;
|
|
288
|
+
cancelPendingWithdrawalRequest(vaultAddress: string, requestSequenceNumber: NumStr, isETHVault?: boolean): ITransactionCall;
|
|
248
289
|
/**
|
|
249
290
|
* Approves a token for spending by the vault
|
|
250
291
|
* @param tokenAddress Address of the token
|
|
@@ -254,9 +295,13 @@ export declare class EVMTxBuilder {
|
|
|
254
295
|
*/
|
|
255
296
|
approveToken(tokenAddress: string, spender: string, amount: NumStr): ITransactionCall;
|
|
256
297
|
/**
|
|
257
|
-
* Gets the EmberVault ABI
|
|
298
|
+
* Gets the EmberVault ABI (standard ERC20 vault)
|
|
258
299
|
*/
|
|
259
300
|
static getVaultABI(): unknown[];
|
|
301
|
+
/**
|
|
302
|
+
* Gets the EmberETHVault ABI (native ETH vault)
|
|
303
|
+
*/
|
|
304
|
+
static getETHVaultABI(): unknown[];
|
|
260
305
|
/**
|
|
261
306
|
* Gets the EmberProtocolConfig ABI
|
|
262
307
|
*/
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.EVMTxBuilder = void 0;
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
8
|
const EmberVault_json_1 = __importDefault(require("../../abis/EmberVault.json"));
|
|
9
|
+
const EmberETHVault_json_1 = __importDefault(require("../../abis/EmberETHVault.json"));
|
|
9
10
|
const EmberProtocolConfig_json_1 = __importDefault(require("../../abis/EmberProtocolConfig.json"));
|
|
10
11
|
const ERC20Token_json_1 = __importDefault(require("../../abis/ERC20Token.json"));
|
|
11
12
|
/**
|
|
@@ -15,14 +16,22 @@ const ERC20Token_json_1 = __importDefault(require("../../abis/ERC20Token.json"))
|
|
|
15
16
|
* on EVM-compatible chains. The vault contracts now implement ERC-4626 standard
|
|
16
17
|
* and are themselves ERC20 tokens representing shares.
|
|
17
18
|
*
|
|
19
|
+
* For ETH vaults (EmberETHVault), pass `isETHVault: true` to vault methods
|
|
20
|
+
* to use the correct ABI.
|
|
21
|
+
*
|
|
18
22
|
* @example
|
|
19
23
|
* ```typescript
|
|
20
24
|
* import { EVMTxBuilder } from "@ember-finance/sdk";
|
|
21
25
|
* import { encodeFunctionData } from "viem";
|
|
22
26
|
*
|
|
23
27
|
* const txBuilder = new EVMTxBuilder(deployment);
|
|
28
|
+
*
|
|
29
|
+
* // Standard ERC20 vault
|
|
24
30
|
* const txCall = txBuilder.deposit(vaultAddress, amount, receiver);
|
|
25
31
|
*
|
|
32
|
+
* // ETH vault - pass isETHVault flag
|
|
33
|
+
* const ethTxCall = txBuilder.deposit(vaultAddress, amount, receiver, true);
|
|
34
|
+
*
|
|
26
35
|
* // Encode with viem
|
|
27
36
|
* const data = encodeFunctionData({
|
|
28
37
|
* abi: txCall.abi,
|
|
@@ -52,6 +61,14 @@ class EVMTxBuilder {
|
|
|
52
61
|
getChainId() {
|
|
53
62
|
return this.parser.getChainId();
|
|
54
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets the appropriate vault ABI based on vault type
|
|
66
|
+
* @param isETHVault If true, returns EmberETHVault ABI; otherwise EmberVault ABI
|
|
67
|
+
* @returns The vault ABI array
|
|
68
|
+
*/
|
|
69
|
+
getVaultAbiForType(isETHVault) {
|
|
70
|
+
return isETHVault ? EmberETHVault_json_1.default.abi : EmberVault_json_1.default.abi;
|
|
71
|
+
}
|
|
55
72
|
// ============================================
|
|
56
73
|
// Protocol Config Admin Methods
|
|
57
74
|
// ============================================
|
|
@@ -366,14 +383,15 @@ class EVMTxBuilder {
|
|
|
366
383
|
* Updates the rate of a vault (rate manager only)
|
|
367
384
|
* @param vaultAddress Address of the vault
|
|
368
385
|
* @param newRate New rate value
|
|
386
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
369
387
|
* @returns Transaction call object
|
|
370
388
|
*/
|
|
371
|
-
updateVaultRate(vaultAddress, newRate) {
|
|
389
|
+
updateVaultRate(vaultAddress, newRate, isETHVault) {
|
|
372
390
|
return {
|
|
373
391
|
to: vaultAddress,
|
|
374
392
|
functionName: "updateVaultRate",
|
|
375
393
|
args: [BigInt(newRate)],
|
|
376
|
-
abi:
|
|
394
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
377
395
|
value: 0n,
|
|
378
396
|
chainId: this.getChainId()
|
|
379
397
|
};
|
|
@@ -382,14 +400,15 @@ class EVMTxBuilder {
|
|
|
382
400
|
* Processes a specified number of withdrawal requests (operator only)
|
|
383
401
|
* @param vaultAddress Address of the vault
|
|
384
402
|
* @param numRequests Maximum number of requests to process
|
|
403
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
385
404
|
* @returns Transaction call object
|
|
386
405
|
*/
|
|
387
|
-
processWithdrawalRequests(vaultAddress, numRequests) {
|
|
406
|
+
processWithdrawalRequests(vaultAddress, numRequests, isETHVault) {
|
|
388
407
|
return {
|
|
389
408
|
to: vaultAddress,
|
|
390
409
|
functionName: "processWithdrawalRequests",
|
|
391
410
|
args: [BigInt(numRequests)],
|
|
392
|
-
abi:
|
|
411
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
393
412
|
value: 0n,
|
|
394
413
|
chainId: this.getChainId()
|
|
395
414
|
};
|
|
@@ -397,14 +416,15 @@ class EVMTxBuilder {
|
|
|
397
416
|
/**
|
|
398
417
|
* Collects accrued platform fees (operator only)
|
|
399
418
|
* @param vaultAddress Address of the vault
|
|
419
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
400
420
|
* @returns Transaction call object
|
|
401
421
|
*/
|
|
402
|
-
collectPlatformFee(vaultAddress) {
|
|
422
|
+
collectPlatformFee(vaultAddress, isETHVault) {
|
|
403
423
|
return {
|
|
404
424
|
to: vaultAddress,
|
|
405
425
|
functionName: "collectPlatformFee",
|
|
406
426
|
args: [],
|
|
407
|
-
abi:
|
|
427
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
408
428
|
value: 0n,
|
|
409
429
|
chainId: this.getChainId()
|
|
410
430
|
};
|
|
@@ -415,14 +435,15 @@ class EVMTxBuilder {
|
|
|
415
435
|
* @param vaultAddress Address of the vault
|
|
416
436
|
* @param subAccount The sub-account address to withdraw to
|
|
417
437
|
* @param amount Amount to withdraw
|
|
438
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
418
439
|
* @returns Transaction call object
|
|
419
440
|
*/
|
|
420
|
-
withdrawFromVaultWithoutRedeemingShares(vaultAddress, subAccount, amount) {
|
|
441
|
+
withdrawFromVaultWithoutRedeemingShares(vaultAddress, subAccount, amount, isETHVault) {
|
|
421
442
|
return {
|
|
422
443
|
to: vaultAddress,
|
|
423
444
|
functionName: "withdrawFromVaultWithoutRedeemingShares",
|
|
424
445
|
args: [subAccount, BigInt(amount)],
|
|
425
|
-
abi:
|
|
446
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
426
447
|
value: 0n,
|
|
427
448
|
chainId: this.getChainId()
|
|
428
449
|
};
|
|
@@ -435,14 +456,15 @@ class EVMTxBuilder {
|
|
|
435
456
|
* @param vaultAddress Address of the vault
|
|
436
457
|
* @param assets Amount of assets to deposit
|
|
437
458
|
* @param receiver Address to receive the shares
|
|
459
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
438
460
|
* @returns Transaction call object
|
|
439
461
|
*/
|
|
440
|
-
deposit(vaultAddress, assets, receiver) {
|
|
462
|
+
deposit(vaultAddress, assets, receiver, isETHVault) {
|
|
441
463
|
return {
|
|
442
464
|
to: vaultAddress,
|
|
443
465
|
functionName: "deposit",
|
|
444
466
|
args: [BigInt(assets), receiver],
|
|
445
|
-
abi:
|
|
467
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
446
468
|
value: 0n,
|
|
447
469
|
chainId: this.getChainId()
|
|
448
470
|
};
|
|
@@ -453,9 +475,10 @@ class EVMTxBuilder {
|
|
|
453
475
|
* @param assets Amount of assets to deposit
|
|
454
476
|
* @param receiver Address to receive the shares
|
|
455
477
|
* @param permitSignature The EIP-2612 permit signature
|
|
478
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
456
479
|
* @returns Transaction call object
|
|
457
480
|
*/
|
|
458
|
-
depositWithPermit(vaultAddress, assets, receiver, permitSignature) {
|
|
481
|
+
depositWithPermit(vaultAddress, assets, receiver, permitSignature, isETHVault) {
|
|
459
482
|
return {
|
|
460
483
|
to: vaultAddress,
|
|
461
484
|
functionName: "depositWithPermit",
|
|
@@ -467,7 +490,7 @@ class EVMTxBuilder {
|
|
|
467
490
|
permitSignature.r,
|
|
468
491
|
permitSignature.s
|
|
469
492
|
],
|
|
470
|
-
abi:
|
|
493
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
471
494
|
value: 0n,
|
|
472
495
|
chainId: this.getChainId()
|
|
473
496
|
};
|
|
@@ -477,14 +500,15 @@ class EVMTxBuilder {
|
|
|
477
500
|
* @param vaultAddress Address of the vault
|
|
478
501
|
* @param shares Amount of shares to mint
|
|
479
502
|
* @param receiver Address to receive the shares
|
|
503
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
480
504
|
* @returns Transaction call object
|
|
481
505
|
*/
|
|
482
|
-
mint(vaultAddress, shares, receiver) {
|
|
506
|
+
mint(vaultAddress, shares, receiver, isETHVault) {
|
|
483
507
|
return {
|
|
484
508
|
to: vaultAddress,
|
|
485
509
|
functionName: "mint",
|
|
486
510
|
args: [BigInt(shares), receiver],
|
|
487
|
-
abi:
|
|
511
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
488
512
|
value: 0n,
|
|
489
513
|
chainId: this.getChainId()
|
|
490
514
|
};
|
|
@@ -495,9 +519,10 @@ class EVMTxBuilder {
|
|
|
495
519
|
* @param shares Amount of shares to mint
|
|
496
520
|
* @param receiver Address to receive the shares
|
|
497
521
|
* @param permitSignature The EIP-2612 permit signature
|
|
522
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
498
523
|
* @returns Transaction call object
|
|
499
524
|
*/
|
|
500
|
-
mintWithPermit(vaultAddress, shares, receiver, permitSignature) {
|
|
525
|
+
mintWithPermit(vaultAddress, shares, receiver, permitSignature, isETHVault) {
|
|
501
526
|
return {
|
|
502
527
|
to: vaultAddress,
|
|
503
528
|
functionName: "mintWithPermit",
|
|
@@ -509,7 +534,7 @@ class EVMTxBuilder {
|
|
|
509
534
|
permitSignature.r,
|
|
510
535
|
permitSignature.s
|
|
511
536
|
],
|
|
512
|
-
abi:
|
|
537
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
513
538
|
value: 0n,
|
|
514
539
|
chainId: this.getChainId()
|
|
515
540
|
};
|
|
@@ -519,30 +544,71 @@ class EVMTxBuilder {
|
|
|
519
544
|
* @param vaultAddress Address of the vault
|
|
520
545
|
* @param shares Amount of shares to redeem
|
|
521
546
|
* @param receiver Address to receive the withdrawn funds
|
|
547
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
522
548
|
* @returns Transaction call object
|
|
523
549
|
*/
|
|
524
|
-
redeemShares(vaultAddress, shares, receiver) {
|
|
550
|
+
redeemShares(vaultAddress, shares, receiver, isETHVault) {
|
|
525
551
|
return {
|
|
526
552
|
to: vaultAddress,
|
|
527
553
|
functionName: "redeemShares",
|
|
528
554
|
args: [BigInt(shares), receiver],
|
|
529
|
-
abi:
|
|
555
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
530
556
|
value: 0n,
|
|
531
557
|
chainId: this.getChainId()
|
|
532
558
|
};
|
|
533
559
|
}
|
|
560
|
+
// ============================================
|
|
561
|
+
// ETH Vault Methods (EmberETHVault)
|
|
562
|
+
// These methods are for vaults that accept native ETH
|
|
563
|
+
// ============================================
|
|
564
|
+
/**
|
|
565
|
+
* Deposits native ETH to an ETH vault and mints shares
|
|
566
|
+
* @param vaultAddress Address of the ETH vault
|
|
567
|
+
* @param receiver Address to receive the shares
|
|
568
|
+
* @param value Amount of ETH to deposit (in wei)
|
|
569
|
+
* @returns Transaction call object
|
|
570
|
+
*/
|
|
571
|
+
depositETH(vaultAddress, receiver, value) {
|
|
572
|
+
return {
|
|
573
|
+
to: vaultAddress,
|
|
574
|
+
functionName: "depositETH",
|
|
575
|
+
args: [receiver],
|
|
576
|
+
abi: EmberETHVault_json_1.default.abi,
|
|
577
|
+
value,
|
|
578
|
+
chainId: this.getChainId()
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Mints a specific number of shares by depositing native ETH
|
|
583
|
+
* @param vaultAddress Address of the ETH vault
|
|
584
|
+
* @param shares Amount of shares to mint
|
|
585
|
+
* @param receiver Address to receive the shares
|
|
586
|
+
* @param value Amount of ETH to send (must cover the required assets for shares)
|
|
587
|
+
* @returns Transaction call object
|
|
588
|
+
*/
|
|
589
|
+
mintWithETH(vaultAddress, shares, receiver, value) {
|
|
590
|
+
return {
|
|
591
|
+
to: vaultAddress,
|
|
592
|
+
functionName: "mintWithETH",
|
|
593
|
+
args: [BigInt(shares), receiver],
|
|
594
|
+
abi: EmberETHVault_json_1.default.abi,
|
|
595
|
+
value,
|
|
596
|
+
chainId: this.getChainId()
|
|
597
|
+
};
|
|
598
|
+
}
|
|
534
599
|
/**
|
|
535
600
|
* Cancels a pending withdrawal request
|
|
536
601
|
* @param vaultAddress Address of the vault
|
|
537
602
|
* @param requestSequenceNumber Sequence number of the withdrawal request to cancel
|
|
603
|
+
* @param isETHVault If true, uses EmberETHVault ABI
|
|
538
604
|
* @returns Transaction call object
|
|
539
605
|
*/
|
|
540
|
-
cancelPendingWithdrawalRequest(vaultAddress, requestSequenceNumber) {
|
|
606
|
+
cancelPendingWithdrawalRequest(vaultAddress, requestSequenceNumber, isETHVault) {
|
|
541
607
|
return {
|
|
542
608
|
to: vaultAddress,
|
|
543
609
|
functionName: "cancelPendingWithdrawalRequest",
|
|
544
610
|
args: [BigInt(requestSequenceNumber)],
|
|
545
|
-
abi:
|
|
611
|
+
abi: this.getVaultAbiForType(isETHVault),
|
|
546
612
|
value: 0n,
|
|
547
613
|
chainId: this.getChainId()
|
|
548
614
|
};
|
|
@@ -571,11 +637,17 @@ class EVMTxBuilder {
|
|
|
571
637
|
// ABI Getters
|
|
572
638
|
// ============================================
|
|
573
639
|
/**
|
|
574
|
-
* Gets the EmberVault ABI
|
|
640
|
+
* Gets the EmberVault ABI (standard ERC20 vault)
|
|
575
641
|
*/
|
|
576
642
|
static getVaultABI() {
|
|
577
643
|
return EmberVault_json_1.default.abi;
|
|
578
644
|
}
|
|
645
|
+
/**
|
|
646
|
+
* Gets the EmberETHVault ABI (native ETH vault)
|
|
647
|
+
*/
|
|
648
|
+
static getETHVaultABI() {
|
|
649
|
+
return EmberETHVault_json_1.default.abi;
|
|
650
|
+
}
|
|
579
651
|
/**
|
|
580
652
|
* Gets the EmberProtocolConfig ABI
|
|
581
653
|
*/
|