@paxoslabs/amplify-sdk 0.1.1 → 0.2.0-alpha.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/CHANGELOG.md +0 -2
- package/README.md +42 -0
- package/dist/{chunk-DTFLXAZJ.js → chunk-4NQCOMCZ.js} +147 -5
- package/dist/chunk-4NQCOMCZ.js.map +1 -0
- package/dist/{chunk-KYR6BFAE.js → chunk-5VOI4WPL.js} +38 -33
- package/dist/chunk-5VOI4WPL.js.map +1 -0
- package/dist/{chunk-ZILA73XN.mjs → chunk-5Y7M43XN.mjs} +144 -4
- package/dist/chunk-5Y7M43XN.mjs.map +1 -0
- package/dist/{chunk-VIULRHK6.mjs → chunk-7PCUTZF6.mjs} +3 -3
- package/dist/{chunk-VIULRHK6.mjs.map → chunk-7PCUTZF6.mjs.map} +1 -1
- package/dist/{chunk-XXHRCCZS.mjs → chunk-AQFFMJX7.mjs} +3 -3
- package/dist/chunk-AQFFMJX7.mjs.map +1 -0
- package/dist/{chunk-REKEQLQA.mjs → chunk-BOW2QPQC.mjs} +3 -3
- package/dist/{chunk-REKEQLQA.mjs.map → chunk-BOW2QPQC.mjs.map} +1 -1
- package/dist/{chunk-HI44AMLC.mjs → chunk-E7R7TL7J.mjs} +24 -19
- package/dist/chunk-E7R7TL7J.mjs.map +1 -0
- package/dist/{chunk-CUGK4ZBJ.mjs → chunk-IMS2HBJ7.mjs} +305 -30
- package/dist/chunk-IMS2HBJ7.mjs.map +1 -0
- package/dist/{chunk-LSNRG5Z2.js → chunk-KB4EPCK2.js} +4 -4
- package/dist/{chunk-LSNRG5Z2.js.map → chunk-KB4EPCK2.js.map} +1 -1
- package/dist/{chunk-ITB7FXG4.js → chunk-OJOKPBK7.js} +3 -3
- package/dist/chunk-OJOKPBK7.js.map +1 -0
- package/dist/{chunk-B2QCI6ET.js → chunk-UMRTU75Q.js} +309 -30
- package/dist/chunk-UMRTU75Q.js.map +1 -0
- package/dist/{chunk-GS7TDQXA.js → chunk-XUS6KI3G.js} +8 -8
- package/dist/{chunk-GS7TDQXA.js.map → chunk-XUS6KI3G.js.map} +1 -1
- package/dist/core.js +16 -16
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +6 -6
- package/dist/core.mjs.map +1 -1
- package/dist/display.d.mts +1 -1
- package/dist/display.d.ts +1 -1
- package/dist/display.js +12 -12
- package/dist/display.mjs +4 -4
- package/dist/{exchange-rate-BfPH_fQt.d.mts → exchange-rate-DCB2CY9v.d.mts} +5 -0
- package/dist/{exchange-rate-Cp1ddpw4.d.ts → exchange-rate-DOmoqut9.d.ts} +5 -0
- package/dist/index.d.mts +455 -8
- package/dist/index.d.ts +455 -8
- package/dist/index.js +402 -215
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +292 -123
- package/dist/index.mjs.map +1 -1
- package/dist/utils.js +5 -5
- package/dist/utils.mjs +2 -2
- package/package.json +2 -1
- package/dist/chunk-B2QCI6ET.js.map +0 -1
- package/dist/chunk-CUGK4ZBJ.mjs.map +0 -1
- package/dist/chunk-DTFLXAZJ.js.map +0 -1
- package/dist/chunk-HI44AMLC.mjs.map +0 -1
- package/dist/chunk-ITB7FXG4.js.map +0 -1
- package/dist/chunk-KYR6BFAE.js.map +0 -1
- package/dist/chunk-XXHRCCZS.mjs.map +0 -1
- package/dist/chunk-ZILA73XN.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Address, erc20Abi, Hex } from 'viem';
|
|
2
2
|
import { A as AmplifyVault, S as SupportedAsset, a as AssetFilterOptions, V as VaultFilterOptions, W as WithdrawSupportedAsset } from './amplify-sdk-api-DGRgEybp.js';
|
|
3
3
|
export { b as APIError } from './amplify-sdk-api-DGRgEybp.js';
|
|
4
|
-
export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-
|
|
4
|
+
export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-DOmoqut9.js';
|
|
5
5
|
import { Y as YieldType } from './config-B-u3VqEX.js';
|
|
6
6
|
import { C as ChainId } from './vault-config-BNzhv3QV.js';
|
|
7
7
|
import './config-BQynVNDC.js';
|
|
@@ -375,11 +375,118 @@ declare function findVaultByConfig(params: {
|
|
|
375
375
|
*/
|
|
376
376
|
declare function getWithdrawSupportedAssets(): Promise<WithdrawSupportedAsset[]>;
|
|
377
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Telemetry Type Definitions
|
|
380
|
+
*
|
|
381
|
+
* Types for SDK telemetry, logging, and PostHog integration.
|
|
382
|
+
*/
|
|
383
|
+
/**
|
|
384
|
+
* Log levels for controlling console output
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* import { LogLevel } from "@paxoslabs/amplify-sdk";
|
|
389
|
+
*
|
|
390
|
+
* // Only show errors (default)
|
|
391
|
+
* await initAmplifySDK(apiKey, { logLevel: LogLevel.ERROR });
|
|
392
|
+
*
|
|
393
|
+
* // Show all logs including debug
|
|
394
|
+
* await initAmplifySDK(apiKey, { logLevel: LogLevel.DEBUG });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
declare enum LogLevel {
|
|
398
|
+
DEBUG = 0,
|
|
399
|
+
INFO = 1,
|
|
400
|
+
WARN = 2,
|
|
401
|
+
ERROR = 3,
|
|
402
|
+
NONE = 4
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Logger interface for consumer use
|
|
406
|
+
*
|
|
407
|
+
* Implement this interface to provide a custom logger.
|
|
408
|
+
* All methods receive a message and optional context object.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* import { setLogger, Logger } from "@paxoslabs/amplify-sdk";
|
|
413
|
+
*
|
|
414
|
+
* const customLogger: Logger = {
|
|
415
|
+
* debug: (msg, ctx) => console.debug(`[MyApp] ${msg}`, ctx),
|
|
416
|
+
* info: (msg, ctx) => console.info(`[MyApp] ${msg}`, ctx),
|
|
417
|
+
* warn: (msg, ctx) => console.warn(`[MyApp] ${msg}`, ctx),
|
|
418
|
+
* error: (msg, ctx) => console.error(`[MyApp] ${msg}`, ctx),
|
|
419
|
+
* };
|
|
420
|
+
*
|
|
421
|
+
* setLogger(customLogger);
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
interface Logger {
|
|
425
|
+
/**
|
|
426
|
+
* Log debug message (verbose, development only)
|
|
427
|
+
*/
|
|
428
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
429
|
+
/**
|
|
430
|
+
* Log informational message
|
|
431
|
+
*/
|
|
432
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
433
|
+
/**
|
|
434
|
+
* Log warning message
|
|
435
|
+
*/
|
|
436
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
437
|
+
/**
|
|
438
|
+
* Log error message
|
|
439
|
+
*/
|
|
440
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
441
|
+
}
|
|
442
|
+
|
|
378
443
|
/**
|
|
379
444
|
* SDK Configuration Types
|
|
380
445
|
*
|
|
381
446
|
* Type definitions for SDK initialization and configuration management.
|
|
382
447
|
*/
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* SDK Initialization Options
|
|
451
|
+
*
|
|
452
|
+
* Options for configuring SDK behavior during initialization.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* // Enable debug logging, disable telemetry
|
|
457
|
+
* await initAmplifySDK(apiKey, {
|
|
458
|
+
* telemetry: false,
|
|
459
|
+
* logLevel: LogLevel.DEBUG,
|
|
460
|
+
* });
|
|
461
|
+
* ```
|
|
462
|
+
*/
|
|
463
|
+
interface SDKInitOptions {
|
|
464
|
+
/**
|
|
465
|
+
* Enable or disable telemetry (PostHog error tracking)
|
|
466
|
+
*
|
|
467
|
+
* When enabled (default), errors are tracked to PostHog for
|
|
468
|
+
* proactive monitoring. Disable for privacy or testing.
|
|
469
|
+
*
|
|
470
|
+
* @default true
|
|
471
|
+
*/
|
|
472
|
+
telemetry?: boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Console log level
|
|
475
|
+
*
|
|
476
|
+
* Controls which log messages are output to the console.
|
|
477
|
+
* Does not affect telemetry (errors are always tracked if enabled).
|
|
478
|
+
*
|
|
479
|
+
* @default LogLevel.ERROR
|
|
480
|
+
*/
|
|
481
|
+
logLevel?: LogLevel;
|
|
482
|
+
/**
|
|
483
|
+
* Custom logger implementation
|
|
484
|
+
*
|
|
485
|
+
* Override the default console logger with a custom implementation.
|
|
486
|
+
* Useful for integrating with existing logging infrastructure.
|
|
487
|
+
*/
|
|
488
|
+
logger?: Logger;
|
|
489
|
+
}
|
|
383
490
|
/**
|
|
384
491
|
* SDK Configuration State
|
|
385
492
|
*
|
|
@@ -413,6 +520,11 @@ interface SDKConfig {
|
|
|
413
520
|
* Allows concurrent calls to wait for same initialization
|
|
414
521
|
*/
|
|
415
522
|
initPromise: Promise<void> | null;
|
|
523
|
+
/**
|
|
524
|
+
* Whether telemetry is enabled
|
|
525
|
+
* Set during initialization based on options
|
|
526
|
+
*/
|
|
527
|
+
telemetryEnabled: boolean;
|
|
416
528
|
}
|
|
417
529
|
/**
|
|
418
530
|
* Request headers for Paxos Labs API
|
|
@@ -439,19 +551,100 @@ type InitErrorCode = "INVALID_API_KEY" | "EMPTY_API_KEY" | "AUTH_FAILED" | "NETW
|
|
|
439
551
|
* Initialize Amplify SDK with API key
|
|
440
552
|
*
|
|
441
553
|
* Validates API key, configures authentication headers, and pre-populates
|
|
442
|
-
* the cache with vault and asset data.
|
|
554
|
+
* the cache with vault and asset data. Optionally initializes telemetry
|
|
555
|
+
* for error tracking.
|
|
443
556
|
*
|
|
444
557
|
* @param apiKey - API key obtained from Paxos Labs
|
|
558
|
+
* @param options - Optional configuration options
|
|
559
|
+
* @param options.telemetry - Enable/disable telemetry (default: true)
|
|
560
|
+
* @param options.logLevel - Console log level (default: LogLevel.ERROR)
|
|
561
|
+
* @param options.logger - Custom logger implementation
|
|
445
562
|
* @throws {APIError} If initialization fails
|
|
446
563
|
*
|
|
447
564
|
* @example
|
|
448
565
|
* ```typescript
|
|
449
566
|
* import { initAmplifySDK } from "@paxoslabs/amplify-sdk";
|
|
450
567
|
*
|
|
568
|
+
* // Basic initialization (telemetry enabled by default)
|
|
451
569
|
* await initAmplifySDK("pxl_internal_your_api_key_here");
|
|
570
|
+
*
|
|
571
|
+
* // Disable telemetry
|
|
572
|
+
* await initAmplifySDK("pxl_your_api_key", { telemetry: false });
|
|
573
|
+
*
|
|
574
|
+
* // Enable debug logging
|
|
575
|
+
* await initAmplifySDK("pxl_your_api_key", { logLevel: LogLevel.DEBUG });
|
|
452
576
|
* ```
|
|
453
577
|
*/
|
|
454
|
-
declare function initAmplifySDK(apiKey: string): Promise<void>;
|
|
578
|
+
declare function initAmplifySDK(apiKey: string, options?: SDKInitOptions): Promise<void>;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Logger Module
|
|
582
|
+
*
|
|
583
|
+
* Provides a consumer-facing logger interface with configurable log levels.
|
|
584
|
+
* Default implementation logs errors only to console.
|
|
585
|
+
*/
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Set a custom logger implementation
|
|
589
|
+
*
|
|
590
|
+
* Replace the default console logger with a custom implementation.
|
|
591
|
+
* Useful for integrating with existing logging infrastructure.
|
|
592
|
+
*
|
|
593
|
+
* @param logger - Custom logger implementing the Logger interface
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```typescript
|
|
597
|
+
* import { setLogger } from "@paxoslabs/amplify-sdk";
|
|
598
|
+
*
|
|
599
|
+
* // Use a custom logger
|
|
600
|
+
* setLogger({
|
|
601
|
+
* debug: (msg, ctx) => winston.debug(msg, ctx),
|
|
602
|
+
* info: (msg, ctx) => winston.info(msg, ctx),
|
|
603
|
+
* warn: (msg, ctx) => winston.warn(msg, ctx),
|
|
604
|
+
* error: (msg, ctx) => winston.error(msg, ctx),
|
|
605
|
+
* });
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
declare function setLogger(logger: Logger): void;
|
|
609
|
+
/**
|
|
610
|
+
* Get the current logger instance
|
|
611
|
+
*
|
|
612
|
+
* Returns the custom logger if set, otherwise the default console logger.
|
|
613
|
+
*
|
|
614
|
+
* @returns Current logger instance
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```typescript
|
|
618
|
+
* import { getLogger } from "@paxoslabs/amplify-sdk";
|
|
619
|
+
*
|
|
620
|
+
* const logger = getLogger();
|
|
621
|
+
* logger.info("Processing deposit", { amount: "100" });
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
declare function getLogger(): Logger;
|
|
625
|
+
/**
|
|
626
|
+
* Set the log level for the default console logger
|
|
627
|
+
*
|
|
628
|
+
* Controls which log messages are output to the console.
|
|
629
|
+
* Has no effect if a custom logger is set.
|
|
630
|
+
*
|
|
631
|
+
* @param level - Minimum log level to output
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* import { setLogLevel, LogLevel } from "@paxoslabs/amplify-sdk";
|
|
636
|
+
*
|
|
637
|
+
* // Show all logs including debug
|
|
638
|
+
* setLogLevel(LogLevel.DEBUG);
|
|
639
|
+
*
|
|
640
|
+
* // Only show errors (default)
|
|
641
|
+
* setLogLevel(LogLevel.ERROR);
|
|
642
|
+
*
|
|
643
|
+
* // Disable all logging
|
|
644
|
+
* setLogLevel(LogLevel.NONE);
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
declare function setLogLevel(level: LogLevel): void;
|
|
455
648
|
|
|
456
649
|
/**
|
|
457
650
|
* @file Approve Asset for deposit functionality for Paxos Labs vaults
|
|
@@ -850,11 +1043,12 @@ interface DepositTxData {
|
|
|
850
1043
|
* Accepts yieldType, recipientAddress, depositToken, and chainId for automatic vault resolution
|
|
851
1044
|
* @interface PrepareDepositTxDataParams
|
|
852
1045
|
* @property {YieldType} yieldType - Yield strategy type (e.g., "PRIME", "TBILL", "LENDING")
|
|
853
|
-
* @property {Address} recipientAddress - Ethereum address of the user
|
|
854
|
-
* @property {Address} depositToken - Token contract address to deposit
|
|
1046
|
+
* @property {Address} recipientAddress - Ethereum address of the user. Must be the same as the address used to sign the deposit transaction.
|
|
1047
|
+
* @property {Address} depositToken - Token contract address to deposit. Must be supported by the vault.
|
|
855
1048
|
* @property {string} depositAmount - Amount of assets to deposit as a decimal string (e.g., "1.5")
|
|
856
1049
|
* @property {number | string} chainId - ID of the chain where the deposit will occur
|
|
857
|
-
* @property {number} [slippage] - Maximum acceptable slippage in basis points (e.g., 100 for 1%)
|
|
1050
|
+
* @property {number} [slippage] - Optional (default is 50 (0.5%)): Maximum acceptable slippage in basis points (e.g., 100 for 1%).
|
|
1051
|
+
* @property {string} [partnerCode] - Optional (default is empty string): Partner code to credit deposit fees to the partner used for the deposit
|
|
858
1052
|
*/
|
|
859
1053
|
interface PrepareDepositTxDataParams {
|
|
860
1054
|
yieldType: YieldType;
|
|
@@ -880,6 +1074,7 @@ interface PrepareDepositTxDataParams {
|
|
|
880
1074
|
* depositAmount: "1.0",
|
|
881
1075
|
* chainId: 1,
|
|
882
1076
|
* slippage: 100, // 1% slippage (100 bps)
|
|
1077
|
+
* partnerCode: 'my-partner-code',
|
|
883
1078
|
* });
|
|
884
1079
|
* ```
|
|
885
1080
|
*
|
|
@@ -975,6 +1170,10 @@ interface ParsedPermitSignature {
|
|
|
975
1170
|
* @property recipientAddress - User address (permit owner)
|
|
976
1171
|
* @property chainId - Blockchain network ID
|
|
977
1172
|
* @property deadline - Optional permit expiration (defaults to 1 hour)
|
|
1173
|
+
* @property nonce - Optional pre-fetched nonce (skips RPC call if provided)
|
|
1174
|
+
* @property decimals - Optional pre-fetched token decimals (skips RPC call)
|
|
1175
|
+
* @property tokenName - Optional pre-fetched token name (skips RPC call)
|
|
1176
|
+
* @property tokenVersion - Optional pre-fetched token version (skips RPC call)
|
|
978
1177
|
*/
|
|
979
1178
|
interface PrepareDepositPermitSignatureParams {
|
|
980
1179
|
yieldType: YieldType;
|
|
@@ -983,6 +1182,14 @@ interface PrepareDepositPermitSignatureParams {
|
|
|
983
1182
|
recipientAddress: Address;
|
|
984
1183
|
chainId: number;
|
|
985
1184
|
deadline?: bigint;
|
|
1185
|
+
/** Pre-fetched nonce from getTokenPermitInfoWithAllowance */
|
|
1186
|
+
nonce?: bigint;
|
|
1187
|
+
/** Pre-fetched token decimals */
|
|
1188
|
+
decimals?: number;
|
|
1189
|
+
/** Pre-fetched token name for EIP-712 domain */
|
|
1190
|
+
tokenName?: string;
|
|
1191
|
+
/** Pre-fetched token version for EIP-712 domain (defaults to "1") */
|
|
1192
|
+
tokenVersion?: string;
|
|
986
1193
|
}
|
|
987
1194
|
/**
|
|
988
1195
|
* T009: Encoded transaction data for permit deposit
|
|
@@ -1070,7 +1277,8 @@ declare function parsePermitSignature(signature: Hex): ParsedPermitSignature;
|
|
|
1070
1277
|
* @property {number | ChainId} chainId - ID of the chain where the deposit will occur
|
|
1071
1278
|
* @property {Hex} signature - Raw hex signature from wallet signing
|
|
1072
1279
|
* @property {bigint} deadline - Deadline timestamp (must match permit signature deadline)
|
|
1073
|
-
* @property {number} [slippage] - Maximum acceptable slippage in basis points (
|
|
1280
|
+
* @property {number} [slippage] - Optional (default is 50 (0.5%)): Maximum acceptable slippage in basis points (e.g., 100 for 1%).
|
|
1281
|
+
* @property {string} [partnerCode] - Optional (default is empty string): Partner code to credit deposit fees to the partner used for the deposit
|
|
1074
1282
|
*
|
|
1075
1283
|
* @example
|
|
1076
1284
|
* ```typescript
|
|
@@ -1086,6 +1294,7 @@ declare function parsePermitSignature(signature: Hex): ParsedPermitSignature;
|
|
|
1086
1294
|
* signature,
|
|
1087
1295
|
* deadline: permitData.message.deadline,
|
|
1088
1296
|
* slippage: 100, // 1%
|
|
1297
|
+
* partnerCode: "my-partner-code",
|
|
1089
1298
|
* };
|
|
1090
1299
|
* ```
|
|
1091
1300
|
*/
|
|
@@ -1120,6 +1329,244 @@ interface PrepareDepositWithPermitTxDataParams {
|
|
|
1120
1329
|
*/
|
|
1121
1330
|
declare function prepareDepositWithPermitTxData(params: PrepareDepositWithPermitTxDataParams): Promise<UnencodedDepositWithPermitData>;
|
|
1122
1331
|
|
|
1332
|
+
/**
|
|
1333
|
+
* @file Unified deposit module with wrapper functions
|
|
1334
|
+
* @module vaults/deposit
|
|
1335
|
+
*
|
|
1336
|
+
* Provides high-level wrapper functions for deposit authorization and execution:
|
|
1337
|
+
* - `prepareDepositAuthorization`: Determines optimal authorization method (permit/approval)
|
|
1338
|
+
* - `prepareDeposit`: Unified deposit preparation with automatic routing
|
|
1339
|
+
*/
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* Authorization methods for deposit operations
|
|
1343
|
+
*
|
|
1344
|
+
* Extensible enum for current and future authorization mechanisms:
|
|
1345
|
+
* - PERMIT: EIP-2612 off-chain signature (gas efficient, single transaction)
|
|
1346
|
+
* - APPROVAL: Traditional ERC20 approval (two transactions)
|
|
1347
|
+
* - ALREADY_APPROVED: Existing allowance is sufficient (no action needed)
|
|
1348
|
+
*
|
|
1349
|
+
* @example
|
|
1350
|
+
* ```typescript
|
|
1351
|
+
* import { DepositAuthMethod } from "@paxoslabs/amplify-sdk";
|
|
1352
|
+
*
|
|
1353
|
+
* if (result.method === DepositAuthMethod.PERMIT) {
|
|
1354
|
+
* // Handle permit flow
|
|
1355
|
+
* }
|
|
1356
|
+
* ```
|
|
1357
|
+
*/
|
|
1358
|
+
declare const DepositAuthMethod: {
|
|
1359
|
+
readonly PERMIT: "permit";
|
|
1360
|
+
readonly APPROVAL: "approval";
|
|
1361
|
+
readonly ALREADY_APPROVED: "already_approved";
|
|
1362
|
+
};
|
|
1363
|
+
type DepositAuthMethod = (typeof DepositAuthMethod)[keyof typeof DepositAuthMethod];
|
|
1364
|
+
/**
|
|
1365
|
+
* Permit authorization result
|
|
1366
|
+
* Returned when token supports EIP-2612 permit
|
|
1367
|
+
*/
|
|
1368
|
+
interface PermitAuthorizationResult {
|
|
1369
|
+
method: typeof DepositAuthMethod.PERMIT;
|
|
1370
|
+
/** EIP-712 typed data ready for wallet signing */
|
|
1371
|
+
permitData: PermitSignatureData;
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Approval authorization result
|
|
1375
|
+
* Returned when an ERC20 approval transaction is needed
|
|
1376
|
+
*/
|
|
1377
|
+
interface ApprovalAuthorizationResult {
|
|
1378
|
+
method: typeof DepositAuthMethod.APPROVAL;
|
|
1379
|
+
/** Transaction data for ERC20 approve() call */
|
|
1380
|
+
txData: ApproveDepositTokenTxData;
|
|
1381
|
+
/** Current allowance (human-readable) */
|
|
1382
|
+
currentAllowance: string;
|
|
1383
|
+
/** Current allowance as BigInt string */
|
|
1384
|
+
currentAllowanceAsBigInt: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Already approved authorization result
|
|
1388
|
+
* Returned when existing allowance is sufficient for the deposit
|
|
1389
|
+
*/
|
|
1390
|
+
interface AlreadyApprovedAuthorizationResult {
|
|
1391
|
+
method: typeof DepositAuthMethod.ALREADY_APPROVED;
|
|
1392
|
+
/** Current allowance (human-readable) */
|
|
1393
|
+
allowance: string;
|
|
1394
|
+
/** Current allowance as BigInt string */
|
|
1395
|
+
allowanceAsBigInt: string;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Discriminated union of all authorization result types
|
|
1399
|
+
*
|
|
1400
|
+
* Use type narrowing with `result.method` to access specific fields:
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* ```typescript
|
|
1404
|
+
* const result = await prepareDepositAuthorization({...});
|
|
1405
|
+
*
|
|
1406
|
+
* switch (result.method) {
|
|
1407
|
+
* case DepositAuthMethod.PERMIT:
|
|
1408
|
+
* // TypeScript knows result.permitData exists
|
|
1409
|
+
* const signature = await signTypedData(result.permitData);
|
|
1410
|
+
* break;
|
|
1411
|
+
* case DepositAuthMethod.APPROVAL:
|
|
1412
|
+
* // TypeScript knows result.txData exists
|
|
1413
|
+
* await writeContract(result.txData);
|
|
1414
|
+
* break;
|
|
1415
|
+
* case DepositAuthMethod.ALREADY_APPROVED:
|
|
1416
|
+
* // TypeScript knows result.allowance exists
|
|
1417
|
+
* console.log(`Already approved: ${result.allowance}`);
|
|
1418
|
+
* break;
|
|
1419
|
+
* }
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
type DepositAuthorizationResult = PermitAuthorizationResult | ApprovalAuthorizationResult | AlreadyApprovedAuthorizationResult;
|
|
1423
|
+
/**
|
|
1424
|
+
* Parameters for prepareDepositAuthorization
|
|
1425
|
+
*/
|
|
1426
|
+
interface PrepareDepositAuthorizationParams {
|
|
1427
|
+
/** Yield strategy type (e.g., "PRIME", "TBILL", "LENDING") */
|
|
1428
|
+
yieldType: YieldType;
|
|
1429
|
+
/** Token contract address to deposit */
|
|
1430
|
+
depositToken: Address;
|
|
1431
|
+
/** Amount of assets to deposit as decimal string (e.g., "100.25") */
|
|
1432
|
+
depositAmount: string;
|
|
1433
|
+
/** User's wallet address (permit owner / approval sender) */
|
|
1434
|
+
recipientAddress: Address;
|
|
1435
|
+
/** Blockchain network ID */
|
|
1436
|
+
chainId: ChainId;
|
|
1437
|
+
/** Optional deadline for permit signature (defaults to 1 hour from now) */
|
|
1438
|
+
deadline?: bigint;
|
|
1439
|
+
/** Force specific authorization method (bypasses automatic detection) */
|
|
1440
|
+
forceMethod?: "permit" | "approval";
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Parameters for prepareDeposit
|
|
1444
|
+
* Unified deposit function accepting optional permit signature
|
|
1445
|
+
*/
|
|
1446
|
+
interface PrepareDepositParams {
|
|
1447
|
+
/** Yield strategy type (e.g., "PRIME", "TBILL", "LENDING") */
|
|
1448
|
+
yieldType: YieldType;
|
|
1449
|
+
/** Token contract address to deposit */
|
|
1450
|
+
depositToken: Address;
|
|
1451
|
+
/** Amount of assets to deposit as decimal string (e.g., "100.25") */
|
|
1452
|
+
depositAmount: string;
|
|
1453
|
+
/** Recipient address for vault shares */
|
|
1454
|
+
recipientAddress: Address;
|
|
1455
|
+
/** Blockchain network ID */
|
|
1456
|
+
chainId: ChainId;
|
|
1457
|
+
/** Optional slippage in basis points (default: 50 = 0.5%) */
|
|
1458
|
+
slippage?: number;
|
|
1459
|
+
/** Optional partner code for fee attribution */
|
|
1460
|
+
partnerCode?: string;
|
|
1461
|
+
/** Optional permit signature (hex string from wallet signing) */
|
|
1462
|
+
signature?: Hex;
|
|
1463
|
+
/** Optional permit deadline (must match signature deadline) */
|
|
1464
|
+
deadline?: bigint;
|
|
1465
|
+
/** Force deposit method (bypasses automatic routing) */
|
|
1466
|
+
forceMethod?: "permit" | "approval";
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Standard deposit result (approval flow)
|
|
1470
|
+
*/
|
|
1471
|
+
interface StandardDepositResult {
|
|
1472
|
+
method: typeof DepositAuthMethod.APPROVAL;
|
|
1473
|
+
txData: DepositTxData;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Permit deposit result
|
|
1477
|
+
*/
|
|
1478
|
+
interface PermitDepositResult {
|
|
1479
|
+
method: typeof DepositAuthMethod.PERMIT;
|
|
1480
|
+
txData: UnencodedDepositWithPermitData;
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Unified deposit result
|
|
1484
|
+
* Returns either standard deposit or permit deposit transaction data
|
|
1485
|
+
*/
|
|
1486
|
+
type PrepareDepositResult = StandardDepositResult | PermitDepositResult;
|
|
1487
|
+
/**
|
|
1488
|
+
* Prepares authorization for a deposit operation
|
|
1489
|
+
*
|
|
1490
|
+
* Intelligently determines the best authorization method:
|
|
1491
|
+
* 1. Check if token supports EIP-2612 permit → return permit signature data
|
|
1492
|
+
* 2. Check existing allowance → if sufficient, return "already approved"
|
|
1493
|
+
* 3. Otherwise → return approval transaction data
|
|
1494
|
+
*
|
|
1495
|
+
* Supports force override via `forceMethod` parameter.
|
|
1496
|
+
*
|
|
1497
|
+
* @param params - Authorization parameters
|
|
1498
|
+
* @returns Discriminated union of authorization results
|
|
1499
|
+
* @throws {APIError} If vault not found, chain not supported, or token invalid
|
|
1500
|
+
*
|
|
1501
|
+
* @example
|
|
1502
|
+
* ```typescript
|
|
1503
|
+
* import { prepareDepositAuthorization, DepositAuthMethod } from "@paxoslabs/amplify-sdk";
|
|
1504
|
+
*
|
|
1505
|
+
* const authResult = await prepareDepositAuthorization({
|
|
1506
|
+
* yieldType: "PRIME",
|
|
1507
|
+
* depositToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
1508
|
+
* depositAmount: "1000.0",
|
|
1509
|
+
* recipientAddress: "0x1234...",
|
|
1510
|
+
* chainId: 1,
|
|
1511
|
+
* });
|
|
1512
|
+
*
|
|
1513
|
+
* if (authResult.method === DepositAuthMethod.PERMIT) {
|
|
1514
|
+
* const signature = await signTypedData(authResult.permitData);
|
|
1515
|
+
* // Use signature in prepareDeposit
|
|
1516
|
+
* } else if (authResult.method === DepositAuthMethod.APPROVAL) {
|
|
1517
|
+
* await writeContract(authResult.txData);
|
|
1518
|
+
* // Wait for confirmation, then call prepareDeposit
|
|
1519
|
+
* } else {
|
|
1520
|
+
* // Already approved, proceed directly to deposit
|
|
1521
|
+
* console.log(`Approved amount: ${authResult.allowance}`);
|
|
1522
|
+
* }
|
|
1523
|
+
* ```
|
|
1524
|
+
*/
|
|
1525
|
+
declare function prepareDepositAuthorization(params: PrepareDepositAuthorizationParams): Promise<DepositAuthorizationResult>;
|
|
1526
|
+
/**
|
|
1527
|
+
* Unified deposit preparation function
|
|
1528
|
+
*
|
|
1529
|
+
* Intelligently routes to permit deposit or standard deposit based on:
|
|
1530
|
+
* 1. Presence of signature/deadline parameters → permit deposit
|
|
1531
|
+
* 2. Force method override → specified method
|
|
1532
|
+
* 3. Otherwise → standard deposit
|
|
1533
|
+
*
|
|
1534
|
+
* @param params - Deposit parameters with optional permit signature
|
|
1535
|
+
* @returns Discriminated union of deposit transaction data
|
|
1536
|
+
* @throws {APIError} If vault not found, invalid signature, or validation fails
|
|
1537
|
+
*
|
|
1538
|
+
* @example
|
|
1539
|
+
* ```typescript
|
|
1540
|
+
* import { prepareDeposit, DepositAuthMethod } from "@paxoslabs/amplify-sdk";
|
|
1541
|
+
*
|
|
1542
|
+
* // Scenario 1: Permit deposit (with signature from prepareDepositAuthorization)
|
|
1543
|
+
* const permitDeposit = await prepareDeposit({
|
|
1544
|
+
* yieldType: "PRIME",
|
|
1545
|
+
* depositToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
1546
|
+
* depositAmount: "1000.0",
|
|
1547
|
+
* recipientAddress: "0x1234...",
|
|
1548
|
+
* chainId: 1,
|
|
1549
|
+
* signature: "0xabc...",
|
|
1550
|
+
* deadline: 1234567890n,
|
|
1551
|
+
* });
|
|
1552
|
+
* // permitDeposit.method === DepositAuthMethod.PERMIT
|
|
1553
|
+
*
|
|
1554
|
+
* // Scenario 2: Standard deposit (after approval)
|
|
1555
|
+
* const standardDeposit = await prepareDeposit({
|
|
1556
|
+
* yieldType: "PRIME",
|
|
1557
|
+
* depositToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
1558
|
+
* depositAmount: "1000.0",
|
|
1559
|
+
* recipientAddress: "0x1234...",
|
|
1560
|
+
* chainId: 1,
|
|
1561
|
+
* });
|
|
1562
|
+
* // standardDeposit.method === DepositAuthMethod.APPROVAL
|
|
1563
|
+
*
|
|
1564
|
+
* // Submit transaction
|
|
1565
|
+
* await writeContract(standardDeposit.txData);
|
|
1566
|
+
* ```
|
|
1567
|
+
*/
|
|
1568
|
+
declare function prepareDeposit(params: PrepareDepositParams): Promise<PrepareDepositResult>;
|
|
1569
|
+
|
|
1123
1570
|
declare const BoringVaultAbi: readonly [{
|
|
1124
1571
|
readonly type: "constructor";
|
|
1125
1572
|
readonly inputs: readonly [{
|
|
@@ -3557,4 +4004,4 @@ interface WithdrawTxData {
|
|
|
3557
4004
|
*/
|
|
3558
4005
|
declare const prepareWithdrawTxData: ({ yieldType, wantAssetAddress, chainId, offerAmount, deadline, slippage, }: PrepareWithdrawTxDataParams) => Promise<WithdrawTxData>;
|
|
3559
4006
|
|
|
3560
|
-
export { AmplifyVault, type ApproveDepositTokenTxData, type ApproveWithdrawTokenTxData, AssetFilterOptions, type BulkWithdrawTxData, type DepositTxData, type EIP712Domain, type InitErrorCode, PERMIT_TYPES, type ParsedPermitSignature, type PermitSignatureData, type PrepareDepositPermitSignatureParams, type PrepareDepositWithPermitTxDataParams, type RequestHeaders, type SDKConfig, SupportedAsset, type UnencodedDepositWithPermitData, VaultFilterOptions, WithdrawSupportedAsset, type WithdrawTxData, YieldType, fetchSupportedAssets, fetchVaults, findVaultByConfig, getAssetsFromCache, getCache, getWithdrawSupportedAssets, initAmplifySDK, initializeCache, parsePermitSignature, prepareApproveDepositTokenTxData, prepareApproveWithdrawTxData, prepareBulkWithdrawTxData, prepareDepositPermitSignature, prepareDepositTxData, prepareDepositWithPermitTxData, prepareWithdrawTxData, refreshVaultCache };
|
|
4007
|
+
export { type AlreadyApprovedAuthorizationResult, AmplifyVault, type ApprovalAuthorizationResult, type ApproveDepositTokenTxData, type ApproveWithdrawTokenTxData, AssetFilterOptions, type BulkWithdrawTxData, DepositAuthMethod, type DepositAuthorizationResult, type DepositTxData, type EIP712Domain, type InitErrorCode, LogLevel, type Logger, PERMIT_TYPES, type ParsedPermitSignature, type PermitAuthorizationResult, type PermitDepositResult, type PermitSignatureData, type PrepareDepositAuthorizationParams, type PrepareDepositParams, type PrepareDepositPermitSignatureParams, type PrepareDepositResult, type PrepareDepositWithPermitTxDataParams, type RequestHeaders, type SDKConfig, type SDKInitOptions, type StandardDepositResult, SupportedAsset, type UnencodedDepositWithPermitData, VaultFilterOptions, WithdrawSupportedAsset, type WithdrawTxData, YieldType, fetchSupportedAssets, fetchVaults, findVaultByConfig, getAssetsFromCache, getCache, getLogger, getWithdrawSupportedAssets, initAmplifySDK, initializeCache, parsePermitSignature, prepareApproveDepositTokenTxData, prepareApproveWithdrawTxData, prepareBulkWithdrawTxData, prepareDeposit, prepareDepositAuthorization, prepareDepositPermitSignature, prepareDepositTxData, prepareDepositWithPermitTxData, prepareWithdrawTxData, refreshVaultCache, setLogLevel, setLogger };
|