@gvnrdao/dh-sdk 0.0.299 → 0.0.301
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/browser.js +1 -1
- package/dist/deployments.js +14 -0
- package/dist/deployments.mjs +14 -0
- package/dist/index.js +442 -571
- package/dist/index.mjs +351 -480
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +15 -24
- package/dist/utils/quantum-revert.utils.d.ts +41 -0
- package/dist/utils/quantum-submission.utils.d.ts +93 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -416,6 +416,20 @@ var init_deployment_addresses = __esm({
|
|
|
416
416
|
upgradedAt: "2026-06-16T17:53:24.979Z",
|
|
417
417
|
upgradedBy: "0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f",
|
|
418
418
|
reason: "Initial PSM deploy / artifact sync"
|
|
419
|
+
},
|
|
420
|
+
CollateralManagerModule: {
|
|
421
|
+
previousImplementation: "0x1919860e528Cd2AbbD31a17858c986b8aCc8C185",
|
|
422
|
+
newImplementation: "0x55110B9dd6B2c9f812564e7a1ef42b3c76E1A3Bb",
|
|
423
|
+
upgradedAt: "2026-07-08T20:33:59Z",
|
|
424
|
+
upgradedBy: "AdminModule generic-op 0x740efe0cfe85044479cbd8ee3058aa244057d90703dd2b37044dd6787cbf3485 (3-of-5 ADMIN_ROLE Safes, 24h timelock; executed by 0xfb3B8cbeFB7D666A6Af34C53e189EdC31862a7be in tx 0x430c8e450f12d3d9359cde356ac5e2ef39661d7a89884b5674a596c1090f6cff)",
|
|
425
|
+
reason: "Validator gas fix (#420): BitcoinAddressValidator packed-table lookups; VERSION 1.3.0 -> 1.3.1"
|
|
426
|
+
},
|
|
427
|
+
BitcoinWithdrawalAddressRegistry: {
|
|
428
|
+
previousImplementation: "0x11731bFEC3068F2cc19D016381dfEA3B93013b1C",
|
|
429
|
+
newImplementation: "0x190c08300Ae650fb88ed8156445BBeb13bE9E8a3",
|
|
430
|
+
upgradedAt: "2026-07-08T20:33:59Z",
|
|
431
|
+
upgradedBy: "AdminModule generic-op 0x2603a486c0f34554b864cc1d909b325c7e105331da10ec0fd7e0b9373fa76207 (3-of-5 ADMIN_ROLE Safes, 24h timelock; executed by 0xfb3B8cbeFB7D666A6Af34C53e189EdC31862a7be in tx 0x430c8e450f12d3d9359cde356ac5e2ef39661d7a89884b5674a596c1090f6cff)",
|
|
432
|
+
reason: "Validator gas fix (#420): BitcoinAddressValidator packed-table lookups; VERSION 1.0.0 -> 1.0.1"
|
|
419
433
|
}
|
|
420
434
|
},
|
|
421
435
|
latestEnv: {
|
|
@@ -1190,17 +1204,17 @@ var require_pkg_src = __commonJS({
|
|
|
1190
1204
|
}
|
|
1191
1205
|
},
|
|
1192
1206
|
btcTransactionSigner: {
|
|
1193
|
-
cid: "
|
|
1207
|
+
cid: "QmcPG9C5Yx9JGrBKCfSVWbKuiRXn8XFwb91yNxQqY4VSJD",
|
|
1194
1208
|
authorizedCidHex: cidToHex(
|
|
1195
|
-
"
|
|
1209
|
+
"QmcPG9C5Yx9JGrBKCfSVWbKuiRXn8XFwb91yNxQqY4VSJD"
|
|
1196
1210
|
),
|
|
1197
1211
|
name: "Btc Transaction Signer",
|
|
1198
1212
|
description: "Production Btc Transaction Signer",
|
|
1199
|
-
version: "1.0.
|
|
1213
|
+
version: "1.0.1",
|
|
1200
1214
|
deployed: true,
|
|
1201
|
-
deployedAt:
|
|
1202
|
-
size:
|
|
1203
|
-
hash: "
|
|
1215
|
+
deployedAt: 1783451891948,
|
|
1216
|
+
size: 43688,
|
|
1217
|
+
hash: "1ea0f0ac66cc68fc9b098dabb3c5e3ba96c25f13b133b95a06eac477028fdb1a"
|
|
1204
1218
|
},
|
|
1205
1219
|
ucdMintValidator: {
|
|
1206
1220
|
cid: "QmPir8F8jmJ4ssQpEC3xFxkEnZxMHcgS6VxBQE1jkTLj5K",
|
|
@@ -2140,7 +2154,7 @@ ${errorReport}`);
|
|
|
2140
2154
|
}
|
|
2141
2155
|
init_debug_logger();
|
|
2142
2156
|
init_session_signature_cache();
|
|
2143
|
-
var
|
|
2157
|
+
var import_ethers16 = require("ethers");
|
|
2144
2158
|
var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
|
|
2145
2159
|
var GRACE_PERIOD_DAYS = 30;
|
|
2146
2160
|
var SATOSHIS_PER_BITCOIN = 100000000n;
|
|
@@ -4375,12 +4389,12 @@ ${auth.clientId}`;
|
|
|
4375
4389
|
}
|
|
4376
4390
|
async function executeVaultSnapshot(params) {
|
|
4377
4391
|
global.ethers = {
|
|
4378
|
-
...
|
|
4392
|
+
...import_ethers16.ethers,
|
|
4379
4393
|
providers: {
|
|
4380
|
-
StaticJsonRpcProvider:
|
|
4394
|
+
StaticJsonRpcProvider: import_ethers16.ethers.JsonRpcProvider
|
|
4381
4395
|
},
|
|
4382
|
-
Contract:
|
|
4383
|
-
utils:
|
|
4396
|
+
Contract: import_ethers16.ethers.Contract,
|
|
4397
|
+
utils: import_ethers16.ethers
|
|
4384
4398
|
// v6 moved utils to top level
|
|
4385
4399
|
};
|
|
4386
4400
|
global.Lit = {
|
|
@@ -4913,7 +4927,7 @@ __export(src_exports, {
|
|
|
4913
4927
|
module.exports = __toCommonJS(src_exports);
|
|
4914
4928
|
|
|
4915
4929
|
// src/modules/diamond-hands-sdk.ts
|
|
4916
|
-
var
|
|
4930
|
+
var import_ethers14 = require("ethers");
|
|
4917
4931
|
|
|
4918
4932
|
// src/types/result.ts
|
|
4919
4933
|
function success(value) {
|
|
@@ -5297,22 +5311,12 @@ var SDKError = class _SDKError extends Error {
|
|
|
5297
5311
|
|
|
5298
5312
|
// src/utils/chunks/eip1559-broadcast.utils.ts
|
|
5299
5313
|
var import_ethers = require("ethers");
|
|
5300
|
-
var MINT_UCD_GAS_CEILING = BigInt(
|
|
5314
|
+
var MINT_UCD_GAS_CEILING = BigInt(13e5);
|
|
5301
5315
|
var WITHDRAW_BTC_GAS_CEILING = BigInt(3e6);
|
|
5302
5316
|
var MAKE_PAYMENT_GAS_CEILING = BigInt(1e6);
|
|
5303
5317
|
var EXTEND_POSITION_GAS_CEILING = BigInt(1e6);
|
|
5304
5318
|
var LIQUIDATION_COMMIT_GAS_CEILING = BigInt(1e6);
|
|
5305
5319
|
var LIQUIDATION_REVEAL_GAS_CEILING = BigInt(2e6);
|
|
5306
|
-
var MINT_UCD_ESTIMATE_MARGIN_BPS = 2500;
|
|
5307
|
-
async function estimateContractCallGasWithMargin(provider, from, to, data, marginBps, ceiling) {
|
|
5308
|
-
try {
|
|
5309
|
-
const estimated = await provider.estimateGas({ from, to, data });
|
|
5310
|
-
const withMargin = estimated * BigInt(1e4 + marginBps) / 10000n;
|
|
5311
|
-
return withMargin > ceiling ? ceiling : withMargin;
|
|
5312
|
-
} catch {
|
|
5313
|
-
return null;
|
|
5314
|
-
}
|
|
5315
|
-
}
|
|
5316
5320
|
async function resolveEip1559FeeFields(provider) {
|
|
5317
5321
|
const feeData = await provider.getFeeData();
|
|
5318
5322
|
let maxFeePerGas = feeData.maxFeePerGas ?? void 0;
|
|
@@ -5915,8 +5919,124 @@ var ServerSession = class {
|
|
|
5915
5919
|
}
|
|
5916
5920
|
};
|
|
5917
5921
|
|
|
5918
|
-
// src/utils/
|
|
5922
|
+
// src/utils/quantum-revert.utils.ts
|
|
5919
5923
|
var import_ethers5 = require("ethers");
|
|
5924
|
+
var DEAD_ZONE_VIOLATION_SELECTOR = "0xbe4b82c1";
|
|
5925
|
+
var ERROR_STRING_SELECTOR = "0x08c379a0";
|
|
5926
|
+
var PANIC_SELECTOR = "0x4e487b71";
|
|
5927
|
+
var QUANTUM_REVERT_NAMES = {
|
|
5928
|
+
"0xbe4b82c1": "DeadZoneViolation()",
|
|
5929
|
+
"0x137f3b70": "InDeadZone()",
|
|
5930
|
+
"0x131d9a21": "QuantumExpired()",
|
|
5931
|
+
"0x52ce5d58": "QuantumAlreadyUsed()",
|
|
5932
|
+
"0x3e76a3c9": "QuantumOutsideWindow()",
|
|
5933
|
+
"0x8baa579f": "InvalidSignature()",
|
|
5934
|
+
"0x62278171": "InvalidValidatorSignature()",
|
|
5935
|
+
"0x3ee5aeb5": "OperationNotAuthorized()",
|
|
5936
|
+
"0x48f5c3ed": "Unauthorized()",
|
|
5937
|
+
"0x70f4b32a": "UnauthorizedSigner()",
|
|
5938
|
+
"0xd92e233d": "ValidationFailed()",
|
|
5939
|
+
"0x36bfdeea": "StateHashMismatch()",
|
|
5940
|
+
"0xb9d419a7": "DebtUpdateVerificationFailed()",
|
|
5941
|
+
"0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
|
|
5942
|
+
"0x0cfd2a97": "MintVerificationMismatch(uint256,uint256)",
|
|
5943
|
+
"0x07637bd8": "MintFailed()"
|
|
5944
|
+
};
|
|
5945
|
+
function decodeQuantumRevert(e) {
|
|
5946
|
+
const raw = e?.data ?? e?.info?.error?.data ?? // ethers v6 BrowserProvider (MetaMask)
|
|
5947
|
+
e?.error?.data?.data ?? e?.error?.data ?? e?.error?.error?.data;
|
|
5948
|
+
const data = typeof raw === "string" && raw.startsWith("0x") ? raw : null;
|
|
5949
|
+
const selector = data && data.length >= 10 ? data.slice(0, 10) : null;
|
|
5950
|
+
let name = selector ? QUANTUM_REVERT_NAMES[selector] ?? null : null;
|
|
5951
|
+
if (!name && selector && data) {
|
|
5952
|
+
try {
|
|
5953
|
+
if (selector === ERROR_STRING_SELECTOR) {
|
|
5954
|
+
const [message] = import_ethers5.AbiCoder.defaultAbiCoder().decode(
|
|
5955
|
+
["string"],
|
|
5956
|
+
"0x" + data.slice(10)
|
|
5957
|
+
);
|
|
5958
|
+
name = `Error("${message}")`;
|
|
5959
|
+
} else if (selector === PANIC_SELECTOR) {
|
|
5960
|
+
const [code] = import_ethers5.AbiCoder.defaultAbiCoder().decode(
|
|
5961
|
+
["uint256"],
|
|
5962
|
+
"0x" + data.slice(10)
|
|
5963
|
+
);
|
|
5964
|
+
name = `Panic(0x${code.toString(16)})`;
|
|
5965
|
+
}
|
|
5966
|
+
} catch {
|
|
5967
|
+
}
|
|
5968
|
+
}
|
|
5969
|
+
return { data, selector, name };
|
|
5970
|
+
}
|
|
5971
|
+
|
|
5972
|
+
// src/utils/quantum-submission.utils.ts
|
|
5973
|
+
var MAX_DEADZONE_RESIMULATIONS = 3;
|
|
5974
|
+
var QuantumRevertError = class extends Error {
|
|
5975
|
+
constructor(errorName, selector, data, cause) {
|
|
5976
|
+
super(
|
|
5977
|
+
`Pre-send simulation reverted: ${errorName ?? selector ?? "unknown"}`
|
|
5978
|
+
);
|
|
5979
|
+
this.errorName = errorName;
|
|
5980
|
+
this.selector = selector;
|
|
5981
|
+
this.data = data;
|
|
5982
|
+
this.cause = cause;
|
|
5983
|
+
this.name = "QuantumRevertError";
|
|
5984
|
+
}
|
|
5985
|
+
};
|
|
5986
|
+
async function assertSafeQuantumSubmission(opts) {
|
|
5987
|
+
const { provider, to, from, data, quantumTimestamp } = opts;
|
|
5988
|
+
const maxResimulations = opts.maxResimulations ?? MAX_DEADZONE_RESIMULATIONS;
|
|
5989
|
+
const now = opts.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
5990
|
+
const onDebug = opts.onDebug ?? (() => {
|
|
5991
|
+
});
|
|
5992
|
+
const gateOpts = {
|
|
5993
|
+
now,
|
|
5994
|
+
...opts.sleep ? { sleep: opts.sleep } : {}
|
|
5995
|
+
};
|
|
5996
|
+
await awaitSafeSubmissionWindow(quantumTimestamp, gateOpts);
|
|
5997
|
+
for (let sim = 1; ; sim++) {
|
|
5998
|
+
try {
|
|
5999
|
+
await provider.call({ to, from, data });
|
|
6000
|
+
break;
|
|
6001
|
+
} catch (simError) {
|
|
6002
|
+
const decoded = decodeQuantumRevert(simError);
|
|
6003
|
+
if (decoded.selector === DEAD_ZONE_VIOLATION_SELECTOR && sim <= maxResimulations) {
|
|
6004
|
+
const sigQuantum = Math.floor(quantumTimestamp / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
6005
|
+
const realCurrentQuantum = Math.floor(now() / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
6006
|
+
if (sigQuantum === realCurrentQuantum) {
|
|
6007
|
+
onDebug(
|
|
6008
|
+
"\u21AA\uFE0F Simulated DeadZoneViolation is a stale-latest-block artifact (signature is the current quantum) \u2014 proceeding to broadcast"
|
|
6009
|
+
);
|
|
6010
|
+
break;
|
|
6011
|
+
}
|
|
6012
|
+
const gate = await awaitSafeSubmissionWindow(quantumTimestamp, gateOpts);
|
|
6013
|
+
if (gate.waited) {
|
|
6014
|
+
onDebug(
|
|
6015
|
+
`\u{1F501} Re-simulating after crossing the quantum boundary (attempt ${sim}/${maxResimulations})`
|
|
6016
|
+
);
|
|
6017
|
+
continue;
|
|
6018
|
+
}
|
|
6019
|
+
}
|
|
6020
|
+
if (!decoded.data) {
|
|
6021
|
+
const label = simError instanceof Error ? simError.message : String(simError);
|
|
6022
|
+
onDebug(
|
|
6023
|
+
`\u26A0\uFE0F Pre-send simulation failed without revert data (${label}) \u2014 proceeding to broadcast`
|
|
6024
|
+
);
|
|
6025
|
+
break;
|
|
6026
|
+
}
|
|
6027
|
+
throw new QuantumRevertError(
|
|
6028
|
+
decoded.name,
|
|
6029
|
+
decoded.selector,
|
|
6030
|
+
decoded.data,
|
|
6031
|
+
simError
|
|
6032
|
+
);
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
6035
|
+
await awaitSafeSubmissionWindow(quantumTimestamp, gateOpts);
|
|
6036
|
+
}
|
|
6037
|
+
|
|
6038
|
+
// src/utils/btc-withdrawal-message.ts
|
|
6039
|
+
var import_ethers6 = require("ethers");
|
|
5920
6040
|
var QUANTUM_SECONDS = 60;
|
|
5921
6041
|
var QUANTUM_SAFE_THRESHOLD = 40;
|
|
5922
6042
|
async function buildBtcExecuteEnvelope(params) {
|
|
@@ -5951,15 +6071,15 @@ async function buildBtcExecuteEnvelope(params) {
|
|
|
5951
6071
|
} else {
|
|
5952
6072
|
timestamp = currentQuantumStart;
|
|
5953
6073
|
}
|
|
5954
|
-
const actionHash = (0,
|
|
5955
|
-
(0,
|
|
6074
|
+
const actionHash = (0, import_ethers6.keccak256)(
|
|
6075
|
+
(0, import_ethers6.toUtf8Bytes)("execute-btc-withdrawal")
|
|
5956
6076
|
);
|
|
5957
6077
|
const utxoIdentifier = `${txid}:${vout}`;
|
|
5958
|
-
const positionIdBytes32 = (0,
|
|
6078
|
+
const positionIdBytes32 = (0, import_ethers6.zeroPadValue)(
|
|
5959
6079
|
positionId.startsWith("0x") ? positionId : `0x${positionId}`,
|
|
5960
6080
|
32
|
|
5961
6081
|
);
|
|
5962
|
-
const messageHash = (0,
|
|
6082
|
+
const messageHash = (0, import_ethers6.solidityPackedKeccak256)(
|
|
5963
6083
|
[
|
|
5964
6084
|
"bytes32",
|
|
5965
6085
|
// positionId
|
|
@@ -5989,7 +6109,7 @@ async function buildBtcExecuteEnvelope(params) {
|
|
|
5989
6109
|
actionHash
|
|
5990
6110
|
]
|
|
5991
6111
|
);
|
|
5992
|
-
const userSignature = await signer.signMessage((0,
|
|
6112
|
+
const userSignature = await signer.signMessage((0, import_ethers6.getBytes)(messageHash));
|
|
5993
6113
|
const borrowerAddress = await signer.getAddress();
|
|
5994
6114
|
return {
|
|
5995
6115
|
positionId,
|
|
@@ -6052,7 +6172,7 @@ function maybeTemperSignature(signature, shouldTemper, operationName) {
|
|
|
6052
6172
|
}
|
|
6053
6173
|
|
|
6054
6174
|
// src/utils/address-conversion.utils.ts
|
|
6055
|
-
var
|
|
6175
|
+
var import_ethers7 = require("ethers");
|
|
6056
6176
|
|
|
6057
6177
|
// src/utils/chunks/bitcoin-utils.ts
|
|
6058
6178
|
var import_sha256 = require("@noble/hashes/sha256");
|
|
@@ -6336,7 +6456,7 @@ function normalizeBitcoinAddress(address) {
|
|
|
6336
6456
|
}
|
|
6337
6457
|
|
|
6338
6458
|
// src/protocol/protocol-pause.ts
|
|
6339
|
-
var
|
|
6459
|
+
var import_ethers8 = require("ethers");
|
|
6340
6460
|
var GET_PROTOCOL_PAUSE_STATUS_ABI = [
|
|
6341
6461
|
"function getProtocolPauseStatus() view returns (tuple(bool positionManagerPaused, bool positionManagerLiquidationsPaused, bool positionManagerCorePaused, bool loanOperationsPaused, bool collateralManagerPaused, bool liquidationManagerPaused, bool circuitBreakerPaused, bool ucdControllerPaused, bool ucdTokenPaused, bool simplePsmPaused))"
|
|
6342
6462
|
];
|
|
@@ -6358,7 +6478,7 @@ function rowToStatus(row) {
|
|
|
6358
6478
|
return row;
|
|
6359
6479
|
}
|
|
6360
6480
|
async function fetchProtocolPauseStatus(provider, positionManagerAddress) {
|
|
6361
|
-
const iface = new
|
|
6481
|
+
const iface = new import_ethers8.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
|
|
6362
6482
|
const data = iface.encodeFunctionData("getProtocolPauseStatus", []);
|
|
6363
6483
|
const raw = await provider.call({ to: positionManagerAddress, data });
|
|
6364
6484
|
const decoded = iface.decodeFunctionResult("getProtocolPauseStatus", raw);
|
|
@@ -6491,7 +6611,7 @@ function extractOptionalLitSignature(raw) {
|
|
|
6491
6611
|
}
|
|
6492
6612
|
|
|
6493
6613
|
// src/modules/contract/contract-manager.module.ts
|
|
6494
|
-
var
|
|
6614
|
+
var import_ethers9 = require("ethers");
|
|
6495
6615
|
init_deployment_addresses();
|
|
6496
6616
|
var POSITION_MANAGER_ABI = [
|
|
6497
6617
|
"function createPosition(bytes32 pkpId, bytes calldata validatorSignature, string mainnetVaultAddress, string regtestVaultAddress, uint256 selectedTermMonths, uint256 validatorVersion, bytes calldata pkpPublicKey) external returns (bytes32 positionId)",
|
|
@@ -6568,43 +6688,43 @@ var ContractManager = class {
|
|
|
6568
6688
|
}
|
|
6569
6689
|
const contractRunner = runner;
|
|
6570
6690
|
const contracts = {
|
|
6571
|
-
positionManager: new
|
|
6691
|
+
positionManager: new import_ethers9.Contract(
|
|
6572
6692
|
contractAddresses.positionManager,
|
|
6573
6693
|
POSITION_MANAGER_ABI,
|
|
6574
6694
|
contractRunner
|
|
6575
6695
|
),
|
|
6576
|
-
loanOperationsManager: new
|
|
6577
|
-
contractAddresses.loanOperationsManager ||
|
|
6696
|
+
loanOperationsManager: new import_ethers9.Contract(
|
|
6697
|
+
contractAddresses.loanOperationsManager || import_ethers9.ZeroAddress,
|
|
6578
6698
|
LOAN_OPS_ABI,
|
|
6579
6699
|
contractRunner
|
|
6580
6700
|
),
|
|
6581
|
-
ucdController: new
|
|
6701
|
+
ucdController: new import_ethers9.Contract(
|
|
6582
6702
|
contractAddresses.ucdToken,
|
|
6583
6703
|
UCD_CONTROLLER_ABI,
|
|
6584
6704
|
contractRunner
|
|
6585
6705
|
),
|
|
6586
|
-
priceFeed: new
|
|
6587
|
-
contractAddresses.priceFeedConsumer ||
|
|
6706
|
+
priceFeed: new import_ethers9.Contract(
|
|
6707
|
+
contractAddresses.priceFeedConsumer || import_ethers9.ZeroAddress,
|
|
6588
6708
|
PRICE_FEED_ABI,
|
|
6589
6709
|
contractRunner
|
|
6590
6710
|
),
|
|
6591
|
-
termManager: new
|
|
6592
|
-
contractAddresses.termManager ||
|
|
6711
|
+
termManager: new import_ethers9.Contract(
|
|
6712
|
+
contractAddresses.termManager || import_ethers9.ZeroAddress,
|
|
6593
6713
|
TERM_MANAGER_ABI,
|
|
6594
6714
|
contractRunner
|
|
6595
6715
|
),
|
|
6596
|
-
circuitBreaker: new
|
|
6597
|
-
contractAddresses.circuitBreaker ||
|
|
6716
|
+
circuitBreaker: new import_ethers9.Contract(
|
|
6717
|
+
contractAddresses.circuitBreaker || import_ethers9.ZeroAddress,
|
|
6598
6718
|
CIRCUIT_BREAKER_ABI,
|
|
6599
6719
|
contractRunner
|
|
6600
6720
|
),
|
|
6601
|
-
liquidationManager: new
|
|
6602
|
-
contractAddresses.liquidationManager ||
|
|
6721
|
+
liquidationManager: new import_ethers9.Contract(
|
|
6722
|
+
contractAddresses.liquidationManager || import_ethers9.ZeroAddress,
|
|
6603
6723
|
LIQUIDATION_MANAGER_ABI,
|
|
6604
6724
|
contractRunner
|
|
6605
6725
|
),
|
|
6606
|
-
bitcoinWithdrawalAddressRegistry: new
|
|
6607
|
-
contractAddresses.bitcoinWithdrawalAddressRegistry ||
|
|
6726
|
+
bitcoinWithdrawalAddressRegistry: new import_ethers9.Contract(
|
|
6727
|
+
contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers9.ZeroAddress,
|
|
6608
6728
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_ABI,
|
|
6609
6729
|
contractRunner
|
|
6610
6730
|
)
|
|
@@ -6654,13 +6774,13 @@ var ContractManager = class {
|
|
|
6654
6774
|
const address = addresses[key];
|
|
6655
6775
|
if (!address) {
|
|
6656
6776
|
missing.push(String(key));
|
|
6657
|
-
} else if (!(0,
|
|
6777
|
+
} else if (!(0, import_ethers9.isAddress)(address)) {
|
|
6658
6778
|
invalid.push(String(key));
|
|
6659
6779
|
}
|
|
6660
6780
|
}
|
|
6661
6781
|
for (const key of optionalAddresses) {
|
|
6662
6782
|
const address = addresses[key];
|
|
6663
|
-
if (address && !(0,
|
|
6783
|
+
if (address && !(0, import_ethers9.isAddress)(address)) {
|
|
6664
6784
|
invalid.push(String(key));
|
|
6665
6785
|
}
|
|
6666
6786
|
}
|
|
@@ -7636,7 +7756,7 @@ function createPKPManager(config) {
|
|
|
7636
7756
|
}
|
|
7637
7757
|
|
|
7638
7758
|
// src/modules/loan/loan-creator.module.ts
|
|
7639
|
-
var
|
|
7759
|
+
var import_ethers10 = require("ethers");
|
|
7640
7760
|
var import_dh_lit_actions = __toESM(require_pkg_src());
|
|
7641
7761
|
var LoanCreator = class {
|
|
7642
7762
|
config;
|
|
@@ -7966,11 +8086,11 @@ var LoanCreator = class {
|
|
|
7966
8086
|
try {
|
|
7967
8087
|
const mainnetVaultAddress = bitcoinAddresses.mainnet;
|
|
7968
8088
|
const regtestVaultAddress = bitcoinAddresses.regtest;
|
|
7969
|
-
const pkpIdBytes32 = (0,
|
|
7970
|
-
(0,
|
|
8089
|
+
const pkpIdBytes32 = (0, import_ethers10.zeroPadValue)(
|
|
8090
|
+
(0, import_ethers10.toBeHex)(BigInt(pkpData.tokenId)),
|
|
7971
8091
|
32
|
|
7972
8092
|
);
|
|
7973
|
-
const pkpPublicKeyUncompressed =
|
|
8093
|
+
const pkpPublicKeyUncompressed = import_ethers10.SigningKey.computePublicKey(
|
|
7974
8094
|
pkpData.publicKey,
|
|
7975
8095
|
false
|
|
7976
8096
|
);
|
|
@@ -7983,7 +8103,7 @@ var LoanCreator = class {
|
|
|
7983
8103
|
);
|
|
7984
8104
|
log.debug(`BigInt conversion: ${BigInt(pkpData.tokenId).toString()}`);
|
|
7985
8105
|
log.debug(
|
|
7986
|
-
`Hex from BigInt: ${(0,
|
|
8106
|
+
`Hex from BigInt: ${(0, import_ethers10.toBeHex)(BigInt(pkpData.tokenId))}`
|
|
7987
8107
|
);
|
|
7988
8108
|
log.debug(`Final bytes32 (zero-padded): ${pkpIdBytes32}`);
|
|
7989
8109
|
log.debug(
|
|
@@ -8147,8 +8267,8 @@ var LoanCreator = class {
|
|
|
8147
8267
|
}
|
|
8148
8268
|
}
|
|
8149
8269
|
if (this.config.debug) {
|
|
8150
|
-
const pkpIdBytes32Check = (0,
|
|
8151
|
-
(0,
|
|
8270
|
+
const pkpIdBytes32Check = (0, import_ethers10.zeroPadValue)(
|
|
8271
|
+
(0, import_ethers10.toBeHex)(BigInt(pkpData.tokenId)),
|
|
8152
8272
|
32
|
|
8153
8273
|
);
|
|
8154
8274
|
log.error("\u274C Loan creation transaction failed", {
|
|
@@ -8194,8 +8314,8 @@ var LoanCreator = class {
|
|
|
8194
8314
|
const newEventAbi = [
|
|
8195
8315
|
"event PositionCreated(bytes32 indexed positionId, bytes32 indexed pkpId, address indexed borrower, uint256 requestedCollateralRatio, uint256 selectedTerm, uint256 expiryAt)"
|
|
8196
8316
|
];
|
|
8197
|
-
const oldIface = new
|
|
8198
|
-
const newIface = new
|
|
8317
|
+
const oldIface = new import_ethers10.Interface(oldEventAbi);
|
|
8318
|
+
const newIface = new import_ethers10.Interface(newEventAbi);
|
|
8199
8319
|
let positionId;
|
|
8200
8320
|
if (this.config.debug) {
|
|
8201
8321
|
log.info("\u{1F50D} Parsing transaction receipt logs", {
|
|
@@ -8289,7 +8409,7 @@ var LoanStatus = /* @__PURE__ */ ((LoanStatus2) => {
|
|
|
8289
8409
|
})(LoanStatus || {});
|
|
8290
8410
|
|
|
8291
8411
|
// src/modules/loan/loan-query.module.ts
|
|
8292
|
-
var
|
|
8412
|
+
var import_ethers11 = require("ethers");
|
|
8293
8413
|
var POSITION_CORE_ABI = [
|
|
8294
8414
|
"function getPositionDetails(bytes32) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status, uint40 previousExpiryAt, uint16 totalTerm))"
|
|
8295
8415
|
];
|
|
@@ -8587,7 +8707,7 @@ var LoanQuery = class {
|
|
|
8587
8707
|
const isChipotlePkpId2 = typeof rawId === "string" && rawId.length === 40 && !rawId.toLowerCase().startsWith("04");
|
|
8588
8708
|
if (isChipotlePkpId2) {
|
|
8589
8709
|
if (this.config.positionManagerCoreAddress && this.config.provider) {
|
|
8590
|
-
const pmContract = new
|
|
8710
|
+
const pmContract = new import_ethers11.Contract(
|
|
8591
8711
|
this.config.positionManagerCoreAddress,
|
|
8592
8712
|
POSITION_CORE_ABI,
|
|
8593
8713
|
this.config.provider
|
|
@@ -8860,7 +8980,7 @@ function createLoanQuery(config) {
|
|
|
8860
8980
|
}
|
|
8861
8981
|
|
|
8862
8982
|
// src/modules/withdrawal-address/withdrawal-address.module.ts
|
|
8863
|
-
var
|
|
8983
|
+
var import_ethers12 = require("ethers");
|
|
8864
8984
|
var WithdrawalAddressModule = class {
|
|
8865
8985
|
config;
|
|
8866
8986
|
graphClient;
|
|
@@ -8877,7 +8997,7 @@ var WithdrawalAddressModule = class {
|
|
|
8877
8997
|
if (!res.success)
|
|
8878
8998
|
return res;
|
|
8879
8999
|
const target = res.value.target;
|
|
8880
|
-
if (!target || target ===
|
|
9000
|
+
if (!target || target === import_ethers12.ZeroAddress) {
|
|
8881
9001
|
return failure(
|
|
8882
9002
|
new SDKError({
|
|
8883
9003
|
code: "SDK_WITHDRAWAL_REGISTRY_NOT_CONFIGURED",
|
|
@@ -8895,7 +9015,7 @@ var WithdrawalAddressModule = class {
|
|
|
8895
9015
|
}
|
|
8896
9016
|
/** keccak256 of the canonicalized address — matches the on-chain key. */
|
|
8897
9017
|
static addressHash(btcAddress) {
|
|
8898
|
-
return (0,
|
|
9018
|
+
return (0, import_ethers12.keccak256)((0, import_ethers12.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress)));
|
|
8899
9019
|
}
|
|
8900
9020
|
/**
|
|
8901
9021
|
* Add a Bitcoin address to the caller's allowlist. It becomes usable only
|
|
@@ -11908,7 +12028,7 @@ var DiamondHandsGraph = class {
|
|
|
11908
12028
|
};
|
|
11909
12029
|
|
|
11910
12030
|
// src/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.ts
|
|
11911
|
-
var
|
|
12031
|
+
var import_ethers13 = require("ethers");
|
|
11912
12032
|
var _abi = [
|
|
11913
12033
|
{
|
|
11914
12034
|
inputs: [],
|
|
@@ -14476,7 +14596,7 @@ var _abi = [
|
|
|
14476
14596
|
];
|
|
14477
14597
|
var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161485a90816100f0823960805181818161278e01526128870152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c8062f7fce91461384657806301ffc9a7146137d5578063021d28931461377c5780630871b20614613743578063114249d214610f6157806311d954f81461371a57806313da3166146136e15780631d44a904146136385780631f77bf65146135ff578063248a9ca3146135e05780632b83cccd146131205780632f2ff15d146130ee57806334bac370146130b557806334e181251461307c57806336568abe14613037578063373c86b614612ffe5780633f4ba83a14612f375780634373b57214612f0e5780634451e89b14612b3a5780634ebd25a514612b015780634f1ef2861461280c5780635273b6f6146127e357806352d1902d1461277b578063568fafca146126ed57806359d5d02a146124205780635bc26aea146123eb5780635c975abb146123bb5780635ecc27081461229d5780638456cb59146121a257806385c15d9a1461216957806389d3ad00146120a25780638bff608e146120695780639010d07c1461201657806390ad8b4014611ffa57806391d1485414611fa15780639b759bf714611f5e5780639baf58d214611f415780639f1d0f59146118a8578063a217fddf1461188c578063a3246ad3146117cf578063ad3cb1cc14611788578063b492fc691461168e578063b9f637af14611463578063bf7d911914611424578063c4c5f62414611371578063c55f15ea1461134e578063ca15c87314611317578063ca2ce65d146112de578063cc1f8ffa146112ac578063cf46075e146111a2578063d21a74ff14611165578063d2f8253614611142578063d547741f14611107578063d5d3f78b14610f9a578063d66bd52414610f61578063e1f1c4a714610f44578063e1f3962c14610f18578063ec2f96fe14610ef4578063eda5a26a14610af7578063f1a1eb8414610ab4578063f385116d14610a7b578063f77c479114610a54578063f8c8765e14610661578063faaebd2114610628578063facdfb5e14610488578063fc99bd9a14610377578063fe32e7281461033e5763ffa1ad741461030857600080fd5b3461033b578060031936011261033b57610337610323613a68565b604051918291602083526020830190613a17565b0390f35b80fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361036661392e565b168152601283522054604051908152f35b503461033b57604036600319011261033b5761039161392e565b6010546024359291906001600160a01b03163303610479576001600160a01b03168082526002602052604082205490929060ff16156104665780156104575782825260076020526040822054926103e88285613cb0565b848110610448576001600160ff1b0381116104395760008051602061482e833981519152604085968493846104369852600760205280838a205582519182526020820152a23090339061421c565b80f35b630700fcb360e11b8452600484fd5b63446c8cc960e01b8452600484fd5b63162908e360e11b8252600482fd5b506024916374ed46ad60e01b8252600452fd5b6349db3bd360e01b8252600482fd5b503461033b57602036600319011261033b576104a261392e565b6104aa613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b5784916105d4575b50818111156105c5576105248282613b6c565b8215908115610570575b505060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b61271081029080820461271014901517156105b157606484029184830460641417156105b157116105a257388061052e565b63a73af74d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b6105cf8183613b6c565b610524565b90506020813d602011610603575b816105ef602093836139c3565b810103126105fe575138610511565b600080fd5b3d91506105e2565b6040513d86823e3d90fd5b6374ed46ad60e01b8252600452602490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361065061392e565b168152600483522054604051908152f35b503461033b57608036600319011261033b5761067b61392e565b610683613944565b6044356001600160a01b03811690818103610a50576064356001600160a01b0381169390849003610a4c5760008051602061480e83398151915254604081901c60ff161595906001600160401b031680159081610a44575b6001149081610a3a575b159081610a31575b50610a225760008051602061480e83398151915280546001600160401b0319166001179055856109fd575b6001600160a01b03169081156109ee576001600160a01b03169081156109df5783156109d05761074661448a565b61074e61448a565b61075661448a565b61075e61448a565b60016000805160206147ce8339815191525561077861448a565b61078061448a565b86546001600160a01b0319908116919091178755600180549182168317905560405163313ce56760e01b8152909190602081600481855afa88918161099f575b506107d457633a24e95b60e11b8852600488fd5b6001600160a81b03199092161760a091821b60ff60a01b16176001819055901c60ff16601119810161098d575061080b8186614348565b80610965575b156109205761082e816000805160206147ee833981519152614348565b8061092f575b15610920576108519060008051602061470e833981519152614348565b90816108e9575b50156108da57806108af575b5061086c5780f35b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160018152a180f35b601080546001600160a01b031916821790558260008051602061474e8339815191528180a338610864565b63cf5a8e3360e01b8352600483fd5b6109199060008051602061470e83398151915286526000805160206146ae833981519152602052604086206144d0565b5038610858565b63cf5a8e3360e01b8552600485fd5b6000805160206147ee83398151915286526000805160206146ae83398151915260205261095f83604088206144d0565b50610834565b8580526000805160206146ae83398151915260205261098783604088206144d0565b50610811565b63167738cf60e21b8652600452602485fd5b6109c291925060203d6020116109c9575b6109ba81836139c3565b810190613ba9565b90386107c0565b503d6109b0565b630b5eba9f60e41b8752600487fd5b63c1ab6dc160e01b8752600487fd5b6336abb4df60e11b8752600487fd5b60008051602061480e833981519152805460ff60401b1916600160401b179055610718565b63f92ee8a960e01b8752600487fd5b905015386106ed565b303b1591506106e5565b8791506106db565b8580fd5b8480fd5b503461033b578060031936011261033b57546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b03610aa361392e565b168152600a83522054604051908152f35b503461033b57604036600319011261033b576020906040906001600160a01b03610adc61392e565b16815260158352818120602435825283522054604051908152f35b503461033b5761016036600319011261033b57610b1261392e565b90606435604435602435610b24613a58565b9160a4359160c43560e43561010435916101243595610144359760018060a01b03601054163303610ee5576001600160a01b038c16808c52600260205260408c2054909a9060ff16610ed1578a15610ec2578615610eb3576127108811610e99576103e88111610e815760ff82169c60128e118e8115610e76575b50610e6257803b15610e4e578915610e3a578a15610e265782610bc191614260565b84151580610e1d575b610e065785151580610dfd575b610de6578b9c602460208d9e9d604051928380926370a0823160e01b82523060048301525afa9c8d15610dda579c610da6575b506001600160ff1b038c11610d97578a8d8f9760408f97838f918f8f8f8f90859f988f99879f9660008051602061476e8339815191529f978b9f988f8d6000805160206146ce8339815191529f988e8e610d4f9b60008051602061468e8339815191529f8f8f8487526002602052878720600160ff198254161790558487526003602052878720558386526004602052868620558285526006602052878686205582855260056020528585209060ff19825416179055818452600c6020528885852055818452600d6020528985852055818452600e6020528a85852055818452600f6020528b8585205581845260076020528484205582526012602052828220558d8152601360205220558a7f991d1ef1b5c0820d213328cba6682059e00a50e49c469a454eb3557e78eaf6668e80518b81528c6020820152a28c5198899889613cbd565b0390a28151908b82526020820152a28151908782526020820152a280610d73578280f35b604060008051602061482e833981519152918151908582526020820152a281808280f35b63556e7a8160e01b8e5260048efd5b909b506020813d602011610dd2575b81610dc2602093836139c3565b810103126105fe57519a38610c0a565b3d9150610db5565b604051903d90823e3d90fd5b60448c858863dd85772b60e01b8352600452602452fd5b50838610610bd7565b60448c8487637449915760e01b8352600452602452fd5b50828510610bca565b636835314760e11b8d52600160045260248dfd5b636835314760e11b8d5260048d905260248dfd5b63377e3f9960e21b8d5260048c905260248dfd5b63ca95039160e01b8d5260048e905260248dfd5b60069150108e610b9f565b631051834f60e11b8c526004526103e860245260448bfd5b63c1e9a14160e01b8c52600488905261271060245260448cfd5b63a2ec3a5560e01b8c5260048cfd5b63df407ac560e01b8c5260048cfd5b6317f4215b60e21b8c5260048b905260248cfd5b6349db3bd360e01b8b5260048bfd5b503461033b578060031936011261033b57602060ff60015460a01c16604051908152f35b503461033b57602036600319011261033b576020610f3c610f3761392e565b613df5565b604051908152f35b503461033b578060031936011261033b5760206040516127108152f35b503461033b57602036600319011261033b576020906040906001600160a01b03610f8961392e565b168152600783522054604051908152f35b503461033b57602036600319011261033b57610fb461392e565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff16156106165780825260076020526040822054806110f1575080825260026020526040822060ff1981541690558082526003602052816040812055808252600460205281604081205580825260056020526040822060ff198154169055808252600c602052816040812055808252600d602052816040812055808252600e602052816040812055808252600f602052816040812055808252600660205281604081205580825260076020526040822054818352600760205282604081205560405190827f3302a1b37f04242bb55603f5449e7ecd690a35eef08ba1353c48c20e2aae9cda8580a2806110ce578380f35b8160409160008051602061482e8339815191529352846020820152a23880808380f35b604492916376bc059760e11b8352600452602452fd5b503461033b57604036600319011261033b5761113e600435611127613944565b9061113961113482613b79565b614088565b61411a565b5080f35b503461033b578060031936011261033b57602060ff600854166040519015158152f35b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361119061392e565b16815260058452205416604051908152f35b503461033b57602036600319011261033b576111bc61392e565b6111c4613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b57849161126c575b5060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b90506020813d6020116112a4575b81611287602093836139c3565b810103126105fe575160008051602061482e83398151915261122b565b3d915061127a565b503461033b57604036600319011261033b5760206112d46112cb61392e565b60243590613cf6565b6040519015158152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361130661392e565b168152601383522054604051908152f35b503461033b57602036600319011261033b57604060209160043581526000805160206146ae83398151915283522054604051908152f35b503461033b578060031936011261033b576020604051670de0b6b3a76400008152f35b503461033b57604036600319011261033b5761138b61392e565b6010546024359291906001600160a01b03163303610479576001600160a01b031680825260076020526040822054929081841061140d578060008051602061482e8339815191526040866113e3866104369899613b6c565b84895260076020528289205583885260076020528188205482519182526020820152a2339061404c565b5091604492633cb8e07360e01b8352600452602452fd5b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361144f61392e565b168152600284522054166040519015158152f35b503461033b5761012036600319011261033b5761147e61392e565b6064359190604435602435611491613a58565b601054610104359660e4359260c4359260a43592906001600160a01b0316330361167f576001600160a01b038816808a52600260205260408a205490989060ff161561166b57861561165c576127108811611642576103e882116116285760ff83169060128211801561161e575b61160a578361150d91614260565b85151580611601575b6115ea578a1515806115e1575b6115ca579260008051602061468e83398151915297969592828c956115c4979460408e8e80825260036020528c8383205580825260046020528d838320558152600660205220558b8d52600560205260408d209060ff198254161790558a8c52600c6020528260408d20558a8c52600d6020528360408d20558a8c52600e6020528460408d20558a8c52600f6020528560408d205560405198899889613cbd565b0390a280f35b60448a868d63dd85772b60e01b8352600452602452fd5b50848b10611523565b60448a8588637449915760e01b8352600452602452fd5b50838610611516565b63ca95039160e01b8b52600482905260248bfd5b50600682106114ff565b631051834f60e11b8a5260048290526103e860245260448afd5b63c1e9a14160e01b8a52600488905261271060245260448afd5b63a2ec3a5560e01b8a5260048afd5b6374ed46ad60e01b8a52600489905260248afd5b6349db3bd360e01b8952600489fd5b503461033b57604036600319011261033b576116a861392e565b6001600160a01b0316808252600260205260408220546024359060ff16156117745780156117655761271061172a604085670de0b6b3a76400006117196117329688859a52600560205260ff85852054169080916012811061173f575b505088845260036020528484205490613a8b565b049581526004602052205484613a8b565b048092613b6c565b9082519182526020820152f35b61175e925060ff61175261175892613ad4565b16613ae5565b90613a8b565b3880611705565b63162908e360e11b8352600483fd5b6374ed46ad60e01b83526004829052602483fd5b503461033b578060031936011261033b5761033760408051906117ab81836139c3565b60058252640352e302e360dc1b602083015251918291602083526020830190613a17565b503461033b57602036600319011261033b5760043581526000805160206146ae83398151915260205260408120604051908160208254918281520190819285526020852090855b818110611876575050508261182c9103836139c3565b604051928392602084019060208552518091526040840192915b818110611854575050500390f35b82516001600160a01b0316845285945060209384019390920191600101611846565b8254845260209093019260019283019201611816565b503461033b578060031936011261033b57602090604051908152f35b503461033b576118b736613969565b9190926118c2613f12565b6118ca613f4e565b338152600960205260408120544303611f1f57338152600a602052600360408220541015611f1057338152600a602052604081206119088154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16611e6f575b828252600260205260ff60408320541615610466578415610457578315611e6057828252600c60205260408220548510611e3b57828252600e60205260408220548015611e2c57808611611e155750846119869161415e565b6040516370a0823160e01b8152306004820152602081602481865afa908115611e0a578291611dd8575b506119bd8530338661421c565b6040516370a0823160e01b8152306004820152602081602481875afa908115611cef57908692918491611d9f575b50906119f691613b6c565b10611d905781815260076020526040812054611a128582613cb0565b818110611d81576001600160ff1b038111611d72576040849260008051602061482e833981519152928486526007602052808387205582519182526020820152a2818152600560205260ff604082205416849060128110611d11575b50611a8f670de0b6b3a7640000918484526003602052604084205490613a8b565b04908281526004602052612710611aaa604083205484613a8b565b0491611ab68382613b6c565b94808610611cfa57506001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611cef578391611cbd575b5082546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523360048401528c60248401528b60448401528d60648401525af1801561060b57908491611ca8575b505083611c34575b6001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa801561060b578490611c00575b611b8a9250613b6c565b90808203611bea575050507fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b611bcd602095604051918291339588429285613bdd565b0390a360016000805160206147ce83398151915255604051908152f35b632d8562a360e11b835260045260245260449150fd5b506020823d602011611c2c575b81611c1a602093836139c3565b810103126105fe57611b8a9151611b80565b3d9150611c0d565b82546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523060048401528a60248401528b60448401528160648401525af1801561060b57908491611c8b575b5050611b4c565b81611c95916139c3565b611ca0578238611c84565b8280fd5b8380fd5b81611cb2916139c3565b611ca0578238611b44565b90506020813d602011611ce7575b81611cd8602093836139c3565b810103126105fe575138611af3565b3d9150611ccb565b6040513d85823e3d90fd5b6371c4efed60e01b83526004869052602452604482fd5b611d21915061175260ff91613ad4565b8015611d5e5780600019048511611d4f57611a8f611d48670de0b6b3a76400009287613a8b565b9150611a6e565b63035fc53d60e41b8252600482fd5b634e487b7160e01b82526012600452602482fd5b630700fcb360e11b8352600483fd5b63446c8cc960e01b8352600483fd5b639bfa3c1760e01b8152600490fd5b919250506020813d602011611dd0575b81611dbc602093836139c3565b810103126105fe57518591906119f66119eb565b3d9150611daf565b90506020813d602011611e02575b81611df3602093836139c3565b810103126105fe5751386119b0565b3d9150611de6565b6040513d84823e3d90fd5b631d7f2ac360e01b83526004869052602452604482fd5b633b5db2f360e11b8352600483fd5b50908152600c6020526040812054630d54e9e160e01b82526004849052602452604490fd5b632cd84af360e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa859181611eef575b50611ea55763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec9575061192d565b90506044928252600560205260ff604083205416631e43476360e11b8352600452602452fd5b611f0991925060203d6020116109c9576109ba81836139c3565b9038611e91565b63a74c1c5f60e01b8152600490fd5b3381526009602052436040822055338152600a6020526001604082205561190b565b503461033b578060031936011261033b5760206040516103e88152f35b503461033b57604036600319011261033b576020906040906001600160a01b03611f8661392e565b16815260148352818120602435825283522054604051908152f35b503461033b57604036600319011261033b576040611fbd613944565b91600435815260008051602061478e833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b503461033b578060031936011261033b57602060405160648152f35b503461033b57604036600319011261033b5761205060209160043581526000805160206146ae8339815191528352604060243591206144b8565b905460405160039290921b1c6001600160a01b03168152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361209161392e565b168152600983522054604051908152f35b503461033b57604036600319011261033b576120bc61392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b57604060008051602061476e8339815191529183855260136020528185205490848652601360205280838720558486526015602052828620438752602052828620548587526019602052838720558486526017602052438387205582519182526020820152a280f35b63df407ac560e01b8352600483fd5b6349db3bd360e01b8352600483fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361219161392e565b168152600383522054604051908152f35b503461033b578060031936011261033b5760008051602061470e833981519152815260008051602061478e83398151915260209081526040808320336000908152925290205460ff1615612278576121f8613f4e565b600160ff196000805160206147ae8339815191525416176000805160206147ae833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a280f35b63e2517d3f60e01b81523360045260008051602061470e833981519152602452604490fd5b503461033b57602036600319011261033b576122b761392e565b60008051602061480e8339815191525460ff8160401c169081156123a3575b506123945760008051602061480e83398151915280546001600160481b0319166003600160401b0117905581805260008051602061478e83398151915260209081526040808420336000908152925290205460ff161561237c5761233990613c5e565b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160038152a180f35b63e2517d3f60e01b8252336004526024829052604482fd5b63f92ee8a960e01b8252600482fd5b60036001600160401b039190911610159050386122d6565b503461033b578060031936011261033b57602060ff6000805160206147ae83398151915254166040519015158152f35b503461033b57602036600319011261033b5761240561392e565b6010546001600160a01b031633036104795761043690613c5e565b503461033b57606036600319011261033b5761243a61392e565b612442613944565b60105490926044359290916001600160a01b0316330361047957612464613f4e565b6011546001600160a01b03169182156126de5760405163babcc53960e01b81526001600160a01b0386166004820181905293602090829060249082905afa908115611e0a57829161269f575b5015612690578215612681576001546001600160a01b03928316921682036125d1576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161259f575b50935b841561259057600019810361258a5750835b841561257b5780851161256357505061252d836020958361404c565b7f0bf519e4b3821615dbdd874fa1a5fbb4bb651b4e6beabedd4ac318e770233b2c604080518581524287820152a3604051908152f35b630555ed4f60e31b8252600485905260245260449150fd5b632e11316f60e11b8252600482fd5b93612511565b63f09872eb60e01b8252600482fd5b90506020813d6020116125c9575b816125ba602093836139c3565b810103126105fe5751386124fc565b3d91506125ad565b8181526002602052604081205460ff161561266f576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161263d575b5082825260076020526040822054808211156126355761262f91613b6c565b936124ff565b50508061262f565b90506020813d602011612667575b81612658602093836139c3565b810103126105fe575138612610565b3d915061264b565b60249163eef7849760e01b8252600452fd5b634e46966960e11b8152600490fd5b63133307bb60e21b8152600490fd5b90506020813d6020116126d6575b816126ba602093836139c3565b810103126126d2575180151581036126d257386124b0565b5080fd5b3d91506126ad565b630e048e7160e41b8152600490fd5b503461033b57602036600319011261033b5761270761392e565b6010546001600160a01b03163303610479576001600160a01b0316801561276c57601180546001600160a01b0319811683179091556001600160a01b03167f1e9c406f2707909cfd9f61e744f73bcab77e5997d063276f67883c5257d51cf08380a380f35b634e46966960e11b8252600482fd5b503461033b578060031936011261033b577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036127d457602060405160008051602061472e8339815191528152f35b63703e46dd60e11b8152600490fd5b503461033b578060031936011261033b576010546040516001600160a01b039091168152602090f35b50604036600319011261033b5761282161392e565b602435906001600160401b038211611ca05736602383011215611ca0578160040135908361284e836139fc565b9361285c60405195866139c3565b83855260208501933660248284010111611ca057806024602093018637850101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115612ade575b50612acf576010546001600160a01b03163303612ac0576001600160a01b038116928315612ab157813b15612aa25760008051602061472e83398151915254846128fa613a68565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f61293060405192604084526040840190613a17565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa879181612a6a575b5061297e57634c9c8ce360e01b87526004869052602487fd5b908160008051602061472e83398151915288979303612a585750833b15612a44576001600160a01b031916811760008051602061472e833981519152558491907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a2805115612a295761113e9382915190845af43d15612a21573d91612a05836139fc565b92612a1360405194856139c3565b83523d85602085013e61460c565b60609161460c565b5050505034612a355780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b86526004829052602486fd5b632a87526960e21b8752600452602486fd5b9091506020813d602011612a9a575b81612a86602093836139c3565b81010312612a9657519038612965565b8780fd5b3d9150612a79565b636f7c43f160e01b8552600485fd5b63e6c4247b60e01b8552600485fd5b6349db3bd360e01b8452600484fd5b63703e46dd60e11b8452600484fd5b60008051602061472e833981519152546001600160a01b031614159050386128b2565b503461033b57602036600319011261033b576020906040906001600160a01b03612b2961392e565b168152600e83522054604051908152f35b503461033b57606036600319011261033b57612b5461395a565b6024356001600160401b038111611ca057612b73903690600401613993565b916044356001600160401b038111610a5057612b93903690600401613993565b60008051602061480e8339815191529291925460ff8160401c16908115612ef6575b50612ee75760008051602061480e83398151915280546001600160481b0319166002600160401b011790556000805160206147ee833981519152865260008051602061478e83398151915260209081526040808820336000908152925290205460ff1615612ec257612c2561448a565b612c2d61448a565b60016000805160206147ce83398151915255600b549160ff8316612eb357818603612ea457612c5b86613bf9565b92612c6960405194856139c3565b868452601f19612c7888613bf9565b01366020860137875b878110612daf575060019060ff191617600b5515159460ff196008541660ff871617600855865b818110612d0c578760008051602061466e833981519152602089604051908152a160ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160028152a180f35b808860008051602061482e8339815191526040612d34612d2f600196888d613c10565b613c36565b612d3f85898c613c10565b357f8f955fa878b4aae8b1ac37b1ab715307470f2822ceff87e23d33ef1e044814a783612d6c888d613c4a565b5193898060a01b0316968793848252600660205280838320558482526007602052858383205582519182526020820152a28151908d82526020820152a201612ca8565b612dbd612d2f828a8a613c10565b612dc8828689613c10565b6001600160a01b03909116808b52600260205260408b20549091359060ff1615612e90576103e88111612e785750906020602492604051938480926370a0823160e01b82523060048301525afa8015612e6d578a90612e37575b60019250612e308288613c4a565b5201612c81565b509060203d8111612e66575b612e4d81836139c3565b6020826000928101031261033b57509060019151612e22565b503d612e43565b6040513d8c823e3d90fd5b631051834f60e11b8b526004526103e860245260448afd5b6351104c5960e01b8b52600482905260248bfd5b63512509d360e11b8752600487fd5b6324d0d1fd60e01b8752600487fd5b63e2517d3f60e01b8652336004526000805160206147ee833981519152602452604486fd5b63f92ee8a960e01b8652600486fd5b60026001600160401b03919091161015905038612bb5565b503461033b578060031936011261033b576011546040516001600160a01b039091168152602090f35b503461033b578060031936011261033b576010546001600160a01b03163303612fef576000805160206147ae8339815191525460ff811615612fe05760ff19166000805160206147ae833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a280f35b638dfc202b60e01b8252600482fd5b6349db3bd360e01b8152600490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361302661392e565b168152601683522054604051908152f35b503461033b57604036600319011261033b57613051613944565b336001600160a01b0382160361306d5761113e9060043561411a565b63334bd91960e11b8252600482fd5b503461033b57602036600319011261033b576020906040906001600160a01b036130a461392e565b168152600c83522054604051908152f35b503461033b57602036600319011261033b576020906040906001600160a01b036130dd61392e565b168152601783522054604051908152f35b503461033b57604036600319011261033b5761113e60043561310e613944565b9061311b61113482613b79565b6140d2565b503461033b5761312f36613969565b91909261313a613f12565b613142613f4e565b3381526009602052604081205443036135be57338152600a602052600360408220541015611f1057338152600a602052604081206131808154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16613543575b828252600260205260ff604083205416156104665760ff6008541615613534578415610457578315611e6057828252600d602052604082205480861061351d5750828252600f6020526040822054801561350e578086116134f857508461320b91613f78565b670de0b6b3a76400008402848104670de0b6b3a7640000036134e4578282526003602052604082205461323d91613ab4565b90828152600560205260ff604082205416601281106134c4575b50828152600660205261327c612710613274604084205485613a8b565b048093613b6c565b938085106134ac575082815260076020528360408220541061348857828152600760205260408120548481106134795760008051602061482e8339815191526040826132c9888895613b6c565b8486526007602052808387205582519182526020820152a26001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611e0a578291613447575b5081546001600160a01b0316803b15611ca057826040518092633a52b90760e11b82528183816133498d3360048401613bc2565b03925af18015611cef57613432575b506001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa908115611cef5783916133fc575b6133989250613b6c565b8581036133e45750507f8caf04742286d017f9ac3924388e188c73e6e5094311c5e59a61a7ef86dda8bf611bcd6020956133d386338761404c565b604051918291339588429285613bdd565b635ab6e2db60e01b8252600486905260245260449150fd5b90506020823d60201161342a575b81613417602093836139c3565b810103126105fe5761339891519061338e565b3d915061340a565b9161344081600493946139c3565b9190613358565b90506020813d602011613471575b81613462602093836139c3565b810103126126d2575138613315565b3d9150613455565b6308aed4ef60e31b8252600482fd5b82815260076020526040812054635960d22160e01b82526004526024849052604490fd5b6371c4efed60e01b8252600485905260245260449150fd5b916134d760ff6117526134dd9495613ad4565b90613ab4565b9038613257565b634e487b7160e01b82526011600452602482fd5b625502a360e91b83526004869052602452604482fd5b636c6ff70d60e11b8352600483fd5b6361767b8560e01b83526004869052602452604482fd5b630df65d9f60e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa85918161359d575b506135795763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec957506131a5565b6135b791925060203d6020116109c9576109ba81836139c3565b9038613565565b3381526009602052436040822055338152600a60205260016040822055613183565b503461033b57602036600319011261033b576020610f3c600435613b79565b503461033b57602036600319011261033b576020906040906001600160a01b0361362761392e565b168152600f83522054604051908152f35b503461033b57604036600319011261033b5761365261392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b5760406000805160206146ce8339815191529183855260126020528185205490848652601260205280838720558486526014602052828620438752602052828620548587526018602052838720558486526016602052438387205582519182526020820152a280f35b503461033b57602036600319011261033b576020906040906001600160a01b0361370961392e565b168152600683522054604051908152f35b503461033b578060031936011261033b576001546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b0361376b61392e565b168152600d83522054604051908152f35b503461033b57602036600319011261033b5761379661395a565b6010546001600160a01b0316330361047957602060008051602061466e83398151915291151560ff196008541660ff821617600855604051908152a180f35b503461033b57602036600319011261033b5760043563ffffffff60e01b81168091036126d257602090635a05180f60e01b811490811561381b575b506040519015158152f35b637965db0b60e01b811491508115613835575b5082613810565b6301ffc9a760e01b1490508261382e565b503461033b57604036600319011261033b5761386061392e565b6001600160a01b0316808252600260205260408220546024359060ff161561177457670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561391a57916138bc60409383835260036020528483205490613ab4565b91808252600560205260ff8483205416601281106138f1575b5061172a84836127109361173295526006602052205484613a8b565b846117329361390f61271094966134d760ff61175261172a97613ad4565b9593509350506138d5565b634e487b7160e01b83526011600452602483fd5b600435906001600160a01b03821682036105fe57565b602435906001600160a01b03821682036105fe57565b6004359081151582036105fe57565b60609060031901126105fe576004356001600160a01b03811681036105fe57906024359060443590565b9181601f840112156105fe578235916001600160401b0383116105fe576020808501948460051b0101116105fe57565b601f909101601f19168101906001600160401b038211908210176139e657604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116139e657601f01601f191660200190565b919082519283825260005b848110613a43575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201613a22565b6084359060ff821682036105fe57565b60405190613a776040836139c3565b6005825264322e332e3360d81b6020830152565b81810292918115918404141715613a9e57565b634e487b7160e01b600052601160045260246000fd5b8115613abe570490565b634e487b7160e01b600052601260045260246000fd5b60ff166012039060ff8211613a9e57565b8015613b665760009060208110600116604e821060011617613b5e57600a916001915b60018111613b35575082600019048211613b2157500290565b634e487b7160e01b81526011600452602490fd5b92806000190481116134e45760018416613b55575b80029260011c613b08565b80920291613b4a565b9050600a0a90565b50600190565b91908203918211613a9e57565b60005260008051602061478e83398151915260205260016040600020015490565b6000198114613a9e5760010190565b908160209103126105fe575160ff811681036105fe5790565b6001600160a01b039091168152602081019190915260400190565b9094939260609260808301968352602083015260408201520152565b6001600160401b0381116139e65760051b60200190565b9190811015613c205760051b0190565b634e487b7160e01b600052603260045260246000fd5b356001600160a01b03811681036105fe5790565b8051821015613c205760209160051b010190565b6001600160a01b03168015613c9f57601080546001600160a01b0319811683179091556001600160a01b031660008051602061474e833981519152600080a3565b63e6c4247b60e01b60005260046000fd5b91908201809211613a9e57565b94919360e0969360ff929a99989561010088019b885260208801526040870152166060850152608084015260a083015260c08201520152565b6001600160a01b03811660008181526002602052604090205490919060ff16158015613de8575b8015613de0575b613dce5781600052600f6020526040600020548015908115613dd6575b50613dce57613d66926040918251948592839262f7fce960e01b845260048401613bc2565b0381305afa918215613dc257600092613d8e575b506000526007602052604060002054101590565b9091506040813d604011613dba575b81613daa604093836139c3565b810103126105fe57519038613d7a565b3d9150613d9d565b6040513d6000823e3d90fd5b505050600090565b9050831138613d41565b508215613d24565b5060ff6008541615613d1d565b6001546001600160a01b0391821691168103613e6a576020602491604051928380926370a0823160e01b82523060048301525afa908115613dc257600091613e3b575090565b90506020813d602011613e62575b81613e56602093836139c3565b810103126105fe575190565b3d9150613e49565b80600052600260205260ff60406000205416613e865750600090565b6040516370a0823160e01b815230600482015290602082602481845afa918215613dc257600092613ede575b506000526007602052604060002054808211600014613ed757613ed491613b6c565b90565b5050600090565b90916020823d602011613f0a575b81613ef9602093836139c3565b8101031261033b5750519038613eb2565b3d9150613eec565b60026000805160206147ce8339815191525414613f3d5760026000805160206147ce83398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206147ae8339815191525416613f6757565b63d93c066560e01b60005260046000fd5b6001600160a01b0316600081815260136020526040902054801561404757816000526015602052604060002043600052602052613fbb6040600020549384613cb0565b92831061403657808260005260176020524360406000205414614018575b8311613ffc57506000526015602052604060002043600052602052604060002055565b925063029359d560e41b60005260045260245260445260646000fd5b5081600052601960205261403160406000205482613cb0565b613fd9565b63446c8cc960e01b60005260046000fd5b505050565b614081614086939261407360405194859263a9059cbb60e01b602085015260248401613bc2565b03601f1981018452836139c3565b6142ed565b565b600081815260008051602061478e8339815191526020908152604080832033845290915290205460ff16156140ba5750565b63e2517d3f60e01b6000523360045260245260446000fd5b6140dc8282614348565b91826140e757505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b0316906144d0565b5090565b61412482826143ea565b918261412f57505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b031690614539565b6001600160a01b03166000818152601260205260409020548015614047578160005260146020526040600020436000526020526141a16040600020549384613cb0565b928310614036578082600052601660205243604060002054146141fe575b83116141e257506000526014602052604060002043600052602052604060002055565b92506319a4e2a760e01b60005260045260245260445260646000fd5b5081600052601860205261421760406000205482613cb0565b6141bf565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152614086916140816084836139c3565b60405163313ce56760e01b81529190602090839060049082906001600160a01b03165afa600092816142cc575b506142a357631eecbb6560e01b60005260046000fd5b60ff91821691168082036142b5575050565b631e43476360e11b60005260045260245260446000fd5b6142e691935060203d6020116109c9576109ba81836139c3565b913861428d565b906000602091828151910182855af115613dc2576000513d61433f57506001600160a01b0381163b155b61431e5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415614317565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff16613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff1615613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b60ff60008051602061480e8339815191525460401c16156144a757565b631afcd79f60e31b60005260046000fd5b8054821015613c205760005260206000200190600090565b6001810190826000528160205260406000205415600014613dce578054600160401b8110156139e65761452461450d8260018794018555846144b8565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b9060018201918160005282602052604060002054801515600014614603576000198101818111613a9e578254600019810191908211613a9e578181036145cc575b505050805480156145b657600019019061459482826144b8565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b6145ec6145dc61450d93866144b8565b90549060031b1c928392866144b8565b90556000528360205260406000205538808061457a565b50505050600090565b90614632575080511561462157602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580614664575b614643575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561463b56fe2c0a5f5ab0ba371221bb3612c2d2f90d36566279309f526000c5b354efd1b0658c67aaac7f77de07240e5a9b36dfdccb2a89c438635abbb27a73142d2aa0f629c1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200048b07fab687f450848f1df8a96db08fef7840f53415f18fdc2ec8e9f810f0930c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc17dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846c4460507c21097c15f6883572ebd157a9ee4b1d989a312314e93afd9d2ecd494002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a006d129bd71f2401cbe77f49f546d7d5f58992faecfca6e51ba06b50b261e83331a164736f6c6343000822000a";
|
|
14478
14598
|
var isSuperArgs = (xs) => xs.length > 1;
|
|
14479
|
-
var SimplePSMV2__factory = class extends
|
|
14599
|
+
var SimplePSMV2__factory = class extends import_ethers13.ContractFactory {
|
|
14480
14600
|
constructor(...args) {
|
|
14481
14601
|
if (isSuperArgs(args)) {
|
|
14482
14602
|
super(...args);
|
|
@@ -14496,10 +14616,10 @@ var SimplePSMV2__factory = class extends import_ethers12.ContractFactory {
|
|
|
14496
14616
|
static bytecode = _bytecode;
|
|
14497
14617
|
static abi = _abi;
|
|
14498
14618
|
static createInterface() {
|
|
14499
|
-
return new
|
|
14619
|
+
return new import_ethers13.Interface(_abi);
|
|
14500
14620
|
}
|
|
14501
14621
|
static connect(address, runner) {
|
|
14502
|
-
return new
|
|
14622
|
+
return new import_ethers13.Contract(address, _abi, runner);
|
|
14503
14623
|
}
|
|
14504
14624
|
};
|
|
14505
14625
|
|
|
@@ -15066,7 +15186,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
15066
15186
|
*/
|
|
15067
15187
|
constructor(config) {
|
|
15068
15188
|
if (!config.provider && config.ethRpcUrl) {
|
|
15069
|
-
config.provider = new
|
|
15189
|
+
config.provider = new import_ethers14.JsonRpcProvider(config.ethRpcUrl);
|
|
15070
15190
|
}
|
|
15071
15191
|
this.config = config;
|
|
15072
15192
|
if (config.debug) {
|
|
@@ -15332,7 +15452,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
15332
15452
|
const network = await config.provider.getNetwork();
|
|
15333
15453
|
chainId = Number(network.chainId);
|
|
15334
15454
|
} else if (config.ethRpcUrl) {
|
|
15335
|
-
const tempProvider = new
|
|
15455
|
+
const tempProvider = new import_ethers14.JsonRpcProvider(
|
|
15336
15456
|
config.ethRpcUrl
|
|
15337
15457
|
);
|
|
15338
15458
|
const network = await tempProvider.getNetwork();
|
|
@@ -15855,7 +15975,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
15855
15975
|
}
|
|
15856
15976
|
const loanOps = this.loanOps();
|
|
15857
15977
|
const protocolConfig = await loanOps.getProtocolConfig();
|
|
15858
|
-
const requestAmountWei = (0,
|
|
15978
|
+
const requestAmountWei = (0, import_ethers14.parseEther)(
|
|
15859
15979
|
request.amount.toString()
|
|
15860
15980
|
);
|
|
15861
15981
|
const minLoanValueWei = BigInt(protocolConfig.minimumLoanValueWei);
|
|
@@ -15937,7 +16057,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
15937
16057
|
pkpNftAddress,
|
|
15938
16058
|
this.getChipotlePublicKeyFallback()
|
|
15939
16059
|
);
|
|
15940
|
-
pkpEthAddress = (0,
|
|
16060
|
+
pkpEthAddress = (0, import_ethers14.computeAddress)(pkpPublicKey);
|
|
15941
16061
|
pkpCache.set(request.positionId, {
|
|
15942
16062
|
publicKey: pkpPublicKey,
|
|
15943
16063
|
ethAddress: pkpEthAddress,
|
|
@@ -16266,8 +16386,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
16266
16386
|
throw new Error(`Position not found: ${request.positionId}`);
|
|
16267
16387
|
}
|
|
16268
16388
|
const currentDebt = position.ucdDebt.toString();
|
|
16269
|
-
const ucdDebtHash = (0,
|
|
16270
|
-
const contractHash = (0,
|
|
16389
|
+
const ucdDebtHash = (0, import_ethers14.keccak256)(import_ethers14.AbiCoder.defaultAbiCoder().encode(["uint256"], [currentDebt]));
|
|
16390
|
+
const contractHash = (0, import_ethers14.keccak256)(import_ethers14.AbiCoder.defaultAbiCoder().encode(
|
|
16271
16391
|
["address", "address", "address", "address"],
|
|
16272
16392
|
[
|
|
16273
16393
|
positionManagerAddress,
|
|
@@ -16328,188 +16448,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
16328
16448
|
{}
|
|
16329
16449
|
);
|
|
16330
16450
|
}
|
|
16331
|
-
if (this.config.debug) {
|
|
16332
|
-
log.info("\u{1F50D} PREFLIGHT: Attempting diagnostic gas estimation...", {});
|
|
16333
|
-
}
|
|
16334
|
-
try {
|
|
16335
|
-
const iface = new import_ethers13.Interface(positionManagerAbi);
|
|
16336
|
-
const signatureHex = finalSignature.startsWith("0x") ? finalSignature : "0x" + finalSignature;
|
|
16337
|
-
if (this.config.debug) {
|
|
16338
|
-
log.info("\u{1F50D} DEBUG: Signature details:", {
|
|
16339
|
-
finalSignature: finalSignature ? `${finalSignature.substring(0, 20)}... (length: ${finalSignature.length})` : "UNDEFINED/EMPTY",
|
|
16340
|
-
signatureHex: signatureHex ? `${signatureHex.substring(0, 22)}... (length: ${signatureHex.length})` : "UNDEFINED/EMPTY"
|
|
16341
|
-
});
|
|
16342
|
-
}
|
|
16343
|
-
const calldata = iface.encodeFunctionData("mintUCD", [
|
|
16344
|
-
positionIdBytes32,
|
|
16345
|
-
validationResponse.mintAmount,
|
|
16346
|
-
validationResponse.mintFee,
|
|
16347
|
-
validationResponse.newDebt,
|
|
16348
|
-
validationResponse.newCollateral,
|
|
16349
|
-
validationResponse.btcPrice,
|
|
16350
|
-
validationResponse.authorizedSpendsHash,
|
|
16351
|
-
ucdDebtHash,
|
|
16352
|
-
contractHash,
|
|
16353
|
-
validationResponse.timestamp,
|
|
16354
|
-
signatureHex
|
|
16355
|
-
]);
|
|
16356
|
-
if (this.config.debug) {
|
|
16357
|
-
log.info("\u{1F50D} DEBUG: Encoded calldata:", {
|
|
16358
|
-
length: calldata.length,
|
|
16359
|
-
signaturePortion: calldata.substring(650, 670)
|
|
16360
|
-
});
|
|
16361
|
-
}
|
|
16362
|
-
const provider = this.getSignerOrThrow().provider;
|
|
16363
|
-
if (!provider) {
|
|
16364
|
-
throw new Error("Provider not available");
|
|
16365
|
-
}
|
|
16366
|
-
const signerAddress = await this.getSignerOrThrow().getAddress();
|
|
16367
|
-
if (this.config.debug) {
|
|
16368
|
-
log.info(" Executing diagnostic eth_call...", {});
|
|
16369
|
-
}
|
|
16370
|
-
await provider.call({
|
|
16371
|
-
to: positionManagerAddress,
|
|
16372
|
-
from: signerAddress,
|
|
16373
|
-
data: calldata
|
|
16374
|
-
});
|
|
16375
|
-
if (this.config.debug) {
|
|
16376
|
-
log.info(" \u2705 Diagnostic eth_call succeeded!", {});
|
|
16377
|
-
}
|
|
16378
|
-
} catch (preflightError) {
|
|
16379
|
-
if (this.config.debug) {
|
|
16380
|
-
log.error(
|
|
16381
|
-
"\u274C PREFLIGHT CHECK FAILED - Diagnostic eth_call reverted",
|
|
16382
|
-
{}
|
|
16383
|
-
);
|
|
16384
|
-
log.error(` Error message: ${preflightError?.message}`, {});
|
|
16385
|
-
log.error(` Error code: ${preflightError?.code}`, {});
|
|
16386
|
-
log.error(` Error data: ${preflightError?.data || "none"}`, {});
|
|
16387
|
-
log.error(` Error reason: ${preflightError?.reason || "none"}`, {});
|
|
16388
|
-
log.error(
|
|
16389
|
-
` Error.error: ${JSON.stringify(preflightError?.error || {})}`,
|
|
16390
|
-
{}
|
|
16391
|
-
);
|
|
16392
|
-
}
|
|
16393
|
-
let errorData = preflightError?.data || preflightError?.error?.data?.data || preflightError?.error?.data || preflightError?.error?.error?.data;
|
|
16394
|
-
const errorMessage = preflightError?.reason || preflightError?.error?.reason || preflightError?.error?.error?.reason || preflightError?.message || "Unknown error";
|
|
16395
|
-
let requireMessage;
|
|
16396
|
-
if (errorData && typeof errorData === "string" && errorData.startsWith("0x") && errorData.length > 138) {
|
|
16397
|
-
try {
|
|
16398
|
-
const errorSelector = errorData.slice(0, 10);
|
|
16399
|
-
if (errorSelector === "0x08c379a0") {
|
|
16400
|
-
const iface = new import_ethers13.Interface([
|
|
16401
|
-
"function Error(string)"
|
|
16402
|
-
]);
|
|
16403
|
-
const decoded = iface.decodeFunctionData("Error", errorData);
|
|
16404
|
-
requireMessage = decoded[0];
|
|
16405
|
-
}
|
|
16406
|
-
} catch (e) {
|
|
16407
|
-
}
|
|
16408
|
-
}
|
|
16409
|
-
if (requireMessage) {
|
|
16410
|
-
throw new Error(
|
|
16411
|
-
`Preflight check failed - mintUCD would revert:
|
|
16412
|
-
${requireMessage}
|
|
16413
|
-
Context: Quantum timestamp=${validationResponse.timestamp}, Position=${request.positionId}`
|
|
16414
|
-
);
|
|
16415
|
-
}
|
|
16416
|
-
if (errorData && typeof errorData === "string" && errorData.startsWith("0x") && errorData.length > 10) {
|
|
16417
|
-
const selector = errorData.slice(0, 10);
|
|
16418
|
-
const knownErrors = {
|
|
16419
|
-
"0x8baa579f": "InvalidSignature()",
|
|
16420
|
-
"0xd92e233d": "ValidationFailed()",
|
|
16421
|
-
"0x3ee5aeb5": "OperationNotAuthorized()",
|
|
16422
|
-
"0x70f4b32a": "UnauthorizedSigner()",
|
|
16423
|
-
"0x48f5c3ed": "Unauthorized()",
|
|
16424
|
-
"0x36bfdeea": "StateHashMismatch()",
|
|
16425
|
-
"0x131d9a21": "QuantumExpired()",
|
|
16426
|
-
"0x52ce5d58": "QuantumAlreadyUsed()",
|
|
16427
|
-
"0x137f3b70": "InDeadZone()",
|
|
16428
|
-
"0xbe4b82c1": "DeadZoneViolation()",
|
|
16429
|
-
"0x3e76a3c9": "QuantumOutsideWindow()",
|
|
16430
|
-
"0x62278171": "InvalidValidatorSignature()",
|
|
16431
|
-
"0xb9d419a7": "DebtUpdateVerificationFailed()",
|
|
16432
|
-
"0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
|
|
16433
|
-
"0x0cfd2a97": "MintVerificationMismatch(uint256,uint256)",
|
|
16434
|
-
"0x07637bd8": "MintFailed()"
|
|
16435
|
-
};
|
|
16436
|
-
const errorName = knownErrors[selector] || `Unknown error ${selector}`;
|
|
16437
|
-
const mintDebtDiagnostics = selector === "0xb9d419a7" || selector === "0xc7e20553" || selector === "0x0cfd2a97" || selector === "0x07637bd8" ? `
|
|
16438
|
-
|
|
16439
|
-
Mint/debt diagnostics (LoanOperationsManager mint path \u2192 increaseDebtFromMint):
|
|
16440
|
-
positionId: ${request.positionId}
|
|
16441
|
-
on-chain ucdDebt before tx: ${currentDebt}
|
|
16442
|
-
Lit newDebt: ${validationResponse.newDebt}
|
|
16443
|
-
Lit mintAmount: ${validationResponse.mintAmount}
|
|
16444
|
-
Lit mintFee: ${validationResponse.mintFee}
|
|
16445
|
-
Call path: mintUCD -> mintUCDWithAuthorization -> increaseDebtFromMint -> finalizeMintDebtIncrease
|
|
16446
|
-
Contract expects UCD supply increase to match mintAmount+mintFee and debt update to newDebt.
|
|
16447
|
-
` : "";
|
|
16448
|
-
let quantumContext = "";
|
|
16449
|
-
if (selector === "0x131d9a21" || selector === "0x52ce5d58" || selector === "0x137f3b70" || selector === "0xbe4b82c1" || selector === "0x3e76a3c9") {
|
|
16450
|
-
const currentTime2 = Math.floor(Date.now() / 1e3);
|
|
16451
|
-
const currentQuantum = Math.floor(currentTime2 / 60) * 60;
|
|
16452
|
-
const sigQuantum2 = Math.floor(validationResponse.timestamp / 60) * 60;
|
|
16453
|
-
const timeDiff = currentTime2 - validationResponse.timestamp;
|
|
16454
|
-
quantumContext = `
|
|
16455
|
-
|
|
16456
|
-
Quantum Timing Analysis:
|
|
16457
|
-
Signature created: ${validationResponse.timestamp} (${new Date(
|
|
16458
|
-
validationResponse.timestamp * 1e3
|
|
16459
|
-
).toISOString()})
|
|
16460
|
-
Current time: ${currentTime2} (${new Date(
|
|
16461
|
-
currentTime2 * 1e3
|
|
16462
|
-
).toISOString()})
|
|
16463
|
-
Time elapsed: ${timeDiff} seconds
|
|
16464
|
-
Signature quantum: ${sigQuantum2}
|
|
16465
|
-
Current quantum: ${currentQuantum}
|
|
16466
|
-
Quantum window: 60 seconds
|
|
16467
|
-
Status: ${sigQuantum2 < currentQuantum ? "\u274C EXPIRED - Signature created in older quantum window" : "\u2705 VALID"}
|
|
16468
|
-
Note: QuantumOutsideWindow can also occur if the tx is mined outside the accepted past/current/next quantum set.`;
|
|
16469
|
-
}
|
|
16470
|
-
throw new Error(
|
|
16471
|
-
`Preflight check failed - mintUCD would revert:
|
|
16472
|
-
Error: ${errorName}
|
|
16473
|
-
Selector: ${selector}
|
|
16474
|
-
Message: ${errorMessage}
|
|
16475
|
-
Data: ${errorData}${quantumContext}${mintDebtDiagnostics}`
|
|
16476
|
-
);
|
|
16477
|
-
} else {
|
|
16478
|
-
const currentTime2 = Math.floor(Date.now() / 1e3);
|
|
16479
|
-
const timeSinceSig = currentTime2 - validationResponse.timestamp;
|
|
16480
|
-
const currentQuantum = Math.floor(currentTime2 / 60) * 60;
|
|
16481
|
-
const sigQuantum2 = Math.floor(validationResponse.timestamp / 60) * 60;
|
|
16482
|
-
throw new Error(
|
|
16483
|
-
`Preflight check failed - mintUCD would revert:
|
|
16484
|
-
${errorMessage}
|
|
16485
|
-
|
|
16486
|
-
Error Details:
|
|
16487
|
-
Error data: ${errorData || "0x (empty - no custom error)"}
|
|
16488
|
-
Error code: ${preflightError?.code || "none"}
|
|
16489
|
-
|
|
16490
|
-
Quantum Timing Analysis:
|
|
16491
|
-
Signature created: ${validationResponse.timestamp} (${new Date(
|
|
16492
|
-
validationResponse.timestamp * 1e3
|
|
16493
|
-
).toISOString()})
|
|
16494
|
-
Current time: ${currentTime2} (${new Date(
|
|
16495
|
-
currentTime2 * 1e3
|
|
16496
|
-
).toISOString()})
|
|
16497
|
-
Time elapsed: ${timeSinceSig} seconds
|
|
16498
|
-
Signature quantum: ${sigQuantum2}
|
|
16499
|
-
Current quantum: ${currentQuantum}
|
|
16500
|
-
Status: ${sigQuantum2 < currentQuantum ? "\u274C EXPIRED - Signature too old" : "\u2705 VALID"}
|
|
16501
|
-
|
|
16502
|
-
Possible Causes (when error data is empty):
|
|
16503
|
-
\u2022 Quantum signature expired (current=${currentQuantum}, signature=${sigQuantum2})
|
|
16504
|
-
\u2022 Contract paused or circuit breaker active
|
|
16505
|
-
\u2022 Position state changed since LIT Action signed
|
|
16506
|
-
\u2022 Authorization registry validation failed
|
|
16507
|
-
\u2022 RPC provider not returning detailed revert data
|
|
16508
|
-
|
|
16509
|
-
Position: ${request.positionId}`
|
|
16510
|
-
);
|
|
16511
|
-
}
|
|
16512
|
-
}
|
|
16513
16451
|
try {
|
|
16514
16452
|
const coreAddress = this.getContractAddressesOrThrow().positionManagerCore;
|
|
16515
16453
|
if (!coreAddress) {
|
|
@@ -16518,7 +16456,7 @@ Position: ${request.positionId}`
|
|
|
16518
16456
|
const coreAbi = [
|
|
16519
16457
|
"function getPositionDetails(bytes32) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status, uint40 previousExpiryAt, uint16 totalTerm))"
|
|
16520
16458
|
];
|
|
16521
|
-
const positionCore = new
|
|
16459
|
+
const positionCore = new import_ethers14.Contract(
|
|
16522
16460
|
coreAddress,
|
|
16523
16461
|
coreAbi,
|
|
16524
16462
|
this.getSignerOrThrow().provider
|
|
@@ -16526,8 +16464,8 @@ Position: ${request.positionId}`
|
|
|
16526
16464
|
const currentPosition = await positionCore["getPositionDetails"](
|
|
16527
16465
|
positionIdBytes32
|
|
16528
16466
|
);
|
|
16529
|
-
const currentDebtHash = (0,
|
|
16530
|
-
|
|
16467
|
+
const currentDebtHash = (0, import_ethers14.keccak256)(
|
|
16468
|
+
import_ethers14.AbiCoder.defaultAbiCoder().encode(
|
|
16531
16469
|
["uint256"],
|
|
16532
16470
|
[currentPosition.ucdDebt]
|
|
16533
16471
|
)
|
|
@@ -16574,7 +16512,7 @@ Position: ${request.positionId}`
|
|
|
16574
16512
|
"function getCurrentQuantum() view returns (uint256)",
|
|
16575
16513
|
"function isQuantumValid(bytes32,uint256) view returns (bool)"
|
|
16576
16514
|
];
|
|
16577
|
-
const registry = new
|
|
16515
|
+
const registry = new import_ethers14.Contract(
|
|
16578
16516
|
registryAddress,
|
|
16579
16517
|
registryAbi,
|
|
16580
16518
|
this.getSignerOrThrow().provider
|
|
@@ -16690,7 +16628,7 @@ Position: ${request.positionId}`
|
|
|
16690
16628
|
});
|
|
16691
16629
|
}
|
|
16692
16630
|
const signatureHexMint = finalSignature.startsWith("0x") ? finalSignature : "0x" + finalSignature;
|
|
16693
|
-
const mintIface = new
|
|
16631
|
+
const mintIface = new import_ethers14.Interface(positionManagerAbi);
|
|
16694
16632
|
const mintCalldata = mintIface.encodeFunctionData("mintUCD", [
|
|
16695
16633
|
positionIdBytes32,
|
|
16696
16634
|
validationResponse.mintAmount,
|
|
@@ -16704,137 +16642,122 @@ Position: ${request.positionId}`
|
|
|
16704
16642
|
validationResponse.timestamp,
|
|
16705
16643
|
signatureHexMint
|
|
16706
16644
|
]);
|
|
16707
|
-
await awaitSafeSubmissionWindow(Number(validationResponse.timestamp));
|
|
16708
16645
|
const fromAddress = await signer.getAddress();
|
|
16709
|
-
|
|
16710
|
-
|
|
16711
|
-
|
|
16712
|
-
positionManagerAddress,
|
|
16713
|
-
mintCalldata,
|
|
16714
|
-
MINT_UCD_ESTIMATE_MARGIN_BPS,
|
|
16715
|
-
MINT_UCD_GAS_CEILING
|
|
16716
|
-
);
|
|
16717
|
-
let tx;
|
|
16718
|
-
if (estimatedGas !== null) {
|
|
16719
|
-
if (this.config.debug) {
|
|
16720
|
-
log.info(
|
|
16721
|
-
`\u{1F4DD} Broadcasting mintUCD (gasLimit=${estimatedGas.toString()})`,
|
|
16722
|
-
{}
|
|
16723
|
-
);
|
|
16724
|
-
}
|
|
16725
|
-
tx = await sendEip1559Transaction({
|
|
16726
|
-
signer,
|
|
16646
|
+
try {
|
|
16647
|
+
await assertSafeQuantumSubmission({
|
|
16648
|
+
provider: signerProvider,
|
|
16727
16649
|
to: positionManagerAddress,
|
|
16650
|
+
from: fromAddress,
|
|
16728
16651
|
data: mintCalldata,
|
|
16729
|
-
|
|
16652
|
+
quantumTimestamp: Number(validationResponse.timestamp),
|
|
16653
|
+
onDebug: this.config.debug ? (msg) => log.info(msg, {}) : void 0
|
|
16730
16654
|
});
|
|
16731
|
-
}
|
|
16732
|
-
if (
|
|
16733
|
-
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
|
|
16739
|
-
|
|
16740
|
-
|
|
16741
|
-
|
|
16742
|
-
|
|
16743
|
-
|
|
16744
|
-
|
|
16745
|
-
|
|
16746
|
-
|
|
16747
|
-
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
|
|
16752
|
-
|
|
16753
|
-
|
|
16754
|
-
|
|
16755
|
-
|
|
16756
|
-
|
|
16757
|
-
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16761
|
-
|
|
16762
|
-
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
|
|
16766
|
-
|
|
16767
|
-
"0x3e76a3c9": "QuantumOutsideWindow()",
|
|
16768
|
-
"0x62278171": "InvalidValidatorSignature()",
|
|
16769
|
-
"0xb9d419a7": "DebtUpdateVerificationFailed()",
|
|
16770
|
-
"0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
|
|
16771
|
-
"0x0cfd2a97": "MintVerificationMismatch(uint256,uint256)",
|
|
16772
|
-
"0x07637bd8": "MintFailed()"
|
|
16773
|
-
};
|
|
16774
|
-
const errorName = knownErrors[selector] || `Unknown error ${selector}`;
|
|
16775
|
-
throw new Error(
|
|
16776
|
-
`mintUCD reverted: ${errorName}
|
|
16777
|
-
Error selector: ${selector}
|
|
16778
|
-
Error data: ${errorData}
|
|
16779
|
-
Call path: mintUCD -> mintUCDWithAuthorization -> increaseDebtFromMint -> finalizeMintDebtIncrease
|
|
16780
|
-
Message: ${errorMessage}`
|
|
16781
|
-
);
|
|
16782
|
-
}
|
|
16783
|
-
if (errorData === "0x" || !errorData) {
|
|
16784
|
-
const viewsAddress = this.config.contractAddresses?.positionManagerViews;
|
|
16785
|
-
if (viewsAddress) {
|
|
16786
|
-
try {
|
|
16787
|
-
const views = new import_ethers13.Contract(
|
|
16788
|
-
viewsAddress,
|
|
16789
|
-
[
|
|
16790
|
-
"function diagnoseMintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes) view returns (string)"
|
|
16791
|
-
],
|
|
16792
|
-
signerProvider
|
|
16793
|
-
);
|
|
16794
|
-
const diagnosis = await views["diagnoseMintUCD"](
|
|
16795
|
-
request.positionId,
|
|
16796
|
-
validationResponse.mintAmount,
|
|
16797
|
-
validationResponse.mintFee,
|
|
16798
|
-
validationResponse.newDebt,
|
|
16799
|
-
validationResponse.newCollateral,
|
|
16800
|
-
validationResponse.btcPrice,
|
|
16801
|
-
validationResponse.authorizedSpendsHash,
|
|
16802
|
-
ucdDebtHash,
|
|
16803
|
-
contractHash,
|
|
16804
|
-
validationResponse.timestamp,
|
|
16805
|
-
signatureHexMint
|
|
16806
|
-
);
|
|
16807
|
-
throw new Error(
|
|
16808
|
-
`mintUCD reverted with empty data; diagnosis: ${diagnosis}`
|
|
16655
|
+
} catch (simError) {
|
|
16656
|
+
if (!(simError instanceof QuantumRevertError)) {
|
|
16657
|
+
throw simError;
|
|
16658
|
+
}
|
|
16659
|
+
const simCause = simError.cause;
|
|
16660
|
+
const causeMessage = simCause?.reason ?? simCause?.shortMessage ?? (simCause instanceof Error ? simCause.message : String(simCause));
|
|
16661
|
+
if (!simError.data) {
|
|
16662
|
+
const viewsAddress = this.config.contractAddresses?.positionManagerViews;
|
|
16663
|
+
if (viewsAddress) {
|
|
16664
|
+
let diagnosis = null;
|
|
16665
|
+
try {
|
|
16666
|
+
const views = new import_ethers14.Contract(
|
|
16667
|
+
viewsAddress,
|
|
16668
|
+
[
|
|
16669
|
+
"function diagnoseMintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes) view returns (string)"
|
|
16670
|
+
],
|
|
16671
|
+
signerProvider
|
|
16672
|
+
);
|
|
16673
|
+
diagnosis = await views["diagnoseMintUCD"](
|
|
16674
|
+
request.positionId,
|
|
16675
|
+
validationResponse.mintAmount,
|
|
16676
|
+
validationResponse.mintFee,
|
|
16677
|
+
validationResponse.newDebt,
|
|
16678
|
+
validationResponse.newCollateral,
|
|
16679
|
+
validationResponse.btcPrice,
|
|
16680
|
+
validationResponse.authorizedSpendsHash,
|
|
16681
|
+
ucdDebtHash,
|
|
16682
|
+
contractHash,
|
|
16683
|
+
validationResponse.timestamp,
|
|
16684
|
+
signatureHexMint
|
|
16685
|
+
);
|
|
16686
|
+
} catch (diagErr) {
|
|
16687
|
+
if (this.config.debug) {
|
|
16688
|
+
log.info(
|
|
16689
|
+
` diagnoseMintUCD unavailable or failed: ${diagErr?.message || diagErr}`,
|
|
16690
|
+
{}
|
|
16809
16691
|
);
|
|
16810
|
-
} catch (diagErr) {
|
|
16811
|
-
if (this.config.debug) {
|
|
16812
|
-
log.info(
|
|
16813
|
-
` diagnoseMintUCD unavailable or failed: ${diagErr?.message || diagErr}`,
|
|
16814
|
-
{}
|
|
16815
|
-
);
|
|
16816
|
-
}
|
|
16817
16692
|
}
|
|
16818
16693
|
}
|
|
16694
|
+
if (diagnosis !== null) {
|
|
16695
|
+
throw new Error(
|
|
16696
|
+
`mintUCD reverted with empty data; diagnosis: ${diagnosis}`
|
|
16697
|
+
);
|
|
16698
|
+
}
|
|
16819
16699
|
}
|
|
16820
16700
|
throw new Error(
|
|
16821
|
-
`mintUCD
|
|
16822
|
-
Error data:
|
|
16701
|
+
`mintUCD would revert (pre-send simulation): ${causeMessage}
|
|
16702
|
+
Error data: none`
|
|
16823
16703
|
);
|
|
16824
16704
|
}
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
|
|
16829
|
-
|
|
16705
|
+
const selector = simError.selector;
|
|
16706
|
+
const errorName = simError.errorName ?? (selector ? `Unknown error ${selector}` : "unknown");
|
|
16707
|
+
const mintDebtDiagnostics = selector === "0xb9d419a7" || // DebtUpdateVerificationFailed()
|
|
16708
|
+
selector === "0xc7e20553" || // DebtUpdateVerificationFailedDetailed(...)
|
|
16709
|
+
selector === "0x0cfd2a97" || // MintVerificationMismatch(uint256,uint256)
|
|
16710
|
+
selector === "0x07637bd8" ? `
|
|
16711
|
+
|
|
16712
|
+
Mint/debt diagnostics (LoanOperationsManager mint path \u2192 increaseDebtFromMint):
|
|
16713
|
+
positionId: ${request.positionId}
|
|
16714
|
+
on-chain ucdDebt before tx: ${currentDebt}
|
|
16715
|
+
Lit newDebt: ${validationResponse.newDebt}
|
|
16716
|
+
Lit mintAmount: ${validationResponse.mintAmount}
|
|
16717
|
+
Lit mintFee: ${validationResponse.mintFee}
|
|
16718
|
+
Call path: mintUCD -> mintUCDWithAuthorization -> increaseDebtFromMint -> finalizeMintDebtIncrease
|
|
16719
|
+
Contract expects UCD supply increase to match mintAmount+mintFee and debt update to newDebt.
|
|
16720
|
+
` : "";
|
|
16721
|
+
let quantumContext = "";
|
|
16722
|
+
if (selector === "0x131d9a21" || // QuantumExpired()
|
|
16723
|
+
selector === "0x52ce5d58" || // QuantumAlreadyUsed()
|
|
16724
|
+
selector === "0x137f3b70" || // InDeadZone()
|
|
16725
|
+
selector === "0xbe4b82c1" || // DeadZoneViolation()
|
|
16726
|
+
selector === "0x3e76a3c9") {
|
|
16727
|
+
const nowSecs = Math.floor(Date.now() / 1e3);
|
|
16728
|
+
const nowQuantum = Math.floor(nowSecs / 60) * 60;
|
|
16729
|
+
const signedQuantum = Math.floor(Number(validationResponse.timestamp) / 60) * 60;
|
|
16730
|
+
const timeDiff = nowSecs - Number(validationResponse.timestamp);
|
|
16731
|
+
quantumContext = `
|
|
16732
|
+
|
|
16733
|
+
Quantum Timing Analysis:
|
|
16734
|
+
Signature created: ${validationResponse.timestamp} (${new Date(
|
|
16735
|
+
Number(validationResponse.timestamp) * 1e3
|
|
16736
|
+
).toISOString()})
|
|
16737
|
+
Current time: ${nowSecs} (${new Date(
|
|
16738
|
+
nowSecs * 1e3
|
|
16739
|
+
).toISOString()})
|
|
16740
|
+
Time elapsed: ${timeDiff} seconds
|
|
16741
|
+
Signature quantum: ${signedQuantum}
|
|
16742
|
+
Current quantum: ${nowQuantum}
|
|
16743
|
+
Quantum window: 60 seconds
|
|
16744
|
+
Status: ${signedQuantum < nowQuantum ? "\u274C EXPIRED - Signature created in older quantum window" : "\u2705 VALID"}
|
|
16745
|
+
Note: QuantumOutsideWindow can also occur if the tx is mined outside the accepted past/current/next quantum set.`;
|
|
16830
16746
|
}
|
|
16831
|
-
|
|
16832
|
-
|
|
16833
|
-
|
|
16834
|
-
|
|
16835
|
-
|
|
16836
|
-
|
|
16747
|
+
throw new Error(
|
|
16748
|
+
`mintUCD would revert (pre-send simulation): ${errorName}
|
|
16749
|
+
Error selector: ${selector}
|
|
16750
|
+
Error data: ${simError.data}
|
|
16751
|
+
Call path: mintUCD -> mintUCDWithAuthorization -> increaseDebtFromMint -> finalizeMintDebtIncrease
|
|
16752
|
+
Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
|
|
16753
|
+
);
|
|
16837
16754
|
}
|
|
16755
|
+
const tx = await sendEip1559Transaction({
|
|
16756
|
+
signer,
|
|
16757
|
+
to: positionManagerAddress,
|
|
16758
|
+
data: mintCalldata,
|
|
16759
|
+
gasLimit: MINT_UCD_GAS_CEILING
|
|
16760
|
+
});
|
|
16838
16761
|
const receipt = await signerProvider.waitForTransaction(
|
|
16839
16762
|
tx.hash,
|
|
16840
16763
|
1,
|
|
@@ -16850,7 +16773,7 @@ Error data: ${errorData || "none"}`
|
|
|
16850
16773
|
if (receipt.logs && receipt.logs.length > 0) {
|
|
16851
16774
|
for (const receiptLog of receipt.logs) {
|
|
16852
16775
|
if (receiptLog.topics && receiptLog.topics[0] === "0x08c379a0") {
|
|
16853
|
-
const iface = new
|
|
16776
|
+
const iface = new import_ethers14.Interface([
|
|
16854
16777
|
"error Error(string)"
|
|
16855
16778
|
]);
|
|
16856
16779
|
const decoded = iface.decodeErrorResult("Error", receiptLog.data);
|
|
@@ -16867,7 +16790,7 @@ Error data: ${errorData || "none"}`
|
|
|
16867
16790
|
const minimalAbi = [
|
|
16868
16791
|
"event UCDMintedWithAuthorization(bytes32 indexed positionId, address indexed borrower, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, uint256 quantumTimestamp, bytes32 authorizedSpendsHash)"
|
|
16869
16792
|
];
|
|
16870
|
-
const iface = new
|
|
16793
|
+
const iface = new import_ethers14.Interface(minimalAbi);
|
|
16871
16794
|
for (const receiptLog of receipt.logs) {
|
|
16872
16795
|
const parsed = (() => {
|
|
16873
16796
|
const logIface = iface;
|
|
@@ -17054,7 +16977,7 @@ Error data: ${errorData || "none"}`
|
|
|
17054
16977
|
pkpNftAddress,
|
|
17055
16978
|
this.getChipotlePublicKeyFallback()
|
|
17056
16979
|
);
|
|
17057
|
-
const pkpEthAddress = (0,
|
|
16980
|
+
const pkpEthAddress = (0, import_ethers14.computeAddress)(pkpPublicKey);
|
|
17058
16981
|
pkpData = {
|
|
17059
16982
|
publicKey: pkpPublicKey,
|
|
17060
16983
|
ethAddress: pkpEthAddress,
|
|
@@ -17456,7 +17379,7 @@ Error data: ${errorData || "none"}`
|
|
|
17456
17379
|
}
|
|
17457
17380
|
const loanOpsForUcd = loanOpsForUcdResult.value;
|
|
17458
17381
|
const ucdTokenAddress = await loanOpsForUcd.ucdToken();
|
|
17459
|
-
const ucdToken = new
|
|
17382
|
+
const ucdToken = new import_ethers14.Contract(
|
|
17460
17383
|
ucdTokenAddress,
|
|
17461
17384
|
[
|
|
17462
17385
|
"function balanceOf(address) view returns (uint256)",
|
|
@@ -17472,9 +17395,9 @@ Error data: ${errorData || "none"}`
|
|
|
17472
17395
|
if (ucdBalance < debtWei) {
|
|
17473
17396
|
return {
|
|
17474
17397
|
success: false,
|
|
17475
|
-
error: `Insufficient UCD balance for liquidation: ${(0,
|
|
17398
|
+
error: `Insufficient UCD balance for liquidation: ${(0, import_ethers14.formatEther)(
|
|
17476
17399
|
ucdBalance
|
|
17477
|
-
)} UCD (need ${(0,
|
|
17400
|
+
)} UCD (need ${(0, import_ethers14.formatEther)(debtWei)} UCD)`,
|
|
17478
17401
|
positionId: request.positionId,
|
|
17479
17402
|
wasLiquidated: false
|
|
17480
17403
|
};
|
|
@@ -17483,7 +17406,7 @@ Error data: ${errorData || "none"}`
|
|
|
17483
17406
|
if (request.skipUcdApproval) {
|
|
17484
17407
|
return {
|
|
17485
17408
|
success: false,
|
|
17486
|
-
error: `Insufficient UCD allowance for UCDController: need at least ${(0,
|
|
17409
|
+
error: `Insufficient UCD allowance for UCDController: need at least ${(0, import_ethers14.formatEther)(
|
|
17487
17410
|
debtWei
|
|
17488
17411
|
)} UCD, or omit skipUcdApproval to let the SDK submit approve`,
|
|
17489
17412
|
positionId: request.positionId,
|
|
@@ -17987,7 +17910,7 @@ Error data: ${errorData || "none"}`
|
|
|
17987
17910
|
if (typeof signatureBytes === "string" && signatureBytes.startsWith("{")) {
|
|
17988
17911
|
try {
|
|
17989
17912
|
const parsed = JSON.parse(signatureBytes);
|
|
17990
|
-
signatureBytes = parsed.signature ?? (parsed.r && parsed.s && parsed.v ?
|
|
17913
|
+
signatureBytes = parsed.signature ?? (parsed.r && parsed.s && parsed.v ? import_ethers14.Signature.from({
|
|
17991
17914
|
r: parsed.r,
|
|
17992
17915
|
s: parsed.s,
|
|
17993
17916
|
v: parsed.v
|
|
@@ -17998,26 +17921,43 @@ Error data: ${errorData || "none"}`
|
|
|
17998
17921
|
if (!signatureBytes.startsWith("0x")) {
|
|
17999
17922
|
signatureBytes = "0x" + signatureBytes;
|
|
18000
17923
|
}
|
|
18001
|
-
const
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
`Failed to get PositionManager: ${positionManagerResult.error.message}`
|
|
18006
|
-
);
|
|
18007
|
-
}
|
|
18008
|
-
const positionManager = positionManagerResult.value;
|
|
18009
|
-
await awaitSafeSubmissionWindow(Number(quantumTimestamp));
|
|
18010
|
-
const extendPositionFn = positionManager["extendPosition"];
|
|
18011
|
-
const tx = await extendPositionFn(
|
|
17924
|
+
const extendIface = new import_ethers14.Interface([
|
|
17925
|
+
"function extendPosition(bytes32 positionId, uint256 selectedTerm, uint256 quantumTimestamp, uint256 btcPrice, uint256 availableBTCBalance, uint256 proRataRenewalFee, bytes calldata extensionValidatorSignature) external returns (bool)"
|
|
17926
|
+
]);
|
|
17927
|
+
const extendCalldata = extendIface.encodeFunctionData("extendPosition", [
|
|
18012
17928
|
positionIdBytes32,
|
|
18013
17929
|
BigInt(_selectedTerm),
|
|
18014
17930
|
quantumTimestamp,
|
|
18015
17931
|
btcPrice,
|
|
18016
17932
|
availableBTCBalance,
|
|
18017
17933
|
proRataRenewalFee,
|
|
18018
|
-
signatureBytes
|
|
18019
|
-
|
|
18020
|
-
);
|
|
17934
|
+
signatureBytes
|
|
17935
|
+
]);
|
|
17936
|
+
const extendTo = this.getContractAddressesOrThrow().positionManager;
|
|
17937
|
+
const extendSigner = this.getSignerOrThrow();
|
|
17938
|
+
try {
|
|
17939
|
+
await assertSafeQuantumSubmission({
|
|
17940
|
+
provider: this.getProviderOrThrow(),
|
|
17941
|
+
to: extendTo,
|
|
17942
|
+
from: await extendSigner.getAddress(),
|
|
17943
|
+
data: extendCalldata,
|
|
17944
|
+
quantumTimestamp: Number(quantumTimestamp),
|
|
17945
|
+
onDebug: this.config.debug ? (msg) => log.info(msg, {}) : void 0
|
|
17946
|
+
});
|
|
17947
|
+
} catch (simError) {
|
|
17948
|
+
if (!(simError instanceof QuantumRevertError)) {
|
|
17949
|
+
throw simError;
|
|
17950
|
+
}
|
|
17951
|
+
throw new Error(
|
|
17952
|
+
`extendPosition would revert (pre-send simulation): ${simError.errorName ?? simError.selector ?? "unknown"}`
|
|
17953
|
+
);
|
|
17954
|
+
}
|
|
17955
|
+
const tx = await sendEip1559Transaction({
|
|
17956
|
+
signer: extendSigner,
|
|
17957
|
+
to: extendTo,
|
|
17958
|
+
data: extendCalldata,
|
|
17959
|
+
gasLimit: EXTEND_POSITION_GAS_CEILING
|
|
17960
|
+
});
|
|
18021
17961
|
const txWithProvider = tx;
|
|
18022
17962
|
if (!txWithProvider.provider) {
|
|
18023
17963
|
const signer2 = this.getSignerOrThrow();
|
|
@@ -18530,7 +18470,7 @@ Error data: ${errorData || "none"}`
|
|
|
18530
18470
|
` Converting payment amount: ${request.paymentAmount} (type: ${typeof request.paymentAmount})`
|
|
18531
18471
|
);
|
|
18532
18472
|
}
|
|
18533
|
-
const paymentAmountWei = (0,
|
|
18473
|
+
const paymentAmountWei = (0, import_ethers14.parseEther)(
|
|
18534
18474
|
request.paymentAmount.toString()
|
|
18535
18475
|
);
|
|
18536
18476
|
if (this.config.debug) {
|
|
@@ -18592,7 +18532,7 @@ Error data: ${errorData || "none"}`
|
|
|
18592
18532
|
};
|
|
18593
18533
|
}
|
|
18594
18534
|
const ucdTokenAddress = await loanOps.ucdToken();
|
|
18595
|
-
const ucdToken = new
|
|
18535
|
+
const ucdToken = new import_ethers14.Contract(
|
|
18596
18536
|
ucdTokenAddress,
|
|
18597
18537
|
[
|
|
18598
18538
|
"function balanceOf(address) view returns (uint256)",
|
|
@@ -18607,16 +18547,16 @@ Error data: ${errorData || "none"}`
|
|
|
18607
18547
|
ucdToken["allowance"](signerAddress, positionManagerAddress)
|
|
18608
18548
|
]);
|
|
18609
18549
|
if (this.config.debug) {
|
|
18610
|
-
log.info(` UCD Balance: ${(0,
|
|
18550
|
+
log.info(` UCD Balance: ${(0, import_ethers14.formatEther)(balance)} UCD`);
|
|
18611
18551
|
log.info(
|
|
18612
|
-
` UCD Allowance: ${(0,
|
|
18552
|
+
` UCD Allowance: ${(0, import_ethers14.formatEther)(allowance)} UCD`
|
|
18613
18553
|
);
|
|
18614
18554
|
log.info(` Required: ${request.paymentAmount} UCD`);
|
|
18615
18555
|
}
|
|
18616
18556
|
if (balance < paymentAmountWei) {
|
|
18617
18557
|
return {
|
|
18618
18558
|
success: false,
|
|
18619
|
-
error: `Insufficient UCD balance: ${(0,
|
|
18559
|
+
error: `Insufficient UCD balance: ${(0, import_ethers14.formatEther)(
|
|
18620
18560
|
balance
|
|
18621
18561
|
)} UCD (need ${request.paymentAmount} UCD)`
|
|
18622
18562
|
};
|
|
@@ -18877,7 +18817,6 @@ Error data: ${errorData || "none"}`
|
|
|
18877
18817
|
quantumTimestamp: quantumTimestamp.toString()
|
|
18878
18818
|
});
|
|
18879
18819
|
}
|
|
18880
|
-
await awaitSafeSubmissionWindow(Number(quantumTimestamp));
|
|
18881
18820
|
const paymentAmountStr = paymentAmountWei.toString();
|
|
18882
18821
|
const quantumTimestampStr = quantumTimestamp.toString();
|
|
18883
18822
|
const btcPriceStr = btcPrice.toString();
|
|
@@ -18885,7 +18824,7 @@ Error data: ${errorData || "none"}`
|
|
|
18885
18824
|
const paymentSigner = this.getSignerOrThrow();
|
|
18886
18825
|
const paymentFrom = await paymentSigner.getAddress();
|
|
18887
18826
|
const paymentProvider = contractManager.getProvider();
|
|
18888
|
-
const paymentIface = new
|
|
18827
|
+
const paymentIface = new import_ethers14.Interface([
|
|
18889
18828
|
"function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)"
|
|
18890
18829
|
]);
|
|
18891
18830
|
const paymentCalldata = paymentIface.encodeFunctionData("makePayment", [
|
|
@@ -18895,71 +18834,30 @@ Error data: ${errorData || "none"}`
|
|
|
18895
18834
|
btcPriceStr,
|
|
18896
18835
|
signature
|
|
18897
18836
|
]);
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
return map2[selector] ?? `Unknown error ${selector}`;
|
|
18916
|
-
};
|
|
18917
|
-
const MAX_DEADZONE_RESIMULATIONS = 3;
|
|
18918
|
-
for (let sim = 1; ; sim++) {
|
|
18919
|
-
try {
|
|
18920
|
-
await paymentProvider.call({
|
|
18921
|
-
to: paymentContractAddress,
|
|
18922
|
-
from: paymentFrom,
|
|
18923
|
-
data: paymentCalldata
|
|
18924
|
-
});
|
|
18925
|
-
break;
|
|
18926
|
-
} catch (simError) {
|
|
18927
|
-
const decoded = decodePaymentRevert(simError);
|
|
18928
|
-
if (decoded === "DeadZoneViolation()" && sim <= MAX_DEADZONE_RESIMULATIONS) {
|
|
18929
|
-
const nowSec = Math.floor(Date.now() / 1e3);
|
|
18930
|
-
const sigQuantum = Math.floor(Number(quantumTimestamp) / 60) * 60;
|
|
18931
|
-
const realCurrentQuantum = Math.floor(nowSec / 60) * 60;
|
|
18932
|
-
if (sigQuantum === realCurrentQuantum) {
|
|
18933
|
-
if (this.config.debug) {
|
|
18934
|
-
log.info(
|
|
18935
|
-
"\u21AA\uFE0F Simulated DeadZoneViolation is a stale-latest-block artifact (signature is the current quantum) \u2014 proceeding to broadcast",
|
|
18936
|
-
{}
|
|
18937
|
-
);
|
|
18938
|
-
}
|
|
18939
|
-
break;
|
|
18940
|
-
}
|
|
18941
|
-
const gate = await awaitSafeSubmissionWindow(Number(quantumTimestamp));
|
|
18942
|
-
if (gate.waited) {
|
|
18943
|
-
if (this.config.debug) {
|
|
18944
|
-
log.info(
|
|
18945
|
-
`\u{1F501} Re-simulating makePayment after crossing the quantum boundary (attempt ${sim}/${MAX_DEADZONE_RESIMULATIONS})`,
|
|
18946
|
-
{}
|
|
18947
|
-
);
|
|
18948
|
-
}
|
|
18949
|
-
continue;
|
|
18950
|
-
}
|
|
18951
|
-
}
|
|
18952
|
-
const label = decoded ?? simError?.reason ?? simError?.shortMessage ?? (simError instanceof Error ? simError.message : String(simError));
|
|
18953
|
-
if (this.config.debug) {
|
|
18954
|
-
log.error("\u274C makePayment pre-send simulation reverted", { error: label });
|
|
18955
|
-
}
|
|
18956
|
-
return {
|
|
18957
|
-
success: false,
|
|
18958
|
-
error: `Payment would revert (pre-send simulation): ${label}`,
|
|
18959
|
-
positionId: request.positionId,
|
|
18960
|
-
paymentAmountUCD: request.paymentAmount
|
|
18961
|
-
};
|
|
18837
|
+
try {
|
|
18838
|
+
await assertSafeQuantumSubmission({
|
|
18839
|
+
provider: paymentProvider,
|
|
18840
|
+
to: paymentContractAddress,
|
|
18841
|
+
from: paymentFrom,
|
|
18842
|
+
data: paymentCalldata,
|
|
18843
|
+
quantumTimestamp: Number(quantumTimestamp),
|
|
18844
|
+
onDebug: this.config.debug ? (msg) => log.info(msg, {}) : void 0
|
|
18845
|
+
});
|
|
18846
|
+
} catch (simError) {
|
|
18847
|
+
if (!(simError instanceof QuantumRevertError)) {
|
|
18848
|
+
throw simError;
|
|
18849
|
+
}
|
|
18850
|
+
const simCause = simError.cause;
|
|
18851
|
+
const label = simError.errorName ?? (simError.selector ? `Unknown error ${simError.selector}` : null) ?? simCause?.reason ?? simCause?.shortMessage ?? (simCause instanceof Error ? simCause.message : String(simCause));
|
|
18852
|
+
if (this.config.debug) {
|
|
18853
|
+
log.error("\u274C makePayment pre-send simulation reverted", { error: label });
|
|
18962
18854
|
}
|
|
18855
|
+
return {
|
|
18856
|
+
success: false,
|
|
18857
|
+
error: `Payment would revert (pre-send simulation): ${label}`,
|
|
18858
|
+
positionId: request.positionId,
|
|
18859
|
+
paymentAmountUCD: request.paymentAmount
|
|
18860
|
+
};
|
|
18963
18861
|
}
|
|
18964
18862
|
const tx = await sendEip1559Transaction({
|
|
18965
18863
|
signer: paymentSigner,
|
|
@@ -19242,7 +19140,7 @@ Error data: ${errorData || "none"}`
|
|
|
19242
19140
|
const pkpId = position.pkpId;
|
|
19243
19141
|
if (litValidatorAddr && pkpId) {
|
|
19244
19142
|
try {
|
|
19245
|
-
const litValidator = new
|
|
19143
|
+
const litValidator = new import_ethers14.Contract(
|
|
19246
19144
|
litValidatorAddr,
|
|
19247
19145
|
["function pkpOwners(bytes32) view returns (address)"],
|
|
19248
19146
|
this.getProviderOrThrow()
|
|
@@ -19250,7 +19148,7 @@ Error data: ${errorData || "none"}`
|
|
|
19250
19148
|
const owner = await litValidator.pkpOwners(
|
|
19251
19149
|
pkpId
|
|
19252
19150
|
);
|
|
19253
|
-
if (owner && owner !==
|
|
19151
|
+
if (owner && owner !== import_ethers14.ZeroAddress) {
|
|
19254
19152
|
controller = owner;
|
|
19255
19153
|
}
|
|
19256
19154
|
} catch {
|
|
@@ -19302,7 +19200,7 @@ Error data: ${errorData || "none"}`
|
|
|
19302
19200
|
pkpNftAddress,
|
|
19303
19201
|
this.getChipotlePublicKeyFallback()
|
|
19304
19202
|
);
|
|
19305
|
-
pkpEthAddress = (0,
|
|
19203
|
+
pkpEthAddress = (0, import_ethers14.computeAddress)(pkpPublicKey);
|
|
19306
19204
|
pkpCache.set(positionId, {
|
|
19307
19205
|
publicKey: pkpPublicKey,
|
|
19308
19206
|
ethAddress: pkpEthAddress,
|
|
@@ -19633,13 +19531,6 @@ Error data: ${errorData || "none"}`
|
|
|
19633
19531
|
error: "PositionManager address not configured"
|
|
19634
19532
|
};
|
|
19635
19533
|
}
|
|
19636
|
-
const positionManagerContract = new import_ethers13.Contract(
|
|
19637
|
-
positionManagerAddress,
|
|
19638
|
-
[
|
|
19639
|
-
"function withdrawBTC((bytes32 positionId, bytes32 actionHash, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractBundleHash, string withdrawalAddress, uint256 totalDeduction, uint256 newCollateral, uint256 quantumTimestamp, uint256 btcPrice, string utxoTxid, uint32 utxoVout) params, bytes withdrawalValidatorSignature, bytes btcSpendAuthSignature) external returns (bool)"
|
|
19640
|
-
],
|
|
19641
|
-
this.getSignerOrThrow()
|
|
19642
|
-
);
|
|
19643
19534
|
const withdrawalParams = {
|
|
19644
19535
|
positionId: positionIdBytes32,
|
|
19645
19536
|
actionHash: validationResponse.actionHash,
|
|
@@ -19672,82 +19563,56 @@ Error data: ${errorData || "none"}`
|
|
|
19672
19563
|
utxoVout: withdrawalParams.utxoVout
|
|
19673
19564
|
});
|
|
19674
19565
|
}
|
|
19675
|
-
|
|
19566
|
+
const withdrawIface = new import_ethers14.Interface([
|
|
19567
|
+
"function withdrawBTC((bytes32 positionId, bytes32 actionHash, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractBundleHash, string withdrawalAddress, uint256 totalDeduction, uint256 newCollateral, uint256 quantumTimestamp, uint256 btcPrice, string utxoTxid, uint32 utxoVout) params, bytes withdrawalValidatorSignature, bytes btcSpendAuthSignature) external returns (bool)"
|
|
19568
|
+
]);
|
|
19569
|
+
const withdrawCalldata = withdrawIface.encodeFunctionData("withdrawBTC", [
|
|
19570
|
+
withdrawalParams,
|
|
19571
|
+
signatureBytes,
|
|
19572
|
+
btcSpendAuthBytes
|
|
19573
|
+
]);
|
|
19574
|
+
const withdrawSigner = this.getSignerOrThrow();
|
|
19676
19575
|
let tx;
|
|
19677
19576
|
try {
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
-
|
|
19681
|
-
|
|
19682
|
-
|
|
19577
|
+
await assertSafeQuantumSubmission({
|
|
19578
|
+
provider: this.getProviderOrThrow(),
|
|
19579
|
+
to: positionManagerAddress,
|
|
19580
|
+
from: await withdrawSigner.getAddress(),
|
|
19581
|
+
data: withdrawCalldata,
|
|
19582
|
+
quantumTimestamp: Number(withdrawalParams.quantumTimestamp),
|
|
19583
|
+
onDebug: this.config.debug ? (msg) => log.info(msg, {}) : void 0
|
|
19584
|
+
});
|
|
19585
|
+
tx = await sendEip1559Transaction({
|
|
19586
|
+
signer: withdrawSigner,
|
|
19587
|
+
to: positionManagerAddress,
|
|
19588
|
+
data: withdrawCalldata,
|
|
19589
|
+
gasLimit: WITHDRAW_BTC_GAS_CEILING
|
|
19590
|
+
});
|
|
19683
19591
|
} catch (txError) {
|
|
19684
|
-
const txErrorMsg = txError instanceof Error ? txError.message : String(txError);
|
|
19592
|
+
const txErrorMsg = txError instanceof QuantumRevertError ? `Withdrawal would revert (pre-send simulation): ${txError.errorName ?? txError.selector ?? "unknown"}` : txError instanceof Error ? txError.message : String(txError);
|
|
19685
19593
|
if (this.config.debug) {
|
|
19686
|
-
log.
|
|
19687
|
-
|
|
19688
|
-
|
|
19689
|
-
|
|
19594
|
+
log.error("\u274C withdrawBTC transaction submission failed", {
|
|
19595
|
+
error: txErrorMsg,
|
|
19596
|
+
withdrawalParams,
|
|
19597
|
+
signatureBytesLength: signatureBytes.length
|
|
19598
|
+
});
|
|
19690
19599
|
}
|
|
19691
19600
|
try {
|
|
19692
|
-
const
|
|
19693
|
-
const
|
|
19694
|
-
|
|
19695
|
-
|
|
19696
|
-
|
|
19697
|
-
|
|
19698
|
-
|
|
19699
|
-
btcSpendAuthBytes
|
|
19700
|
-
]);
|
|
19701
|
-
const signer = this.getSignerOrThrow();
|
|
19702
|
-
const fromAddress = await signer.getAddress();
|
|
19703
|
-
const estimatedGas = await estimateContractCallGasWithMargin(
|
|
19704
|
-
this.getProviderOrThrow(),
|
|
19705
|
-
fromAddress,
|
|
19706
|
-
contractAddress,
|
|
19707
|
-
calldata,
|
|
19708
|
-
MINT_UCD_ESTIMATE_MARGIN_BPS,
|
|
19709
|
-
WITHDRAW_BTC_GAS_CEILING
|
|
19601
|
+
const position = await this.getPosition(positionId);
|
|
19602
|
+
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
19603
|
+
const message = formatBTCWithdrawalFailureMessage(
|
|
19604
|
+
btcAmount,
|
|
19605
|
+
position?.vaultAddress || "unknown",
|
|
19606
|
+
withdrawalAddress,
|
|
19607
|
+
positionId
|
|
19710
19608
|
);
|
|
19711
|
-
|
|
19712
|
-
|
|
19713
|
-
to: contractAddress,
|
|
19714
|
-
data: calldata,
|
|
19715
|
-
value: "0x0",
|
|
19716
|
-
gasLimit
|
|
19717
|
-
});
|
|
19718
|
-
if (this.config.debug) {
|
|
19719
|
-
log.info("\u2705 withdrawBTC raw transaction fallback succeeded", {
|
|
19720
|
-
txHash: tx.hash,
|
|
19721
|
-
gasLimit: gasLimit.toString(),
|
|
19722
|
-
estimated: estimatedGas !== null
|
|
19723
|
-
});
|
|
19724
|
-
}
|
|
19725
|
-
} catch (rawError) {
|
|
19726
|
-
const rawErrorMsg = rawError instanceof Error ? rawError.message : String(rawError);
|
|
19727
|
-
if (this.config.debug) {
|
|
19728
|
-
log.error("\u274C withdrawBTC transaction failed (raw fallback also failed)", {
|
|
19729
|
-
error: rawErrorMsg,
|
|
19730
|
-
withdrawalParams,
|
|
19731
|
-
signatureBytesLength: signatureBytes.length
|
|
19732
|
-
});
|
|
19733
|
-
}
|
|
19734
|
-
try {
|
|
19735
|
-
const position = await this.getPosition(positionId);
|
|
19736
|
-
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
19737
|
-
const message = formatBTCWithdrawalFailureMessage(
|
|
19738
|
-
btcAmount,
|
|
19739
|
-
position?.vaultAddress || "unknown",
|
|
19740
|
-
withdrawalAddress,
|
|
19741
|
-
positionId
|
|
19742
|
-
);
|
|
19743
|
-
await this._relayNotification(message);
|
|
19744
|
-
} catch {
|
|
19745
|
-
}
|
|
19746
|
-
return {
|
|
19747
|
-
success: false,
|
|
19748
|
-
error: `Transaction submission failed: ${rawErrorMsg}`
|
|
19749
|
-
};
|
|
19609
|
+
await this._relayNotification(message);
|
|
19610
|
+
} catch {
|
|
19750
19611
|
}
|
|
19612
|
+
return {
|
|
19613
|
+
success: false,
|
|
19614
|
+
error: `Transaction submission failed: ${txErrorMsg}`
|
|
19615
|
+
};
|
|
19751
19616
|
}
|
|
19752
19617
|
if (this.config.debug) {
|
|
19753
19618
|
log.info("\u2705 Transaction submitted, waiting for confirmation:", {
|
|
@@ -19770,6 +19635,12 @@ Error data: ${errorData || "none"}`
|
|
|
19770
19635
|
error: `Transaction confirmation failed: ${waitErrorMsg}`
|
|
19771
19636
|
};
|
|
19772
19637
|
}
|
|
19638
|
+
if (!receipt) {
|
|
19639
|
+
return {
|
|
19640
|
+
success: false,
|
|
19641
|
+
error: `Transaction confirmation returned no receipt. Hash: ${tx.hash}`
|
|
19642
|
+
};
|
|
19643
|
+
}
|
|
19773
19644
|
if (this.config.debug) {
|
|
19774
19645
|
log.info("\u2705 BTC withdrawal confirmed", {
|
|
19775
19646
|
blockNumber: receipt.blockNumber,
|
|
@@ -20037,7 +19908,7 @@ Error data: ${errorData || "none"}`
|
|
|
20037
19908
|
const btcSpendAuthorizerAbi = [
|
|
20038
19909
|
"function getAuthorizedSpends(bytes32) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"
|
|
20039
19910
|
];
|
|
20040
|
-
const btcSpendAuthorizer = new
|
|
19911
|
+
const btcSpendAuthorizer = new import_ethers14.Contract(
|
|
20041
19912
|
btcSpendAuthorizerAddress,
|
|
20042
19913
|
btcSpendAuthorizerAbi,
|
|
20043
19914
|
this.getProviderOrThrow()
|
|
@@ -20123,7 +19994,7 @@ Error data: ${errorData || "none"}`
|
|
|
20123
19994
|
const abi = [
|
|
20124
19995
|
"function getAuthorizedSpends(bytes32) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"
|
|
20125
19996
|
];
|
|
20126
|
-
const contract = new
|
|
19997
|
+
const contract = new import_ethers14.Contract(
|
|
20127
19998
|
btcSpendAuthorizerAddress,
|
|
20128
19999
|
abi,
|
|
20129
20000
|
this.getProviderOrThrow()
|
|
@@ -20137,7 +20008,7 @@ Error data: ${errorData || "none"}`
|
|
|
20137
20008
|
targetAddress: spend.targetAddress,
|
|
20138
20009
|
targetAmount: Number(spend.targetAmount),
|
|
20139
20010
|
authorizedAt: Number(spend.authorizedAt),
|
|
20140
|
-
utxoKey: (0,
|
|
20011
|
+
utxoKey: (0, import_ethers14.solidityPackedKeccak256)(
|
|
20141
20012
|
["string", "uint32"],
|
|
20142
20013
|
[spend.txid, Number(spend.vout)]
|
|
20143
20014
|
)
|
|
@@ -20273,7 +20144,7 @@ Error data: ${errorData || "none"}`
|
|
|
20273
20144
|
error: attRes.error ?? attRes.reason ?? `LIT recovery attestation rejected${attRes.failedStep ? ` at step ${attRes.failedStep}` : ""}`
|
|
20274
20145
|
};
|
|
20275
20146
|
}
|
|
20276
|
-
const btcSpendAuthorizer = new
|
|
20147
|
+
const btcSpendAuthorizer = new import_ethers14.Contract(
|
|
20277
20148
|
btcSpendAuthorizerAddress,
|
|
20278
20149
|
[
|
|
20279
20150
|
"function cancelStaleSpendWithProof(bytes32 positionId, bytes32 utxoKey, uint256 authorizedAt, string calldata invalidatorTxid, uint256 attestationTimestamp, bytes calldata litSignature) external"
|
|
@@ -20668,10 +20539,10 @@ Error data: ${errorData || "none"}`
|
|
|
20668
20539
|
"function allowance(address owner, address spender) view returns (uint256)",
|
|
20669
20540
|
"function approve(address spender, uint256 amount) returns (bool)"
|
|
20670
20541
|
];
|
|
20671
|
-
const stablecoin = new
|
|
20542
|
+
const stablecoin = new import_ethers14.Contract(params.stablecoinAddress, erc20Abi, params.signer);
|
|
20672
20543
|
const allowance = await stablecoin.allowance(signerAddress, psmAddress);
|
|
20673
20544
|
if (allowance < params.amountWei) {
|
|
20674
|
-
const approveTx = await stablecoin.approve(psmAddress,
|
|
20545
|
+
const approveTx = await stablecoin.approve(psmAddress, import_ethers14.MaxUint256);
|
|
20675
20546
|
await approveTx.wait();
|
|
20676
20547
|
}
|
|
20677
20548
|
const psm = SimplePSMV2__factory.connect(psmAddress, params.signer);
|
|
@@ -20706,10 +20577,10 @@ Error data: ${errorData || "none"}`
|
|
|
20706
20577
|
"function allowance(address owner, address spender) view returns (uint256)",
|
|
20707
20578
|
"function approve(address spender, uint256 amount) returns (bool)"
|
|
20708
20579
|
];
|
|
20709
|
-
const ucdToken = new
|
|
20580
|
+
const ucdToken = new import_ethers14.Contract(ucdAddress, erc20Abi, params.signer);
|
|
20710
20581
|
const allowance = await ucdToken.allowance(signerAddress, ucdControllerAddress);
|
|
20711
20582
|
if (allowance < params.ucdAmountWei) {
|
|
20712
|
-
const approveTx = await ucdToken.approve(ucdControllerAddress,
|
|
20583
|
+
const approveTx = await ucdToken.approve(ucdControllerAddress, import_ethers14.MaxUint256);
|
|
20713
20584
|
await approveTx.wait();
|
|
20714
20585
|
}
|
|
20715
20586
|
const psm = SimplePSMV2__factory.connect(psmAddress, params.signer);
|
|
@@ -20921,7 +20792,7 @@ Error data: ${errorData || "none"}`
|
|
|
20921
20792
|
const maxUcdWhole = BigInt(result[3].toString());
|
|
20922
20793
|
return success({
|
|
20923
20794
|
liquidationThreshold: result[0].toString(),
|
|
20924
|
-
minimumLoanValueUcd: (0,
|
|
20795
|
+
minimumLoanValueUcd: (0, import_ethers14.formatUnits)(result[2], 18),
|
|
20925
20796
|
minimumLoanValueWei: result[2].toString(),
|
|
20926
20797
|
maxSingleLoanValueUcd: maxUcdWhole.toString(),
|
|
20927
20798
|
maxSingleLoanValueWei: (maxUcdWhole * 10n ** 18n).toString()
|
|
@@ -20958,7 +20829,7 @@ Error data: ${errorData || "none"}`
|
|
|
20958
20829
|
const balanceWei = await provider.getBalance(address);
|
|
20959
20830
|
return success({
|
|
20960
20831
|
balanceWei: balanceWei.toString(),
|
|
20961
|
-
balanceEth: (0,
|
|
20832
|
+
balanceEth: (0, import_ethers14.formatEther)(balanceWei)
|
|
20962
20833
|
});
|
|
20963
20834
|
} catch (error) {
|
|
20964
20835
|
return failure(new SDKError({
|
|
@@ -21297,7 +21168,7 @@ Error data: ${errorData || "none"}`
|
|
|
21297
21168
|
* Convert decimal position ID to bytes32 format
|
|
21298
21169
|
*/
|
|
21299
21170
|
toBytes32(value) {
|
|
21300
|
-
return (0,
|
|
21171
|
+
return (0, import_ethers14.zeroPadValue)((0, import_ethers14.toBeHex)(BigInt(value)), 32);
|
|
21301
21172
|
}
|
|
21302
21173
|
/**
|
|
21303
21174
|
* Check if an error indicates a technical failure vs business logic rejection
|
|
@@ -21338,7 +21209,7 @@ Error data: ${errorData || "none"}`
|
|
|
21338
21209
|
const coreModuleAbi = [
|
|
21339
21210
|
"function getPositionDetails(bytes32) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status, uint40 previousExpiryAt, uint16 totalTerm))"
|
|
21340
21211
|
];
|
|
21341
|
-
const coreModule = new
|
|
21212
|
+
const coreModule = new import_ethers14.Contract(
|
|
21342
21213
|
coreModuleAddress,
|
|
21343
21214
|
coreModuleAbi,
|
|
21344
21215
|
provider
|
|
@@ -21405,7 +21276,7 @@ Error data: ${errorData || "none"}`
|
|
|
21405
21276
|
const corePositionAbi = [
|
|
21406
21277
|
"function getPositionDetails(bytes32) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status, uint40 previousExpiryAt, uint16 totalTerm))"
|
|
21407
21278
|
];
|
|
21408
|
-
const corePositionContract = new
|
|
21279
|
+
const corePositionContract = new import_ethers14.Contract(
|
|
21409
21280
|
coreAddress,
|
|
21410
21281
|
corePositionAbi,
|
|
21411
21282
|
provider
|
|
@@ -21416,7 +21287,7 @@ Error data: ${errorData || "none"}`
|
|
|
21416
21287
|
positionIdBytes32
|
|
21417
21288
|
);
|
|
21418
21289
|
const positionIdFromCore = corePosition?.positionId || corePosition?.[0] || null;
|
|
21419
|
-
if (positionIdFromCore && positionIdFromCore !==
|
|
21290
|
+
if (positionIdFromCore && positionIdFromCore !== import_ethers14.ZeroHash && positionIdFromCore !== "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
21420
21291
|
if (this.config.debug) {
|
|
21421
21292
|
log.info("Position exists in core contract", {
|
|
21422
21293
|
positionId,
|
|
@@ -21484,7 +21355,7 @@ Error data: ${errorData || "none"}`
|
|
|
21484
21355
|
throw new Error("loanOperationsManager address not configured");
|
|
21485
21356
|
}
|
|
21486
21357
|
const runner = this.config.contractSigner || this.getProviderOrThrow();
|
|
21487
|
-
const contract = new
|
|
21358
|
+
const contract = new import_ethers14.Contract(
|
|
21488
21359
|
addr.loanOperationsManager,
|
|
21489
21360
|
[
|
|
21490
21361
|
"function getProtocolConfig() external view returns (uint256 liquidationThreshold, uint256 minimumLoanValueUcd, uint256 minimumLoanValueWei, uint256 maxSingleLoanValueUcd)"
|
|
@@ -21497,7 +21368,7 @@ Error data: ${errorData || "none"}`
|
|
|
21497
21368
|
const maxUcdWhole = BigInt(result[3].toString());
|
|
21498
21369
|
return {
|
|
21499
21370
|
liquidationThreshold: result[0].toString(),
|
|
21500
|
-
minimumLoanValueUcd: (0,
|
|
21371
|
+
minimumLoanValueUcd: (0, import_ethers14.formatUnits)(result[2], 18),
|
|
21501
21372
|
minimumLoanValueWei: result[2].toString(),
|
|
21502
21373
|
maxSingleLoanValueUcd: maxUcdWhole.toString(),
|
|
21503
21374
|
maxSingleLoanValueWei: (maxUcdWhole * 10n ** 18n).toString()
|
|
@@ -21515,8 +21386,8 @@ Error data: ${errorData || "none"}`
|
|
|
21515
21386
|
const MIN_REVEAL_DELAY = 60;
|
|
21516
21387
|
const MAX_RANDOM_DELAY = 240;
|
|
21517
21388
|
const entropyInput = positionId + quantumTimestamp.toString();
|
|
21518
|
-
const hash = (0,
|
|
21519
|
-
(0,
|
|
21389
|
+
const hash = (0, import_ethers14.keccak256)(
|
|
21390
|
+
(0, import_ethers14.toUtf8Bytes)(entropyInput)
|
|
21520
21391
|
);
|
|
21521
21392
|
const randomValue = BigInt(hash);
|
|
21522
21393
|
const randomDelay = Number(randomValue % BigInt(MAX_RANDOM_DELAY));
|
|
@@ -21579,7 +21450,7 @@ Error data: ${errorData || "none"}`
|
|
|
21579
21450
|
const vrfSeedRaw = await lmResult.value["vrfSeeds"](positionId);
|
|
21580
21451
|
const vrfSeed = BigInt(vrfSeedRaw.toString());
|
|
21581
21452
|
if (vrfSeed !== 0n) {
|
|
21582
|
-
const finalEntropy = (0,
|
|
21453
|
+
const finalEntropy = (0, import_ethers14.solidityPackedKeccak256)(
|
|
21583
21454
|
["uint256", "uint256", "bytes32"],
|
|
21584
21455
|
[vrfSeed, BigInt(quantumTimestamp.toString()), positionId]
|
|
21585
21456
|
);
|
|
@@ -21857,14 +21728,14 @@ var EventHelpers = {
|
|
|
21857
21728
|
};
|
|
21858
21729
|
|
|
21859
21730
|
// src/utils/position-delegate.utils.ts
|
|
21860
|
-
var
|
|
21731
|
+
var import_ethers15 = require("ethers");
|
|
21861
21732
|
var POSITION_DELEGATE_REGISTRY_ABI = [
|
|
21862
21733
|
"function positionDelegate(bytes32 positionId) view returns (address)",
|
|
21863
21734
|
"function setPositionDelegate(bytes32 positionId, address newDelegate) external",
|
|
21864
21735
|
"event PositionDelegateUpdated(bytes32 indexed positionId, address indexed oldDelegate, address indexed newDelegate)"
|
|
21865
21736
|
];
|
|
21866
21737
|
async function setPositionDelegate(positionId, delegate, signer, registryAddress) {
|
|
21867
|
-
const registry = new
|
|
21738
|
+
const registry = new import_ethers15.Contract(
|
|
21868
21739
|
registryAddress,
|
|
21869
21740
|
POSITION_DELEGATE_REGISTRY_ABI,
|
|
21870
21741
|
signer
|
|
@@ -21872,7 +21743,7 @@ async function setPositionDelegate(positionId, delegate, signer, registryAddress
|
|
|
21872
21743
|
return registry["setPositionDelegate"](positionId, delegate);
|
|
21873
21744
|
}
|
|
21874
21745
|
async function getPositionDelegate(positionId, provider, registryAddress) {
|
|
21875
|
-
const registry = new
|
|
21746
|
+
const registry = new import_ethers15.Contract(
|
|
21876
21747
|
registryAddress,
|
|
21877
21748
|
POSITION_DELEGATE_REGISTRY_ABI,
|
|
21878
21749
|
provider
|