@defindex/sdk 0.1.0 → 0.1.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/README.md +4 -1
- package/dist/.DS_Store +0 -0
- package/dist/defindex-sdk.d.ts +247 -51
- package/dist/defindex-sdk.d.ts.map +1 -1
- package/dist/defindex-sdk.js +300 -50
- package/dist/defindex-sdk.js.map +1 -1
- package/dist/types/factory.types.d.ts +71 -0
- package/dist/types/factory.types.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/stellar.types.d.ts +46 -20
- package/dist/types/stellar.types.d.ts.map +1 -1
- package/dist/types/vault.types.d.ts +93 -135
- package/dist/types/vault.types.d.ts.map +1 -1
- package/dist/types/vault.types.js +68 -0
- package/dist/types/vault.types.js.map +1 -1
- package/package.json +14 -16
package/dist/defindex-sdk.js
CHANGED
|
@@ -7,16 +7,24 @@ const http_client_1 = require("./clients/http-client");
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* // Basic initialization
|
|
10
|
+
* // Basic initialization with default network
|
|
11
11
|
* const sdk = new DefindexSDK({
|
|
12
|
-
* baseUrl: 'https://api.defindex.io'
|
|
12
|
+
* baseUrl: 'https://api.defindex.io',
|
|
13
|
+
* defaultNetwork: SupportedNetworks.TESTNET
|
|
13
14
|
* });
|
|
14
15
|
*
|
|
15
16
|
* // With API key authentication
|
|
16
17
|
* const sdk = new DefindexSDK({
|
|
17
18
|
* apiKey: 'sk_your_api_key_here',
|
|
18
|
-
* baseUrl: 'https://api.defindex.io'
|
|
19
|
+
* baseUrl: 'https://api.defindex.io',
|
|
20
|
+
* defaultNetwork: SupportedNetworks.MAINNET
|
|
19
21
|
* });
|
|
22
|
+
*
|
|
23
|
+
* // Now you can call methods without specifying network
|
|
24
|
+
* const vaultInfo = await sdk.getVaultInfo('CVAULT...');
|
|
25
|
+
*
|
|
26
|
+
* // Or override for a specific call
|
|
27
|
+
* const testnetInfo = await sdk.getVaultInfo('CVAULT...', SupportedNetworks.TESTNET);
|
|
20
28
|
* ```
|
|
21
29
|
*/
|
|
22
30
|
class DefindexSDK {
|
|
@@ -26,9 +34,37 @@ class DefindexSDK {
|
|
|
26
34
|
*/
|
|
27
35
|
constructor(config) {
|
|
28
36
|
this.config = config;
|
|
37
|
+
this.defaultNetwork = config.defaultNetwork;
|
|
29
38
|
this.httpClient = new http_client_1.HttpClient(config.baseUrl || 'https://api.defindex.io', config.apiKey || '', // API key or empty string
|
|
30
39
|
config.timeout || 30000);
|
|
31
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the network to use for a request
|
|
43
|
+
* @param network - Optional network override
|
|
44
|
+
* @returns The network to use (provided network or default)
|
|
45
|
+
* @throws Error if no network is provided and no default is set
|
|
46
|
+
*/
|
|
47
|
+
getNetwork(network) {
|
|
48
|
+
const resolvedNetwork = network ?? this.defaultNetwork;
|
|
49
|
+
if (!resolvedNetwork) {
|
|
50
|
+
throw new Error('No network specified. Either provide a network parameter or set defaultNetwork in SDK config.');
|
|
51
|
+
}
|
|
52
|
+
return resolvedNetwork;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the current default network
|
|
56
|
+
* @returns The default network or undefined if not set
|
|
57
|
+
*/
|
|
58
|
+
getDefaultNetwork() {
|
|
59
|
+
return this.defaultNetwork;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Set the default network for all operations
|
|
63
|
+
* @param network - The network to use as default
|
|
64
|
+
*/
|
|
65
|
+
setDefaultNetwork(network) {
|
|
66
|
+
this.defaultNetwork = network;
|
|
67
|
+
}
|
|
32
68
|
//=======================================================================
|
|
33
69
|
// System Operations
|
|
34
70
|
//=======================================================================
|
|
@@ -51,21 +87,22 @@ class DefindexSDK {
|
|
|
51
87
|
//=======================================================================
|
|
52
88
|
/**
|
|
53
89
|
* Get the factory contract address for a specific network
|
|
54
|
-
* @param network - Stellar network (
|
|
90
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
55
91
|
* @returns Factory contract address
|
|
56
92
|
* @example
|
|
57
93
|
* ```typescript
|
|
58
|
-
* const factory = await sdk.getFactoryAddress(
|
|
94
|
+
* const factory = await sdk.getFactoryAddress();
|
|
59
95
|
* console.log('Factory address:', factory.address);
|
|
60
96
|
* ```
|
|
61
97
|
*/
|
|
62
98
|
async getFactoryAddress(network) {
|
|
63
|
-
|
|
99
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
100
|
+
return this.httpClient.get(`/factory/address?network=${resolvedNetwork}`);
|
|
64
101
|
}
|
|
65
102
|
/**
|
|
66
103
|
* Create a new vault (requires Vault Manager role)
|
|
67
104
|
* @param vaultConfig - Vault configuration including assets, fees, and roles
|
|
68
|
-
* @param network - Stellar network (
|
|
105
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
69
106
|
* @returns Transaction XDR for vault creation
|
|
70
107
|
* @example
|
|
71
108
|
* ```typescript
|
|
@@ -77,16 +114,17 @@ class DefindexSDK {
|
|
|
77
114
|
* upgradable: true,
|
|
78
115
|
* caller: "GCALLER..."
|
|
79
116
|
* };
|
|
80
|
-
* const response = await sdk.createVault(vaultConfig
|
|
117
|
+
* const response = await sdk.createVault(vaultConfig);
|
|
81
118
|
* ```
|
|
82
119
|
*/
|
|
83
120
|
async createVault(vaultConfig, network) {
|
|
84
|
-
|
|
121
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
122
|
+
return this.httpClient.post(`/factory/create-vault?network=${resolvedNetwork}`, vaultConfig);
|
|
85
123
|
}
|
|
86
124
|
/**
|
|
87
125
|
* Create a new vault with initial deposit in a single transaction
|
|
88
126
|
* @param vaultConfig - Vault configuration with initial deposit amounts
|
|
89
|
-
* @param network - Stellar network (
|
|
127
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
90
128
|
* @returns Transaction XDR for vault creation and deposit
|
|
91
129
|
* @example
|
|
92
130
|
* ```typescript
|
|
@@ -94,11 +132,58 @@ class DefindexSDK {
|
|
|
94
132
|
* // ... vault config
|
|
95
133
|
* deposit_amounts: [1000000, 2000000] // Initial deposit amounts
|
|
96
134
|
* };
|
|
97
|
-
* const response = await sdk.createVaultWithDeposit(vaultConfig
|
|
135
|
+
* const response = await sdk.createVaultWithDeposit(vaultConfig);
|
|
98
136
|
* ```
|
|
99
137
|
*/
|
|
100
138
|
async createVaultWithDeposit(vaultConfig, network) {
|
|
101
|
-
|
|
139
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
140
|
+
return this.httpClient.post(`/factory/create-vault-deposit?network=${resolvedNetwork}`, vaultConfig);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create a new vault with auto-invest in a single atomic transaction
|
|
144
|
+
*
|
|
145
|
+
* This endpoint creates a batched transaction that:
|
|
146
|
+
* 1. Creates the vault with initial deposit
|
|
147
|
+
* 2. Invests funds in specified strategies (rebalance)
|
|
148
|
+
* 3. Changes manager to the final address
|
|
149
|
+
*
|
|
150
|
+
* All operations are atomic - either all succeed or all fail.
|
|
151
|
+
*
|
|
152
|
+
* @param params - Auto-invest vault configuration with asset allocations and strategies
|
|
153
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
154
|
+
* @returns Transaction XDR, predicted vault address, and warning about address prediction
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const params = {
|
|
158
|
+
* caller: 'GCALLER...',
|
|
159
|
+
* roles: {
|
|
160
|
+
* emergencyManager: 'GEMERGENCY...',
|
|
161
|
+
* rebalanceManager: 'GREBALANCE...',
|
|
162
|
+
* feeReceiver: 'GFEE...',
|
|
163
|
+
* manager: 'GMANAGER...'
|
|
164
|
+
* },
|
|
165
|
+
* name: 'My Auto-Invest Vault',
|
|
166
|
+
* symbol: 'MAIV',
|
|
167
|
+
* vaultFee: 10, // 0.1% in basis points
|
|
168
|
+
* upgradable: true,
|
|
169
|
+
* assets: [{
|
|
170
|
+
* address: 'CASSET...',
|
|
171
|
+
* symbol: 'XLM',
|
|
172
|
+
* amount: 2000000000, // 200 XLM in stroops
|
|
173
|
+
* strategies: [
|
|
174
|
+
* { address: 'CSTRAT1...', name: 'hodl_strategy', amount: 1000000000 },
|
|
175
|
+
* { address: 'CSTRAT2...', name: 'yield_strategy', amount: 1000000000 }
|
|
176
|
+
* ]
|
|
177
|
+
* }]
|
|
178
|
+
* };
|
|
179
|
+
* const response = await sdk.createVaultAutoInvest(params);
|
|
180
|
+
* console.log('Sign this XDR:', response.xdr);
|
|
181
|
+
* console.log('Predicted vault address:', response.predictedVaultAddress);
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
async createVaultAutoInvest(params, network) {
|
|
185
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
186
|
+
return this.httpClient.post(`/factory/create-vault-auto-invest?network=${resolvedNetwork}`, params);
|
|
102
187
|
}
|
|
103
188
|
//=======================================================================
|
|
104
189
|
// Vault Operations
|
|
@@ -106,56 +191,67 @@ class DefindexSDK {
|
|
|
106
191
|
/**
|
|
107
192
|
* Get comprehensive vault information
|
|
108
193
|
* @param vaultAddress - The vault contract address
|
|
109
|
-
* @param network - Stellar network (
|
|
194
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
110
195
|
* @returns Vault metadata, assets, strategies, and TVL information
|
|
111
196
|
* @example
|
|
112
197
|
* ```typescript
|
|
113
|
-
* const vaultInfo = await sdk.getVaultInfo(
|
|
114
|
-
* 'GVAULT...',
|
|
115
|
-
* SupportedNetworks.TESTNET
|
|
116
|
-
* );
|
|
198
|
+
* const vaultInfo = await sdk.getVaultInfo('CVAULT...');
|
|
117
199
|
* console.log(`Vault: ${vaultInfo.name} (${vaultInfo.symbol})`);
|
|
118
200
|
* console.log(`Total Assets: ${vaultInfo.totalAssets}`);
|
|
119
201
|
* ```
|
|
120
202
|
*/
|
|
121
203
|
async getVaultInfo(vaultAddress, network) {
|
|
122
|
-
|
|
204
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
205
|
+
return this.httpClient.get(`/vault/${vaultAddress}?network=${resolvedNetwork}`);
|
|
123
206
|
}
|
|
124
207
|
/**
|
|
125
208
|
* Get user's vault balance and shares
|
|
126
209
|
* @param vaultAddress - The vault contract address
|
|
127
210
|
* @param userAddress - User's wallet address
|
|
128
|
-
* @param network - Stellar network (
|
|
211
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
129
212
|
* @returns User's vault shares and underlying asset values
|
|
130
213
|
* @example
|
|
131
214
|
* ```typescript
|
|
132
|
-
* const balance = await sdk.getVaultBalance(
|
|
133
|
-
* 'GVAULT...',
|
|
134
|
-
* 'GUSER...',
|
|
135
|
-
* SupportedNetworks.TESTNET
|
|
136
|
-
* );
|
|
215
|
+
* const balance = await sdk.getVaultBalance('CVAULT...', 'GUSER...');
|
|
137
216
|
* console.log(`Shares: ${balance.dfTokens}`);
|
|
138
217
|
* console.log(`Underlying values: ${balance.underlyingBalance}`);
|
|
139
218
|
* ```
|
|
140
219
|
*/
|
|
141
220
|
async getVaultBalance(vaultAddress, userAddress, network) {
|
|
142
|
-
|
|
221
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
222
|
+
return this.httpClient.get(`/vault/${vaultAddress}/balance?from=${userAddress}&network=${resolvedNetwork}`);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get vault report with transaction details
|
|
226
|
+
* @param vaultAddress - The vault contract address
|
|
227
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
228
|
+
* @returns Vault report with transaction XDR and simulation response
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const report = await sdk.getReport('CVAULT...');
|
|
232
|
+
* console.log(`Report XDR: ${report.xdr}`);
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
async getReport(vaultAddress, network) {
|
|
236
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
237
|
+
return this.httpClient.get(`/vault/${vaultAddress}/report?network=${resolvedNetwork}`);
|
|
143
238
|
}
|
|
144
239
|
/**
|
|
145
240
|
* Deposit assets into a vault
|
|
146
241
|
* @param vaultAddress - The vault contract address
|
|
147
242
|
* @param depositData - Deposit parameters including amounts and caller address
|
|
148
|
-
* @param network - Stellar network (
|
|
243
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
149
244
|
* @returns Transaction XDR for signing and simulation response
|
|
150
245
|
*/
|
|
151
246
|
async depositToVault(vaultAddress, depositData, network) {
|
|
152
|
-
|
|
247
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
248
|
+
return this.httpClient.post(`/vault/${vaultAddress}/deposit?network=${resolvedNetwork}`, depositData);
|
|
153
249
|
}
|
|
154
250
|
/**
|
|
155
251
|
* Withdraw specific asset amounts from vault
|
|
156
252
|
* @param vaultAddress - The vault contract address
|
|
157
253
|
* @param withdrawData - Withdrawal parameters including amounts and caller
|
|
158
|
-
* @param network - Stellar network (
|
|
254
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
159
255
|
* @returns Transaction XDR for signing and simulation response
|
|
160
256
|
* @example
|
|
161
257
|
* ```typescript
|
|
@@ -164,92 +260,245 @@ class DefindexSDK {
|
|
|
164
260
|
* caller: 'GUSER...',
|
|
165
261
|
* slippageBps: 100 // 1% slippage tolerance
|
|
166
262
|
* };
|
|
167
|
-
* const response = await sdk.withdrawFromVault('
|
|
263
|
+
* const response = await sdk.withdrawFromVault('CVAULT...', withdrawData);
|
|
168
264
|
* ```
|
|
169
265
|
*/
|
|
170
266
|
async withdrawFromVault(vaultAddress, withdrawData, network) {
|
|
171
|
-
|
|
267
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
268
|
+
return this.httpClient.post(`/vault/${vaultAddress}/withdraw?network=${resolvedNetwork}`, withdrawData);
|
|
172
269
|
}
|
|
173
270
|
/**
|
|
174
271
|
* Withdraw vault shares for underlying assets
|
|
175
272
|
* @param vaultAddress - The vault contract address
|
|
176
273
|
* @param shareData - Share withdrawal parameters including share amount and caller
|
|
177
|
-
* @param network - Stellar network (
|
|
274
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
178
275
|
* @returns Transaction XDR for signing and simulation response
|
|
179
276
|
*/
|
|
180
277
|
async withdrawShares(vaultAddress, shareData, network) {
|
|
181
|
-
|
|
278
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
279
|
+
return this.httpClient.post(`/vault/${vaultAddress}/withdraw-shares?network=${resolvedNetwork}`, shareData);
|
|
182
280
|
}
|
|
183
281
|
/**
|
|
184
282
|
* Get vault's Annual Percentage Yield (APY)
|
|
185
283
|
* @param vaultAddress - The vault contract address
|
|
186
|
-
* @param network - Stellar network (
|
|
284
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
187
285
|
* @returns APY information including percentage and calculation period
|
|
188
286
|
* @example
|
|
189
287
|
* ```typescript
|
|
190
|
-
* const apy = await sdk.getVaultAPY('
|
|
288
|
+
* const apy = await sdk.getVaultAPY('CVAULT...');
|
|
191
289
|
* console.log(`APY: ${apy.apyPercent}% (calculated over ${apy.period})`);
|
|
192
290
|
* ```
|
|
193
291
|
*/
|
|
194
292
|
async getVaultAPY(vaultAddress, network) {
|
|
195
|
-
|
|
293
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
294
|
+
return this.httpClient.get(`/vault/${vaultAddress}/apy?network=${resolvedNetwork}`);
|
|
196
295
|
}
|
|
197
296
|
//=======================================================================
|
|
198
297
|
// Vault Management Operations
|
|
199
298
|
//=======================================================================
|
|
299
|
+
/**
|
|
300
|
+
* Rebalance vault strategies (Rebalance Manager role required)
|
|
301
|
+
* @param vaultAddress - The vault contract address
|
|
302
|
+
* @param rebalanceData - Rebalance parameters including investment instructions
|
|
303
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
304
|
+
* @returns Transaction XDR for Rebalance Manager signing
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const rebalanceData = {
|
|
308
|
+
* caller: 'GREBALANCE_MANAGER...',
|
|
309
|
+
* instructions: [
|
|
310
|
+
* { type: 'Unwind', strategy_address: 'CSTRATEGY1...', amount: 500000 },
|
|
311
|
+
* { type: 'Invest', strategy_address: 'CSTRATEGY2...', amount: 1000000 },
|
|
312
|
+
* {
|
|
313
|
+
* type: 'SwapExactIn',
|
|
314
|
+
* token_in: 'GTOKEN1...',
|
|
315
|
+
* token_out: 'GTOKEN2...',
|
|
316
|
+
* amount: 250000,
|
|
317
|
+
* slippageToleranceBps: 100
|
|
318
|
+
* }
|
|
319
|
+
* ]
|
|
320
|
+
* };
|
|
321
|
+
* const response = await sdk.rebalanceVault('CVAULT...', rebalanceData);
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
async rebalanceVault(vaultAddress, rebalanceData, network) {
|
|
325
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
326
|
+
return this.httpClient.post(`/vault/${vaultAddress}/rebalance?network=${resolvedNetwork}`, rebalanceData);
|
|
327
|
+
}
|
|
200
328
|
/**
|
|
201
329
|
* Emergency rescue assets from strategy (Emergency Manager role required)
|
|
202
330
|
* @param vaultAddress - The vault contract address
|
|
203
331
|
* @param rescueData - Rescue parameters including strategy address and caller
|
|
204
|
-
* @param network - Stellar network (
|
|
332
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
205
333
|
* @returns Transaction XDR for Emergency Manager signing and rescued assets info
|
|
206
334
|
* @example
|
|
207
335
|
* ```typescript
|
|
208
336
|
* const rescueData = {
|
|
209
|
-
* strategy_address: '
|
|
337
|
+
* strategy_address: 'CSTRATEGY...',
|
|
210
338
|
* caller: 'GEMERGENCY_MANAGER...'
|
|
211
339
|
* };
|
|
212
|
-
* const response = await sdk.emergencyRescue('
|
|
340
|
+
* const response = await sdk.emergencyRescue('CVAULT...', rescueData);
|
|
213
341
|
* ```
|
|
214
342
|
*/
|
|
215
343
|
async emergencyRescue(vaultAddress, rescueData, network) {
|
|
216
|
-
|
|
344
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
345
|
+
return this.httpClient.post(`/vault/${vaultAddress}/rescue?network=${resolvedNetwork}`, rescueData);
|
|
217
346
|
}
|
|
218
347
|
/**
|
|
219
348
|
* Pause a specific strategy (Strategy Manager role required)
|
|
220
349
|
* @param vaultAddress - The vault contract address
|
|
221
350
|
* @param strategyData - Strategy pause parameters
|
|
222
|
-
* @param network - Stellar network (
|
|
351
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
223
352
|
* @returns Transaction XDR for Strategy Manager signing
|
|
224
353
|
* @example
|
|
225
354
|
* ```typescript
|
|
226
355
|
* const strategyData = {
|
|
227
|
-
* strategy_address: '
|
|
228
|
-
* caller: '
|
|
356
|
+
* strategy_address: 'CSTRATEGY...',
|
|
357
|
+
* caller: 'CSTRATEGY_MANAGER...'
|
|
229
358
|
* };
|
|
230
|
-
* const response = await sdk.pauseStrategy('
|
|
359
|
+
* const response = await sdk.pauseStrategy('CVAULT...', strategyData);
|
|
231
360
|
* ```
|
|
232
361
|
*/
|
|
233
362
|
async pauseStrategy(vaultAddress, strategyData, network) {
|
|
234
|
-
|
|
363
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
364
|
+
return this.httpClient.post(`/vault/${vaultAddress}/pause-strategy?network=${resolvedNetwork}`, strategyData);
|
|
235
365
|
}
|
|
236
366
|
/**
|
|
237
367
|
* Unpause a specific strategy (Strategy Manager role required)
|
|
238
368
|
* @param vaultAddress - The vault contract address
|
|
239
369
|
* @param strategyData - Strategy unpause parameters
|
|
240
|
-
* @param network - Stellar network (
|
|
370
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
241
371
|
* @returns Transaction XDR for Strategy Manager signing
|
|
242
372
|
* @example
|
|
243
373
|
* ```typescript
|
|
244
374
|
* const strategyData = {
|
|
245
|
-
* strategy_address: '
|
|
375
|
+
* strategy_address: 'CSTRATEGY...',
|
|
246
376
|
* caller: 'GSTRATEGY_MANAGER...'
|
|
247
377
|
* };
|
|
248
|
-
* const response = await sdk.unpauseStrategy('
|
|
378
|
+
* const response = await sdk.unpauseStrategy('CVAULT...', strategyData);
|
|
249
379
|
* ```
|
|
250
380
|
*/
|
|
251
381
|
async unpauseStrategy(vaultAddress, strategyData, network) {
|
|
252
|
-
|
|
382
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
383
|
+
return this.httpClient.post(`/vault/${vaultAddress}/unpause-strategy?network=${resolvedNetwork}`, strategyData);
|
|
384
|
+
}
|
|
385
|
+
//=======================================================================
|
|
386
|
+
// Role Operations
|
|
387
|
+
//=======================================================================
|
|
388
|
+
/**
|
|
389
|
+
* Get a specific vault role address
|
|
390
|
+
* @param vaultAddress - The vault contract address
|
|
391
|
+
* @param roleToGet - The role to retrieve (manager, emergency_manager, rebalance_manager, fee_receiver)
|
|
392
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
393
|
+
* @returns Role information with address
|
|
394
|
+
* @example
|
|
395
|
+
* ```typescript
|
|
396
|
+
* const role = await sdk.getVaultRole('CVAULT...', VaultRoles.MANAGER);
|
|
397
|
+
* console.log(`Manager address: ${role.address}`);
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
async getVaultRole(vaultAddress, roleToGet, network) {
|
|
401
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
402
|
+
return this.httpClient.get(`/vault/${vaultAddress}/get/${roleToGet}?network=${resolvedNetwork}`);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Set a vault role to a new address (Manager role required)
|
|
406
|
+
* @param vaultAddress - The vault contract address
|
|
407
|
+
* @param roleToSet - The role to set
|
|
408
|
+
* @param roleData - Role assignment parameters including new address and caller
|
|
409
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
410
|
+
* @returns Transaction XDR for Manager signing
|
|
411
|
+
* @example
|
|
412
|
+
* ```typescript
|
|
413
|
+
* const roleData = {
|
|
414
|
+
* caller: 'GMANAGER...',
|
|
415
|
+
* new_address: 'GNEW_MANAGER...'
|
|
416
|
+
* };
|
|
417
|
+
* const response = await sdk.setVaultRole('CVAULT...', VaultRoles.MANAGER, roleData);
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
async setVaultRole(vaultAddress, roleToSet, roleData, network) {
|
|
421
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
422
|
+
return this.httpClient.post(`/vault/${vaultAddress}/set/${roleToSet}?network=${resolvedNetwork}`, roleData);
|
|
423
|
+
}
|
|
424
|
+
//=======================================================================
|
|
425
|
+
// Vault Management Operations
|
|
426
|
+
//=======================================================================
|
|
427
|
+
/**
|
|
428
|
+
* Lock vault fees and optionally update fee rate (Manager role required)
|
|
429
|
+
* @param vaultAddress - The vault contract address
|
|
430
|
+
* @param lockData - Lock fees parameters including optional new fee rate
|
|
431
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
432
|
+
* @returns Transaction XDR for Manager signing
|
|
433
|
+
* @example
|
|
434
|
+
* ```typescript
|
|
435
|
+
* const lockData = {
|
|
436
|
+
* caller: 'GMANAGER...',
|
|
437
|
+
* new_fee_bps: 150 // Optional: new fee rate in basis points (1.5%)
|
|
438
|
+
* };
|
|
439
|
+
* const response = await sdk.lockVaultFees('CVAULT...', lockData);
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
async lockVaultFees(vaultAddress, lockData, network) {
|
|
443
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
444
|
+
return this.httpClient.post(`/vault/${vaultAddress}/lock-fees?network=${resolvedNetwork}`, lockData);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Release fees from a specific strategy (Manager role required)
|
|
448
|
+
* @param vaultAddress - The vault contract address
|
|
449
|
+
* @param releaseData - Release fees parameters including strategy address and amount
|
|
450
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
451
|
+
* @returns Transaction XDR for Manager signing
|
|
452
|
+
* @example
|
|
453
|
+
* ```typescript
|
|
454
|
+
* const releaseData = {
|
|
455
|
+
* caller: 'GMANAGER...',
|
|
456
|
+
* strategy_address: 'CSTRATEGY...',
|
|
457
|
+
* amount: 100000
|
|
458
|
+
* };
|
|
459
|
+
* const response = await sdk.releaseVaultFees('CVAULT...', releaseData);
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
async releaseVaultFees(vaultAddress, releaseData, network) {
|
|
463
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
464
|
+
return this.httpClient.post(`/vault/${vaultAddress}/release-fees?network=${resolvedNetwork}`, releaseData);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Distribute accumulated vault fees to fee receiver (Manager role required)
|
|
468
|
+
* @param vaultAddress - The vault contract address
|
|
469
|
+
* @param distributeData - Distribution parameters including caller
|
|
470
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
471
|
+
* @returns Transaction XDR for Manager signing
|
|
472
|
+
* @example
|
|
473
|
+
* ```typescript
|
|
474
|
+
* const distributeData = {
|
|
475
|
+
* caller: 'GMANAGER...'
|
|
476
|
+
* };
|
|
477
|
+
* const response = await sdk.distributeVaultFees('CVAULT...', distributeData);
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
async distributeVaultFees(vaultAddress, distributeData, network) {
|
|
481
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
482
|
+
return this.httpClient.post(`/vault/${vaultAddress}/distribute-fees?network=${resolvedNetwork}`, distributeData);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Upgrade vault WASM contract (Manager role required)
|
|
486
|
+
* @param vaultAddress - The vault contract address
|
|
487
|
+
* @param newWasmHash - Upgrade parameters including new WASM hash and caller
|
|
488
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
489
|
+
* @returns Transaction XDR for Manager signing
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* const upgradeData = {
|
|
493
|
+
* caller: 'GMANAGER...',
|
|
494
|
+
* new_wasm_hash: 'abcd1234...' // New WASM hash to upgrade to
|
|
495
|
+
* };
|
|
496
|
+
* const response = await sdk.upgradeVaultWasm('CVAULT...', upgradeData);
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
async upgradeVaultWasm(vaultAddress, newWasmHash, network) {
|
|
500
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
501
|
+
return this.httpClient.post(`/vault/${vaultAddress}/upgrade?network=${resolvedNetwork}`, newWasmHash);
|
|
253
502
|
}
|
|
254
503
|
//=======================================================================
|
|
255
504
|
// Transaction Operations
|
|
@@ -257,13 +506,14 @@ class DefindexSDK {
|
|
|
257
506
|
/**
|
|
258
507
|
* Submit a signed transaction to the Stellar blockchain
|
|
259
508
|
* @param xdr - Base64 encoded signed transaction XDR
|
|
260
|
-
* @param network - Stellar network (
|
|
509
|
+
* @param network - Stellar network (optional, uses default if not specified)
|
|
261
510
|
* @param launchtube - Whether to use LaunchTube service (defaults to false)
|
|
262
511
|
* @returns Transaction response with hash and status
|
|
263
512
|
*/
|
|
264
513
|
async sendTransaction(xdr, network, launchtube) {
|
|
514
|
+
const resolvedNetwork = this.getNetwork(network);
|
|
265
515
|
const payload = { xdr, launchtube: launchtube ?? false };
|
|
266
|
-
return this.httpClient.post(`/send?network=${
|
|
516
|
+
return this.httpClient.post(`/send?network=${resolvedNetwork}`, payload);
|
|
267
517
|
}
|
|
268
518
|
}
|
|
269
519
|
exports.DefindexSDK = DefindexSDK;
|
package/dist/defindex-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defindex-sdk.js","sourceRoot":"","sources":["../src/defindex-sdk.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;
|
|
1
|
+
{"version":3,"file":"defindex-sdk.js","sourceRoot":"","sources":["../src/defindex-sdk.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AA6CnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,WAAW;IAKtB;;;OAGG;IACH,YAAY,MAAyB;QACnC,IA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CAAC,mBAAmB,CAC9B,YAAoB,EACpB,cAAoC,EACpC,OAA2B;QAE3B,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,UAAU,YAAY,4BAA4B,eAAe,EAAE,EACnE,cAAc,CACf,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,KAAK,CAAC,gBAAgB,CAC3B,YAAoB,EACpB,WAA8B,EAC9B,OAA2B;QAE3B,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,UAAU,YAAY,oBAAoB,eAAe,EAAE,EAC3D,WAAW,CACZ,CAAC;IACJ,CAAC;IAGD,yEAAyE;IACzE,yBAAyB;IACzB,yEAAyE;IAEzE;;;;;;OAMG;IACI,KAAK,CAAC,eAAe,CAC1B,GAAW,EACX,OAA2B,EAC3B,UAAoB;QAEpB,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,IAAI,KAAK,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,iBAAiB,eAAe,EAAE,EAClC,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AA5pBD,kCA4pBC"}
|
|
@@ -12,4 +12,75 @@ export interface CreateVaultDepositResponse extends BaseTransactionResponse {
|
|
|
12
12
|
export interface CreateDefindexVaultDepositDto extends CreateDefindexVault {
|
|
13
13
|
deposit_amounts: number[];
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Strategy allocation for auto-invest operations
|
|
17
|
+
*/
|
|
18
|
+
export interface StrategyAllocation {
|
|
19
|
+
/** Strategy contract address */
|
|
20
|
+
address: string;
|
|
21
|
+
/** Strategy name */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Amount to invest in this strategy (in stroops) */
|
|
24
|
+
amount: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Asset configuration with strategies for auto-invest
|
|
28
|
+
*/
|
|
29
|
+
export interface AssetAllocation {
|
|
30
|
+
/** Asset contract address */
|
|
31
|
+
address: string;
|
|
32
|
+
/** Asset symbol */
|
|
33
|
+
symbol: string;
|
|
34
|
+
/** Total amount to deposit for this asset (in stroops) */
|
|
35
|
+
amount: number;
|
|
36
|
+
/** Strategies for this asset with allocation amounts */
|
|
37
|
+
strategies: StrategyAllocation[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Vault roles configuration for auto-invest
|
|
41
|
+
*/
|
|
42
|
+
export interface VaultRolesConfig {
|
|
43
|
+
/** Emergency manager address */
|
|
44
|
+
emergencyManager: string;
|
|
45
|
+
/** Rebalance manager address */
|
|
46
|
+
rebalanceManager: string;
|
|
47
|
+
/** Fee receiver address */
|
|
48
|
+
feeReceiver: string;
|
|
49
|
+
/** Final vault manager address (will be set after auto-invest) */
|
|
50
|
+
manager: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Parameters for creating a vault with auto-invest
|
|
54
|
+
* Creates vault, deposits funds, and invests in strategies atomically
|
|
55
|
+
*/
|
|
56
|
+
export interface CreateVaultAutoInvestParams {
|
|
57
|
+
/** Caller address who will deposit and initially manage */
|
|
58
|
+
caller: string;
|
|
59
|
+
/** Vault roles configuration */
|
|
60
|
+
roles: VaultRolesConfig;
|
|
61
|
+
/** Vault name (1-32 characters) */
|
|
62
|
+
name: string;
|
|
63
|
+
/** Vault symbol (1-10 characters) */
|
|
64
|
+
symbol: string;
|
|
65
|
+
/** Vault fee in basis points (0-10000, where 10000 = 100%) */
|
|
66
|
+
vaultFee: number;
|
|
67
|
+
/** Whether vault is upgradable */
|
|
68
|
+
upgradable: boolean;
|
|
69
|
+
/** Asset allocations with strategies (1-10 assets) */
|
|
70
|
+
assets: AssetAllocation[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Response from creating a vault with auto-invest
|
|
74
|
+
*/
|
|
75
|
+
export interface CreateVaultAutoInvestResponse {
|
|
76
|
+
/** Transaction XDR to sign and submit */
|
|
77
|
+
xdr: string;
|
|
78
|
+
/**
|
|
79
|
+
* Predicted vault address from simulation.
|
|
80
|
+
* Note: actual address may differ if network state changes between simulation and execution.
|
|
81
|
+
*/
|
|
82
|
+
predictedVaultAddress: string;
|
|
83
|
+
/** Warning about address prediction reliability */
|
|
84
|
+
warning?: string;
|
|
85
|
+
}
|
|
15
86
|
//# sourceMappingURL=factory.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.types.d.ts","sourceRoot":"","sources":["../../src/types/factory.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IACzE,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED,MAAM,WAAW,6BAA8B,SAAQ,mBAAmB;IACxE,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B"}
|
|
1
|
+
{"version":3,"file":"factory.types.d.ts","sourceRoot":"","sources":["../../src/types/factory.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;I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AA6B;IAC5C,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
|