@defindex/sdk 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 +402 -0
- package/dist/clients/http-client.d.ts +21 -0
- package/dist/clients/http-client.d.ts.map +1 -0
- package/dist/clients/http-client.js +75 -0
- package/dist/clients/http-client.js.map +1 -0
- package/dist/defindex-sdk.d.ts +230 -0
- package/dist/defindex-sdk.d.ts.map +1 -0
- package/dist/defindex-sdk.js +270 -0
- package/dist/defindex-sdk.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/types/auth.types.d.ts +82 -0
- package/dist/types/auth.types.d.ts.map +1 -0
- package/dist/types/auth.types.js +4 -0
- package/dist/types/auth.types.js.map +1 -0
- package/dist/types/base.types.d.ts +12 -0
- package/dist/types/base.types.d.ts.map +1 -0
- package/dist/types/base.types.js +3 -0
- package/dist/types/base.types.js.map +1 -0
- package/dist/types/error.types.d.ts +123 -0
- package/dist/types/error.types.d.ts.map +1 -0
- package/dist/types/error.types.js +68 -0
- package/dist/types/error.types.js.map +1 -0
- package/dist/types/factory.types.d.ts +15 -0
- package/dist/types/factory.types.d.ts.map +1 -0
- package/dist/types/factory.types.js +3 -0
- package/dist/types/factory.types.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +24 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/network.types.d.ts +5 -0
- package/dist/types/network.types.d.ts.map +1 -0
- package/dist/types/network.types.js +10 -0
- package/dist/types/network.types.js.map +1 -0
- package/dist/types/stellar.types.d.ts +29 -0
- package/dist/types/stellar.types.d.ts.map +1 -0
- package/dist/types/stellar.types.js +3 -0
- package/dist/types/stellar.types.js.map +1 -0
- package/dist/types/vault.types.d.ts +253 -0
- package/dist/types/vault.types.d.ts.map +1 -0
- package/dist/types/vault.types.js +3 -0
- package/dist/types/vault.types.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { CreateDefindexVault, CreateDefindexVaultDepositDto, CreateVaultDepositResponse, CreateVaultResponse, DepositToVaultParams, FactoryAddressResponse, PauseStrategyParams, RescueFromVaultParams, StellarSendTransactionResponse, SupportedNetworks, UnpauseStrategyParams, VaultApyResponse, VaultBalanceResponse, VaultInfoResponse, VaultRescueResponse, VaultStrategyStatusResponse, VaultTransactionResponse, WithdrawFromVaultParams, WithdrawSharesParams } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the DeFindex SDK
|
|
4
|
+
*/
|
|
5
|
+
export interface DefindexSDKConfig {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/** Custom API base URL (defaults to 'https://api.defindex.io') */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Request timeout in milliseconds (defaults to 30000) */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* DeFindex SDK - TypeScript client for DeFindex API
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Basic initialization
|
|
18
|
+
* const sdk = new DefindexSDK({
|
|
19
|
+
* baseUrl: 'https://api.defindex.io'
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // With API key authentication
|
|
23
|
+
* const sdk = new DefindexSDK({
|
|
24
|
+
* apiKey: 'sk_your_api_key_here',
|
|
25
|
+
* baseUrl: 'https://api.defindex.io'
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class DefindexSDK {
|
|
30
|
+
private httpClient;
|
|
31
|
+
private config;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new DeFindex SDK instance
|
|
34
|
+
* @param config - SDK configuration options
|
|
35
|
+
*/
|
|
36
|
+
constructor(config: DefindexSDKConfig);
|
|
37
|
+
/**
|
|
38
|
+
* Check API health status
|
|
39
|
+
* @returns Health status information
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const health = await sdk.healthCheck();
|
|
43
|
+
* if (health.status.reachable) {
|
|
44
|
+
* console.log('API is healthy');
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
healthCheck(): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Get the factory contract address for a specific network
|
|
51
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
52
|
+
* @returns Factory contract address
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const factory = await sdk.getFactoryAddress(SupportedNetworks.TESTNET);
|
|
56
|
+
* console.log('Factory address:', factory.address);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
getFactoryAddress(network: SupportedNetworks): Promise<FactoryAddressResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new vault (requires Vault Manager role)
|
|
62
|
+
* @param vaultConfig - Vault configuration including assets, fees, and roles
|
|
63
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
64
|
+
* @returns Transaction XDR for vault creation
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const vaultConfig = {
|
|
68
|
+
* roles: { "0": "GMANAGER...", "1": "CFEE..." },
|
|
69
|
+
* vault_fee_bps: 100, // 1%
|
|
70
|
+
* assets: [{ address: "CASSET...", strategies: [...] }],
|
|
71
|
+
* name_symbol: { name: "My Vault", symbol: "MVLT" },
|
|
72
|
+
* upgradable: true,
|
|
73
|
+
* caller: "GCALLER..."
|
|
74
|
+
* };
|
|
75
|
+
* const response = await sdk.createVault(vaultConfig, SupportedNetworks.TESTNET);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
createVault(vaultConfig: CreateDefindexVault, network: SupportedNetworks): Promise<CreateVaultResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Create a new vault with initial deposit in a single transaction
|
|
81
|
+
* @param vaultConfig - Vault configuration with initial deposit amounts
|
|
82
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
83
|
+
* @returns Transaction XDR for vault creation and deposit
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const vaultConfig = {
|
|
87
|
+
* // ... vault config
|
|
88
|
+
* deposit_amounts: [1000000, 2000000] // Initial deposit amounts
|
|
89
|
+
* };
|
|
90
|
+
* const response = await sdk.createVaultWithDeposit(vaultConfig, SupportedNetworks.TESTNET);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
createVaultWithDeposit(vaultConfig: CreateDefindexVaultDepositDto, network: SupportedNetworks): Promise<CreateVaultDepositResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Get comprehensive vault information
|
|
96
|
+
* @param vaultAddress - The vault contract address
|
|
97
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
98
|
+
* @returns Vault metadata, assets, strategies, and TVL information
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const vaultInfo = await sdk.getVaultInfo(
|
|
102
|
+
* 'GVAULT...',
|
|
103
|
+
* SupportedNetworks.TESTNET
|
|
104
|
+
* );
|
|
105
|
+
* console.log(`Vault: ${vaultInfo.name} (${vaultInfo.symbol})`);
|
|
106
|
+
* console.log(`Total Assets: ${vaultInfo.totalAssets}`);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
getVaultInfo(vaultAddress: string, network: SupportedNetworks): Promise<VaultInfoResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Get user's vault balance and shares
|
|
112
|
+
* @param vaultAddress - The vault contract address
|
|
113
|
+
* @param userAddress - User's wallet address
|
|
114
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
115
|
+
* @returns User's vault shares and underlying asset values
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const balance = await sdk.getVaultBalance(
|
|
119
|
+
* 'GVAULT...',
|
|
120
|
+
* 'GUSER...',
|
|
121
|
+
* SupportedNetworks.TESTNET
|
|
122
|
+
* );
|
|
123
|
+
* console.log(`Shares: ${balance.dfTokens}`);
|
|
124
|
+
* console.log(`Underlying values: ${balance.underlyingBalance}`);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
getVaultBalance(vaultAddress: string, userAddress: string, network: SupportedNetworks): Promise<VaultBalanceResponse>;
|
|
128
|
+
/**
|
|
129
|
+
* Deposit assets into a vault
|
|
130
|
+
* @param vaultAddress - The vault contract address
|
|
131
|
+
* @param depositData - Deposit parameters including amounts and caller address
|
|
132
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
133
|
+
* @returns Transaction XDR for signing and simulation response
|
|
134
|
+
*/
|
|
135
|
+
depositToVault(vaultAddress: string, depositData: DepositToVaultParams, network: SupportedNetworks): Promise<VaultTransactionResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Withdraw specific asset amounts from vault
|
|
138
|
+
* @param vaultAddress - The vault contract address
|
|
139
|
+
* @param withdrawData - Withdrawal parameters including amounts and caller
|
|
140
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
141
|
+
* @returns Transaction XDR for signing and simulation response
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const withdrawData = {
|
|
145
|
+
* amounts: [500000, 1000000],
|
|
146
|
+
* caller: 'GUSER...',
|
|
147
|
+
* slippageBps: 100 // 1% slippage tolerance
|
|
148
|
+
* };
|
|
149
|
+
* const response = await sdk.withdrawFromVault('GVAULT...', withdrawData, SupportedNetworks.TESTNET);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
withdrawFromVault(vaultAddress: string, withdrawData: WithdrawFromVaultParams, network: SupportedNetworks): Promise<VaultTransactionResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Withdraw vault shares for underlying assets
|
|
155
|
+
* @param vaultAddress - The vault contract address
|
|
156
|
+
* @param shareData - Share withdrawal parameters including share amount and caller
|
|
157
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
158
|
+
* @returns Transaction XDR for signing and simulation response
|
|
159
|
+
*/
|
|
160
|
+
withdrawShares(vaultAddress: string, shareData: WithdrawSharesParams, network: SupportedNetworks): Promise<VaultTransactionResponse>;
|
|
161
|
+
/**
|
|
162
|
+
* Get vault's Annual Percentage Yield (APY)
|
|
163
|
+
* @param vaultAddress - The vault contract address
|
|
164
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
165
|
+
* @returns APY information including percentage and calculation period
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const apy = await sdk.getVaultAPY('GVAULT...', SupportedNetworks.TESTNET);
|
|
169
|
+
* console.log(`APY: ${apy.apyPercent}% (calculated over ${apy.period})`);
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
getVaultAPY(vaultAddress: string, network: SupportedNetworks): Promise<VaultApyResponse>;
|
|
173
|
+
/**
|
|
174
|
+
* Emergency rescue assets from strategy (Emergency Manager role required)
|
|
175
|
+
* @param vaultAddress - The vault contract address
|
|
176
|
+
* @param rescueData - Rescue parameters including strategy address and caller
|
|
177
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
178
|
+
* @returns Transaction XDR for Emergency Manager signing and rescued assets info
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const rescueData = {
|
|
182
|
+
* strategy_address: 'GSTRATEGY...',
|
|
183
|
+
* caller: 'GEMERGENCY_MANAGER...'
|
|
184
|
+
* };
|
|
185
|
+
* const response = await sdk.emergencyRescue('GVAULT...', rescueData, SupportedNetworks.TESTNET);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
emergencyRescue(vaultAddress: string, rescueData: RescueFromVaultParams, network: SupportedNetworks): Promise<VaultRescueResponse>;
|
|
189
|
+
/**
|
|
190
|
+
* Pause a specific strategy (Strategy Manager role required)
|
|
191
|
+
* @param vaultAddress - The vault contract address
|
|
192
|
+
* @param strategyData - Strategy pause parameters
|
|
193
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
194
|
+
* @returns Transaction XDR for Strategy Manager signing
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const strategyData = {
|
|
198
|
+
* strategy_address: 'GSTRATEGY...',
|
|
199
|
+
* caller: 'GSTRATEGY_MANAGER...'
|
|
200
|
+
* };
|
|
201
|
+
* const response = await sdk.pauseStrategy('GVAULT...', strategyData, SupportedNetworks.TESTNET);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
pauseStrategy(vaultAddress: string, strategyData: PauseStrategyParams, network: SupportedNetworks): Promise<VaultStrategyStatusResponse>;
|
|
205
|
+
/**
|
|
206
|
+
* Unpause a specific strategy (Strategy Manager role required)
|
|
207
|
+
* @param vaultAddress - The vault contract address
|
|
208
|
+
* @param strategyData - Strategy unpause parameters
|
|
209
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
210
|
+
* @returns Transaction XDR for Strategy Manager signing
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const strategyData = {
|
|
214
|
+
* strategy_address: 'GSTRATEGY...',
|
|
215
|
+
* caller: 'GSTRATEGY_MANAGER...'
|
|
216
|
+
* };
|
|
217
|
+
* const response = await sdk.unpauseStrategy('GVAULT...', strategyData, SupportedNetworks.TESTNET);
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
unpauseStrategy(vaultAddress: string, strategyData: UnpauseStrategyParams, network: SupportedNetworks): Promise<VaultStrategyStatusResponse>;
|
|
221
|
+
/**
|
|
222
|
+
* Submit a signed transaction to the Stellar blockchain
|
|
223
|
+
* @param xdr - Base64 encoded signed transaction XDR
|
|
224
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
225
|
+
* @param launchtube - Whether to use LaunchTube service (defaults to false)
|
|
226
|
+
* @returns Transaction response with hash and status
|
|
227
|
+
*/
|
|
228
|
+
sendTransaction(xdr: string, network: SupportedNetworks, launchtube?: boolean): Promise<StellarSendTransactionResponse>;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=defindex-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defindex-sdk.d.ts","sourceRoot":"","sources":["../src/defindex-sdk.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,8BAA8B,EAC9B,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAoB;IAElC;;;OAGG;gBACS,MAAM,EAAE,iBAAiB;IAarC;;;;;;;;;;OAUG;IACU,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAQxC;;;;;;;;;OASG;IACU,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAI3F;;;;;;;;;;;;;;;;;OAiBG;IACU,WAAW,CACtB,WAAW,EAAE,mBAAmB,EAChC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,mBAAmB,CAAC;IAO/B;;;;;;;;;;;;;OAaG;IACU,sBAAsB,CACjC,WAAW,EAAE,6BAA6B,EAC1C,OAAO,EAAE,iBAAiB,GACz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EAAE,qBAAqB,EACnC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,2BAA2B,CAAC;IAWvC;;;;;;OAMG;IACU,eAAe,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,iBAAiB,EAC1B,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,8BAA8B,CAAC;CAO3C"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefindexSDK = void 0;
|
|
4
|
+
const http_client_1 = require("./clients/http-client");
|
|
5
|
+
/**
|
|
6
|
+
* DeFindex SDK - TypeScript client for DeFindex API
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Basic initialization
|
|
11
|
+
* const sdk = new DefindexSDK({
|
|
12
|
+
* baseUrl: 'https://api.defindex.io'
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // With API key authentication
|
|
16
|
+
* const sdk = new DefindexSDK({
|
|
17
|
+
* apiKey: 'sk_your_api_key_here',
|
|
18
|
+
* baseUrl: 'https://api.defindex.io'
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
class DefindexSDK {
|
|
23
|
+
/**
|
|
24
|
+
* Create a new DeFindex SDK instance
|
|
25
|
+
* @param config - SDK configuration options
|
|
26
|
+
*/
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.httpClient = new http_client_1.HttpClient(config.baseUrl || 'https://api.defindex.io', config.apiKey || '', // API key or empty string
|
|
30
|
+
config.timeout || 30000);
|
|
31
|
+
}
|
|
32
|
+
//=======================================================================
|
|
33
|
+
// System Operations
|
|
34
|
+
//=======================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Check API health status
|
|
37
|
+
* @returns Health status information
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const health = await sdk.healthCheck();
|
|
41
|
+
* if (health.status.reachable) {
|
|
42
|
+
* console.log('API is healthy');
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
async healthCheck() {
|
|
47
|
+
return this.httpClient.get('/health');
|
|
48
|
+
}
|
|
49
|
+
//=======================================================================
|
|
50
|
+
// Factory Operations
|
|
51
|
+
//=======================================================================
|
|
52
|
+
/**
|
|
53
|
+
* Get the factory contract address for a specific network
|
|
54
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
55
|
+
* @returns Factory contract address
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const factory = await sdk.getFactoryAddress(SupportedNetworks.TESTNET);
|
|
59
|
+
* console.log('Factory address:', factory.address);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
async getFactoryAddress(network) {
|
|
63
|
+
return this.httpClient.get(`/factory/address?network=${network}`);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a new vault (requires Vault Manager role)
|
|
67
|
+
* @param vaultConfig - Vault configuration including assets, fees, and roles
|
|
68
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
69
|
+
* @returns Transaction XDR for vault creation
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const vaultConfig = {
|
|
73
|
+
* roles: { "0": "GMANAGER...", "1": "CFEE..." },
|
|
74
|
+
* vault_fee_bps: 100, // 1%
|
|
75
|
+
* assets: [{ address: "CASSET...", strategies: [...] }],
|
|
76
|
+
* name_symbol: { name: "My Vault", symbol: "MVLT" },
|
|
77
|
+
* upgradable: true,
|
|
78
|
+
* caller: "GCALLER..."
|
|
79
|
+
* };
|
|
80
|
+
* const response = await sdk.createVault(vaultConfig, SupportedNetworks.TESTNET);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
async createVault(vaultConfig, network) {
|
|
84
|
+
return this.httpClient.post(`/factory/create-vault?network=${network}`, vaultConfig);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a new vault with initial deposit in a single transaction
|
|
88
|
+
* @param vaultConfig - Vault configuration with initial deposit amounts
|
|
89
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
90
|
+
* @returns Transaction XDR for vault creation and deposit
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const vaultConfig = {
|
|
94
|
+
* // ... vault config
|
|
95
|
+
* deposit_amounts: [1000000, 2000000] // Initial deposit amounts
|
|
96
|
+
* };
|
|
97
|
+
* const response = await sdk.createVaultWithDeposit(vaultConfig, SupportedNetworks.TESTNET);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
async createVaultWithDeposit(vaultConfig, network) {
|
|
101
|
+
return this.httpClient.post(`/factory/create-vault-deposit?network=${network}`, vaultConfig);
|
|
102
|
+
}
|
|
103
|
+
//=======================================================================
|
|
104
|
+
// Vault Operations
|
|
105
|
+
//=======================================================================
|
|
106
|
+
/**
|
|
107
|
+
* Get comprehensive vault information
|
|
108
|
+
* @param vaultAddress - The vault contract address
|
|
109
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
110
|
+
* @returns Vault metadata, assets, strategies, and TVL information
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const vaultInfo = await sdk.getVaultInfo(
|
|
114
|
+
* 'GVAULT...',
|
|
115
|
+
* SupportedNetworks.TESTNET
|
|
116
|
+
* );
|
|
117
|
+
* console.log(`Vault: ${vaultInfo.name} (${vaultInfo.symbol})`);
|
|
118
|
+
* console.log(`Total Assets: ${vaultInfo.totalAssets}`);
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
async getVaultInfo(vaultAddress, network) {
|
|
122
|
+
return this.httpClient.get(`/vault/${vaultAddress}?network=${network}`);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get user's vault balance and shares
|
|
126
|
+
* @param vaultAddress - The vault contract address
|
|
127
|
+
* @param userAddress - User's wallet address
|
|
128
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
129
|
+
* @returns User's vault shares and underlying asset values
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const balance = await sdk.getVaultBalance(
|
|
133
|
+
* 'GVAULT...',
|
|
134
|
+
* 'GUSER...',
|
|
135
|
+
* SupportedNetworks.TESTNET
|
|
136
|
+
* );
|
|
137
|
+
* console.log(`Shares: ${balance.dfTokens}`);
|
|
138
|
+
* console.log(`Underlying values: ${balance.underlyingBalance}`);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
async getVaultBalance(vaultAddress, userAddress, network) {
|
|
142
|
+
return this.httpClient.get(`/vault/${vaultAddress}/balance?from=${userAddress}&network=${network}`);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Deposit assets into a vault
|
|
146
|
+
* @param vaultAddress - The vault contract address
|
|
147
|
+
* @param depositData - Deposit parameters including amounts and caller address
|
|
148
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
149
|
+
* @returns Transaction XDR for signing and simulation response
|
|
150
|
+
*/
|
|
151
|
+
async depositToVault(vaultAddress, depositData, network) {
|
|
152
|
+
return this.httpClient.post(`/vault/${vaultAddress}/deposit?network=${network}`, depositData);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Withdraw specific asset amounts from vault
|
|
156
|
+
* @param vaultAddress - The vault contract address
|
|
157
|
+
* @param withdrawData - Withdrawal parameters including amounts and caller
|
|
158
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
159
|
+
* @returns Transaction XDR for signing and simulation response
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const withdrawData = {
|
|
163
|
+
* amounts: [500000, 1000000],
|
|
164
|
+
* caller: 'GUSER...',
|
|
165
|
+
* slippageBps: 100 // 1% slippage tolerance
|
|
166
|
+
* };
|
|
167
|
+
* const response = await sdk.withdrawFromVault('GVAULT...', withdrawData, SupportedNetworks.TESTNET);
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
async withdrawFromVault(vaultAddress, withdrawData, network) {
|
|
171
|
+
return this.httpClient.post(`/vault/${vaultAddress}/withdraw?network=${network}`, withdrawData);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Withdraw vault shares for underlying assets
|
|
175
|
+
* @param vaultAddress - The vault contract address
|
|
176
|
+
* @param shareData - Share withdrawal parameters including share amount and caller
|
|
177
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
178
|
+
* @returns Transaction XDR for signing and simulation response
|
|
179
|
+
*/
|
|
180
|
+
async withdrawShares(vaultAddress, shareData, network) {
|
|
181
|
+
return this.httpClient.post(`/vault/${vaultAddress}/withdraw-shares?network=${network}`, shareData);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get vault's Annual Percentage Yield (APY)
|
|
185
|
+
* @param vaultAddress - The vault contract address
|
|
186
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
187
|
+
* @returns APY information including percentage and calculation period
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const apy = await sdk.getVaultAPY('GVAULT...', SupportedNetworks.TESTNET);
|
|
191
|
+
* console.log(`APY: ${apy.apyPercent}% (calculated over ${apy.period})`);
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
async getVaultAPY(vaultAddress, network) {
|
|
195
|
+
return this.httpClient.get(`/vault/${vaultAddress}/apy?network=${network}`);
|
|
196
|
+
}
|
|
197
|
+
//=======================================================================
|
|
198
|
+
// Vault Management Operations
|
|
199
|
+
//=======================================================================
|
|
200
|
+
/**
|
|
201
|
+
* Emergency rescue assets from strategy (Emergency Manager role required)
|
|
202
|
+
* @param vaultAddress - The vault contract address
|
|
203
|
+
* @param rescueData - Rescue parameters including strategy address and caller
|
|
204
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
205
|
+
* @returns Transaction XDR for Emergency Manager signing and rescued assets info
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const rescueData = {
|
|
209
|
+
* strategy_address: 'GSTRATEGY...',
|
|
210
|
+
* caller: 'GEMERGENCY_MANAGER...'
|
|
211
|
+
* };
|
|
212
|
+
* const response = await sdk.emergencyRescue('GVAULT...', rescueData, SupportedNetworks.TESTNET);
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
async emergencyRescue(vaultAddress, rescueData, network) {
|
|
216
|
+
return this.httpClient.post(`/vault/${vaultAddress}/rescue?network=${network}`, rescueData);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Pause a specific strategy (Strategy Manager role required)
|
|
220
|
+
* @param vaultAddress - The vault contract address
|
|
221
|
+
* @param strategyData - Strategy pause parameters
|
|
222
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
223
|
+
* @returns Transaction XDR for Strategy Manager signing
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const strategyData = {
|
|
227
|
+
* strategy_address: 'GSTRATEGY...',
|
|
228
|
+
* caller: 'GSTRATEGY_MANAGER...'
|
|
229
|
+
* };
|
|
230
|
+
* const response = await sdk.pauseStrategy('GVAULT...', strategyData, SupportedNetworks.TESTNET);
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
async pauseStrategy(vaultAddress, strategyData, network) {
|
|
234
|
+
return this.httpClient.post(`/vault/${vaultAddress}/pause-strategy?network=${network}`, strategyData);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Unpause a specific strategy (Strategy Manager role required)
|
|
238
|
+
* @param vaultAddress - The vault contract address
|
|
239
|
+
* @param strategyData - Strategy unpause parameters
|
|
240
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
241
|
+
* @returns Transaction XDR for Strategy Manager signing
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* const strategyData = {
|
|
245
|
+
* strategy_address: 'GSTRATEGY...',
|
|
246
|
+
* caller: 'GSTRATEGY_MANAGER...'
|
|
247
|
+
* };
|
|
248
|
+
* const response = await sdk.unpauseStrategy('GVAULT...', strategyData, SupportedNetworks.TESTNET);
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
async unpauseStrategy(vaultAddress, strategyData, network) {
|
|
252
|
+
return this.httpClient.post(`/vault/${vaultAddress}/unpause-strategy?network=${network}`, strategyData);
|
|
253
|
+
}
|
|
254
|
+
//=======================================================================
|
|
255
|
+
// Transaction Operations
|
|
256
|
+
//=======================================================================
|
|
257
|
+
/**
|
|
258
|
+
* Submit a signed transaction to the Stellar blockchain
|
|
259
|
+
* @param xdr - Base64 encoded signed transaction XDR
|
|
260
|
+
* @param network - Stellar network (testnet or mainnet)
|
|
261
|
+
* @param launchtube - Whether to use LaunchTube service (defaults to false)
|
|
262
|
+
* @returns Transaction response with hash and status
|
|
263
|
+
*/
|
|
264
|
+
async sendTransaction(xdr, network, launchtube) {
|
|
265
|
+
const payload = { xdr, launchtube: launchtube ?? false };
|
|
266
|
+
return this.httpClient.post(`/send?network=${network}`, payload);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.DefindexSDK = DefindexSDK;
|
|
270
|
+
//# sourceMappingURL=defindex-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defindex-sdk.js","sourceRoot":"","sources":["../src/defindex-sdk.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAkCnD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,WAAW;IAItB;;;OAGG;IACH,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,CAC9B,MAAM,CAAC,OAAO,IAAI,yBAAyB,EAC3C,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,0BAA0B;QAC/C,MAAM,CAAC,OAAO,IAAI,KAAK,CACxB,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I,KAAK,CAAC,eAAe,CAC1B,YAAoB,EACpB,YAAmC,EACnC,OAA0B;QAE1B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,UAAU,YAAY,6BAA6B,OAAO,EAAE,EAC5D,YAAY,CACb,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,yBAAyB;IACzB,yEAAyE;IAEzE;;;;;;OAMG;IACI,KAAK,CAAC,eAAe,CAC1B,GAAW,EACX,OAA0B,EAC1B,UAAoB;QAEpB,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,IAAI,KAAK,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,iBAAiB,OAAO,EAAE,EAC1B,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AA5VD,kCA4VC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,eAAe,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.HttpClient = exports.DefindexSDK = void 0;
|
|
18
|
+
// Main SDK class
|
|
19
|
+
var defindex_sdk_1 = require("./defindex-sdk");
|
|
20
|
+
Object.defineProperty(exports, "DefindexSDK", { enumerable: true, get: function () { return defindex_sdk_1.DefindexSDK; } });
|
|
21
|
+
// Export all types for TypeScript users
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
// Export utility classes that might be useful
|
|
24
|
+
var http_client_1 = require("./clients/http-client");
|
|
25
|
+
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_client_1.HttpClient; } });
|
|
26
|
+
// Default export is the main SDK class
|
|
27
|
+
const defindex_sdk_2 = require("./defindex-sdk");
|
|
28
|
+
exports.default = defindex_sdk_2.DefindexSDK;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iBAAiB;AACjB,+CAAgE;AAAvD,2GAAA,WAAW,OAAA;AAEpB,wCAAwC;AACxC,0CAAwB;AAExB,8CAA8C;AAC9C,qDAAmD;AAA1C,yGAAA,UAAU,OAAA;AAEnB,uCAAuC;AACvC,iDAA6C;AAC7C,kBAAe,0BAAW,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export interface BaseTokenResponse {
|
|
2
|
+
username: string;
|
|
3
|
+
role: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RegisterParams {
|
|
6
|
+
email: string;
|
|
7
|
+
password: string;
|
|
8
|
+
username: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LoginParams {
|
|
11
|
+
email: string;
|
|
12
|
+
password: string;
|
|
13
|
+
}
|
|
14
|
+
export interface RefreshParams {
|
|
15
|
+
refreshToken: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RegisterResponse {
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export interface LoginResponse extends BaseTokenResponse {
|
|
21
|
+
accessToken: string;
|
|
22
|
+
refreshToken: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RefreshResponse extends LoginResponse {
|
|
25
|
+
}
|
|
26
|
+
export interface AuthLoginResponse extends BaseTokenResponse {
|
|
27
|
+
access_token: string;
|
|
28
|
+
refresh_token: string;
|
|
29
|
+
}
|
|
30
|
+
export interface AuthRefreshResponse extends AuthLoginResponse {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* API key generation request parameters
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const keyRequest: ApiKeyGenerateRequest = {
|
|
37
|
+
* name: 'Production API Key'
|
|
38
|
+
* };
|
|
39
|
+
* const apiKey = await sdk.generateApiKey(keyRequest);
|
|
40
|
+
* console.log('New API key:', apiKey.key);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export interface ApiKeyGenerateRequest {
|
|
44
|
+
/** Optional descriptive name for the API key */
|
|
45
|
+
name?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ApiKeyGenerateResponse {
|
|
48
|
+
key: string;
|
|
49
|
+
id: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* API key information
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const apiKeys = await sdk.getUserApiKeys();
|
|
56
|
+
* apiKeys.forEach(key => {
|
|
57
|
+
* console.log(`ID: ${key.id}, Name: ${key.name || 'Unnamed'}`);
|
|
58
|
+
* console.log(`Created: ${key.createdAt}`);
|
|
59
|
+
* console.log(`Last used: ${key.lastUsedAt || 'Never'}`);
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export interface ApiKeyInfo {
|
|
64
|
+
/** Unique API key identifier */
|
|
65
|
+
id: number;
|
|
66
|
+
/** Optional descriptive name */
|
|
67
|
+
name?: string;
|
|
68
|
+
/** The actual API key string (truncated in list responses) */
|
|
69
|
+
key: string;
|
|
70
|
+
/** ISO timestamp when the key was created */
|
|
71
|
+
createdAt: string;
|
|
72
|
+
/** ISO timestamp when the key was last used (if ever) */
|
|
73
|
+
lastUsedAt?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ApiKeyRevokeRequest {
|
|
76
|
+
keyId: number;
|
|
77
|
+
}
|
|
78
|
+
export interface ApiKeyRevokeResponse {
|
|
79
|
+
success: boolean;
|
|
80
|
+
}
|
|
81
|
+
export type GetUserApiKeysResponse = ApiKeyInfo[];
|
|
82
|
+
//# sourceMappingURL=auth.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.types.d.ts","sourceRoot":"","sources":["../../src/types/auth.types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAGD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;CAAG;AAGzD,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;CAAG;AAGjE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAU;IACzB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.types.js","sourceRoot":"","sources":["../../src/types/auth.types.ts"],"names":[],"mappings":";AAEA,qCAAqC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface BaseTransactionResponse {
|
|
2
|
+
xdr: string | null;
|
|
3
|
+
simulation_result: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BaseVaultTransactionResponse {
|
|
7
|
+
xdr: string;
|
|
8
|
+
simulationResponse: any;
|
|
9
|
+
functionName: string;
|
|
10
|
+
params: any[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=base.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.types.d.ts","sourceRoot":"","sources":["../../src/types/base.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,kBAAkB,EAAE,GAAG,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,GAAG,EAAE,CAAC;CACf"}
|