@gvnrdao/dh-sdk 0.0.339 → 0.0.341
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/browser/dist/833.browser.js +2 -0
- package/browser/dist/833.browser.js.LICENSE.txt +1 -0
- package/browser/dist/browser.js +1 -1
- package/browser/dist/browser.js.LICENSE.txt +0 -4
- package/dist/constants/chunks/contract-errors.generated.d.ts +15 -0
- package/dist/contract-errors.js +498 -0
- package/dist/contract-errors.mjs +461 -0
- package/dist/index.js +7110 -372
- package/dist/index.mjs +7350 -613
- package/dist/modules/diamond-hands-sdk.d.ts +12 -5
- package/dist/sign-guard.js +147 -2
- package/dist/sign-guard.mjs +139 -2
- package/dist/utils/address-conversion.utils.d.ts +15 -6
- package/dist/utils/agent-delegation.utils.d.ts +39 -0
- package/dist/utils/assert-provider-chain.d.ts +16 -0
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +2 -2
- package/dist/utils/concurrency-limiter.utils.d.ts +59 -0
- package/dist/utils/contract-error-decoder.d.ts +47 -0
- package/dist/utils/lit-action-chain-name.d.ts +14 -0
- package/dist/utils/loan-helpers.utils.d.ts +115 -0
- package/dist/utils/quantum-revert.utils.d.ts +14 -2
- package/dist/utils/sign-guard/errors.d.ts +5 -1
- package/dist/utils/sign-guard/fee-ceiling.d.ts +16 -0
- package/dist/utils/sign-guard/index.d.ts +2 -1
- package/dist/utils/sign-guard/psm-exchange.d.ts +122 -0
- package/package.json +20 -6
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
// src/utils/contract-error-decoder.ts
|
|
2
|
+
import { Interface } from "ethers";
|
|
3
|
+
|
|
4
|
+
// src/constants/chunks/contract-errors.generated.ts
|
|
5
|
+
var CONTRACT_ERROR_FRAGMENTS = [
|
|
6
|
+
{ fragment: "error AboveMaxRedeem(uint256 amount, uint256 maximum)", contracts: ["SimplePSMV2"] },
|
|
7
|
+
{ fragment: "error AboveMaxSwap(uint256 amount, uint256 maximum)", contracts: ["SimplePSMV2"] },
|
|
8
|
+
{ fragment: "error AccessControlBadConfirmation()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
9
|
+
{ fragment: "error AccessControlUnauthorizedAccount(address account, bytes32 neededRole)", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
10
|
+
{ fragment: "error AddressEmptyCode(address target)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
11
|
+
{ fragment: "error AlreadyActive()", contracts: ["PositionManagerErrors"] },
|
|
12
|
+
{ fragment: "error AlreadySigned()", contracts: ["PositionManagerErrors", "OperationAuthorizationRegistry"] },
|
|
13
|
+
{ fragment: "error AmountMustBePositive()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
|
|
14
|
+
{ fragment: "error ArrayLengthMismatch()", contracts: ["BTCSpendAuthorizer", "SimplePSMV2"] },
|
|
15
|
+
{ fragment: "error BTCSpendAuthorizerNotSet()", contracts: ["LoanOperationsManagerModule"] },
|
|
16
|
+
{ fragment: "error BalanceMismatch()", contracts: ["UCDController"] },
|
|
17
|
+
{ fragment: "error BatchSizeTooLarge()", contracts: ["BTCSpendAuthorizer"] },
|
|
18
|
+
{ fragment: "error BelowMinRedeem(uint256 amount, uint256 minimum)", contracts: ["SimplePSMV2"] },
|
|
19
|
+
{ fragment: "error BelowMinSwap(uint256 amount, uint256 minimum)", contracts: ["SimplePSMV2"] },
|
|
20
|
+
{ fragment: "error BorrowerBTCSpendMutationDisabled()", contracts: ["LoanOperationsManagerModule"] },
|
|
21
|
+
{ fragment: "error BtcAmountTooLarge()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
|
|
22
|
+
{ fragment: "error BtcPriceBoundOutOfRange()", contracts: ["LoanOperationsManagerModule"] },
|
|
23
|
+
{ fragment: "error BtcPriceDeviationExceeded(uint256 signedPrice, uint256 chainlinkPrice, uint16 deviationBps)", contracts: ["LoanOperationsManagerModule"] },
|
|
24
|
+
{ fragment: "error BtcPriceFeedStale(uint256 updatedAt, uint256 maxAge)", contracts: ["LoanOperationsManagerModule"] },
|
|
25
|
+
{ fragment: "error BtcPriceTooHigh()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
|
|
26
|
+
{ fragment: "error BurnCallFailed()", contracts: ["UCDController"] },
|
|
27
|
+
{ fragment: "error BurnGuardFailed(uint8 code)", contracts: ["UCDController"] },
|
|
28
|
+
{ fragment: "error BurnVerificationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
29
|
+
{ fragment: "error CannotRemoveLastTerm()", contracts: ["PositionManagerErrors"] },
|
|
30
|
+
{ fragment: "error CannotUpgradeToSelf()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer"] },
|
|
31
|
+
{ fragment: "error CircuitBreakerNotActive()", contracts: ["PositionManagerErrors"] },
|
|
32
|
+
{ fragment: "error CircuitBreakerTriggered()", contracts: ["PositionManagerErrors"] },
|
|
33
|
+
{ fragment: "error CollateralOverflow()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
|
|
34
|
+
{ fragment: "error CollateralRatioTooLargeForStorage()", contracts: ["PositionManagerErrors"] },
|
|
35
|
+
{ fragment: "error CollateralRatioTooLow()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
|
|
36
|
+
{ fragment: "error ContractNotDeployed(address addr)", contracts: ["PositionManager"] },
|
|
37
|
+
{ fragment: "error DailyLimitExceeded()", contracts: ["UCDController"] },
|
|
38
|
+
{ fragment: "error DeadZoneViolation()", contracts: ["OperationAuthorizationRegistry"] },
|
|
39
|
+
{ fragment: "error DebtCalculationMismatch()", contracts: ["LoanOperationsManagerModule"] },
|
|
40
|
+
{ fragment: "error DebtNotZero()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
41
|
+
{ fragment: "error DebtOverflow()", contracts: ["LoanOperationsManagerModule"] },
|
|
42
|
+
{ fragment: "error DebtUpdateVerificationFailed()", contracts: ["LoanOperationsValidation", "LoanOperationsManagerModule"] },
|
|
43
|
+
{ fragment: "error DebtUpdateVerificationFailedDetailed(bytes32 positionId, uint256 currentDebt, uint256 newDebt, uint256 quantumTimestamp, uint256 supplyAfterMint, uint256 expectedIncrease)", contracts: ["LoanOperationsManagerModule"] },
|
|
44
|
+
{ fragment: "error DecimalsMismatch(uint8 provided, uint8 actual)", contracts: ["SimplePSMV2"] },
|
|
45
|
+
{ fragment: "error DecimalsQueryFailed()", contracts: ["SimplePSMV2"] },
|
|
46
|
+
{ fragment: "error DivisionByZero()", contracts: ["PositionManager", "CollateralManagerModule"] },
|
|
47
|
+
{ fragment: "error ECDSAInvalidSignature()", contracts: ["BTCSpendAuthorizer"] },
|
|
48
|
+
{ fragment: "error ECDSAInvalidSignatureLength(uint256 length)", contracts: ["BTCSpendAuthorizer"] },
|
|
49
|
+
{ fragment: "error ECDSAInvalidSignatureS(bytes32 s)", contracts: ["BTCSpendAuthorizer"] },
|
|
50
|
+
{ fragment: "error ERC1967InvalidImplementation(address implementation)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
51
|
+
{ fragment: "error ERC1967NonPayable()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
52
|
+
{ fragment: "error EnforcedPause()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
53
|
+
{ fragment: "error EntryFeeTooHigh(uint256 fee, uint256 max)", contracts: ["SimplePSMV2"] },
|
|
54
|
+
{ fragment: "error ExceedsFeeBalance(uint256 requested, uint256 max)", contracts: ["SimplePSMV2"] },
|
|
55
|
+
{ fragment: "error ExceedsMaxLoan()", contracts: ["PositionManagerErrors"] },
|
|
56
|
+
{ fragment: "error ExitFeeTooHigh(uint256 fee, uint256 max)", contracts: ["SimplePSMV2"] },
|
|
57
|
+
{ fragment: "error ExpectedPause()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
58
|
+
{ fragment: "error ExtensionFeeMintingFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
59
|
+
{ fragment: "error ExtensionNotAllowed()", contracts: ["PositionManagerErrors"] },
|
|
60
|
+
{ fragment: "error FailedCall()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
61
|
+
{ fragment: "error FailedToGetStablecoinDecimals()", contracts: ["SimplePSMV2"] },
|
|
62
|
+
{ fragment: "error FailedToGetUCDDecimals()", contracts: ["SimplePSMV2"] },
|
|
63
|
+
{ fragment: "error FeeOnTransferNotSupported()", contracts: ["SimplePSMV2"] },
|
|
64
|
+
{ fragment: "error FeeTooHigh(uint256 fee, uint256 max)", contracts: ["PositionManagerErrors"] },
|
|
65
|
+
{ fragment: "error FeeTooLow(uint256 fee, uint256 min)", contracts: ["PositionManagerErrors"] },
|
|
66
|
+
{ fragment: "error ImplNotDeployed()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
|
|
67
|
+
{ fragment: "error ImplementationNotDeployed()", contracts: ["UCDController"] },
|
|
68
|
+
{ fragment: "error InitialBalanceTooLarge()", contracts: ["SimplePSMV2"] },
|
|
69
|
+
{ fragment: "error InsufficientBalance()", contracts: ["PositionManagerErrors"] },
|
|
70
|
+
{ fragment: "error InsufficientCollateralForAmount()", contracts: ["PositionManagerErrors"] },
|
|
71
|
+
{ fragment: "error InsufficientCollateralRatio()", contracts: ["CollateralManagerModule"] },
|
|
72
|
+
{ fragment: "error InsufficientFeeBal()", contracts: ["LoanOperationsManagerModule"] },
|
|
73
|
+
{ fragment: "error InsufficientReserves(uint256 available, uint256 required)", contracts: ["SimplePSMV2"] },
|
|
74
|
+
{ fragment: "error InsufficientSignatures()", contracts: ["OperationAuthorizationRegistry"] },
|
|
75
|
+
{ fragment: "error IntegrityCheckFailed()", contracts: ["PositionManagerErrors"] },
|
|
76
|
+
{ fragment: "error InvalidActionHash()", contracts: ["CollateralManagerModule"] },
|
|
77
|
+
{ fragment: "error InvalidAddress()", contracts: ["PositionManager", "PositionManagerErrors", "OperationAuthorizationRegistry", "CollateralManagerModule", "SimplePSMV2"] },
|
|
78
|
+
{ fragment: "error InvalidAdmin()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "SimplePSMV2"] },
|
|
79
|
+
{ fragment: "error InvalidAmount()", contracts: ["PositionManagerErrors", "SimplePSMV2"] },
|
|
80
|
+
{ fragment: "error InvalidBTCPrice()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
81
|
+
{ fragment: "error InvalidBytes32()", contracts: ["PositionManager"] },
|
|
82
|
+
{ fragment: "error InvalidCollateralAmount()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
83
|
+
{ fragment: "error InvalidController()", contracts: ["SimplePSMV2"] },
|
|
84
|
+
{ fragment: "error InvalidDecimals(uint8 decimals)", contracts: ["SimplePSMV2"] },
|
|
85
|
+
{ fragment: "error InvalidExchangeRate()", contracts: ["SimplePSMV2"] },
|
|
86
|
+
{ fragment: "error InvalidImpl()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
|
|
87
|
+
{ fragment: "error InvalidImplementation()", contracts: ["UCDController"] },
|
|
88
|
+
{ fragment: "error InvalidInitialization()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
89
|
+
{ fragment: "error InvalidLitSignature()", contracts: ["BTCSpendAuthorizer"] },
|
|
90
|
+
{ fragment: "error InvalidLoanOps()", contracts: ["BTCSpendAuthorizer"] },
|
|
91
|
+
{ fragment: "error InvalidModuleAddress()", contracts: ["UCDController"] },
|
|
92
|
+
{ fragment: "error InvalidNetwork()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
93
|
+
{ fragment: "error InvalidNetworkMode()", contracts: ["PositionManagerErrors"] },
|
|
94
|
+
{ fragment: "error InvalidOracleConfig()", contracts: ["LoanOperationsManagerModule"] },
|
|
95
|
+
{ fragment: "error InvalidPKPId()", contracts: ["PositionManagerErrors"] },
|
|
96
|
+
{ fragment: "error InvalidParameter()", contracts: ["UCDController"] },
|
|
97
|
+
{ fragment: "error InvalidPkpPublicKey()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
98
|
+
{ fragment: "error InvalidPosMgr()", contracts: ["LoanOperationsManagerModule"] },
|
|
99
|
+
{ fragment: "error InvalidPositionId()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsValidation", "LoanOperationsManagerModule", "CollateralManagerModule"] },
|
|
100
|
+
{ fragment: "error InvalidPositionState()", contracts: ["LoanOperationsManagerModule"] },
|
|
101
|
+
{ fragment: "error InvalidPriceFeed()", contracts: ["LoanOperationsManagerModule"] },
|
|
102
|
+
{ fragment: "error InvalidRecipient()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
|
|
103
|
+
{ fragment: "error InvalidRegistry()", contracts: ["LoanOperationsManagerModule"] },
|
|
104
|
+
{ fragment: "error InvalidRequestedExpiryDate()", contracts: ["PositionManagerErrors"] },
|
|
105
|
+
{ fragment: "error InvalidSignature(string reason)", contracts: ["PositionManager"] },
|
|
106
|
+
{ fragment: "error InvalidSignatureLength()", contracts: ["PositionManagerErrors"] },
|
|
107
|
+
{ fragment: "error InvalidStablecoinAddress()", contracts: ["SimplePSMV2"] },
|
|
108
|
+
{ fragment: "error InvalidStaleSpendAttestation()", contracts: ["BTCSpendAuthorizer"] },
|
|
109
|
+
{ fragment: "error InvalidString(string value)", contracts: ["PositionManager"] },
|
|
110
|
+
{ fragment: "error InvalidTerm()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
111
|
+
{ fragment: "error InvalidTerm(uint256 term, uint256 min, uint256 max)", contracts: ["PositionManager"] },
|
|
112
|
+
{ fragment: "error InvalidTermMgr()", contracts: ["LoanOperationsManagerModule"] },
|
|
113
|
+
{ fragment: "error InvalidTermStartTime()", contracts: ["PositionManagerErrors"] },
|
|
114
|
+
{ fragment: "error InvalidToken()", contracts: ["SimplePSMV2"] },
|
|
115
|
+
{ fragment: "error InvalidUCDCtrl()", contracts: ["LoanOperationsManagerModule"] },
|
|
116
|
+
{ fragment: "error InvalidUCDDecimals(uint8 decimals)", contracts: ["SimplePSMV2"] },
|
|
117
|
+
{ fragment: "error InvalidUCDToken()", contracts: ["LoanOperationsManagerModule"] },
|
|
118
|
+
{ fragment: "error InvalidValidatorAddress()", contracts: ["BTCSpendAuthorizer"] },
|
|
119
|
+
{ fragment: "error InvalidValidatorSignature()", contracts: ["PositionManagerErrors"] },
|
|
120
|
+
{ fragment: "error InvalidVaultAddress()", contracts: ["PositionManagerErrors"] },
|
|
121
|
+
{ fragment: "error InvalidVolumeCap(bool isRedeem)", contracts: ["SimplePSMV2"] },
|
|
122
|
+
{ fragment: "error InvalidWithdrawalAddress()", contracts: ["CollateralManagerModule"] },
|
|
123
|
+
{ fragment: "error InvalidWithdrawalLoanStatusType()", contracts: ["CollateralManagerModule"] },
|
|
124
|
+
{ fragment: "error LiquidationsPaused()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
125
|
+
{ fragment: "error LoanAmountTooHigh()", contracts: ["PositionManagerErrors"] },
|
|
126
|
+
{ fragment: "error LoanAmountTooLow()", contracts: ["PositionManagerErrors"] },
|
|
127
|
+
{ fragment: "error MaxAuthorizedSpendsReached()", contracts: ["BTCSpendAuthorizer"] },
|
|
128
|
+
{ fragment: "error MaxLoanOutOfBounds()", contracts: ["LoanOperationsManagerModule"] },
|
|
129
|
+
{ fragment: "error MaxRedeemBelowMin(uint256 maximum, uint256 minimum)", contracts: ["SimplePSMV2"] },
|
|
130
|
+
{ fragment: "error MaxRedeemCapDisabled()", contracts: ["SimplePSMV2"] },
|
|
131
|
+
{ fragment: "error MaxSupplyExceeded()", contracts: ["UCDController"] },
|
|
132
|
+
{ fragment: "error MaxSwapBelowMin(uint256 maximum, uint256 minimum)", contracts: ["SimplePSMV2"] },
|
|
133
|
+
{ fragment: "error MaxSwapCapDisabled()", contracts: ["SimplePSMV2"] },
|
|
134
|
+
{ fragment: "error MinLoanOutOfBounds()", contracts: ["LoanOperationsManagerModule"] },
|
|
135
|
+
{ fragment: "error MintBorrowerMismatch()", contracts: ["LoanOperationsManagerModule"] },
|
|
136
|
+
{ fragment: "error MintCallFailed()", contracts: ["UCDController"] },
|
|
137
|
+
{ fragment: "error MintFailed()", contracts: ["LoanOperationsManagerModule"] },
|
|
138
|
+
{ fragment: "error MintGuardFailed(uint8 code)", contracts: ["UCDController"] },
|
|
139
|
+
{ fragment: "error MintVerificationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
140
|
+
{ fragment: "error MintVerificationMismatch(uint256 expectedSupply, uint256 currentSupply)", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
141
|
+
{ fragment: "error MissingVERSION()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "UCDController"] },
|
|
142
|
+
{ fragment: "error MissingVersion()", contracts: ["PositionManagerErrors", "CollateralManagerModule"] },
|
|
143
|
+
{ fragment: "error ModuleCallFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
144
|
+
{ fragment: "error NoFeesToTransfer()", contracts: ["SimplePSMV2"] },
|
|
145
|
+
{ fragment: "error NoRegistry()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
146
|
+
{ fragment: "error NoVersion()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "UCDController"] },
|
|
147
|
+
{ fragment: "error NonZeroReserves(address stablecoin, uint256 reserves)", contracts: ["SimplePSMV2"] },
|
|
148
|
+
{ fragment: "error NormalizationOverflow()", contracts: ["SimplePSMV2"] },
|
|
149
|
+
{ fragment: "error NotAdminModule()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
150
|
+
{ fragment: "error NotAuthorized()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
151
|
+
{ fragment: "error NotAuthorizedConsumer()", contracts: ["OperationAuthorizationRegistry"] },
|
|
152
|
+
{ fragment: "error NotAuthorizedSigner()", contracts: ["OperationAuthorizationRegistry"] },
|
|
153
|
+
{ fragment: "error NotBorrower()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
|
|
154
|
+
{ fragment: "error NotContract()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "SimplePSMV2"] },
|
|
155
|
+
{ fragment: "error NotInitializing()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
156
|
+
{ fragment: "error NotLiquidationPkpOwner()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
157
|
+
{ fragment: "error NotLiquidator()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
158
|
+
{ fragment: "error NotOwner()", contracts: ["OperationAuthorizationRegistry"] },
|
|
159
|
+
{ fragment: "error NotPendingOwner()", contracts: ["OperationAuthorizationRegistry"] },
|
|
160
|
+
{ fragment: "error NotProductionAuthorizer()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule"] },
|
|
161
|
+
{ fragment: "error NotProductionRegistry()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
|
|
162
|
+
{ fragment: "error OnlyCore()", contracts: ["CollateralManagerModule"] },
|
|
163
|
+
{ fragment: "error OnlyLoanOps()", contracts: ["BTCSpendAuthorizer"] },
|
|
164
|
+
{ fragment: "error OnlyPosMgr()", contracts: ["LoanOperationsManagerModule"] },
|
|
165
|
+
{ fragment: "error OnlyPositionManager()", contracts: ["LoanOperationsManagerModule"] },
|
|
166
|
+
{ fragment: "error OperationInProgress()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
167
|
+
{ fragment: "error OracleDecimalMismatch()", contracts: ["LoanOperationsManagerModule"] },
|
|
168
|
+
{ fragment: "error PKPAlreadyUsed()", contracts: ["PositionManagerErrors"] },
|
|
169
|
+
{ fragment: "error PaymentAmountTooLarge()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
170
|
+
{ fragment: "error PaymentAmountZero()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
171
|
+
{ fragment: "error PaymentMustBeLessThanDebt()", contracts: ["LoanOperationsManagerModule"] },
|
|
172
|
+
{ fragment: "error PaymentMustBePositive()", contracts: ["LoanOperationsManagerModule"] },
|
|
173
|
+
{ fragment: "error PositionAlreadyExists()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
174
|
+
{ fragment: "error PositionDoesNotExist()", contracts: ["CollateralManagerModule"] },
|
|
175
|
+
{ fragment: "error PositionLiquidatable()", contracts: ["PositionManagerErrors"] },
|
|
176
|
+
{ fragment: "error PositionManagerNotContract()", contracts: ["LoanOperationsValidation"] },
|
|
177
|
+
{ fragment: "error PositionManagerNotSet()", contracts: ["LoanOperationsValidation"] },
|
|
178
|
+
{ fragment: "error PositionNotActive()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
179
|
+
{ fragment: "error PositionNotEligible()", contracts: ["LoanOperationsManagerModule"] },
|
|
180
|
+
{ fragment: "error PositionNotEligibleForOperation()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
181
|
+
{ fragment: "error PositionNotFound()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
|
|
182
|
+
{ fragment: "error PositionNotInCore()", contracts: ["LoanOperationsValidation"] },
|
|
183
|
+
{ fragment: "error PositionStatusInvalid()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
|
|
184
|
+
{ fragment: "error PositionWouldBecomeLiquidatable()", contracts: ["PositionManagerErrors"] },
|
|
185
|
+
{ fragment: "error ProposalAlreadyExecuted()", contracts: ["OperationAuthorizationRegistry"] },
|
|
186
|
+
{ fragment: "error ProposalAlreadyExists()", contracts: ["OperationAuthorizationRegistry"] },
|
|
187
|
+
{ fragment: "error ProposalCancelled()", contracts: ["OperationAuthorizationRegistry"] },
|
|
188
|
+
{ fragment: "error ProposalNotFound()", contracts: ["OperationAuthorizationRegistry"] },
|
|
189
|
+
{ fragment: "error PsmBurnSupplyMismatch(uint256 expected, uint256 actual)", contracts: ["SimplePSMV2"] },
|
|
190
|
+
{ fragment: "error PsmMintSupplyMismatch(uint256 expected, uint256 actual)", contracts: ["SimplePSMV2"] },
|
|
191
|
+
{ fragment: "error QuantumAlreadyUsed()", contracts: ["OperationAuthorizationRegistry"] },
|
|
192
|
+
{ fragment: "error QuantumOutsideWindow()", contracts: ["OperationAuthorizationRegistry"] },
|
|
193
|
+
{ fragment: "error RateLimitExceeded()", contracts: ["SimplePSMV2"] },
|
|
194
|
+
{ fragment: "error RatioOverflow()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
|
|
195
|
+
{ fragment: "error RecipientNotAllowed()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
|
|
196
|
+
{ fragment: "error RedeemVolumeExceededThisBlock(address stablecoin, uint256 attempted, uint256 cap)", contracts: ["SimplePSMV2"] },
|
|
197
|
+
{ fragment: "error RedemptionsPaused()", contracts: ["SimplePSMV2"] },
|
|
198
|
+
{ fragment: "error ReentrancyGuardReentrantCall()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
199
|
+
{ fragment: "error RegistryNotSet()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
|
|
200
|
+
{ fragment: "error ReserveOverflow()", contracts: ["SimplePSMV2"] },
|
|
201
|
+
{ fragment: "error ReserveTooLarge()", contracts: ["SimplePSMV2"] },
|
|
202
|
+
{ fragment: "error ReserveUnderflow()", contracts: ["SimplePSMV2"] },
|
|
203
|
+
{ fragment: "error SafeERC20FailedOperation(address token)", contracts: ["PositionManager", "LoanOperationsManagerModule", "SimplePSMV2"] },
|
|
204
|
+
{ fragment: "error SameBlockInteraction()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
205
|
+
{ fragment: "error SameImpl()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
|
|
206
|
+
{ fragment: "error SameImplementation()", contracts: ["PositionManagerErrors", "CollateralManagerModule"] },
|
|
207
|
+
{ fragment: "error SignatureVerificationFailed(bytes4 selector, address recovered, address expected, bytes32 messageHash, uint8 errorCode)", contracts: ["OperationAuthorizationRegistry"] },
|
|
208
|
+
{ fragment: "error SlippageExceeded(uint256 got, uint256 minimum)", contracts: ["SimplePSMV2"] },
|
|
209
|
+
{ fragment: "error SlippageProtectionRequired()", contracts: ["SimplePSMV2"] },
|
|
210
|
+
{ fragment: "error StablecoinAlreadySupported(address stablecoin)", contracts: ["SimplePSMV2"] },
|
|
211
|
+
{ fragment: "error StablecoinNotContract(address stablecoin)", contracts: ["SimplePSMV2"] },
|
|
212
|
+
{ fragment: "error StablecoinNotSupported(address stablecoin)", contracts: ["SimplePSMV2"] },
|
|
213
|
+
{ fragment: "error StablecoinNotSupportedInV1(address stablecoin)", contracts: ["SimplePSMV2"] },
|
|
214
|
+
{ fragment: "error StaleAttestationMismatch()", contracts: ["BTCSpendAuthorizer"] },
|
|
215
|
+
{ fragment: "error StaleAttestationTooOld()", contracts: ["BTCSpendAuthorizer"] },
|
|
216
|
+
{ fragment: "error StaleSpendValidatorNotSet()", contracts: ["BTCSpendAuthorizer"] },
|
|
217
|
+
{ fragment: "error StateHashMismatch()", contracts: ["LoanOperationsValidation", "LoanOperationsManagerModule", "CollateralManagerModule"] },
|
|
218
|
+
{ fragment: "error SwapVolumeExceededThisBlock(address stablecoin, uint256 attempted, uint256 cap)", contracts: ["SimplePSMV2"] },
|
|
219
|
+
{ fragment: "error SyncDriftTooLarge()", contracts: ["SimplePSMV2"] },
|
|
220
|
+
{ fragment: "error TargetAddrRequired()", contracts: ["BTCSpendAuthorizer"] },
|
|
221
|
+
{ fragment: "error TargetExceedsInputValue()", contracts: ["BTCSpendAuthorizer"] },
|
|
222
|
+
{ fragment: "error TargetMustBePositive()", contracts: ["BTCSpendAuthorizer"] },
|
|
223
|
+
{ fragment: "error TermAlreadyExists()", contracts: ["PositionManagerErrors"] },
|
|
224
|
+
{ fragment: "error TermExceedsMaximum()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
225
|
+
{ fragment: "error TermNotFound()", contracts: ["PositionManagerErrors"] },
|
|
226
|
+
{ fragment: "error ThresholdTooHigh()", contracts: ["LoanOperationsManagerModule"] },
|
|
227
|
+
{ fragment: "error TimelockNotMet()", contracts: ["OperationAuthorizationRegistry"] },
|
|
228
|
+
{ fragment: "error TimelockRequiredOnThisChain()", contracts: ["OperationAuthorizationRegistry"] },
|
|
229
|
+
{ fragment: "error TimestampOverflow()", contracts: ["LoanOperationsManagerModule"] },
|
|
230
|
+
{ fragment: "error TooManySigners()", contracts: ["OperationAuthorizationRegistry"] },
|
|
231
|
+
{ fragment: "error UTXOAlreadyAuthorized()", contracts: ["BTCSpendAuthorizer"] },
|
|
232
|
+
{ fragment: "error UTXONotAuthorized()", contracts: ["BTCSpendAuthorizer"] },
|
|
233
|
+
{ fragment: "error UUPSUnauthorizedCallContext()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
234
|
+
{ fragment: "error UUPSUnsupportedProxiableUUID(bytes32 slot)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
235
|
+
{ fragment: "error UcdAmountTooLarge()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
|
|
236
|
+
{ fragment: "error Unauthorized()", contracts: ["UCDController"] },
|
|
237
|
+
{ fragment: "error UnexpectedRoleGrantFailure()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
|
|
238
|
+
{ fragment: "error UnsupportedFeeToken(address token)", contracts: ["SimplePSMV2"] },
|
|
239
|
+
{ fragment: "error UserDailyMintLimitExceeded()", contracts: ["LoanOperationsManagerModule"] },
|
|
240
|
+
{ fragment: "error V2AlreadyInitialized()", contracts: ["SimplePSMV2"] },
|
|
241
|
+
{ fragment: "error ValidationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
|
|
242
|
+
{ fragment: "error ValidatorNotActive()", contracts: ["OperationAuthorizationRegistry"] },
|
|
243
|
+
{ fragment: "error WithdrawalAddressNotApproved()", contracts: ["CollateralManagerModule"] },
|
|
244
|
+
{ fragment: "error WithdrawalExceedsReserves(uint256 amount, uint256 reserves)", contracts: ["SimplePSMV2"] },
|
|
245
|
+
{ fragment: "error ZeroAddress()", contracts: ["PositionManager", "UCDController"] },
|
|
246
|
+
{ fragment: "error ZeroAmount()", contracts: ["UCDController"] }
|
|
247
|
+
];
|
|
248
|
+
|
|
249
|
+
// src/utils/quantum-revert.utils.ts
|
|
250
|
+
import { AbiCoder } from "ethers";
|
|
251
|
+
var DEAD_ZONE_VIOLATION_SELECTOR = "0xbe4b82c1";
|
|
252
|
+
var ERROR_STRING_SELECTOR = "0x08c379a0";
|
|
253
|
+
var PANIC_SELECTOR = "0x4e487b71";
|
|
254
|
+
var QUANTUM_REVERT_NAMES = {
|
|
255
|
+
"0xbe4b82c1": "DeadZoneViolation()",
|
|
256
|
+
"0x52ce5d58": "QuantumAlreadyUsed()",
|
|
257
|
+
"0x3e76a3c9": "QuantumOutsideWindow()",
|
|
258
|
+
"0x62278171": "InvalidValidatorSignature()",
|
|
259
|
+
"0x82b42900": "Unauthorized()",
|
|
260
|
+
"0x3ee5aeb5": "ReentrancyGuardReentrantCall()",
|
|
261
|
+
"0x0a0b0d79": "ValidationFailed()",
|
|
262
|
+
"0xd92e233d": "ZeroAddress()",
|
|
263
|
+
"0x36bfdeea": "StateHashMismatch()",
|
|
264
|
+
"0xb9d419a7": "DebtUpdateVerificationFailed()",
|
|
265
|
+
"0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
|
|
266
|
+
"0x0cfd2a97": "MintVerificationMismatch(uint256,uint256)",
|
|
267
|
+
"0x07637bd8": "MintFailed()"
|
|
268
|
+
};
|
|
269
|
+
function decodeQuantumRevert(e) {
|
|
270
|
+
const raw = e?.data ?? e?.info?.error?.data ?? // ethers v6 BrowserProvider (MetaMask)
|
|
271
|
+
e?.error?.data?.data ?? e?.error?.data ?? e?.error?.error?.data;
|
|
272
|
+
const data = typeof raw === "string" && raw.startsWith("0x") ? raw : null;
|
|
273
|
+
const selector = data && data.length >= 10 ? data.slice(0, 10) : null;
|
|
274
|
+
let name = selector ? QUANTUM_REVERT_NAMES[selector] ?? null : null;
|
|
275
|
+
if (!name && selector && data) {
|
|
276
|
+
try {
|
|
277
|
+
if (selector === ERROR_STRING_SELECTOR) {
|
|
278
|
+
const [message] = AbiCoder.defaultAbiCoder().decode(
|
|
279
|
+
["string"],
|
|
280
|
+
"0x" + data.slice(10)
|
|
281
|
+
);
|
|
282
|
+
name = `Error("${message}")`;
|
|
283
|
+
} else if (selector === PANIC_SELECTOR) {
|
|
284
|
+
const [code] = AbiCoder.defaultAbiCoder().decode(
|
|
285
|
+
["uint256"],
|
|
286
|
+
"0x" + data.slice(10)
|
|
287
|
+
);
|
|
288
|
+
name = `Panic(0x${code.toString(16)})`;
|
|
289
|
+
}
|
|
290
|
+
} catch {
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return { data, selector, name };
|
|
294
|
+
}
|
|
295
|
+
function isDeadZoneViolation(e) {
|
|
296
|
+
return decodeQuantumRevert(e).selector === DEAD_ZONE_VIOLATION_SELECTOR;
|
|
297
|
+
}
|
|
298
|
+
var RETRYABLE_QUANTUM_ERROR_NAMES = [
|
|
299
|
+
"DeadZoneViolation",
|
|
300
|
+
"QuantumOutsideWindow",
|
|
301
|
+
"QuantumAlreadyUsed",
|
|
302
|
+
"QuantumExpired"
|
|
303
|
+
];
|
|
304
|
+
function isRetryableQuantumFailure(message) {
|
|
305
|
+
if (!message)
|
|
306
|
+
return false;
|
|
307
|
+
if (message.includes("Transaction timeout") || message.includes("Transaction confirmation failed") || message.includes("Transaction receipt not found")) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
return RETRYABLE_QUANTUM_ERROR_NAMES.some((name) => message.includes(name)) || message.includes("Transaction reverted");
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/utils/contract-error-decoder.ts
|
|
314
|
+
var TABLE = null;
|
|
315
|
+
function contractErrorTable() {
|
|
316
|
+
if (TABLE)
|
|
317
|
+
return TABLE;
|
|
318
|
+
const table = /* @__PURE__ */ new Map();
|
|
319
|
+
const iface = new Interface(CONTRACT_ERROR_FRAGMENTS.map((e) => e.fragment));
|
|
320
|
+
const contractsByName = new Map(
|
|
321
|
+
CONTRACT_ERROR_FRAGMENTS.map((e) => [e.fragment.slice("error ".length, e.fragment.indexOf("(")), e.contracts])
|
|
322
|
+
);
|
|
323
|
+
iface.forEachError((fragment) => {
|
|
324
|
+
const existing = table.get(fragment.selector);
|
|
325
|
+
const contracts = contractsByName.get(fragment.name) ?? [];
|
|
326
|
+
if (existing) {
|
|
327
|
+
for (const c of contracts)
|
|
328
|
+
if (!existing.contracts.includes(c))
|
|
329
|
+
existing.contracts.push(c);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
table.set(fragment.selector, {
|
|
333
|
+
signature: fragment.format("sighash"),
|
|
334
|
+
fragment,
|
|
335
|
+
contracts: [...contracts]
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
TABLE = table;
|
|
339
|
+
return table;
|
|
340
|
+
}
|
|
341
|
+
function lookupContractError(selector) {
|
|
342
|
+
return contractErrorTable().get(selector.toLowerCase()) ?? null;
|
|
343
|
+
}
|
|
344
|
+
function extractErrorData(error) {
|
|
345
|
+
const viaQuantum = decodeQuantumRevert(error).data;
|
|
346
|
+
if (viaQuantum && viaQuantum.length >= 10)
|
|
347
|
+
return viaQuantum;
|
|
348
|
+
const candidates = [
|
|
349
|
+
error?.error?.error?.error?.data,
|
|
350
|
+
error?.error?.error?.data,
|
|
351
|
+
error?.data?.data,
|
|
352
|
+
error?.transaction?.data
|
|
353
|
+
];
|
|
354
|
+
for (const data of candidates) {
|
|
355
|
+
if (typeof data === "string" && data.startsWith("0x") && data.length >= 10)
|
|
356
|
+
return data;
|
|
357
|
+
}
|
|
358
|
+
const body = typeof error?.body === "string" ? error.body : null;
|
|
359
|
+
if (body) {
|
|
360
|
+
try {
|
|
361
|
+
const parsed = JSON.parse(body);
|
|
362
|
+
const data = parsed?.error?.data;
|
|
363
|
+
if (typeof data === "string" && data.startsWith("0x") && data.length >= 10)
|
|
364
|
+
return data;
|
|
365
|
+
} catch {
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
function extractRevertString(error) {
|
|
371
|
+
if (typeof error?.reason === "string" && error.reason.length > 0)
|
|
372
|
+
return error.reason;
|
|
373
|
+
const message = typeof error?.message === "string" ? error.message : null;
|
|
374
|
+
if (!message)
|
|
375
|
+
return null;
|
|
376
|
+
const withReasonString = message.match(/reverted with reason string ['"](.+?)['"]/);
|
|
377
|
+
if (withReasonString)
|
|
378
|
+
return withReasonString[1];
|
|
379
|
+
const withReason = message.match(/reason: ['"](.+?)['"]/);
|
|
380
|
+
return withReason ? withReason[1] : null;
|
|
381
|
+
}
|
|
382
|
+
function renderArgs(args) {
|
|
383
|
+
return args.map((arg) => typeof arg === "object" && arg !== null ? JSON.stringify(arg) : String(arg)).join(", ");
|
|
384
|
+
}
|
|
385
|
+
function decodeContractError(error) {
|
|
386
|
+
const errorData = extractErrorData(error);
|
|
387
|
+
if (!errorData) {
|
|
388
|
+
const revertString2 = extractRevertString(error);
|
|
389
|
+
if (revertString2 && !revertString2.includes("cannot estimate gas")) {
|
|
390
|
+
return {
|
|
391
|
+
name: "RevertString",
|
|
392
|
+
selector: "0x00000000",
|
|
393
|
+
args: [revertString2],
|
|
394
|
+
contract: "Unknown",
|
|
395
|
+
message: `Revert: ${revertString2}`
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
const selector = errorData.slice(0, 10).toLowerCase();
|
|
401
|
+
if (selector === ERROR_STRING_SELECTOR || selector === PANIC_SELECTOR) {
|
|
402
|
+
const { name } = decodeQuantumRevert(error);
|
|
403
|
+
if (name) {
|
|
404
|
+
return { name, selector, args: [], contract: "Solidity", message: name };
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const entry = lookupContractError(selector);
|
|
408
|
+
if (entry) {
|
|
409
|
+
const contract = entry.contracts.join(" | ");
|
|
410
|
+
let args = [];
|
|
411
|
+
try {
|
|
412
|
+
const decoded = new Interface([entry.fragment]).decodeErrorResult(entry.fragment, errorData);
|
|
413
|
+
args = Array.from(decoded);
|
|
414
|
+
} catch {
|
|
415
|
+
args = [];
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
name: entry.fragment.name,
|
|
419
|
+
selector,
|
|
420
|
+
args,
|
|
421
|
+
contract,
|
|
422
|
+
message: `${contract}.${entry.fragment.name}(${renderArgs(args)})`
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
const revertString = extractRevertString(error);
|
|
426
|
+
if (revertString && !revertString.includes("cannot estimate gas")) {
|
|
427
|
+
return {
|
|
428
|
+
name: "RevertString",
|
|
429
|
+
selector,
|
|
430
|
+
args: [revertString],
|
|
431
|
+
contract: "Unknown",
|
|
432
|
+
message: `Revert: ${revertString}`
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
name: "UnknownError",
|
|
437
|
+
selector,
|
|
438
|
+
args: [],
|
|
439
|
+
contract: "Unknown",
|
|
440
|
+
message: `Unknown error (selector: ${selector})`
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
function formatDecodedError(decoded) {
|
|
444
|
+
if (decoded.args && decoded.args.length > 0) {
|
|
445
|
+
return `${decoded.contract}.${decoded.name}(${renderArgs(decoded.args)})`;
|
|
446
|
+
}
|
|
447
|
+
return `${decoded.contract}.${decoded.name}()`;
|
|
448
|
+
}
|
|
449
|
+
export {
|
|
450
|
+
DEAD_ZONE_VIOLATION_SELECTOR,
|
|
451
|
+
ERROR_STRING_SELECTOR,
|
|
452
|
+
PANIC_SELECTOR,
|
|
453
|
+
QUANTUM_REVERT_NAMES,
|
|
454
|
+
contractErrorTable,
|
|
455
|
+
decodeContractError,
|
|
456
|
+
decodeQuantumRevert,
|
|
457
|
+
formatDecodedError,
|
|
458
|
+
isDeadZoneViolation,
|
|
459
|
+
isRetryableQuantumFailure,
|
|
460
|
+
lookupContractError
|
|
461
|
+
};
|