@paxoslabs/amplify-sdk 0.5.1 → 0.5.3

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 (72) hide show
  1. package/CHANGELOG.md +7 -45
  2. package/README.md +22 -22
  3. package/dist/{chain-utils-D_b2LEEi.d.mts → chain-utils-5r2UnCDS.d.mts} +57 -1
  4. package/dist/{chain-utils-D_b2LEEi.d.ts → chain-utils-5r2UnCDS.d.ts} +57 -1
  5. package/dist/{chunk-L5XT67QZ.js → chunk-4NQPS3JC.js} +813 -147
  6. package/dist/chunk-4NQPS3JC.js.map +1 -0
  7. package/dist/{chunk-7RWWVUHP.mjs → chunk-6CU533DM.mjs} +2 -2
  8. package/dist/chunk-6CU533DM.mjs.map +1 -0
  9. package/dist/chunk-6JLKHV6O.js +128 -0
  10. package/dist/chunk-6JLKHV6O.js.map +1 -0
  11. package/dist/{chunk-YAYUSBC6.js → chunk-FHE43NKY.js} +12 -12
  12. package/dist/chunk-FHE43NKY.js.map +1 -0
  13. package/dist/chunk-GOJQYEJQ.js +3212 -0
  14. package/dist/chunk-GOJQYEJQ.js.map +1 -0
  15. package/dist/{chunk-3D6EDR3Z.mjs → chunk-LMNADWTH.mjs} +703 -41
  16. package/dist/chunk-LMNADWTH.mjs.map +1 -0
  17. package/dist/chunk-ODXJYXUH.mjs +3168 -0
  18. package/dist/chunk-ODXJYXUH.mjs.map +1 -0
  19. package/dist/{chunk-WJGSTAPB.mjs → chunk-QMFYPHX5.mjs} +300 -87
  20. package/dist/chunk-QMFYPHX5.mjs.map +1 -0
  21. package/dist/{chunk-3I3PYX2F.js → chunk-TNL23CO2.js} +2 -2
  22. package/dist/chunk-TNL23CO2.js.map +1 -0
  23. package/dist/{chunk-E6SBQNDA.mjs → chunk-UY2WD7MF.mjs} +3 -3
  24. package/dist/chunk-UY2WD7MF.mjs.map +1 -0
  25. package/dist/chunk-WD6QFSXZ.js +701 -0
  26. package/dist/chunk-WD6QFSXZ.js.map +1 -0
  27. package/dist/chunk-Y5LBT2WT.mjs +118 -0
  28. package/dist/chunk-Y5LBT2WT.mjs.map +1 -0
  29. package/dist/core.d.mts +50 -7
  30. package/dist/core.d.ts +50 -7
  31. package/dist/core.js +32 -16
  32. package/dist/core.js.map +1 -1
  33. package/dist/core.mjs +4 -4
  34. package/dist/core.mjs.map +1 -1
  35. package/dist/display.d.mts +212 -3
  36. package/dist/display.d.ts +212 -3
  37. package/dist/display.js +27 -11
  38. package/dist/display.mjs +5 -5
  39. package/dist/index-D8RtV9cB.d.mts +5114 -0
  40. package/dist/index-ev_V5sjt.d.ts +5114 -0
  41. package/dist/index.d.mts +41 -6
  42. package/dist/index.d.ts +41 -6
  43. package/dist/index.js +90 -58
  44. package/dist/index.mjs +6 -6
  45. package/dist/utils.d.mts +1 -1
  46. package/dist/utils.d.ts +1 -1
  47. package/dist/utils.js +13 -13
  48. package/dist/utils.js.map +1 -1
  49. package/dist/utils.mjs +3 -3
  50. package/dist/utils.mjs.map +1 -1
  51. package/dist/vaults.d.mts +3 -3817
  52. package/dist/vaults.d.ts +3 -3817
  53. package/dist/vaults.js +26 -26
  54. package/dist/vaults.mjs +5 -5
  55. package/package.json +30 -65
  56. package/dist/chunk-3D6EDR3Z.mjs.map +0 -1
  57. package/dist/chunk-3I3PYX2F.js.map +0 -1
  58. package/dist/chunk-7RWWVUHP.mjs.map +0 -1
  59. package/dist/chunk-AUDMOT6F.js +0 -1230
  60. package/dist/chunk-AUDMOT6F.js.map +0 -1
  61. package/dist/chunk-E5DH5YEE.js +0 -1485
  62. package/dist/chunk-E5DH5YEE.js.map +0 -1
  63. package/dist/chunk-E6SBQNDA.mjs.map +0 -1
  64. package/dist/chunk-JLZL25CY.mjs +0 -1450
  65. package/dist/chunk-JLZL25CY.mjs.map +0 -1
  66. package/dist/chunk-L5XT67QZ.js.map +0 -1
  67. package/dist/chunk-WJGSTAPB.mjs.map +0 -1
  68. package/dist/chunk-XVDK6J72.js +0 -484
  69. package/dist/chunk-XVDK6J72.js.map +0 -1
  70. package/dist/chunk-Y6RXVDQN.mjs +0 -1222
  71. package/dist/chunk-Y6RXVDQN.mjs.map +0 -1
  72. package/dist/chunk-YAYUSBC6.js.map +0 -1
package/dist/display.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Address } from 'viem';
2
- import { C as ChainId } from './chain-utils-D_b2LEEi.js';
2
+ import { C as ChainId } from './chain-utils-5r2UnCDS.js';
3
3
  import 'viem/chains';
4
4
 
5
5
  /**
@@ -8,7 +8,7 @@ import 'viem/chains';
8
8
  */
9
9
 
10
10
  /** Status of a withdrawal request */
11
- type WithdrawalRequestStatus = "PENDING" | "COMPLETE" | "PENDING_REFUND" | "REFUNDED";
11
+ type WithdrawalRequestStatus = 'PENDING' | 'COMPLETE' | 'PENDING_REFUND' | 'REFUNDED';
12
12
  /** A withdrawal request returned from the backend API */
13
13
  interface WithdrawalRequest {
14
14
  id: string;
@@ -92,6 +92,107 @@ interface MinimumMintResult {
92
92
  shareDecimals: number;
93
93
  assetDecimals: number;
94
94
  }
95
+ /** Parameters for getDepositCap */
96
+ interface GetDepositCapParams {
97
+ /** Human-readable vault name (e.g. "Amplify USDC Core") */
98
+ vaultName: string;
99
+ /** Chain ID where the vault is deployed. Must match the vault's chain. */
100
+ chainId: ChainId;
101
+ /** Token contract address used to validate the vault (should match the vault's supported asset) */
102
+ assetAddress: Address;
103
+ }
104
+ /**
105
+ * Return type for {@link getDepositCap}.
106
+ * Only produced for vaults with both a CommunityCodeDepositor and a deposit fee module.
107
+ */
108
+ interface DepositCapResult {
109
+ /** Supply cap denominated in base asset units (raw uint256 from DCD contract) */
110
+ supplyCapInBase: bigint;
111
+ /** True when `supplyCapInBase` is neither `0` nor `maxUint256` (unlimited). */
112
+ hasDepositCap: boolean;
113
+ /** Deposit fee module contract address from the DCD (zero address means no fees) */
114
+ depositFeeModuleAddress: Address;
115
+ /** Whether the vault has deposit fees (depositFeeModuleAddress != zero address) */
116
+ hasFees: boolean;
117
+ }
118
+ /** Parameters for calculateDepositFee */
119
+ interface CalculateDepositFeeParams {
120
+ /** Human-readable vault name (e.g. "Amplify USDC Core") */
121
+ vaultName: string;
122
+ /** Chain ID where the vault is deployed. Must match the vault's chain. */
123
+ chainId: ChainId;
124
+ /** Token contract address of the deposit asset */
125
+ assetAddress: Address;
126
+ /** Human-readable deposit amount (e.g. "1000.0") */
127
+ depositAmount: string;
128
+ }
129
+ /** Return type for calculateDepositFee */
130
+ interface DepositFeeResult {
131
+ /** Whether the vault has a fee module configured */
132
+ hasFees: boolean;
133
+ /** The deposit fee module contract address (zero address if no fees) */
134
+ depositFeeModuleAddress: Address;
135
+ /** Variable fee percentage as raw uint256 from the contract */
136
+ feePercentage: bigint;
137
+ /** ONE_HUNDRED_PERCENT constant from the fee module (denominator for percentage calc) */
138
+ oneHundredPercent: bigint;
139
+ /** Flat fee in deposit-token units (raw uint256) */
140
+ flatFee: bigint;
141
+ /** Computed variable fee amount for the given deposit: depositAmount * feePercentage / oneHundredPercent */
142
+ variableFeeAmount: bigint;
143
+ /** Total fee amount: variableFeeAmount + flatFee */
144
+ totalFeeAmount: bigint;
145
+ /** Deposit amount after total fee deduction */
146
+ depositAmountAfterFees: bigint;
147
+ /** Decimals of the deposit asset (for display formatting) */
148
+ assetDecimals: number;
149
+ }
150
+ /** Parameters for getCurrentSupply */
151
+ interface GetCurrentSupplyParams {
152
+ /** Human-readable vault name (e.g. "Amplify USDC Core") */
153
+ vaultName: string;
154
+ /** Chain ID where the vault is deployed. Must match the vault's chain. */
155
+ chainId: ChainId;
156
+ /** Token contract address used to validate the vault (should match the vault's supported asset) */
157
+ assetAddress: Address;
158
+ }
159
+ /** Return type for getCurrentSupply */
160
+ interface CurrentSupplyResult {
161
+ /** Total share supply of the boring vault (raw ERC-20 totalSupply) */
162
+ totalShareSupply: bigint;
163
+ /** Exchange rate from the accountant (getRate) */
164
+ exchangeRate: bigint;
165
+ /** Decimals reported by the accountant contract */
166
+ accountantDecimals: number;
167
+ /** Total value in base-asset units: totalShareSupply * exchangeRate / 10^accountantDecimals */
168
+ totalValueInBase: bigint;
169
+ }
170
+ /** Parameters for getShareValue */
171
+ interface GetShareValueParams {
172
+ /** Human-readable vault name (e.g. "Amplify USDC Core") */
173
+ vaultName: string;
174
+ /** Chain ID where the vault is deployed. Must match the vault's chain. */
175
+ chainId: ChainId;
176
+ /** Quote asset address to value shares in (e.g. USDC). Must match the vault's supported asset. */
177
+ quoteAssetAddress: Address;
178
+ /** Wallet address to read share balance for via balanceOf. Optional when shareAmount is provided. */
179
+ userAddress?: Address;
180
+ /** Explicit share amount to value (human-readable, e.g. "100.0"). Overrides on-chain balanceOf when provided. */
181
+ shareAmount?: string;
182
+ }
183
+ /** Return type for getShareValue */
184
+ interface ShareValueResult {
185
+ /** Share balance used for the calculation (read from chain or derived from shareAmount) */
186
+ shareBalance: bigint;
187
+ /** Value of the shares in quote-asset units (raw bigint) */
188
+ value: bigint;
189
+ /** Exchange rate from getRateInQuote — quote-asset units per one full share */
190
+ exchangeRate: bigint;
191
+ /** Decimals of the BoringVault share token */
192
+ shareDecimals: number;
193
+ /** Decimals of the quote asset */
194
+ quoteAssetDecimals: number;
195
+ }
95
196
  /** Parameters for getVaultAPY */
96
197
  interface GetVaultAPYParams {
97
198
  vaultAddress?: Address;
@@ -147,6 +248,114 @@ interface VaultTVLResult {
147
248
  * ```
148
249
  */
149
250
  declare function getMinimumMint(params: GetMinimumMintParams): Promise<MinimumMintResult>;
251
+ /**
252
+ * Reads the deposit cap and fee module info from the DCD contract on-chain
253
+ *
254
+ * Uses the customer's configured RPC to call `supplyCapInBase()` and
255
+ * `feeModule()` on the DistributorCodeDepositor contract.
256
+ *
257
+ * @param params - Vault identification parameters
258
+ * @returns Supply cap, fee module address, and derived boolean flags
259
+ * @throws {APIError} If vault not found or contract read fails
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * const cap = await getDepositCap({
264
+ * vaultName: "Amplify USDC Core",
265
+ * chainId: 1,
266
+ * assetAddress: "0xA0b8...",
267
+ * });
268
+ * console.log(cap.hasDepositCap); // true if supplyCapInBase != 0 and != maxUint256
269
+ * console.log(cap.hasFees); // true if depositFeeModuleAddress from vault config != zeroAddress
270
+ * ```
271
+ */
272
+ declare function getDepositCap(params: GetDepositCapParams): Promise<DepositCapResult>;
273
+ /**
274
+ * Reads the current total supply value from the boring vault and accountant
275
+ *
276
+ * Computes `totalValueInBase = totalSupply * accountant.getRate() / 10^accountant.decimals()`,
277
+ * matching the on-chain supply cap enforcement logic in the DCD contract.
278
+ *
279
+ * @param params - Vault identification parameters
280
+ * @returns Total share supply, exchange rate, and computed value in base-asset units
281
+ * @throws {APIError} If vault not found or contract read fails
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * const supply = await getCurrentSupply({
286
+ * vaultName: "Amplify USDC Core",
287
+ * chainId: 1,
288
+ * assetAddress: "0xA0b8...",
289
+ * });
290
+ * console.log(supply.totalValueInBase); // current TVL in base-asset raw units
291
+ * ```
292
+ */
293
+ declare function getCurrentSupply(params: GetCurrentSupplyParams): Promise<CurrentSupplyResult>;
294
+ /**
295
+ * Calculates the deposit fee for a given deposit amount by reading the
296
+ * fee module's `depositTokenFeeData` and `ONE_HUNDRED_PERCENT` on-chain.
297
+ *
298
+ * Returns both the fixed (flat) and variable fee components, along with
299
+ * the total fee and the net deposit amount after fees.
300
+ *
301
+ * @param params - Deposit parameters including vault name, chain, asset, and amount
302
+ * @returns Fee breakdown with fixed, variable, total, and net amounts
303
+ * @throws {APIError} If vault not found, no fee module, or contract read fails
304
+ *
305
+ * @example
306
+ * ```typescript
307
+ * const fee = await calculateDepositFee({
308
+ * vaultName: "Amplify USDC Core",
309
+ * chainId: 1,
310
+ * assetAddress: "0xA0b8...",
311
+ * depositAmount: "1000.0",
312
+ * });
313
+ * console.log(fee.variableFeeAmount); // variable portion
314
+ * console.log(fee.flatFee); // fixed portion
315
+ * console.log(fee.totalFeeAmount); // variable + fixed
316
+ * ```
317
+ */
318
+ declare function calculateDepositFee(params: CalculateDepositFeeParams): Promise<DepositFeeResult>;
319
+ /**
320
+ * Calculates the value of vault shares in a quote asset
321
+ *
322
+ * Reads the on-chain exchange rate from the Accountant contract via
323
+ * `getRateInQuote(quoteAsset)` and computes:
324
+ * value = shareBalance * rateInQuote / 10^shareDecimals
325
+ *
326
+ * The share balance can come from two sources:
327
+ * - `userAddress`: reads `balanceOf(userAddress)` on the BoringVault on-chain
328
+ * - `shareAmount`: uses the provided amount directly (skips balanceOf)
329
+ *
330
+ * When both are provided, `shareAmount` takes precedence. At least one
331
+ * must be specified.
332
+ *
333
+ * @param params - Share value parameters
334
+ * @returns Share balance, value in quote-asset units, exchange rate, and decimal info
335
+ * @throws {APIError} If neither userAddress nor shareAmount provided, vault not found, or contract read fails
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * // Look up a user's position value by wallet address
340
+ * const result = await getShareValue({
341
+ * vaultName: "pxlUSDCc",
342
+ * chainId: 1,
343
+ * quoteAssetAddress: "0xA0b8...", // USDC
344
+ * userAddress: "0x1234...",
345
+ * });
346
+ * console.log(result.shareBalance); // shares held
347
+ * console.log(result.value); // worth in USDC units
348
+ *
349
+ * // Or value a known share amount directly
350
+ * const preview = await getShareValue({
351
+ * vaultName: "pxlUSDCc",
352
+ * chainId: 1,
353
+ * quoteAssetAddress: "0xA0b8...",
354
+ * shareAmount: "100.0",
355
+ * });
356
+ * ```
357
+ */
358
+ declare function getShareValue(params: GetShareValueParams): Promise<ShareValueResult>;
150
359
 
151
360
  /**
152
361
  * @file Vault display helpers
@@ -260,4 +469,4 @@ declare function getWithdrawalFee(params: GetWithdrawalFeeParams): Promise<Withd
260
469
  */
261
470
  declare function getMinimumWithdrawalOrderSize(params: GetMinimumWithdrawalOrderSizeParams): Promise<MinimumWithdrawalOrderSizeResult>;
262
471
 
263
- export { type GetMinimumMintParams, type GetMinimumWithdrawalOrderSizeParams, type GetVaultAPYParams, type GetVaultTVLParams, type GetWithdrawalFeeParams, type GetWithdrawalRequestsParams, type MinimumMintResult, type MinimumWithdrawalOrderSizeResult, type VaultAPYResult, type VaultTVLResult, type WithdrawalFeeResult, type WithdrawalRequest, type WithdrawalRequestStatus, type WithdrawalRequestsResult, getMinimumMint, getMinimumWithdrawalOrderSize, getVaultAPY, getVaultTVL, getWithdrawalFee, getWithdrawalRequests };
472
+ export { type CalculateDepositFeeParams, type CurrentSupplyResult, type DepositCapResult, type DepositFeeResult, type GetCurrentSupplyParams, type GetDepositCapParams, type GetMinimumMintParams, type GetMinimumWithdrawalOrderSizeParams, type GetShareValueParams, type GetVaultAPYParams, type GetVaultTVLParams, type GetWithdrawalFeeParams, type GetWithdrawalRequestsParams, type MinimumMintResult, type MinimumWithdrawalOrderSizeResult, type ShareValueResult, type VaultAPYResult, type VaultTVLResult, type WithdrawalFeeResult, type WithdrawalRequest, type WithdrawalRequestStatus, type WithdrawalRequestsResult, calculateDepositFee, getCurrentSupply, getDepositCap, getMinimumMint, getMinimumWithdrawalOrderSize, getShareValue, getVaultAPY, getVaultTVL, getWithdrawalFee, getWithdrawalRequests };
package/dist/display.js CHANGED
@@ -1,36 +1,52 @@
1
1
  'use strict';
2
2
 
3
- var chunkXVDK6J72_js = require('./chunk-XVDK6J72.js');
4
- require('./chunk-AUDMOT6F.js');
5
- require('./chunk-YAYUSBC6.js');
6
- require('./chunk-3I3PYX2F.js');
7
- require('./chunk-E5DH5YEE.js');
3
+ var chunkWD6QFSXZ_js = require('./chunk-WD6QFSXZ.js');
4
+ require('./chunk-6JLKHV6O.js');
5
+ require('./chunk-FHE43NKY.js');
6
+ require('./chunk-TNL23CO2.js');
7
+ require('./chunk-GOJQYEJQ.js');
8
8
 
9
9
 
10
10
 
11
+ Object.defineProperty(exports, "calculateDepositFee", {
12
+ enumerable: true,
13
+ get: function () { return chunkWD6QFSXZ_js.calculateDepositFee; }
14
+ });
15
+ Object.defineProperty(exports, "getCurrentSupply", {
16
+ enumerable: true,
17
+ get: function () { return chunkWD6QFSXZ_js.getCurrentSupply; }
18
+ });
19
+ Object.defineProperty(exports, "getDepositCap", {
20
+ enumerable: true,
21
+ get: function () { return chunkWD6QFSXZ_js.getDepositCap; }
22
+ });
11
23
  Object.defineProperty(exports, "getMinimumMint", {
12
24
  enumerable: true,
13
- get: function () { return chunkXVDK6J72_js.getMinimumMint; }
25
+ get: function () { return chunkWD6QFSXZ_js.getMinimumMint; }
14
26
  });
15
27
  Object.defineProperty(exports, "getMinimumWithdrawalOrderSize", {
16
28
  enumerable: true,
17
- get: function () { return chunkXVDK6J72_js.getMinimumWithdrawalOrderSize; }
29
+ get: function () { return chunkWD6QFSXZ_js.getMinimumWithdrawalOrderSize; }
30
+ });
31
+ Object.defineProperty(exports, "getShareValue", {
32
+ enumerable: true,
33
+ get: function () { return chunkWD6QFSXZ_js.getShareValue; }
18
34
  });
19
35
  Object.defineProperty(exports, "getVaultAPY", {
20
36
  enumerable: true,
21
- get: function () { return chunkXVDK6J72_js.getVaultAPY; }
37
+ get: function () { return chunkWD6QFSXZ_js.getVaultAPY; }
22
38
  });
23
39
  Object.defineProperty(exports, "getVaultTVL", {
24
40
  enumerable: true,
25
- get: function () { return chunkXVDK6J72_js.getVaultTVL; }
41
+ get: function () { return chunkWD6QFSXZ_js.getVaultTVL; }
26
42
  });
27
43
  Object.defineProperty(exports, "getWithdrawalFee", {
28
44
  enumerable: true,
29
- get: function () { return chunkXVDK6J72_js.getWithdrawalFee; }
45
+ get: function () { return chunkWD6QFSXZ_js.getWithdrawalFee; }
30
46
  });
31
47
  Object.defineProperty(exports, "getWithdrawalRequests", {
32
48
  enumerable: true,
33
- get: function () { return chunkXVDK6J72_js.getWithdrawalRequests; }
49
+ get: function () { return chunkWD6QFSXZ_js.getWithdrawalRequests; }
34
50
  });
35
51
  //# sourceMappingURL=display.js.map
36
52
  //# sourceMappingURL=display.js.map
package/dist/display.mjs CHANGED
@@ -1,7 +1,7 @@
1
- export { getMinimumMint, getMinimumWithdrawalOrderSize, getVaultAPY, getVaultTVL, getWithdrawalFee, getWithdrawalRequests } from './chunk-WJGSTAPB.mjs';
2
- import './chunk-Y6RXVDQN.mjs';
3
- import './chunk-E6SBQNDA.mjs';
4
- import './chunk-7RWWVUHP.mjs';
5
- import './chunk-JLZL25CY.mjs';
1
+ export { calculateDepositFee, getCurrentSupply, getDepositCap, getMinimumMint, getMinimumWithdrawalOrderSize, getShareValue, getVaultAPY, getVaultTVL, getWithdrawalFee, getWithdrawalRequests } from './chunk-QMFYPHX5.mjs';
2
+ import './chunk-Y5LBT2WT.mjs';
3
+ import './chunk-UY2WD7MF.mjs';
4
+ import './chunk-6CU533DM.mjs';
5
+ import './chunk-ODXJYXUH.mjs';
6
6
  //# sourceMappingURL=display.mjs.map
7
7
  //# sourceMappingURL=display.mjs.map