@circle-fin/app-kit 1.15.2 → 1.15.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.
- package/CHANGELOG.md +6 -0
- package/bridge.cjs +58 -15
- package/bridge.d.cts +71 -0
- package/bridge.d.mts +71 -0
- package/bridge.d.ts +71 -0
- package/bridge.mjs +58 -15
- package/context.d.cts +71 -0
- package/context.d.mts +71 -0
- package/context.d.ts +71 -0
- package/earn.cjs +382 -42
- package/earn.d.cts +19 -26
- package/earn.d.mts +19 -26
- package/earn.d.ts +19 -26
- package/earn.mjs +382 -42
- package/estimateBridge.cjs +58 -15
- package/estimateBridge.d.cts +71 -0
- package/estimateBridge.d.mts +71 -0
- package/estimateBridge.d.ts +71 -0
- package/estimateBridge.mjs +58 -15
- package/estimateSwap.cjs +58 -15
- package/estimateSwap.d.cts +71 -0
- package/estimateSwap.d.mts +71 -0
- package/estimateSwap.d.ts +71 -0
- package/estimateSwap.mjs +58 -15
- package/index.cjs +288 -60
- package/index.d.cts +184 -91
- package/index.d.mts +184 -91
- package/index.d.ts +184 -91
- package/index.mjs +288 -60
- package/package.json +3 -3
- package/server.cjs +13 -17
- package/server.d.cts +10 -9
- package/server.d.mts +10 -9
- package/server.d.ts +10 -9
- package/server.mjs +13 -17
- package/swap.cjs +58 -15
- package/swap.d.cts +71 -0
- package/swap.d.mts +71 -0
- package/swap.d.ts +71 -0
- package/swap.mjs +58 -15
package/CHANGELOG.md
CHANGED
package/bridge.cjs
CHANGED
|
@@ -29506,7 +29506,7 @@ new Set(Object.values(Blockchain));
|
|
|
29506
29506
|
registerKit(`${pkg$1.name}/${pkg$1.version}`);
|
|
29507
29507
|
|
|
29508
29508
|
var name = "@circle-fin/earn-kit";
|
|
29509
|
-
var version = "1.
|
|
29509
|
+
var version = "1.8.0";
|
|
29510
29510
|
var pkg = {
|
|
29511
29511
|
name: name,
|
|
29512
29512
|
version: version};
|
|
@@ -29648,10 +29648,8 @@ const bridgeFeeTokenSchema = hexAddressSchema;
|
|
|
29648
29648
|
assetAddress: zod.z.string(),
|
|
29649
29649
|
lltv: zod.z.number(),
|
|
29650
29650
|
supplyUsd: zod.z.number(),
|
|
29651
|
-
//
|
|
29652
|
-
|
|
29653
|
-
// schema; `null` when the product exposes no per-market allocation (V2).
|
|
29654
|
-
allocationPct: zod.z.number().nullable().optional()
|
|
29651
|
+
// `null` when the product exposes no per-market allocation (V2).
|
|
29652
|
+
allocationPct: zod.z.number().nullable()
|
|
29655
29653
|
});
|
|
29656
29654
|
/**
|
|
29657
29655
|
* Zod schema for a Morpho vault warning in the API response.
|
|
@@ -29758,19 +29756,20 @@ const bridgeFeeTokenSchema = hexAddressSchema;
|
|
|
29758
29756
|
earnKitWarnings: zod.z.array(zod.z.string()).optional()
|
|
29759
29757
|
});
|
|
29760
29758
|
/**
|
|
29761
|
-
* Shared base schema: existing flat fields (kept
|
|
29762
|
-
* facets
|
|
29763
|
-
*
|
|
29759
|
+
* Shared base schema: existing flat fields (kept as deprecated aliases) plus
|
|
29760
|
+
* the nested facets. Zenith emits all facets on every response; required here
|
|
29761
|
+
* so a partial emission is caught at parse time rather than surfacing as a
|
|
29762
|
+
* runtime `undefined` access.
|
|
29764
29763
|
*
|
|
29765
29764
|
* @internal
|
|
29766
29765
|
*/ const earnBaseSchema = vaultInfoResponseSchema.extend({
|
|
29767
|
-
address: zod.z.string()
|
|
29768
|
-
asOf: zod.z.string()
|
|
29769
|
-
manager: managerSchema.nullable()
|
|
29770
|
-
apyProfile: apyProfileSchema
|
|
29771
|
-
fee: feeInfoSchema
|
|
29772
|
-
liquidityProfile: liquidityProfileSchema
|
|
29773
|
-
riskSignals: riskSignalsSchema
|
|
29766
|
+
address: zod.z.string(),
|
|
29767
|
+
asOf: zod.z.string(),
|
|
29768
|
+
manager: managerSchema.nullable(),
|
|
29769
|
+
apyProfile: apyProfileSchema,
|
|
29770
|
+
fee: feeInfoSchema,
|
|
29771
|
+
liquidityProfile: liquidityProfileSchema,
|
|
29772
|
+
riskSignals: riskSignalsSchema
|
|
29774
29773
|
});
|
|
29775
29774
|
/**
|
|
29776
29775
|
* Zod schema for the `vault` opportunity variant.
|
|
@@ -30740,6 +30739,49 @@ const sourceAdapterContextSchema = zod.z.object({
|
|
|
30740
30739
|
vaultAddress: vaultAddressSchema,
|
|
30741
30740
|
config: earnConfigSchema.optional()
|
|
30742
30741
|
});
|
|
30742
|
+
/**
|
|
30743
|
+
* Schema for a successful gas fee entry (fees is non-null).
|
|
30744
|
+
*
|
|
30745
|
+
* Validates the kit shape — {@link EarnEstimatedGas} uses decimal strings for
|
|
30746
|
+
* `gas`, `gasPrice`, and `fee`. Only digits are accepted so that the deposit
|
|
30747
|
+
* operation can safely convert them to `bigint` before passing them to the
|
|
30748
|
+
* provider's `computeGasReserve`.
|
|
30749
|
+
*
|
|
30750
|
+
* @internal
|
|
30751
|
+
*/ const earnGasFeeEstimateSuccessSchema = zod.z.object({
|
|
30752
|
+
name: zod.z.string(),
|
|
30753
|
+
token: zod.z.string(),
|
|
30754
|
+
blockchain: zod.z.string(),
|
|
30755
|
+
fees: zod.z.object({
|
|
30756
|
+
gas: zod.z.string().regex(/^\d+$/, 'gas must be a non-negative integer string'),
|
|
30757
|
+
gasPrice: zod.z.string().regex(/^\d+$/, 'gasPrice must be a non-negative integer string'),
|
|
30758
|
+
fee: zod.z.string().regex(/^\d+$/, 'fee must be a non-negative integer string')
|
|
30759
|
+
}),
|
|
30760
|
+
error: zod.z.undefined().optional()
|
|
30761
|
+
}).strict();
|
|
30762
|
+
/**
|
|
30763
|
+
* Schema for a failed gas fee entry (fees is null, error is a string).
|
|
30764
|
+
*
|
|
30765
|
+
* @internal
|
|
30766
|
+
*/ const earnGasFeeEstimateFailureSchema = zod.z.object({
|
|
30767
|
+
name: zod.z.string(),
|
|
30768
|
+
token: zod.z.string(),
|
|
30769
|
+
blockchain: zod.z.string(),
|
|
30770
|
+
fees: zod.z.null(),
|
|
30771
|
+
error: zod.z.string()
|
|
30772
|
+
}).strict();
|
|
30773
|
+
/**
|
|
30774
|
+
* Schema for a single kit-level gas fee estimate entry.
|
|
30775
|
+
*
|
|
30776
|
+
* Rejects arbitrary inputs (null, numbers, empty objects, non-numeric fee
|
|
30777
|
+
* strings) so callers receive a descriptive validation error instead of a
|
|
30778
|
+
* raw `BigInt` conversion error inside `computeGasReserve`.
|
|
30779
|
+
*
|
|
30780
|
+
* @internal
|
|
30781
|
+
*/ const earnGasFeeEstimateSchema = zod.z.union([
|
|
30782
|
+
earnGasFeeEstimateSuccessSchema,
|
|
30783
|
+
earnGasFeeEstimateFailureSchema
|
|
30784
|
+
]);
|
|
30743
30785
|
/**
|
|
30744
30786
|
* Validation schema for the same-chain variant of DepositParams.
|
|
30745
30787
|
*
|
|
@@ -30752,6 +30794,7 @@ const sourceAdapterContextSchema = zod.z.object({
|
|
|
30752
30794
|
to: zod.z.undefined().optional(),
|
|
30753
30795
|
vaultAddress: vaultAddressSchema,
|
|
30754
30796
|
amount: amountSchema,
|
|
30797
|
+
gasFees: zod.z.array(earnGasFeeEstimateSchema).optional(),
|
|
30755
30798
|
config: earnConfigSchema.optional()
|
|
30756
30799
|
}).strict();
|
|
30757
30800
|
const crossChainDepositDestinationSchema = zod.z.object({
|
package/bridge.d.cts
CHANGED
|
@@ -7467,6 +7467,26 @@ interface VaultQuery {
|
|
|
7467
7467
|
/** On-chain vault contract address. */
|
|
7468
7468
|
readonly vaultAddress: string;
|
|
7469
7469
|
}
|
|
7470
|
+
/**
|
|
7471
|
+
* Fields shared by both {@link EarnGasFeeEstimate} variants.
|
|
7472
|
+
*
|
|
7473
|
+
* @example
|
|
7474
|
+
* ```typescript
|
|
7475
|
+
* const base: EarnGasFeeEstimateBase = {
|
|
7476
|
+
* name: 'Deposit',
|
|
7477
|
+
* token: 'ETH',
|
|
7478
|
+
* blockchain: 'Arc_Testnet',
|
|
7479
|
+
* }
|
|
7480
|
+
* ```
|
|
7481
|
+
*/
|
|
7482
|
+
interface EarnGasFeeEstimateBase {
|
|
7483
|
+
/** The earn step being estimated, e.g. "Approve", "Deposit", "Withdraw". */
|
|
7484
|
+
readonly name: string;
|
|
7485
|
+
/** Native token used to pay gas fees, e.g. "ETH". */
|
|
7486
|
+
readonly token: string;
|
|
7487
|
+
/** Blockchain where this gas fee applies. */
|
|
7488
|
+
readonly blockchain: ChainDefinition['chain'];
|
|
7489
|
+
}
|
|
7470
7490
|
/**
|
|
7471
7491
|
* Sort order for a vault discovery query.
|
|
7472
7492
|
*
|
|
@@ -7481,6 +7501,51 @@ interface VaultQuery {
|
|
|
7481
7501
|
*/
|
|
7482
7502
|
type ExploreVaultsSortBy = 'apy' | 'tvl' | 'name';
|
|
7483
7503
|
|
|
7504
|
+
/**
|
|
7505
|
+
* Estimated gas details for one transaction in a kit-level Earn quote, with
|
|
7506
|
+
* every amount as a decimal string so quote results stay JSON-serializable.
|
|
7507
|
+
*
|
|
7508
|
+
* @example
|
|
7509
|
+
* ```typescript
|
|
7510
|
+
* const gas: EarnEstimatedGas = { gas: '73567', gasPrice: '20003763738', fee: '1471616886913446' }
|
|
7511
|
+
* ```
|
|
7512
|
+
*/
|
|
7513
|
+
interface EarnEstimatedGas {
|
|
7514
|
+
/** Estimated gas units as a decimal string, e.g. '73567'. */
|
|
7515
|
+
readonly gas: string;
|
|
7516
|
+
/** Estimated price per gas unit as a decimal string in wei. */
|
|
7517
|
+
readonly gasPrice: string;
|
|
7518
|
+
/** Total estimated fee as a decimal string in wei. */
|
|
7519
|
+
readonly fee: string;
|
|
7520
|
+
}
|
|
7521
|
+
/**
|
|
7522
|
+
* Estimated native gas fee for one transaction in an Earn quote.
|
|
7523
|
+
*
|
|
7524
|
+
* A discriminated union on `fees`: a successful estimate carries
|
|
7525
|
+
* {@link EarnEstimatedGas} details and no `error`; a failed estimate carries
|
|
7526
|
+
* `fees: null` and a sanitized `error` message.
|
|
7527
|
+
*
|
|
7528
|
+
* @example
|
|
7529
|
+
* ```typescript
|
|
7530
|
+
* function describe(entry: EarnGasFeeEstimate): string {
|
|
7531
|
+
* if (entry.fees === null) {
|
|
7532
|
+
* return `${entry.name}: estimation failed (${entry.error})`
|
|
7533
|
+
* }
|
|
7534
|
+
* return `${entry.name}: ${entry.fees.fee} wei`
|
|
7535
|
+
* }
|
|
7536
|
+
* ```
|
|
7537
|
+
*/
|
|
7538
|
+
type EarnGasFeeEstimate = (EarnGasFeeEstimateBase & {
|
|
7539
|
+
/** Estimated gas details with amounts formatted as decimal strings. */
|
|
7540
|
+
readonly fees: EarnEstimatedGas;
|
|
7541
|
+
/** Never present on a successful estimate. */
|
|
7542
|
+
readonly error?: never;
|
|
7543
|
+
}) | (EarnGasFeeEstimateBase & {
|
|
7544
|
+
/** Null because estimation failed. */
|
|
7545
|
+
readonly fees: null;
|
|
7546
|
+
/** Sanitized estimation error message. */
|
|
7547
|
+
readonly error: string;
|
|
7548
|
+
});
|
|
7484
7549
|
/**
|
|
7485
7550
|
* Adapter context for earn operations, constrained to earn-supported chains.
|
|
7486
7551
|
*
|
|
@@ -7664,6 +7729,12 @@ interface SameChainDepositParams<TFromAdapterCapabilities extends AdapterCapabil
|
|
|
7664
7729
|
* @example '100.50' for 100.50 USDC
|
|
7665
7730
|
*/
|
|
7666
7731
|
readonly amount: string;
|
|
7732
|
+
/**
|
|
7733
|
+
* Gas fee estimates from a prior {@link getDepositQuote} call. When provided,
|
|
7734
|
+
* the pre-broadcast gas reserve check uses the actual estimated cost instead
|
|
7735
|
+
* of the conservative fallback reserve.
|
|
7736
|
+
*/
|
|
7737
|
+
readonly gasFees?: readonly EarnGasFeeEstimate[] | undefined;
|
|
7667
7738
|
/** Optional earn configuration. */
|
|
7668
7739
|
readonly config?: EarnConfig | undefined;
|
|
7669
7740
|
}
|
package/bridge.d.mts
CHANGED
|
@@ -7467,6 +7467,26 @@ interface VaultQuery {
|
|
|
7467
7467
|
/** On-chain vault contract address. */
|
|
7468
7468
|
readonly vaultAddress: string;
|
|
7469
7469
|
}
|
|
7470
|
+
/**
|
|
7471
|
+
* Fields shared by both {@link EarnGasFeeEstimate} variants.
|
|
7472
|
+
*
|
|
7473
|
+
* @example
|
|
7474
|
+
* ```typescript
|
|
7475
|
+
* const base: EarnGasFeeEstimateBase = {
|
|
7476
|
+
* name: 'Deposit',
|
|
7477
|
+
* token: 'ETH',
|
|
7478
|
+
* blockchain: 'Arc_Testnet',
|
|
7479
|
+
* }
|
|
7480
|
+
* ```
|
|
7481
|
+
*/
|
|
7482
|
+
interface EarnGasFeeEstimateBase {
|
|
7483
|
+
/** The earn step being estimated, e.g. "Approve", "Deposit", "Withdraw". */
|
|
7484
|
+
readonly name: string;
|
|
7485
|
+
/** Native token used to pay gas fees, e.g. "ETH". */
|
|
7486
|
+
readonly token: string;
|
|
7487
|
+
/** Blockchain where this gas fee applies. */
|
|
7488
|
+
readonly blockchain: ChainDefinition['chain'];
|
|
7489
|
+
}
|
|
7470
7490
|
/**
|
|
7471
7491
|
* Sort order for a vault discovery query.
|
|
7472
7492
|
*
|
|
@@ -7481,6 +7501,51 @@ interface VaultQuery {
|
|
|
7481
7501
|
*/
|
|
7482
7502
|
type ExploreVaultsSortBy = 'apy' | 'tvl' | 'name';
|
|
7483
7503
|
|
|
7504
|
+
/**
|
|
7505
|
+
* Estimated gas details for one transaction in a kit-level Earn quote, with
|
|
7506
|
+
* every amount as a decimal string so quote results stay JSON-serializable.
|
|
7507
|
+
*
|
|
7508
|
+
* @example
|
|
7509
|
+
* ```typescript
|
|
7510
|
+
* const gas: EarnEstimatedGas = { gas: '73567', gasPrice: '20003763738', fee: '1471616886913446' }
|
|
7511
|
+
* ```
|
|
7512
|
+
*/
|
|
7513
|
+
interface EarnEstimatedGas {
|
|
7514
|
+
/** Estimated gas units as a decimal string, e.g. '73567'. */
|
|
7515
|
+
readonly gas: string;
|
|
7516
|
+
/** Estimated price per gas unit as a decimal string in wei. */
|
|
7517
|
+
readonly gasPrice: string;
|
|
7518
|
+
/** Total estimated fee as a decimal string in wei. */
|
|
7519
|
+
readonly fee: string;
|
|
7520
|
+
}
|
|
7521
|
+
/**
|
|
7522
|
+
* Estimated native gas fee for one transaction in an Earn quote.
|
|
7523
|
+
*
|
|
7524
|
+
* A discriminated union on `fees`: a successful estimate carries
|
|
7525
|
+
* {@link EarnEstimatedGas} details and no `error`; a failed estimate carries
|
|
7526
|
+
* `fees: null` and a sanitized `error` message.
|
|
7527
|
+
*
|
|
7528
|
+
* @example
|
|
7529
|
+
* ```typescript
|
|
7530
|
+
* function describe(entry: EarnGasFeeEstimate): string {
|
|
7531
|
+
* if (entry.fees === null) {
|
|
7532
|
+
* return `${entry.name}: estimation failed (${entry.error})`
|
|
7533
|
+
* }
|
|
7534
|
+
* return `${entry.name}: ${entry.fees.fee} wei`
|
|
7535
|
+
* }
|
|
7536
|
+
* ```
|
|
7537
|
+
*/
|
|
7538
|
+
type EarnGasFeeEstimate = (EarnGasFeeEstimateBase & {
|
|
7539
|
+
/** Estimated gas details with amounts formatted as decimal strings. */
|
|
7540
|
+
readonly fees: EarnEstimatedGas;
|
|
7541
|
+
/** Never present on a successful estimate. */
|
|
7542
|
+
readonly error?: never;
|
|
7543
|
+
}) | (EarnGasFeeEstimateBase & {
|
|
7544
|
+
/** Null because estimation failed. */
|
|
7545
|
+
readonly fees: null;
|
|
7546
|
+
/** Sanitized estimation error message. */
|
|
7547
|
+
readonly error: string;
|
|
7548
|
+
});
|
|
7484
7549
|
/**
|
|
7485
7550
|
* Adapter context for earn operations, constrained to earn-supported chains.
|
|
7486
7551
|
*
|
|
@@ -7664,6 +7729,12 @@ interface SameChainDepositParams<TFromAdapterCapabilities extends AdapterCapabil
|
|
|
7664
7729
|
* @example '100.50' for 100.50 USDC
|
|
7665
7730
|
*/
|
|
7666
7731
|
readonly amount: string;
|
|
7732
|
+
/**
|
|
7733
|
+
* Gas fee estimates from a prior {@link getDepositQuote} call. When provided,
|
|
7734
|
+
* the pre-broadcast gas reserve check uses the actual estimated cost instead
|
|
7735
|
+
* of the conservative fallback reserve.
|
|
7736
|
+
*/
|
|
7737
|
+
readonly gasFees?: readonly EarnGasFeeEstimate[] | undefined;
|
|
7667
7738
|
/** Optional earn configuration. */
|
|
7668
7739
|
readonly config?: EarnConfig | undefined;
|
|
7669
7740
|
}
|
package/bridge.d.ts
CHANGED
|
@@ -7467,6 +7467,26 @@ interface VaultQuery {
|
|
|
7467
7467
|
/** On-chain vault contract address. */
|
|
7468
7468
|
readonly vaultAddress: string;
|
|
7469
7469
|
}
|
|
7470
|
+
/**
|
|
7471
|
+
* Fields shared by both {@link EarnGasFeeEstimate} variants.
|
|
7472
|
+
*
|
|
7473
|
+
* @example
|
|
7474
|
+
* ```typescript
|
|
7475
|
+
* const base: EarnGasFeeEstimateBase = {
|
|
7476
|
+
* name: 'Deposit',
|
|
7477
|
+
* token: 'ETH',
|
|
7478
|
+
* blockchain: 'Arc_Testnet',
|
|
7479
|
+
* }
|
|
7480
|
+
* ```
|
|
7481
|
+
*/
|
|
7482
|
+
interface EarnGasFeeEstimateBase {
|
|
7483
|
+
/** The earn step being estimated, e.g. "Approve", "Deposit", "Withdraw". */
|
|
7484
|
+
readonly name: string;
|
|
7485
|
+
/** Native token used to pay gas fees, e.g. "ETH". */
|
|
7486
|
+
readonly token: string;
|
|
7487
|
+
/** Blockchain where this gas fee applies. */
|
|
7488
|
+
readonly blockchain: ChainDefinition['chain'];
|
|
7489
|
+
}
|
|
7470
7490
|
/**
|
|
7471
7491
|
* Sort order for a vault discovery query.
|
|
7472
7492
|
*
|
|
@@ -7481,6 +7501,51 @@ interface VaultQuery {
|
|
|
7481
7501
|
*/
|
|
7482
7502
|
type ExploreVaultsSortBy = 'apy' | 'tvl' | 'name';
|
|
7483
7503
|
|
|
7504
|
+
/**
|
|
7505
|
+
* Estimated gas details for one transaction in a kit-level Earn quote, with
|
|
7506
|
+
* every amount as a decimal string so quote results stay JSON-serializable.
|
|
7507
|
+
*
|
|
7508
|
+
* @example
|
|
7509
|
+
* ```typescript
|
|
7510
|
+
* const gas: EarnEstimatedGas = { gas: '73567', gasPrice: '20003763738', fee: '1471616886913446' }
|
|
7511
|
+
* ```
|
|
7512
|
+
*/
|
|
7513
|
+
interface EarnEstimatedGas {
|
|
7514
|
+
/** Estimated gas units as a decimal string, e.g. '73567'. */
|
|
7515
|
+
readonly gas: string;
|
|
7516
|
+
/** Estimated price per gas unit as a decimal string in wei. */
|
|
7517
|
+
readonly gasPrice: string;
|
|
7518
|
+
/** Total estimated fee as a decimal string in wei. */
|
|
7519
|
+
readonly fee: string;
|
|
7520
|
+
}
|
|
7521
|
+
/**
|
|
7522
|
+
* Estimated native gas fee for one transaction in an Earn quote.
|
|
7523
|
+
*
|
|
7524
|
+
* A discriminated union on `fees`: a successful estimate carries
|
|
7525
|
+
* {@link EarnEstimatedGas} details and no `error`; a failed estimate carries
|
|
7526
|
+
* `fees: null` and a sanitized `error` message.
|
|
7527
|
+
*
|
|
7528
|
+
* @example
|
|
7529
|
+
* ```typescript
|
|
7530
|
+
* function describe(entry: EarnGasFeeEstimate): string {
|
|
7531
|
+
* if (entry.fees === null) {
|
|
7532
|
+
* return `${entry.name}: estimation failed (${entry.error})`
|
|
7533
|
+
* }
|
|
7534
|
+
* return `${entry.name}: ${entry.fees.fee} wei`
|
|
7535
|
+
* }
|
|
7536
|
+
* ```
|
|
7537
|
+
*/
|
|
7538
|
+
type EarnGasFeeEstimate = (EarnGasFeeEstimateBase & {
|
|
7539
|
+
/** Estimated gas details with amounts formatted as decimal strings. */
|
|
7540
|
+
readonly fees: EarnEstimatedGas;
|
|
7541
|
+
/** Never present on a successful estimate. */
|
|
7542
|
+
readonly error?: never;
|
|
7543
|
+
}) | (EarnGasFeeEstimateBase & {
|
|
7544
|
+
/** Null because estimation failed. */
|
|
7545
|
+
readonly fees: null;
|
|
7546
|
+
/** Sanitized estimation error message. */
|
|
7547
|
+
readonly error: string;
|
|
7548
|
+
});
|
|
7484
7549
|
/**
|
|
7485
7550
|
* Adapter context for earn operations, constrained to earn-supported chains.
|
|
7486
7551
|
*
|
|
@@ -7664,6 +7729,12 @@ interface SameChainDepositParams<TFromAdapterCapabilities extends AdapterCapabil
|
|
|
7664
7729
|
* @example '100.50' for 100.50 USDC
|
|
7665
7730
|
*/
|
|
7666
7731
|
readonly amount: string;
|
|
7732
|
+
/**
|
|
7733
|
+
* Gas fee estimates from a prior {@link getDepositQuote} call. When provided,
|
|
7734
|
+
* the pre-broadcast gas reserve check uses the actual estimated cost instead
|
|
7735
|
+
* of the conservative fallback reserve.
|
|
7736
|
+
*/
|
|
7737
|
+
readonly gasFees?: readonly EarnGasFeeEstimate[] | undefined;
|
|
7667
7738
|
/** Optional earn configuration. */
|
|
7668
7739
|
readonly config?: EarnConfig | undefined;
|
|
7669
7740
|
}
|
package/bridge.mjs
CHANGED
|
@@ -29499,7 +29499,7 @@ new Set(Object.values(Blockchain));
|
|
|
29499
29499
|
registerKit(`${pkg$1.name}/${pkg$1.version}`);
|
|
29500
29500
|
|
|
29501
29501
|
var name = "@circle-fin/earn-kit";
|
|
29502
|
-
var version = "1.
|
|
29502
|
+
var version = "1.8.0";
|
|
29503
29503
|
var pkg = {
|
|
29504
29504
|
name: name,
|
|
29505
29505
|
version: version};
|
|
@@ -29641,10 +29641,8 @@ const bridgeFeeTokenSchema = hexAddressSchema;
|
|
|
29641
29641
|
assetAddress: z.string(),
|
|
29642
29642
|
lltv: z.number(),
|
|
29643
29643
|
supplyUsd: z.number(),
|
|
29644
|
-
//
|
|
29645
|
-
|
|
29646
|
-
// schema; `null` when the product exposes no per-market allocation (V2).
|
|
29647
|
-
allocationPct: z.number().nullable().optional()
|
|
29644
|
+
// `null` when the product exposes no per-market allocation (V2).
|
|
29645
|
+
allocationPct: z.number().nullable()
|
|
29648
29646
|
});
|
|
29649
29647
|
/**
|
|
29650
29648
|
* Zod schema for a Morpho vault warning in the API response.
|
|
@@ -29751,19 +29749,20 @@ const bridgeFeeTokenSchema = hexAddressSchema;
|
|
|
29751
29749
|
earnKitWarnings: z.array(z.string()).optional()
|
|
29752
29750
|
});
|
|
29753
29751
|
/**
|
|
29754
|
-
* Shared base schema: existing flat fields (kept
|
|
29755
|
-
* facets
|
|
29756
|
-
*
|
|
29752
|
+
* Shared base schema: existing flat fields (kept as deprecated aliases) plus
|
|
29753
|
+
* the nested facets. Zenith emits all facets on every response; required here
|
|
29754
|
+
* so a partial emission is caught at parse time rather than surfacing as a
|
|
29755
|
+
* runtime `undefined` access.
|
|
29757
29756
|
*
|
|
29758
29757
|
* @internal
|
|
29759
29758
|
*/ const earnBaseSchema = vaultInfoResponseSchema.extend({
|
|
29760
|
-
address: z.string()
|
|
29761
|
-
asOf: z.string()
|
|
29762
|
-
manager: managerSchema.nullable()
|
|
29763
|
-
apyProfile: apyProfileSchema
|
|
29764
|
-
fee: feeInfoSchema
|
|
29765
|
-
liquidityProfile: liquidityProfileSchema
|
|
29766
|
-
riskSignals: riskSignalsSchema
|
|
29759
|
+
address: z.string(),
|
|
29760
|
+
asOf: z.string(),
|
|
29761
|
+
manager: managerSchema.nullable(),
|
|
29762
|
+
apyProfile: apyProfileSchema,
|
|
29763
|
+
fee: feeInfoSchema,
|
|
29764
|
+
liquidityProfile: liquidityProfileSchema,
|
|
29765
|
+
riskSignals: riskSignalsSchema
|
|
29767
29766
|
});
|
|
29768
29767
|
/**
|
|
29769
29768
|
* Zod schema for the `vault` opportunity variant.
|
|
@@ -30733,6 +30732,49 @@ const sourceAdapterContextSchema = z.object({
|
|
|
30733
30732
|
vaultAddress: vaultAddressSchema,
|
|
30734
30733
|
config: earnConfigSchema.optional()
|
|
30735
30734
|
});
|
|
30735
|
+
/**
|
|
30736
|
+
* Schema for a successful gas fee entry (fees is non-null).
|
|
30737
|
+
*
|
|
30738
|
+
* Validates the kit shape — {@link EarnEstimatedGas} uses decimal strings for
|
|
30739
|
+
* `gas`, `gasPrice`, and `fee`. Only digits are accepted so that the deposit
|
|
30740
|
+
* operation can safely convert them to `bigint` before passing them to the
|
|
30741
|
+
* provider's `computeGasReserve`.
|
|
30742
|
+
*
|
|
30743
|
+
* @internal
|
|
30744
|
+
*/ const earnGasFeeEstimateSuccessSchema = z.object({
|
|
30745
|
+
name: z.string(),
|
|
30746
|
+
token: z.string(),
|
|
30747
|
+
blockchain: z.string(),
|
|
30748
|
+
fees: z.object({
|
|
30749
|
+
gas: z.string().regex(/^\d+$/, 'gas must be a non-negative integer string'),
|
|
30750
|
+
gasPrice: z.string().regex(/^\d+$/, 'gasPrice must be a non-negative integer string'),
|
|
30751
|
+
fee: z.string().regex(/^\d+$/, 'fee must be a non-negative integer string')
|
|
30752
|
+
}),
|
|
30753
|
+
error: z.undefined().optional()
|
|
30754
|
+
}).strict();
|
|
30755
|
+
/**
|
|
30756
|
+
* Schema for a failed gas fee entry (fees is null, error is a string).
|
|
30757
|
+
*
|
|
30758
|
+
* @internal
|
|
30759
|
+
*/ const earnGasFeeEstimateFailureSchema = z.object({
|
|
30760
|
+
name: z.string(),
|
|
30761
|
+
token: z.string(),
|
|
30762
|
+
blockchain: z.string(),
|
|
30763
|
+
fees: z.null(),
|
|
30764
|
+
error: z.string()
|
|
30765
|
+
}).strict();
|
|
30766
|
+
/**
|
|
30767
|
+
* Schema for a single kit-level gas fee estimate entry.
|
|
30768
|
+
*
|
|
30769
|
+
* Rejects arbitrary inputs (null, numbers, empty objects, non-numeric fee
|
|
30770
|
+
* strings) so callers receive a descriptive validation error instead of a
|
|
30771
|
+
* raw `BigInt` conversion error inside `computeGasReserve`.
|
|
30772
|
+
*
|
|
30773
|
+
* @internal
|
|
30774
|
+
*/ const earnGasFeeEstimateSchema = z.union([
|
|
30775
|
+
earnGasFeeEstimateSuccessSchema,
|
|
30776
|
+
earnGasFeeEstimateFailureSchema
|
|
30777
|
+
]);
|
|
30736
30778
|
/**
|
|
30737
30779
|
* Validation schema for the same-chain variant of DepositParams.
|
|
30738
30780
|
*
|
|
@@ -30745,6 +30787,7 @@ const sourceAdapterContextSchema = z.object({
|
|
|
30745
30787
|
to: z.undefined().optional(),
|
|
30746
30788
|
vaultAddress: vaultAddressSchema,
|
|
30747
30789
|
amount: amountSchema,
|
|
30790
|
+
gasFees: z.array(earnGasFeeEstimateSchema).optional(),
|
|
30748
30791
|
config: earnConfigSchema.optional()
|
|
30749
30792
|
}).strict();
|
|
30750
30793
|
const crossChainDepositDestinationSchema = z.object({
|
package/context.d.cts
CHANGED
|
@@ -7225,6 +7225,26 @@ interface VaultQuery {
|
|
|
7225
7225
|
/** On-chain vault contract address. */
|
|
7226
7226
|
readonly vaultAddress: string;
|
|
7227
7227
|
}
|
|
7228
|
+
/**
|
|
7229
|
+
* Fields shared by both {@link EarnGasFeeEstimate} variants.
|
|
7230
|
+
*
|
|
7231
|
+
* @example
|
|
7232
|
+
* ```typescript
|
|
7233
|
+
* const base: EarnGasFeeEstimateBase = {
|
|
7234
|
+
* name: 'Deposit',
|
|
7235
|
+
* token: 'ETH',
|
|
7236
|
+
* blockchain: 'Arc_Testnet',
|
|
7237
|
+
* }
|
|
7238
|
+
* ```
|
|
7239
|
+
*/
|
|
7240
|
+
interface EarnGasFeeEstimateBase {
|
|
7241
|
+
/** The earn step being estimated, e.g. "Approve", "Deposit", "Withdraw". */
|
|
7242
|
+
readonly name: string;
|
|
7243
|
+
/** Native token used to pay gas fees, e.g. "ETH". */
|
|
7244
|
+
readonly token: string;
|
|
7245
|
+
/** Blockchain where this gas fee applies. */
|
|
7246
|
+
readonly blockchain: ChainDefinition['chain'];
|
|
7247
|
+
}
|
|
7228
7248
|
/**
|
|
7229
7249
|
* Sort order for a vault discovery query.
|
|
7230
7250
|
*
|
|
@@ -7239,6 +7259,51 @@ interface VaultQuery {
|
|
|
7239
7259
|
*/
|
|
7240
7260
|
type ExploreVaultsSortBy = 'apy' | 'tvl' | 'name';
|
|
7241
7261
|
|
|
7262
|
+
/**
|
|
7263
|
+
* Estimated gas details for one transaction in a kit-level Earn quote, with
|
|
7264
|
+
* every amount as a decimal string so quote results stay JSON-serializable.
|
|
7265
|
+
*
|
|
7266
|
+
* @example
|
|
7267
|
+
* ```typescript
|
|
7268
|
+
* const gas: EarnEstimatedGas = { gas: '73567', gasPrice: '20003763738', fee: '1471616886913446' }
|
|
7269
|
+
* ```
|
|
7270
|
+
*/
|
|
7271
|
+
interface EarnEstimatedGas {
|
|
7272
|
+
/** Estimated gas units as a decimal string, e.g. '73567'. */
|
|
7273
|
+
readonly gas: string;
|
|
7274
|
+
/** Estimated price per gas unit as a decimal string in wei. */
|
|
7275
|
+
readonly gasPrice: string;
|
|
7276
|
+
/** Total estimated fee as a decimal string in wei. */
|
|
7277
|
+
readonly fee: string;
|
|
7278
|
+
}
|
|
7279
|
+
/**
|
|
7280
|
+
* Estimated native gas fee for one transaction in an Earn quote.
|
|
7281
|
+
*
|
|
7282
|
+
* A discriminated union on `fees`: a successful estimate carries
|
|
7283
|
+
* {@link EarnEstimatedGas} details and no `error`; a failed estimate carries
|
|
7284
|
+
* `fees: null` and a sanitized `error` message.
|
|
7285
|
+
*
|
|
7286
|
+
* @example
|
|
7287
|
+
* ```typescript
|
|
7288
|
+
* function describe(entry: EarnGasFeeEstimate): string {
|
|
7289
|
+
* if (entry.fees === null) {
|
|
7290
|
+
* return `${entry.name}: estimation failed (${entry.error})`
|
|
7291
|
+
* }
|
|
7292
|
+
* return `${entry.name}: ${entry.fees.fee} wei`
|
|
7293
|
+
* }
|
|
7294
|
+
* ```
|
|
7295
|
+
*/
|
|
7296
|
+
type EarnGasFeeEstimate = (EarnGasFeeEstimateBase & {
|
|
7297
|
+
/** Estimated gas details with amounts formatted as decimal strings. */
|
|
7298
|
+
readonly fees: EarnEstimatedGas;
|
|
7299
|
+
/** Never present on a successful estimate. */
|
|
7300
|
+
readonly error?: never;
|
|
7301
|
+
}) | (EarnGasFeeEstimateBase & {
|
|
7302
|
+
/** Null because estimation failed. */
|
|
7303
|
+
readonly fees: null;
|
|
7304
|
+
/** Sanitized estimation error message. */
|
|
7305
|
+
readonly error: string;
|
|
7306
|
+
});
|
|
7242
7307
|
/**
|
|
7243
7308
|
* Adapter context for earn operations, constrained to earn-supported chains.
|
|
7244
7309
|
*
|
|
@@ -7422,6 +7487,12 @@ interface SameChainDepositParams<TFromAdapterCapabilities extends AdapterCapabil
|
|
|
7422
7487
|
* @example '100.50' for 100.50 USDC
|
|
7423
7488
|
*/
|
|
7424
7489
|
readonly amount: string;
|
|
7490
|
+
/**
|
|
7491
|
+
* Gas fee estimates from a prior {@link getDepositQuote} call. When provided,
|
|
7492
|
+
* the pre-broadcast gas reserve check uses the actual estimated cost instead
|
|
7493
|
+
* of the conservative fallback reserve.
|
|
7494
|
+
*/
|
|
7495
|
+
readonly gasFees?: readonly EarnGasFeeEstimate[] | undefined;
|
|
7425
7496
|
/** Optional earn configuration. */
|
|
7426
7497
|
readonly config?: EarnConfig | undefined;
|
|
7427
7498
|
}
|
package/context.d.mts
CHANGED
|
@@ -7225,6 +7225,26 @@ interface VaultQuery {
|
|
|
7225
7225
|
/** On-chain vault contract address. */
|
|
7226
7226
|
readonly vaultAddress: string;
|
|
7227
7227
|
}
|
|
7228
|
+
/**
|
|
7229
|
+
* Fields shared by both {@link EarnGasFeeEstimate} variants.
|
|
7230
|
+
*
|
|
7231
|
+
* @example
|
|
7232
|
+
* ```typescript
|
|
7233
|
+
* const base: EarnGasFeeEstimateBase = {
|
|
7234
|
+
* name: 'Deposit',
|
|
7235
|
+
* token: 'ETH',
|
|
7236
|
+
* blockchain: 'Arc_Testnet',
|
|
7237
|
+
* }
|
|
7238
|
+
* ```
|
|
7239
|
+
*/
|
|
7240
|
+
interface EarnGasFeeEstimateBase {
|
|
7241
|
+
/** The earn step being estimated, e.g. "Approve", "Deposit", "Withdraw". */
|
|
7242
|
+
readonly name: string;
|
|
7243
|
+
/** Native token used to pay gas fees, e.g. "ETH". */
|
|
7244
|
+
readonly token: string;
|
|
7245
|
+
/** Blockchain where this gas fee applies. */
|
|
7246
|
+
readonly blockchain: ChainDefinition['chain'];
|
|
7247
|
+
}
|
|
7228
7248
|
/**
|
|
7229
7249
|
* Sort order for a vault discovery query.
|
|
7230
7250
|
*
|
|
@@ -7239,6 +7259,51 @@ interface VaultQuery {
|
|
|
7239
7259
|
*/
|
|
7240
7260
|
type ExploreVaultsSortBy = 'apy' | 'tvl' | 'name';
|
|
7241
7261
|
|
|
7262
|
+
/**
|
|
7263
|
+
* Estimated gas details for one transaction in a kit-level Earn quote, with
|
|
7264
|
+
* every amount as a decimal string so quote results stay JSON-serializable.
|
|
7265
|
+
*
|
|
7266
|
+
* @example
|
|
7267
|
+
* ```typescript
|
|
7268
|
+
* const gas: EarnEstimatedGas = { gas: '73567', gasPrice: '20003763738', fee: '1471616886913446' }
|
|
7269
|
+
* ```
|
|
7270
|
+
*/
|
|
7271
|
+
interface EarnEstimatedGas {
|
|
7272
|
+
/** Estimated gas units as a decimal string, e.g. '73567'. */
|
|
7273
|
+
readonly gas: string;
|
|
7274
|
+
/** Estimated price per gas unit as a decimal string in wei. */
|
|
7275
|
+
readonly gasPrice: string;
|
|
7276
|
+
/** Total estimated fee as a decimal string in wei. */
|
|
7277
|
+
readonly fee: string;
|
|
7278
|
+
}
|
|
7279
|
+
/**
|
|
7280
|
+
* Estimated native gas fee for one transaction in an Earn quote.
|
|
7281
|
+
*
|
|
7282
|
+
* A discriminated union on `fees`: a successful estimate carries
|
|
7283
|
+
* {@link EarnEstimatedGas} details and no `error`; a failed estimate carries
|
|
7284
|
+
* `fees: null` and a sanitized `error` message.
|
|
7285
|
+
*
|
|
7286
|
+
* @example
|
|
7287
|
+
* ```typescript
|
|
7288
|
+
* function describe(entry: EarnGasFeeEstimate): string {
|
|
7289
|
+
* if (entry.fees === null) {
|
|
7290
|
+
* return `${entry.name}: estimation failed (${entry.error})`
|
|
7291
|
+
* }
|
|
7292
|
+
* return `${entry.name}: ${entry.fees.fee} wei`
|
|
7293
|
+
* }
|
|
7294
|
+
* ```
|
|
7295
|
+
*/
|
|
7296
|
+
type EarnGasFeeEstimate = (EarnGasFeeEstimateBase & {
|
|
7297
|
+
/** Estimated gas details with amounts formatted as decimal strings. */
|
|
7298
|
+
readonly fees: EarnEstimatedGas;
|
|
7299
|
+
/** Never present on a successful estimate. */
|
|
7300
|
+
readonly error?: never;
|
|
7301
|
+
}) | (EarnGasFeeEstimateBase & {
|
|
7302
|
+
/** Null because estimation failed. */
|
|
7303
|
+
readonly fees: null;
|
|
7304
|
+
/** Sanitized estimation error message. */
|
|
7305
|
+
readonly error: string;
|
|
7306
|
+
});
|
|
7242
7307
|
/**
|
|
7243
7308
|
* Adapter context for earn operations, constrained to earn-supported chains.
|
|
7244
7309
|
*
|
|
@@ -7422,6 +7487,12 @@ interface SameChainDepositParams<TFromAdapterCapabilities extends AdapterCapabil
|
|
|
7422
7487
|
* @example '100.50' for 100.50 USDC
|
|
7423
7488
|
*/
|
|
7424
7489
|
readonly amount: string;
|
|
7490
|
+
/**
|
|
7491
|
+
* Gas fee estimates from a prior {@link getDepositQuote} call. When provided,
|
|
7492
|
+
* the pre-broadcast gas reserve check uses the actual estimated cost instead
|
|
7493
|
+
* of the conservative fallback reserve.
|
|
7494
|
+
*/
|
|
7495
|
+
readonly gasFees?: readonly EarnGasFeeEstimate[] | undefined;
|
|
7425
7496
|
/** Optional earn configuration. */
|
|
7426
7497
|
readonly config?: EarnConfig | undefined;
|
|
7427
7498
|
}
|