@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.
Files changed (46) hide show
  1. package/README.md +402 -0
  2. package/dist/clients/http-client.d.ts +21 -0
  3. package/dist/clients/http-client.d.ts.map +1 -0
  4. package/dist/clients/http-client.js +75 -0
  5. package/dist/clients/http-client.js.map +1 -0
  6. package/dist/defindex-sdk.d.ts +230 -0
  7. package/dist/defindex-sdk.d.ts.map +1 -0
  8. package/dist/defindex-sdk.js +270 -0
  9. package/dist/defindex-sdk.js.map +1 -0
  10. package/dist/index.d.ts +6 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +29 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/types/auth.types.d.ts +82 -0
  15. package/dist/types/auth.types.d.ts.map +1 -0
  16. package/dist/types/auth.types.js +4 -0
  17. package/dist/types/auth.types.js.map +1 -0
  18. package/dist/types/base.types.d.ts +12 -0
  19. package/dist/types/base.types.d.ts.map +1 -0
  20. package/dist/types/base.types.js +3 -0
  21. package/dist/types/base.types.js.map +1 -0
  22. package/dist/types/error.types.d.ts +123 -0
  23. package/dist/types/error.types.d.ts.map +1 -0
  24. package/dist/types/error.types.js +68 -0
  25. package/dist/types/error.types.js.map +1 -0
  26. package/dist/types/factory.types.d.ts +15 -0
  27. package/dist/types/factory.types.d.ts.map +1 -0
  28. package/dist/types/factory.types.js +3 -0
  29. package/dist/types/factory.types.js.map +1 -0
  30. package/dist/types/index.d.ts +7 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/index.js +24 -0
  33. package/dist/types/index.js.map +1 -0
  34. package/dist/types/network.types.d.ts +5 -0
  35. package/dist/types/network.types.d.ts.map +1 -0
  36. package/dist/types/network.types.js +10 -0
  37. package/dist/types/network.types.js.map +1 -0
  38. package/dist/types/stellar.types.d.ts +29 -0
  39. package/dist/types/stellar.types.d.ts.map +1 -0
  40. package/dist/types/stellar.types.js +3 -0
  41. package/dist/types/stellar.types.js.map +1 -0
  42. package/dist/types/vault.types.d.ts +253 -0
  43. package/dist/types/vault.types.d.ts.map +1 -0
  44. package/dist/types/vault.types.js +3 -0
  45. package/dist/types/vault.types.js.map +1 -0
  46. package/package.json +72 -0
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=base.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.types.js","sourceRoot":"","sources":["../../src/types/base.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Error types for DeFindex SDK
3
+ */
4
+ /**
5
+ * Base API error interface
6
+ */
7
+ export interface BaseApiError {
8
+ /** Error message */
9
+ message: string;
10
+ /** HTTP status code */
11
+ statusCode: number;
12
+ /** Error timestamp */
13
+ timestamp?: string;
14
+ /** Request path that caused the error */
15
+ path?: string;
16
+ }
17
+ /**
18
+ * Authentication related errors
19
+ */
20
+ export interface AuthError extends BaseApiError {
21
+ /** Error type identifier */
22
+ error: 'Unauthorized' | 'Forbidden' | 'TokenExpired' | 'InvalidCredentials';
23
+ }
24
+ /**
25
+ * Validation related errors
26
+ */
27
+ export interface ValidationError extends BaseApiError {
28
+ /** Error type identifier */
29
+ error: 'BadRequest' | 'ValidationFailed';
30
+ /** Detailed validation errors by field */
31
+ details?: {
32
+ field: string;
33
+ message: string;
34
+ value?: any;
35
+ }[];
36
+ }
37
+ /**
38
+ * Network/blockchain related errors
39
+ */
40
+ export interface NetworkError extends BaseApiError {
41
+ /** Error type identifier */
42
+ error: 'NetworkError' | 'TransactionFailed' | 'ContractError';
43
+ /** Network-specific error details */
44
+ networkDetails?: {
45
+ /** Stellar error code */
46
+ stellarErrorCode?: string;
47
+ /** Transaction result XDR */
48
+ resultXdr?: string;
49
+ /** Additional network context */
50
+ context?: string;
51
+ };
52
+ }
53
+ /**
54
+ * Resource not found errors
55
+ */
56
+ export interface NotFoundError extends BaseApiError {
57
+ /** Error type identifier */
58
+ error: 'NotFound';
59
+ /** Resource that was not found */
60
+ resource?: string;
61
+ }
62
+ /**
63
+ * Rate limiting errors
64
+ */
65
+ export interface RateLimitError extends BaseApiError {
66
+ /** Error type identifier */
67
+ error: 'TooManyRequests';
68
+ /** When the rate limit resets */
69
+ retryAfter?: number;
70
+ /** Current rate limit */
71
+ rateLimit?: {
72
+ limit: number;
73
+ remaining: number;
74
+ reset: number;
75
+ };
76
+ }
77
+ /**
78
+ * Internal server errors
79
+ */
80
+ export interface ServerError extends BaseApiError {
81
+ /** Error type identifier */
82
+ error: 'InternalServerError' | 'ServiceUnavailable' | 'BadGateway';
83
+ /** Internal error reference ID */
84
+ errorId?: string;
85
+ }
86
+ /**
87
+ * Union type for all possible API errors
88
+ */
89
+ export type ApiError = AuthError | ValidationError | NetworkError | NotFoundError | RateLimitError | ServerError;
90
+ /**
91
+ * Type guard to check if an error is an API error
92
+ */
93
+ export declare function isApiError(error: any): error is ApiError;
94
+ /**
95
+ * Type guard to check if an error is an authentication error
96
+ */
97
+ export declare function isAuthError(error: any): error is AuthError;
98
+ /**
99
+ * Type guard to check if an error is a validation error
100
+ */
101
+ export declare function isValidationError(error: any): error is ValidationError;
102
+ /**
103
+ * Type guard to check if an error is a network/blockchain error
104
+ */
105
+ export declare function isNetworkError(error: any): error is NetworkError;
106
+ /**
107
+ * Type guard to check if an error is a rate limit error
108
+ */
109
+ export declare function isRateLimitError(error: any): error is RateLimitError;
110
+ /**
111
+ * Enhanced error class for SDK operations
112
+ */
113
+ export declare class DefindexSDKError extends Error {
114
+ readonly statusCode: number;
115
+ readonly errorType: string;
116
+ readonly details?: any;
117
+ constructor(message: string, statusCode?: number, errorType?: string, details?: any);
118
+ /**
119
+ * Create SDK error from API error response
120
+ */
121
+ static fromApiError(apiError: ApiError): DefindexSDKError;
122
+ }
123
+ //# sourceMappingURL=error.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.types.d.ts","sourceRoot":"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;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB;CAQ1D"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * Error types for DeFindex SDK
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DefindexSDKError = void 0;
7
+ exports.isApiError = isApiError;
8
+ exports.isAuthError = isAuthError;
9
+ exports.isValidationError = isValidationError;
10
+ exports.isNetworkError = isNetworkError;
11
+ exports.isRateLimitError = isRateLimitError;
12
+ /**
13
+ * Type guard to check if an error is an API error
14
+ */
15
+ function isApiError(error) {
16
+ return error &&
17
+ typeof error === 'object' &&
18
+ 'message' in error &&
19
+ 'statusCode' in error &&
20
+ 'error' in error;
21
+ }
22
+ /**
23
+ * Type guard to check if an error is an authentication error
24
+ */
25
+ function isAuthError(error) {
26
+ return isApiError(error) &&
27
+ ['Unauthorized', 'Forbidden', 'TokenExpired', 'InvalidCredentials'].includes(error.error);
28
+ }
29
+ /**
30
+ * Type guard to check if an error is a validation error
31
+ */
32
+ function isValidationError(error) {
33
+ return isApiError(error) &&
34
+ ['BadRequest', 'ValidationFailed'].includes(error.error);
35
+ }
36
+ /**
37
+ * Type guard to check if an error is a network/blockchain error
38
+ */
39
+ function isNetworkError(error) {
40
+ return isApiError(error) &&
41
+ ['NetworkError', 'TransactionFailed', 'ContractError'].includes(error.error);
42
+ }
43
+ /**
44
+ * Type guard to check if an error is a rate limit error
45
+ */
46
+ function isRateLimitError(error) {
47
+ return isApiError(error) && error.error === 'TooManyRequests';
48
+ }
49
+ /**
50
+ * Enhanced error class for SDK operations
51
+ */
52
+ class DefindexSDKError extends Error {
53
+ constructor(message, statusCode = 500, errorType = 'UnknownError', details) {
54
+ super(message);
55
+ this.name = 'DefindexSDKError';
56
+ this.statusCode = statusCode;
57
+ this.errorType = errorType;
58
+ this.details = details;
59
+ }
60
+ /**
61
+ * Create SDK error from API error response
62
+ */
63
+ static fromApiError(apiError) {
64
+ return new DefindexSDKError(apiError.message, apiError.statusCode, apiError.error, 'details' in apiError ? apiError.details : undefined);
65
+ }
66
+ }
67
+ exports.DefindexSDKError = DefindexSDKError;
68
+ //# sourceMappingURL=error.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.types.js","sourceRoot":"","sources":["../../src/types/error.types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAyGH,gCAMC;AAKD,kCAGC;AAKD,8CAGC;AAKD,wCAGC;AAKD,4CAEC;AAxCD;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,SAAS,IAAI,KAAK;QAClB,YAAY,IAAI,KAAK;QACrB,OAAO,IAAI,KAAK,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAU;IACpC,OAAO,UAAU,CAAC,KAAK,CAAC;QACjB,CAAC,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACnG,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAAU;IAC1C,OAAO,UAAU,CAAC,KAAK,CAAC;QACjB,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,OAAO,UAAU,CAAC,KAAK,CAAC;QACjB,CAAC,cAAc,EAAE,mBAAmB,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAU;IACzC,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,KAAK,iBAAiB,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IAKzC,YACE,OAAe,EACf,aAAqB,GAAG,EACxB,YAAoB,cAAc,EAClC,OAAa;QAEb,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,QAAkB;QACpC,OAAO,IAAI,gBAAgB,CACzB,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,KAAK,EACd,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CACrD,CAAC;IACJ,CAAC;CACF;AA7BD,4CA6BC"}
@@ -0,0 +1,15 @@
1
+ import { BaseTransactionResponse } from "./base.types";
2
+ import { CreateDefindexVault } from "./vault.types";
3
+ export interface FactoryAddressResponse {
4
+ address: string;
5
+ }
6
+ export interface CreateVaultResponse extends BaseTransactionResponse {
7
+ call_params: CreateDefindexVault;
8
+ }
9
+ export interface CreateVaultDepositResponse extends BaseTransactionResponse {
10
+ call_params: CreateDefindexVault;
11
+ }
12
+ export interface CreateDefindexVaultDepositDto extends CreateDefindexVault {
13
+ deposit_amounts: number[];
14
+ }
15
+ //# sourceMappingURL=factory.types.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=factory.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.types.js","sourceRoot":"","sources":["../../src/types/factory.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export * from './base.types';
2
+ export * from './error.types';
3
+ export * from './factory.types';
4
+ export * from './network.types';
5
+ export * from './stellar.types';
6
+ export * from './vault.types';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,24 @@
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
+ /* Export all type definitions */
18
+ __exportStar(require("./base.types"), exports);
19
+ __exportStar(require("./error.types"), exports);
20
+ __exportStar(require("./factory.types"), exports);
21
+ __exportStar(require("./network.types"), exports);
22
+ __exportStar(require("./stellar.types"), exports);
23
+ __exportStar(require("./vault.types"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,+CAA6B;AAC7B,gDAA8B;AAC9B,kDAAgC;AAChC,kDAAgC;AAChC,kDAAgC;AAChC,gDAA8B"}
@@ -0,0 +1,5 @@
1
+ export declare enum SupportedNetworks {
2
+ TESTNET = "testnet",
3
+ MAINNET = "mainnet"
4
+ }
5
+ //# sourceMappingURL=network.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.types.d.ts","sourceRoot":"","sources":["../../src/types/network.types.ts"],"names":[],"mappings":"AACA,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SupportedNetworks = void 0;
4
+ /* Network configuration types */
5
+ var SupportedNetworks;
6
+ (function (SupportedNetworks) {
7
+ SupportedNetworks["TESTNET"] = "testnet";
8
+ SupportedNetworks["MAINNET"] = "mainnet";
9
+ })(SupportedNetworks || (exports.SupportedNetworks = SupportedNetworks = {}));
10
+ //# sourceMappingURL=network.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.types.js","sourceRoot":"","sources":["../../src/types/network.types.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,wCAAmB,CAAA;AACrB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B"}
@@ -0,0 +1,29 @@
1
+ export interface StellarSendTransactionResponse {
2
+ /** Transaction hash */
3
+ hash: string;
4
+ /** Transaction status */
5
+ status: 'PENDING' | 'SUCCESS' | 'ERROR';
6
+ /** Latest ledger number */
7
+ latestLedger: number;
8
+ /** Latest ledger close time */
9
+ latestLedgerCloseTime: number;
10
+ /** Error result XDR if transaction failed */
11
+ errorResultXdr?: string;
12
+ }
13
+ export type TransactionResponse = StellarSendTransactionResponse | LaunchTubeResponse;
14
+ export interface LaunchTubeResponse {
15
+ hash?: string;
16
+ status: 'PENDING' | 'SUCCESS' | 'FAILED';
17
+ errorResultXdr?: string;
18
+ envelopeXdr?: string;
19
+ resultXdr?: string;
20
+ resultMetaXdr?: string;
21
+ error?: string;
22
+ message?: string;
23
+ }
24
+ export interface LaunchTubeErrorResponse {
25
+ error: string;
26
+ message?: string;
27
+ statusCode?: number;
28
+ }
29
+ //# sourceMappingURL=stellar.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stellar.types.d.ts","sourceRoot":"","sources":["../../src/types/stellar.types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,8BAA8B;IAC7C,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,MAAM,mBAAmB,GAAG,8BAA8B,GAAG,kBAAkB,CAAC;AAGtF,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=stellar.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stellar.types.js","sourceRoot":"","sources":["../../src/types/stellar.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,253 @@
1
+ import { BaseVaultTransactionResponse } from "./base.types";
2
+ export interface AssetStrategySet {
3
+ address: string;
4
+ strategies: Strategy[];
5
+ }
6
+ export interface Strategy {
7
+ address: string;
8
+ name: string;
9
+ paused: boolean;
10
+ }
11
+ /**
12
+ * Configuration for creating a DeFindex vault
13
+ * @example
14
+ * ```typescript
15
+ * const vaultConfig: CreateDefindexVault = {
16
+ * roles: {
17
+ * 0: "GEMERGENCY...", // Emergency Manager
18
+ * 1: "GFEE...", // Fee Receiver
19
+ * 2: "GMANAGER...", // Vault Manager
20
+ * 3: "GREBALANCE..." // Rebalance Manager
21
+ * },
22
+ * vault_fee_bps: 100, // 1% fee
23
+ * assets: [{
24
+ * address: "CUSDC...",
25
+ * strategies: [{
26
+ * address: "GSTRATEGY...",
27
+ * name: "USDC Lending Strategy",
28
+ * paused: false
29
+ * }]
30
+ * }],
31
+ * name_symbol: { name: "My DeFi Vault", symbol: "MDV" },
32
+ * upgradable: true,
33
+ * caller: "GCREATOR..."
34
+ * };
35
+ * ```
36
+ */
37
+ export interface CreateDefindexVault {
38
+ /** Role assignments for vault management (0: Emergency, 1: Fee Receiver, 2: Manager, 3: Rebalance) */
39
+ roles: Record<number, string>;
40
+ /** Vault fee in basis points (100 = 1%, max 10000 = 100%) */
41
+ vault_fee_bps: number;
42
+ /** Assets and their associated strategies */
43
+ assets: AssetStrategySet[];
44
+ /** Optional Soroswap router address for swaps */
45
+ soroswap_router?: string;
46
+ /** Vault name and symbol metadata */
47
+ name_symbol: Record<string, string>;
48
+ /** Whether the vault contract is upgradable */
49
+ upgradable: boolean;
50
+ /** Address that will create and sign the vault creation transaction */
51
+ caller: string;
52
+ /** Optional initial deposit amounts (deprecated, use CreateDefindexVaultDepositDto) */
53
+ amounts?: number[];
54
+ }
55
+ export interface CreateDefindexVaultResponse {
56
+ call_params: CreateDefindexVault;
57
+ xdr: string | null;
58
+ simulation_result: string;
59
+ error?: string;
60
+ }
61
+ interface BaseCallerParams {
62
+ /** Stellar address of the transaction caller/signer
63
+ * @example "GCKFBEIYTKP6RNYXDXCVN5NHQG7C37VFTCB5BBXZ4F6PUB7FFLLKSZQJ"
64
+ */
65
+ caller: string;
66
+ }
67
+ interface BaseStrategyParams extends BaseCallerParams {
68
+ /** Stellar address of the strategy contract
69
+ * @example "GSTRATEGY123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789ABC"
70
+ */
71
+ strategy_address: string;
72
+ }
73
+ interface BaseAmountParams extends BaseCallerParams {
74
+ /** Array of amounts for each asset. Must be non-negative numbers. */
75
+ amounts: number[];
76
+ /** Slippage tolerance in basis points (0-10000). 100 = 1%, 10000 = 100%. Defaults to 0. */
77
+ slippageBps?: number;
78
+ }
79
+ export interface DepositToVaultParams extends BaseAmountParams {
80
+ /** Whether to invest the deposited assets immediately. Defaults to true. */
81
+ invest?: boolean;
82
+ }
83
+ export interface WithdrawFromVaultParams extends BaseAmountParams {
84
+ }
85
+ export interface WithdrawSharesParams extends BaseCallerParams {
86
+ /** Amount of vault shares to withdraw. Must be a positive number. */
87
+ shares: number;
88
+ /** Slippage tolerance in basis points (0-10000). 100 = 1%, 10000 = 100%. Defaults to 0. */
89
+ slippageBps?: number;
90
+ }
91
+ export interface RescueFromVaultParams extends BaseStrategyParams {
92
+ }
93
+ export interface PauseStrategyParams extends BaseStrategyParams {
94
+ }
95
+ export interface UnpauseStrategyParams extends BaseStrategyParams {
96
+ }
97
+ export interface SetFeeRecieverParams extends BaseCallerParams {
98
+ fee_reciever: string;
99
+ }
100
+ export interface SetManagerParams extends BaseCallerParams {
101
+ manager: string;
102
+ }
103
+ export interface SetEmergencyManagerParams extends BaseCallerParams {
104
+ emergency_manager: string;
105
+ }
106
+ export interface SetRebalanceManagerParams extends BaseCallerParams {
107
+ rebalance_manager: string;
108
+ }
109
+ export interface UpgradeContractParams extends BaseCallerParams {
110
+ new_wasm_hash: string;
111
+ }
112
+ export interface RebalanceParams extends BaseCallerParams {
113
+ instructions: Instruction[];
114
+ }
115
+ export interface LockFeesParams extends BaseCallerParams {
116
+ new_fee_bps: number;
117
+ }
118
+ export interface ReleaseFeesParams extends BaseStrategyParams {
119
+ }
120
+ export interface DistributeFeesParams extends BaseCallerParams {
121
+ }
122
+ export type Instruction = {
123
+ type: "Unwind";
124
+ strategy: string;
125
+ amount: number;
126
+ } | {
127
+ type: "Invest";
128
+ strategy: string;
129
+ amount: number;
130
+ } | {
131
+ type: "SwapExactIn";
132
+ token_in: string;
133
+ token_out: string;
134
+ amount_in: number;
135
+ amount_out_min: number;
136
+ deadline: number;
137
+ } | {
138
+ type: "SwapExactOut";
139
+ token_in: string;
140
+ token_out: string;
141
+ amount_out: number;
142
+ amount_in_max: number;
143
+ deadline: number;
144
+ };
145
+ export interface VaultRole {
146
+ manager: string;
147
+ emergencyManager: string;
148
+ rebalanceManager: string;
149
+ feeReceiver: string;
150
+ }
151
+ export interface VaultStrategy {
152
+ address: string;
153
+ name: string;
154
+ paused: boolean;
155
+ }
156
+ export interface VaultAsset {
157
+ address: string;
158
+ name: string;
159
+ symbol: string;
160
+ strategies: VaultStrategy[];
161
+ }
162
+ export interface VaultFees {
163
+ vaultFee: number;
164
+ defindexFee: number;
165
+ }
166
+ /**
167
+ * Comprehensive vault information response
168
+ * @example
169
+ * ```typescript
170
+ * const vaultInfo = await sdk.getVaultInfo('GVAULT...', SupportedNetworks.TESTNET);
171
+ * console.log(`${vaultInfo.name} (${vaultInfo.symbol})`);
172
+ * console.log(`Total Supply: ${vaultInfo.totalSupply}`);
173
+ * console.log(`Total Assets: ${vaultInfo.totalAssets}`);
174
+ * console.log(`Vault Fee: ${vaultInfo.feesBps.vaultFee / 100}%`);
175
+ * ```
176
+ */
177
+ export interface VaultInfoResponse {
178
+ /** Vault contract address */
179
+ address: string;
180
+ /** Vault display name */
181
+ name: string;
182
+ /** Vault token symbol */
183
+ symbol: string;
184
+ /** Total vault shares in circulation */
185
+ totalSupply: number;
186
+ /** Total value locked in the vault */
187
+ totalAssets: number;
188
+ /** Assets managed by the vault */
189
+ assets: VaultAsset[];
190
+ /** Detailed breakdown of managed funds per asset */
191
+ totalManagedFunds: {
192
+ /** Asset contract address */
193
+ asset: string;
194
+ /** Amount not actively invested */
195
+ idle_amount: number;
196
+ /** Amount actively invested in strategies */
197
+ invested_amount: number;
198
+ /** Per-strategy allocation breakdown */
199
+ strategy_allocations: {
200
+ /** Amount allocated to this strategy */
201
+ amount: number;
202
+ /** Whether the strategy is paused */
203
+ paused: boolean;
204
+ /** Strategy contract address */
205
+ strategy_address: string;
206
+ }[];
207
+ /** Total amount for this asset */
208
+ total_amount: number;
209
+ }[];
210
+ /** Fee structure in basis points */
211
+ feesBps: VaultFees;
212
+ }
213
+ export interface VaultBalanceResponse {
214
+ dfTokens: number;
215
+ underlyingBalance: number[];
216
+ }
217
+ export interface VaultTransactionResponse extends BaseVaultTransactionResponse {
218
+ }
219
+ export interface VaultRescueResponse extends BaseVaultTransactionResponse {
220
+ }
221
+ export interface VaultStrategyStatusResponse extends BaseVaultTransactionResponse {
222
+ }
223
+ /**
224
+ * Vault Annual Percentage Yield information
225
+ * @example
226
+ * ```typescript
227
+ * const apy = await sdk.getVaultAPY('GVAULT...', SupportedNetworks.TESTNET);
228
+ * console.log(`Current APY: ${apy.apyPercent}%`);
229
+ * console.log(`Calculated over: ${apy.period}`);
230
+ * console.log(`Last updated: ${apy.lastUpdated}`);
231
+ * ```
232
+ */
233
+ export interface VaultApyResponse {
234
+ /** APY as decimal (0.15 = 15%) */
235
+ apy: number;
236
+ /** APY as percentage (15.0 = 15%) */
237
+ apyPercent: number;
238
+ /** Time period over which APY was calculated */
239
+ period: string;
240
+ /** ISO timestamp of last APY calculation */
241
+ lastUpdated: string;
242
+ }
243
+ export interface VaultInfoServiceResponse extends VaultInfoResponse {
244
+ }
245
+ export interface VaultBalanceServiceResponse extends VaultBalanceResponse {
246
+ }
247
+ export interface VaultTransactionServiceResponse extends BaseVaultTransactionResponse {
248
+ }
249
+ export interface VaultApyServiceResponse {
250
+ apy: number;
251
+ }
252
+ export {};
253
+ //# sourceMappingURL=vault.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault.types.d.ts","sourceRoot":"","sources":["../../src/types/vault.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,mBAAmB;IAClC,sGAAsG;IACtG,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC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ACpC,OAAO,EAAE,SAAS,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,wBAAyB,SAAQ,4BAA4B;CAAG;AAEjF,MAAM,WAAW,mBAAoB,SAAQ,4BAA4B;CAAG;AAE5E,MAAM,WAAW,2BAA4B,SAAQ,4BAA4B;CAAG;AAEpF;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;CAAG;AAEtE,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;CAAG;AAE5E,MAAM,WAAW,+BAAgC,SAAQ,4BAA4B;CAAG;AAExF,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;CACb"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=vault.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault.types.js","sourceRoot":"","sources":["../../src/types/vault.types.ts"],"names":[],"mappings":""}