@panoptic-eng/sdk 1.0.56 → 1.0.57
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/dist/chainDeployments-D_bvyWEm.js +408 -0
- package/dist/{cow-BahYFov0.js → cow-45nsAaEr.js} +1 -1
- package/dist/index.d.ts +29 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -28
- package/dist/index.js.map +1 -1
- package/dist/{irm-Dwl2er4W.js → irm-DsM35dGO.js} +2 -409
- package/dist/panoptic/v2/react-public.d.ts.map +1 -1
- package/dist/{rates-B0uPUed1.js → rates-CEJz8fjw.js} +1 -1
- package/dist/{router-CJCJkqFo.js → router-DOUAKfn6.js} +2 -2
- package/dist/{router-BDp3WQqI.js → router-DUOHNdYZ.js} +2 -2
- package/dist/{transactionFees-DE-Whxab.js → transactionFees-qweht4Rd.js} +54 -28
- package/dist/{v2-DvrVwC5h.js → v2-B3MqHVHt.js} +4 -4
- package/dist/vault-transaction-fees.d.ts +5 -3
- package/dist/vault-transaction-fees.d.ts.map +1 -1
- package/dist/vault-transaction-fees.js +443 -28
- package/dist/vault-transaction-fees.js.map +1 -1
- package/dist/{writes-B4nGIi6h.js → writes-CQrevcCu.js} +2 -2
- package/package.json +1 -1
|
@@ -11948,4 +11948,4 @@ function formatPerSecondRateWadAsAprPct(ratePerSecondWad, precision) {
|
|
|
11948
11948
|
}
|
|
11949
11949
|
|
|
11950
11950
|
//#endregion
|
|
11951
|
-
export { AccountInsolventError, AlreadyInitializedError, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTickLimitsError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MaxRetriesExceededError, MissingPositionIdsError, MulticallNoDataError, MulticallResultFailedError, MulticallResultMissingError, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NoLoanPositionsError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, ReentrancyError, RpcError, RpcResponseError, STANDARD_TICK_WIDTHS, STRIKE_CONVERSION_FACTOR, SafeModeError, StaleDataError, StaleOracleError, StorageDataNotFoundError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, WrongPoolIdError, WrongUniswapPoolError, ZeroAddressError, ZeroCollateralRequirementError, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, availableToBorrow, clearTrackedPositions, collateralTrackerV2Abi, createFileStorage, createMemoryStorage, createTxResult, decodeAllDispatchCalldata, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePosition, decodePositionBalance$1 as decodePositionBalance, decodeTickSpacing, diagnoseOracleSafeMode, fetchPoolId, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatRateWad, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatWad, formatWadPercent, formatWadSigned, getBlockMeta, getClosedPositionsKey, getOpenPositionIds, getOracleRiskParameters, getOracleState, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPosition, getPositionGreeks, getPositionMetaKey, getPositions, getPositionsKey, getRiskParameters, getSchemaVersionKey, getSyncCheckpointKey, getTrackedChunksKey, getTrackedPositionIds, getUtilization, isPanopticErrorType, isPositionTracked, jsonSerializer, mintableAfterBuffer, oracleEpochAt, panopticErrorsAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parsePanopticError, parseTokenAmount, parseWad, recoverSnapshot, recoverSnapshotFromTx, riskEngineAbi, selectDispatchForAccount, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, submitWrite, uniswapV3PoolAbi, validateBuilderCode };
|
|
11951
|
+
export { AccountInsolventError, AlreadyInitializedError, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTickLimitsError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MaxRetriesExceededError, MissingPositionIdsError, MulticallNoDataError, MulticallResultFailedError, MulticallResultMissingError, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NoLoanPositionsError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, ReentrancyError, RpcError, RpcResponseError, STANDARD_TICK_WIDTHS, STRIKE_CONVERSION_FACTOR, SafeModeError, StaleDataError, StaleOracleError, StorageDataNotFoundError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, WrongPoolIdError, WrongUniswapPoolError, ZeroAddressError, ZeroCollateralRequirementError, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, availableToBorrow, clearTrackedPositions, collateralTrackerV2Abi, createFileStorage, createMemoryStorage, createTxResult, decodeAllDispatchCalldata, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePosition, decodePositionBalance$1 as decodePositionBalance, decodeTickSpacing as decodeTickSpacing$1, diagnoseOracleSafeMode, fetchPoolId, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatRateWad, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatWad, formatWadPercent, formatWadSigned, getBlockMeta, getClosedPositionsKey, getOpenPositionIds, getOracleRiskParameters, getOracleState, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPosition, getPositionGreeks, getPositionMetaKey, getPositions, getPositionsKey, getRiskParameters, getSchemaVersionKey, getSyncCheckpointKey, getTrackedChunksKey, getTrackedPositionIds, getUtilization, isPanopticErrorType, isPositionTracked, jsonSerializer, mintableAfterBuffer, oracleEpochAt, panopticErrorsAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parsePanopticError, parseTokenAmount, parseWad, recoverSnapshot, recoverSnapshotFromTx, riskEngineAbi, selectDispatchForAccount, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, submitWrite, uniswapV3PoolAbi, validateBuilderCode };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PanopticError, getBlockMeta, getPool, submitWrite } from "./rates-
|
|
2
|
-
import { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, QuoterUnavailableError, getUniswapV4Addresses, universalRouterAbi } from "./router-
|
|
1
|
+
import { PanopticError, getBlockMeta, getPool, submitWrite } from "./rates-CEJz8fjw.js";
|
|
2
|
+
import { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, QuoterUnavailableError, getUniswapV4Addresses, universalRouterAbi } from "./router-DUOHNdYZ.js";
|
|
3
3
|
import { BaseError, ContractFunctionRevertedError, encodeAbiParameters, encodeFunctionData, encodePacked, erc20Abi, isAddressEqual, maxUint256, zeroAddress } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/uniswap/v4/router/encodeSwap.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PanopticError, getBlockMeta, getPoolMetadata, submitWrite } from "./rates-
|
|
1
|
+
import { PanopticError, getBlockMeta, getPoolMetadata, submitWrite } from "./rates-CEJz8fjw.js";
|
|
2
2
|
import { tickToSqrtPriceX96 } from "./greeks-CNi1-cnp.js";
|
|
3
|
-
import { decodeAllLegs } from "./writes-
|
|
3
|
+
import { decodeAllLegs } from "./writes-CQrevcCu.js";
|
|
4
4
|
import { BaseError, ContractFunctionRevertedError, encodeAbiParameters, encodeFunctionData, encodePacked, isAddressEqual, zeroAddress } from "viem";
|
|
5
5
|
|
|
6
6
|
//#region src/uniswap/lpDeposit.ts
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ROBINHOOD_CHAIN_ID } from "./chainDeployments-D_bvyWEm.js";
|
|
1
2
|
import { hexToBigInt } from "viem";
|
|
2
3
|
import { estimateFeesPerGas, getBlock, getFeeHistory } from "viem/actions";
|
|
3
4
|
|
|
@@ -67,12 +68,15 @@ function medianBigInt(values) {
|
|
|
67
68
|
const lowerMiddle = sorted[upperMiddleIndex - 1];
|
|
68
69
|
return lowerMiddle === void 0 ? void 0 : (lowerMiddle + upperMiddle) / 2n;
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
71
|
+
function getChainPriorityFeeFloor(chainId) {
|
|
72
|
+
return chainId === ROBINHOOD_CHAIN_ID ? 0n : void 0;
|
|
73
|
+
}
|
|
74
|
+
function clampPriorityFee(priorityFee, minimumPriorityFeePerGas = MIN_VAULT_PRIORITY_FEE_PER_GAS) {
|
|
75
|
+
if (priorityFee < minimumPriorityFeePerGas) return minimumPriorityFeePerGas;
|
|
72
76
|
if (priorityFee > MAX_VAULT_PRIORITY_FEE_PER_GAS) return MAX_VAULT_PRIORITY_FEE_PER_GAS;
|
|
73
77
|
return priorityFee;
|
|
74
78
|
}
|
|
75
|
-
function resolveFeeHistoryQuote({ baseFeePerGas, reward }) {
|
|
79
|
+
function resolveFeeHistoryQuote({ baseFeePerGas, reward, minimumPriorityFeePerGas }) {
|
|
76
80
|
const latestBaseFeeIndex = baseFeePerGas.length - 2;
|
|
77
81
|
if (latestBaseFeeIndex < 0 || reward === void 0 || reward.length === 0) return null;
|
|
78
82
|
const p90Rewards = reward.flatMap((blockRewards) => {
|
|
@@ -81,16 +85,18 @@ function resolveFeeHistoryQuote({ baseFeePerGas, reward }) {
|
|
|
81
85
|
});
|
|
82
86
|
const sampledPriorityFee = medianBigInt(p90Rewards);
|
|
83
87
|
if (sampledPriorityFee === void 0) return null;
|
|
84
|
-
const
|
|
88
|
+
const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
|
|
89
|
+
const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee, effectivePriorityFeeFloor);
|
|
85
90
|
const bufferedBaseFee = ceilMultiplyFraction(baseFeePerGas[latestBaseFeeIndex], BASE_FEE_BUFFER_NUMERATOR, BASE_FEE_BUFFER_DENOMINATOR);
|
|
86
91
|
return {
|
|
87
92
|
maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,
|
|
88
93
|
maxPriorityFeePerGas,
|
|
89
|
-
minimumMaxFeePerGas: bufferedBaseFee +
|
|
94
|
+
minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,
|
|
95
|
+
...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
|
|
90
96
|
source: "fee_history"
|
|
91
97
|
};
|
|
92
98
|
}
|
|
93
|
-
function resolveDeltaHedgeFeeHistoryQuote({ baseFeePerGas, reward }) {
|
|
99
|
+
function resolveDeltaHedgeFeeHistoryQuote({ baseFeePerGas, reward, minimumPriorityFeePerGas }) {
|
|
94
100
|
const latestBaseFeeIndex = baseFeePerGas.length - 2;
|
|
95
101
|
if (latestBaseFeeIndex < 0 || reward === void 0 || reward.length === 0) return null;
|
|
96
102
|
const p25Rewards = reward.flatMap((blockRewards) => {
|
|
@@ -99,22 +105,25 @@ function resolveDeltaHedgeFeeHistoryQuote({ baseFeePerGas, reward }) {
|
|
|
99
105
|
});
|
|
100
106
|
const rawPriorityFeePerGas = medianBigInt(p25Rewards);
|
|
101
107
|
if (rawPriorityFeePerGas === void 0) return null;
|
|
102
|
-
const
|
|
108
|
+
const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
|
|
109
|
+
const maxPriorityFeePerGas = clampPriorityFee(rawPriorityFeePerGas, effectivePriorityFeeFloor);
|
|
103
110
|
const bufferedBaseFee = ceilMultiplyFraction(baseFeePerGas[latestBaseFeeIndex], BASE_FEE_BUFFER_NUMERATOR, BASE_FEE_BUFFER_DENOMINATOR);
|
|
104
111
|
return {
|
|
105
112
|
maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,
|
|
106
113
|
maxPriorityFeePerGas,
|
|
107
|
-
minimumMaxFeePerGas: bufferedBaseFee +
|
|
114
|
+
minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,
|
|
115
|
+
...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
|
|
108
116
|
rawPriorityFeePerGas,
|
|
109
117
|
source: "fee_history_p25"
|
|
110
118
|
};
|
|
111
119
|
}
|
|
112
|
-
function resolveRpcPriorityFeeQuote({ baseFeePerGas, rawPriorityFeePerGas }) {
|
|
120
|
+
function resolveRpcPriorityFeeQuote({ baseFeePerGas, rawPriorityFeePerGas, minimumPriorityFeePerGas }) {
|
|
113
121
|
const bufferedBaseFee = ceilMultiplyFraction(baseFeePerGas, BASE_FEE_BUFFER_NUMERATOR, BASE_FEE_BUFFER_DENOMINATOR);
|
|
114
122
|
return {
|
|
115
123
|
maxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,
|
|
116
124
|
maxPriorityFeePerGas: rawPriorityFeePerGas,
|
|
117
|
-
minimumMaxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,
|
|
125
|
+
minimumMaxFeePerGas: bufferedBaseFee + (minimumPriorityFeePerGas ?? rawPriorityFeePerGas),
|
|
126
|
+
...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
|
|
118
127
|
rawPriorityFeePerGas,
|
|
119
128
|
source: "rpc_priority_fee"
|
|
120
129
|
};
|
|
@@ -135,7 +144,7 @@ function getVaultTransactionReplacementFeeQuote({ originalQuote, historicalQuote
|
|
|
135
144
|
requiredMaxPriorityFeePerGas: requiredReplacementPriorityFee,
|
|
136
145
|
maximumAffordableFeePerGas: MAX_VAULT_TRANSACTION_GAS_COST / gasLimit
|
|
137
146
|
});
|
|
138
|
-
const bufferedBaseFee = historicalQuote.minimumMaxFeePerGas - MIN_VAULT_PRIORITY_FEE_PER_GAS;
|
|
147
|
+
const bufferedBaseFee = historicalQuote.minimumMaxFeePerGas - (historicalQuote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS);
|
|
139
148
|
const currentMarketMaxFee = bufferedBaseFee + requiredMaxPriorityFeePerGas;
|
|
140
149
|
const desiredMaxFeePerGas = currentMarketMaxFee > bumpedMaxFee ? currentMarketMaxFee : bumpedMaxFee;
|
|
141
150
|
const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit;
|
|
@@ -153,13 +162,15 @@ function getVaultTransactionReplacementFeeQuote({ originalQuote, historicalQuote
|
|
|
153
162
|
maxPriorityFeePerGas: requiredMaxPriorityFeePerGas
|
|
154
163
|
};
|
|
155
164
|
}
|
|
156
|
-
function resolveFallbackQuote({ maxFeePerGas: estimatedMaxFeePerGas, maxPriorityFeePerGas: estimatedPriorityFeePerGas }) {
|
|
157
|
-
const
|
|
165
|
+
function resolveFallbackQuote({ maxFeePerGas: estimatedMaxFeePerGas, maxPriorityFeePerGas: estimatedPriorityFeePerGas, minimumPriorityFeePerGas }) {
|
|
166
|
+
const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
|
|
167
|
+
const maxPriorityFeePerGas = clampPriorityFee(estimatedPriorityFeePerGas, effectivePriorityFeeFloor);
|
|
158
168
|
const estimatedBaseFeeAllowance = estimatedMaxFeePerGas > estimatedPriorityFeePerGas ? estimatedMaxFeePerGas - estimatedPriorityFeePerGas : 0n;
|
|
159
169
|
return {
|
|
160
170
|
maxFeePerGas: estimatedBaseFeeAllowance + maxPriorityFeePerGas,
|
|
161
171
|
maxPriorityFeePerGas,
|
|
162
|
-
minimumMaxFeePerGas: estimatedBaseFeeAllowance +
|
|
172
|
+
minimumMaxFeePerGas: estimatedBaseFeeAllowance + effectivePriorityFeeFloor,
|
|
173
|
+
...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
|
|
163
174
|
source: "viem_fallback"
|
|
164
175
|
};
|
|
165
176
|
}
|
|
@@ -172,7 +183,7 @@ function applyVaultTransactionGasCostLimit(quote, gasLimit) {
|
|
|
172
183
|
minimumRequiredFeePerGas: quote.minimumMaxFeePerGas
|
|
173
184
|
});
|
|
174
185
|
if (quote.maxFeePerGas <= maximumAffordableFeePerGas) return quote;
|
|
175
|
-
const bufferedBaseFee = quote.minimumMaxFeePerGas - MIN_VAULT_PRIORITY_FEE_PER_GAS;
|
|
186
|
+
const bufferedBaseFee = quote.minimumMaxFeePerGas - (quote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS);
|
|
176
187
|
const affordablePriorityFee = maximumAffordableFeePerGas - bufferedBaseFee;
|
|
177
188
|
return {
|
|
178
189
|
...quote,
|
|
@@ -185,7 +196,8 @@ function bufferVaultTransactionGasEstimate(gasEstimate) {
|
|
|
185
196
|
return ceilMultiplyFraction(gasEstimate, GAS_ESTIMATE_BUFFER_NUMERATOR, GAS_ESTIMATE_BUFFER_DENOMINATOR);
|
|
186
197
|
}
|
|
187
198
|
function validateVaultSignedTransactionFeeCaps(feeCaps, quote) {
|
|
188
|
-
const { gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps;
|
|
199
|
+
const { chainId, gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps;
|
|
200
|
+
const minimumPriorityFeePerGas = quote?.minimumPriorityFeePerGas ?? getChainPriorityFeeFloor(chainId) ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
|
|
189
201
|
if (maxFeePerGas === null || maxPriorityFeePerGas === null) return {
|
|
190
202
|
valid: false,
|
|
191
203
|
code: "MissingEip1559Fees",
|
|
@@ -196,10 +208,10 @@ function validateVaultSignedTransactionFeeCaps(feeCaps, quote) {
|
|
|
196
208
|
code: "InvalidFeeCaps",
|
|
197
209
|
reason: `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) cannot exceed maxFeePerGas (${maxFeePerGas.toString()} wei).`
|
|
198
210
|
};
|
|
199
|
-
if (maxPriorityFeePerGas <
|
|
211
|
+
if (maxPriorityFeePerGas < minimumPriorityFeePerGas) return {
|
|
200
212
|
valid: false,
|
|
201
213
|
code: "PriorityFeeTooLow",
|
|
202
|
-
reason: `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) must be at least ${
|
|
214
|
+
reason: `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) must be at least ${minimumPriorityFeePerGas.toString()} wei.`
|
|
203
215
|
};
|
|
204
216
|
if (maxPriorityFeePerGas > MAX_VAULT_PRIORITY_FEE_PER_GAS) return {
|
|
205
217
|
valid: false,
|
|
@@ -214,21 +226,27 @@ function validateVaultSignedTransactionFeeCaps(feeCaps, quote) {
|
|
|
214
226
|
if (quote !== void 0 && maxFeePerGas < quote.minimumMaxFeePerGas) return {
|
|
215
227
|
valid: false,
|
|
216
228
|
code: "MaxFeeTooLow",
|
|
217
|
-
reason: `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ${quote.minimumMaxFeePerGas.toString()} wei for the buffered next-block base fee and
|
|
229
|
+
reason: `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ${quote.minimumMaxFeePerGas.toString()} wei for the buffered next-block base fee and configured minimum priority fee.`
|
|
218
230
|
};
|
|
219
231
|
return { valid: true };
|
|
220
232
|
}
|
|
221
|
-
async function resolveVaultTransactionFeeQuote({ readFeeHistory, readFallbackEstimate }) {
|
|
233
|
+
async function resolveVaultTransactionFeeQuote({ readFeeHistory, readFallbackEstimate, minimumPriorityFeePerGas }) {
|
|
222
234
|
let feeHistoryError;
|
|
223
235
|
try {
|
|
224
|
-
const quote = resolveFeeHistoryQuote(
|
|
236
|
+
const quote = resolveFeeHistoryQuote({
|
|
237
|
+
...await readFeeHistory(),
|
|
238
|
+
minimumPriorityFeePerGas
|
|
239
|
+
});
|
|
225
240
|
if (quote !== null) return quote;
|
|
226
241
|
feeHistoryError = new Error("eth_feeHistory returned incomplete base fee or reward data");
|
|
227
242
|
} catch (error) {
|
|
228
243
|
feeHistoryError = error;
|
|
229
244
|
}
|
|
230
245
|
try {
|
|
231
|
-
return resolveFallbackQuote(
|
|
246
|
+
return resolveFallbackQuote({
|
|
247
|
+
...await readFallbackEstimate(),
|
|
248
|
+
minimumPriorityFeePerGas
|
|
249
|
+
});
|
|
232
250
|
} catch (fallbackError) {
|
|
233
251
|
throw new VaultTransactionFeeEstimationError({
|
|
234
252
|
feeHistoryError,
|
|
@@ -240,12 +258,13 @@ async function resolveVaultTransactionFeeQuote({ readFeeHistory, readFallbackEst
|
|
|
240
258
|
* Resolve explicit EIP-1559 fees for operator-controlled vault transactions.
|
|
241
259
|
*
|
|
242
260
|
* The normal path follows the median p90 priority fee from the last 20 blocks,
|
|
243
|
-
* with a 0.1 gwei floor
|
|
244
|
-
*
|
|
245
|
-
* base-fee allowance.
|
|
261
|
+
* with a 3 gwei ceiling and a 0.1 gwei floor except on chains that do not use
|
|
262
|
+
* tips for ordering. If fee history is unavailable, Viem's estimate is used
|
|
263
|
+
* while preserving those bounds and its original base-fee allowance.
|
|
246
264
|
*/
|
|
247
265
|
async function getVaultTransactionFeeQuote(client) {
|
|
248
266
|
return resolveVaultTransactionFeeQuote({
|
|
267
|
+
minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),
|
|
249
268
|
readFeeHistory: () => getFeeHistory(client, {
|
|
250
269
|
blockCount: FEE_HISTORY_BLOCK_COUNT,
|
|
251
270
|
blockTag: "latest",
|
|
@@ -260,13 +279,19 @@ async function getVaultDeltaHedgeHistoricalFeeQuote(client) {
|
|
|
260
279
|
blockTag: "latest",
|
|
261
280
|
rewardPercentiles: DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES
|
|
262
281
|
});
|
|
263
|
-
const quote = resolveDeltaHedgeFeeHistoryQuote(
|
|
282
|
+
const quote = resolveDeltaHedgeFeeHistoryQuote({
|
|
283
|
+
...feeHistory,
|
|
284
|
+
minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id)
|
|
285
|
+
});
|
|
264
286
|
if (quote === null) throw new Error("eth_feeHistory returned incomplete p25 base fee or reward data");
|
|
265
287
|
return quote;
|
|
266
288
|
}
|
|
267
|
-
async function resolveVaultDeltaHedgeInitialFeeQuote({ readRpcQuote, readHistoricalQuote }) {
|
|
289
|
+
async function resolveVaultDeltaHedgeInitialFeeQuote({ readRpcQuote, readHistoricalQuote, minimumPriorityFeePerGas }) {
|
|
268
290
|
try {
|
|
269
|
-
return resolveRpcPriorityFeeQuote(
|
|
291
|
+
return resolveRpcPriorityFeeQuote({
|
|
292
|
+
...await readRpcQuote(),
|
|
293
|
+
minimumPriorityFeePerGas
|
|
294
|
+
});
|
|
270
295
|
} catch {
|
|
271
296
|
return readHistoricalQuote();
|
|
272
297
|
}
|
|
@@ -278,6 +303,7 @@ async function resolveVaultDeltaHedgeInitialFeeQuote({ readRpcQuote, readHistori
|
|
|
278
303
|
*/
|
|
279
304
|
async function getVaultDeltaHedgeInitialFeeQuote(client) {
|
|
280
305
|
return resolveVaultDeltaHedgeInitialFeeQuote({
|
|
306
|
+
minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),
|
|
281
307
|
readRpcQuote: async () => {
|
|
282
308
|
const [rawPriorityFee, latestBlock] = await Promise.all([client.request({ method: "eth_maxPriorityFeePerGas" }), getBlock(client, { blockTag: "latest" })]);
|
|
283
309
|
if (latestBlock.baseFeePerGas === null) throw new Error("Latest block does not include an EIP-1559 base fee");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { StateViewAbi, getAccountCollateral, panopticQueryAbi$1 as panopticQueryAbi, readBlockAndAggregate, requireReturnData } from "./irm-
|
|
2
|
-
import { AccountInsolventError, ChunkLimitError, DEFAULT_VEGOID, InvalidHistoryRangeError, MulticallResultMissingError, NotEnoughTokensError, PanopticError, PanopticValidationError, SafeModeError, StaleDataError, StorageDataNotFoundError, UnhealthyPoolError, WrongUniswapPoolError, applyMintBufferPerToken, availableToBorrow, collateralTrackerV2Abi, decodeLeftRightSigned, decodeLeftRightUnsigned, decodePositionBalance, getBlockMeta, getClosedPositionsKey, getPendingPositionsKey, getPool, getPoolMetaKey, getPoolMetadata, getPositionMetaKey, getPositionsKey, getTrackedChunksKey, getTrackedPositionIds, isPanopticErrorType, jsonSerializer, mintableAfterBuffer, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi as panopticQueryAbi$1, parsePanopticError, riskEngineAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./rates-
|
|
1
|
+
import { StateViewAbi, getAccountCollateral, panopticQueryAbi$1 as panopticQueryAbi, readBlockAndAggregate, requireReturnData } from "./irm-DsM35dGO.js";
|
|
2
|
+
import { AccountInsolventError, ChunkLimitError, DEFAULT_VEGOID, InvalidHistoryRangeError, MulticallResultMissingError, NotEnoughTokensError, PanopticError, PanopticValidationError, SafeModeError, StaleDataError, StorageDataNotFoundError, UnhealthyPoolError, WrongUniswapPoolError, applyMintBufferPerToken, availableToBorrow, collateralTrackerV2Abi, decodeLeftRightSigned, decodeLeftRightUnsigned, decodePositionBalance, getBlockMeta, getClosedPositionsKey, getPendingPositionsKey, getPool, getPoolMetaKey, getPoolMetadata, getPositionMetaKey, getPositionsKey, getTrackedChunksKey, getTrackedPositionIds, isPanopticErrorType, jsonSerializer, mintableAfterBuffer, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi as panopticQueryAbi$1, parsePanopticError, riskEngineAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./rates-CEJz8fjw.js";
|
|
3
3
|
import { MAX_TICK, MAX_TRACKED_CHUNKS, MIN_TICK, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, WAD, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionGamma, calculatePositionValue, priceToTick, sqrtPriceX96ToTick, tickLimits, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick } from "./greeks-CNi1-cnp.js";
|
|
4
|
-
import { addLegToTokenId, buildBatchDispatchArgs, buildSettleSequenceCalls, buildUniqueCredit, buildUniqueLoan, countLegs, createTokenIdBuilder, decodeAllLegs, decodeTokenId, getPoolTokensForSimulation, loadCheckpoint, resolveTokenIndex, simulateOpenPosition, simulateWithTokenFlow } from "./writes-
|
|
5
|
-
import { getLpPositionFunding, getMaxLpPositionSize } from "./router-
|
|
4
|
+
import { addLegToTokenId, buildBatchDispatchArgs, buildSettleSequenceCalls, buildUniqueCredit, buildUniqueLoan, countLegs, createTokenIdBuilder, decodeAllLegs, decodeTokenId, getPoolTokensForSimulation, loadCheckpoint, resolveTokenIndex, simulateOpenPosition, simulateWithTokenFlow } from "./writes-CQrevcCu.js";
|
|
5
|
+
import { getLpPositionFunding, getMaxLpPositionSize } from "./router-DUOHNdYZ.js";
|
|
6
6
|
import { BaseError, ContractFunctionExecutionError, ContractFunctionRevertedError, ExecutionRevertedError, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, getAddress, keccak256, parseAbi, toHex, zeroAddress } from "viem";
|
|
7
7
|
import { multicall } from "viem/actions";
|
|
8
8
|
import Decimal from "decimal.js";
|
|
@@ -9,12 +9,14 @@ type VaultTransactionFeeQuote = {
|
|
|
9
9
|
maxFeePerGas: bigint;
|
|
10
10
|
maxPriorityFeePerGas: bigint;
|
|
11
11
|
minimumMaxFeePerGas: bigint;
|
|
12
|
+
minimumPriorityFeePerGas?: bigint;
|
|
12
13
|
source: 'fee_history' | 'viem_fallback' | 'rpc_priority_fee' | 'fee_history_p25';
|
|
13
14
|
};
|
|
14
15
|
type VaultDeltaHedgeFeeQuote = VaultTransactionFeeQuote & {
|
|
15
16
|
rawPriorityFeePerGas: bigint;
|
|
16
17
|
};
|
|
17
18
|
type VaultSignedTransactionFeeCaps = {
|
|
19
|
+
chainId?: number;
|
|
18
20
|
gasLimit?: bigint | null;
|
|
19
21
|
maxFeePerGas: bigint | null;
|
|
20
22
|
maxPriorityFeePerGas: bigint | null;
|
|
@@ -90,9 +92,9 @@ declare function validateVaultSignedTransactionFeeCaps(feeCaps: VaultSignedTrans
|
|
|
90
92
|
* Resolve explicit EIP-1559 fees for operator-controlled vault transactions.
|
|
91
93
|
*
|
|
92
94
|
* The normal path follows the median p90 priority fee from the last 20 blocks,
|
|
93
|
-
* with a 0.1 gwei floor
|
|
94
|
-
*
|
|
95
|
-
* base-fee allowance.
|
|
95
|
+
* with a 3 gwei ceiling and a 0.1 gwei floor except on chains that do not use
|
|
96
|
+
* tips for ordering. If fee history is unavailable, Viem's estimate is used
|
|
97
|
+
* while preserving those bounds and its original base-fee allowance.
|
|
96
98
|
*/
|
|
97
99
|
declare function getVaultTransactionFeeQuote<chain extends Chain | undefined>(client: Client<Transport, chain>): Promise<VaultTransactionFeeQuote>;
|
|
98
100
|
declare function getVaultDeltaHedgeHistoricalFeeQuote<chain extends Chain | undefined>(client: Client<Transport, chain>): Promise<VaultDeltaHedgeFeeQuote>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault-transaction-fees.d.ts","names":["Chain","Client","Transport","MIN_VAULT_PRIORITY_FEE_PER_GAS","MAX_VAULT_PRIORITY_FEE_PER_GAS","MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS","MAX_VAULT_TRANSACTION_GAS_COST","VaultTransactionFeeQuote","VaultDeltaHedgeFeeQuote","VaultSignedTransactionFeeCaps","VaultSignedTransactionFeeValidationResult","VaultTransactionFeeEstimationError","feeHistoryError","fallbackError","Error","VaultTransactionGasCostLimitError","gasLimit","maximumAffordableFeePerGas","minimumRequiredFeePerGas","VaultTransactionReplacementLimitError","code","requiredMaxFeePerGas","requiredMaxPriorityFeePerGas","FeeHistorySnapshot","FallbackFeeEstimate","clampPriorityFee","resolveFeeHistoryQuote","baseFeePerGas","reward","resolveDeltaHedgeFeeHistoryQuote","resolveRpcPriorityFeeQuote","rawPriorityFeePerGas","getVaultTransactionReplacementFeeQuote","originalQuote","historicalQuote","finalReplacement","staleBoundsReplacement","Pick","resolveFallbackQuote","estimatedMaxFeePerGas","estimatedPriorityFeePerGas","applyVaultTransactionGasCostLimit","bufferVaultTransactionGasEstimate","validateVaultSignedTransactionFeeCaps","resolveVaultTransactionFeeQuote","readFeeHistory","readFallbackEstimate","Promise","getVaultTransactionFeeQuote","chain","getVaultDeltaHedgeHistoricalFeeQuote","resolveVaultDeltaHedgeInitialFeeQuote","readRpcQuote","readHistoricalQuote","getVaultDeltaHedgeInitialFeeQuote","__transactionFeeTestUtils"],"sources":["../src/hypoVault/transactionFees.d.ts"],"sourcesContent":null,"mappings":";;;cACqBG,8BAAAA;cACAC,8BAAAA;AADAD,cAEAE,0CAAAA,GAF8B,WAAA;AAC9BD,cAEAE,8BAAAA,GAF8B,kBAAA;AAC9BD,KAETE,wBAAAA,GAFSF;EACAC,YAAAA,EAAAA,MAAAA;EACTC,oBAAAA,EAAAA,MAAwB;
|
|
1
|
+
{"version":3,"file":"vault-transaction-fees.d.ts","names":["Chain","Client","Transport","MIN_VAULT_PRIORITY_FEE_PER_GAS","MAX_VAULT_PRIORITY_FEE_PER_GAS","MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS","MAX_VAULT_TRANSACTION_GAS_COST","VaultTransactionFeeQuote","VaultDeltaHedgeFeeQuote","VaultSignedTransactionFeeCaps","VaultSignedTransactionFeeValidationResult","VaultTransactionFeeEstimationError","feeHistoryError","fallbackError","Error","VaultTransactionGasCostLimitError","gasLimit","maximumAffordableFeePerGas","minimumRequiredFeePerGas","VaultTransactionReplacementLimitError","code","requiredMaxFeePerGas","requiredMaxPriorityFeePerGas","FeeHistorySnapshot","FallbackFeeEstimate","getChainPriorityFeeFloor","clampPriorityFee","resolveFeeHistoryQuote","baseFeePerGas","reward","minimumPriorityFeePerGas","resolveDeltaHedgeFeeHistoryQuote","resolveRpcPriorityFeeQuote","rawPriorityFeePerGas","getVaultTransactionReplacementFeeQuote","originalQuote","historicalQuote","finalReplacement","staleBoundsReplacement","Pick","resolveFallbackQuote","estimatedMaxFeePerGas","estimatedPriorityFeePerGas","applyVaultTransactionGasCostLimit","bufferVaultTransactionGasEstimate","validateVaultSignedTransactionFeeCaps","resolveVaultTransactionFeeQuote","readFeeHistory","readFallbackEstimate","Promise","getVaultTransactionFeeQuote","chain","getVaultDeltaHedgeHistoricalFeeQuote","resolveVaultDeltaHedgeInitialFeeQuote","readRpcQuote","readHistoricalQuote","getVaultDeltaHedgeInitialFeeQuote","__transactionFeeTestUtils"],"sources":["../src/hypoVault/transactionFees.d.ts"],"sourcesContent":null,"mappings":"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"}
|