@gvnrdao/dh-sdk 0.0.346 → 0.0.348
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 +2 -0
- package/browser/dist/browser.js.LICENSE.txt +18 -0
- package/dist/contracts/typechain-contracts/factories/src/agent/AgentDelegationRegistry__factory.d.ts +80 -1
- package/dist/contracts/typechain-contracts/src/agent/AgentDelegationRegistry.d.ts +85 -8
- package/dist/deployments.js +20 -8
- package/dist/deployments.mjs +20 -8
- package/dist/index.d.ts +3 -1
- package/dist/index.js +935 -411
- package/dist/index.mjs +842 -329
- package/dist/interfaces/chunks/loan-operations.i.d.ts +0 -6
- package/dist/modules/diamond-hands-sdk.d.ts +8 -4
- package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +9 -1
- package/dist/safe-delegation.js +20 -8
- package/dist/safe-delegation.mjs +20 -8
- package/dist/sign-guard.js +737 -0
- package/dist/sign-guard.mjs +734 -0
- package/dist/utils/address-conversion.utils.d.ts +16 -3
- package/dist/utils/agent-delegation.utils.d.ts +19 -4
- package/dist/utils/btc-spend-request-712.d.ts +150 -0
- package/dist/utils/btc-withdrawal-message.d.ts +40 -27
- package/dist/utils/sign-guard/index.d.ts +1 -0
- package/dist/utils/sign-guard/typed-data-guard.d.ts +68 -0
- package/dist/utils/stale-spend-invalidate-message.d.ts +28 -15
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -358,7 +358,7 @@ var init_deployment_addresses = __esm({
|
|
|
358
358
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
359
359
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
|
|
360
360
|
AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
361
|
-
AGENT_DELEGATION_REGISTRY_IMPL: "
|
|
361
|
+
AGENT_DELEGATION_REGISTRY_IMPL: "0x56a5af2C1549EFf70feD1F3BB8E1997717A84973",
|
|
362
362
|
DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
|
|
363
363
|
}
|
|
364
364
|
};
|
|
@@ -541,14 +541,26 @@ var init_deployment_addresses = __esm({
|
|
|
541
541
|
block: 25669024
|
|
542
542
|
},
|
|
543
543
|
PositionManagerViews: {
|
|
544
|
-
previousImplementation: "
|
|
545
|
-
newImplementation: "
|
|
544
|
+
previousImplementation: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
|
|
545
|
+
newImplementation: "0x8fe7aF14dB9Bef814c4c8fBc0ce206Cb17F25E8e",
|
|
546
546
|
proxy: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
|
|
547
|
-
upgradedAt: "2026-
|
|
548
|
-
upgradedBy: "
|
|
549
|
-
reason: "
|
|
550
|
-
executeTx: "
|
|
551
|
-
block:
|
|
547
|
+
upgradedAt: "2026-10-17T12:16:35.000Z",
|
|
548
|
+
upgradedBy: "AdminModule generic-op 0x60494d283c30afb95748d8c1bb95b800ab8f17d2a2a45fb04784ebde7b05393c upgradeToAndCall(0x8fe7aF14, initializeV2(AdminModule)) \u2014 3-of-3 signatures (0x3030C041, 0x52b67f31, 0xfb3B8cbe), 24h timelock; proposed by Safe 0x3030C0414B6d95aA9d5A57269E51a347fCBaB472 in tx 0xffe3dd376736d542a89f944290b876d8eb8e5c3df8fc8349bc34a963106dd0f2, executed from Safe 0x52b67f31Ca7A58Ef20322512EB359b7D4758C868 via onchain-auth/.safe-batches/mainnet-pmv-backing-view-execute.json",
|
|
549
|
+
reason: "PoR vault-address gaps (tasks/vault-address-por-gaps-plan-2026-10-02.md, runbook tasks/RUNBOOK-pmv-backing-view-mainnet-2026-10-02.md). VERSION 1.1.1 -> 1.1.2: adds getBackingVaults (paged backing set: positions with ucdDebt > 0 and their stored vault addresses), locks the implementation (_disableInitializers constructor), and the call data initializeV2(AdminModule) consumes the previously OPEN reinitializer(2) (Cloudflare audit finding) without changing adminModule. No storage layout change. Post-upgrade: scripts/audit/backing-vaults-verify.ts PASS @ block 26226360 (72 positions, 15 backing vaults, view == independent scan; Initializable version 2; impl locked). Pre-proposed rollback op 0x43f50eb30d360a779f24c8229dd2d3b56a5d9eb40f056d3cd13047e5f0f51e84 (1/3 sigs) is to be cancelled by the proposer Safe via mainnet-pmv-backing-view-cancel-REVERT.json.",
|
|
550
|
+
executeTx: "0xbb36e557141827a0de990b7124ef8615352a2eb8c197efb3ce3a63998994fef5",
|
|
551
|
+
block: 26212216,
|
|
552
|
+
history: [
|
|
553
|
+
{
|
|
554
|
+
previousImplementation: "0x9225647a30bbACA4Acc0491B786869036914242e",
|
|
555
|
+
newImplementation: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
|
|
556
|
+
proxy: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
|
|
557
|
+
upgradedAt: "2026-08-03T08:34:23.000Z",
|
|
558
|
+
upgradedBy: "REPLACED, not upgraded. Fresh ERC1967Proxy (atomically initialized) + AdminModule generic-op 0x848a97186f0d PositionManager.setViews(proxy) \u2014 3-of-3, 24h timelock, executed in onchain-auth/.safe-batches/mainnet-release-execute-B.json",
|
|
559
|
+
reason: "2026-08 agent-stack release. The mainnet PositionManagerViews at 0x9225647a was deployed as a BARE implementation (EIP-1967 slot 0x00), so upgradeToAndCall reverts UUPSUnauthorizedCallContext \u2014 it could never be upgraded. PositionManager.setViews (added in the same Execute B batch) removed the repoint blocker, so Views was replaced behind a new proxy rather than upgraded. This makes the Pashov F3 renewal debt-ceiling check REACHABLE for the first time: ExceedsMaxLoan (0x499e7985) is present in 0xE68DC096 and absent from 0x9225647a. Views holds no protocol state (8 wiring slots + roles + pause), which is what made replacement safe. The old contract is ABANDONED, not decommissioned \u2014 it stays live and callable as the rollback target for setViews. NOTE: VERSION reads 1.1.1 on both sides; verify by address.",
|
|
560
|
+
executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
|
|
561
|
+
block: 25673200
|
|
562
|
+
}
|
|
563
|
+
]
|
|
552
564
|
},
|
|
553
565
|
AgentDelegationRegistry: {
|
|
554
566
|
newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
|
|
@@ -1111,6 +1123,9 @@ var require_pkg_src = __commonJS({
|
|
|
1111
1123
|
BORROWER_AUTHORIZATION_ENCODE_TYPES: () => BORROWER_AUTHORIZATION_ENCODE_TYPES,
|
|
1112
1124
|
BORROWER_AUTHORIZATION_FIELDS: () => BORROWER_AUTHORIZATION_FIELDS,
|
|
1113
1125
|
BORROWER_AUTHORIZATION_PRIMARY_TYPES: () => BORROWER_AUTHORIZATION_PRIMARY_TYPES,
|
|
1126
|
+
BTC_SPEND_REQUEST_ENCODE_TYPES: () => BTC_SPEND_REQUEST_ENCODE_TYPES,
|
|
1127
|
+
BTC_SPEND_REQUEST_FIELDS: () => BTC_SPEND_REQUEST_FIELDS,
|
|
1128
|
+
BTC_SPEND_REQUEST_PRIMARY_TYPES: () => BTC_SPEND_REQUEST_PRIMARY_TYPES,
|
|
1114
1129
|
CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
|
|
1115
1130
|
DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
|
|
1116
1131
|
DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
|
|
@@ -1124,8 +1139,11 @@ var require_pkg_src = __commonJS({
|
|
|
1124
1139
|
RetryStrategy: () => RetryStrategy,
|
|
1125
1140
|
analyzeError: () => analyzeError,
|
|
1126
1141
|
borrowerAuthorizationTypes: () => borrowerAuthorizationTypes,
|
|
1142
|
+
btcSpendRequestTypes: () => btcSpendRequestTypes,
|
|
1127
1143
|
buildBorrowerAuthorizationDomain: () => buildBorrowerAuthorizationDomain,
|
|
1144
|
+
buildBtcSpendRequestDomain: () => buildBtcSpendRequestDomain,
|
|
1128
1145
|
calculateDelay: () => calculateDelay,
|
|
1146
|
+
canonicalBtcTxid: () => canonicalBtcTxid2,
|
|
1129
1147
|
cidToHex: () => cidToHex,
|
|
1130
1148
|
classifyError: () => classifyError,
|
|
1131
1149
|
clearSessionSignatureCache: () => clearSessionSignatureCache,
|
|
@@ -1371,30 +1389,30 @@ var require_pkg_src = __commonJS({
|
|
|
1371
1389
|
}
|
|
1372
1390
|
},
|
|
1373
1391
|
btcTransactionSigner: {
|
|
1374
|
-
cid: "
|
|
1392
|
+
cid: "Qmb6TKy8Qv9PYXzjhgfKRnVaNW7SPXsrRUrUhcaaDQ39wd",
|
|
1375
1393
|
authorizedCidHex: cidToHex(
|
|
1376
|
-
"
|
|
1394
|
+
"Qmb6TKy8Qv9PYXzjhgfKRnVaNW7SPXsrRUrUhcaaDQ39wd"
|
|
1377
1395
|
),
|
|
1378
1396
|
name: "Btc Transaction Signer",
|
|
1379
1397
|
description: "Production Btc Transaction Signer",
|
|
1380
|
-
version: "1.
|
|
1398
|
+
version: "1.3.1",
|
|
1381
1399
|
deployed: true,
|
|
1382
|
-
deployedAt:
|
|
1383
|
-
size:
|
|
1384
|
-
hash: "
|
|
1400
|
+
deployedAt: 1792436882589,
|
|
1401
|
+
size: 78254,
|
|
1402
|
+
hash: "194e1c3e9d2f07873bab8e431ba0cda4f66143b15deb196651a375682408c8c4"
|
|
1385
1403
|
},
|
|
1386
1404
|
ucdMintValidator: {
|
|
1387
|
-
cid: "
|
|
1405
|
+
cid: "QmTheJyLmR3xCyxUUV3Bf3W2bHKe7JZCxCrU5ocha32nL6",
|
|
1388
1406
|
authorizedCidHex: cidToHex(
|
|
1389
|
-
"
|
|
1407
|
+
"QmTheJyLmR3xCyxUUV3Bf3W2bHKe7JZCxCrU5ocha32nL6"
|
|
1390
1408
|
),
|
|
1391
1409
|
name: "Ucd Mint Validator",
|
|
1392
1410
|
description: "Production Ucd Mint Validator",
|
|
1393
|
-
version: "1.3
|
|
1411
|
+
version: "1.4.3",
|
|
1394
1412
|
deployed: true,
|
|
1395
|
-
deployedAt:
|
|
1396
|
-
size:
|
|
1397
|
-
hash: "
|
|
1413
|
+
deployedAt: 1792436891664,
|
|
1414
|
+
size: 90935,
|
|
1415
|
+
hash: "d23ab7c00adfaf6c9feebd47314e98f82c03a2d9af0a13cbe67f2e4fa8c843fc",
|
|
1398
1416
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1399
1417
|
pkp: {
|
|
1400
1418
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
@@ -1402,17 +1420,17 @@ var require_pkg_src = __commonJS({
|
|
|
1402
1420
|
}
|
|
1403
1421
|
},
|
|
1404
1422
|
processPaymentValidator: {
|
|
1405
|
-
cid: "
|
|
1423
|
+
cid: "QmP29cmhkiQnAdzXZJdYRKCw1ckdDj7RLEsLjzJD3udFQc",
|
|
1406
1424
|
authorizedCidHex: cidToHex(
|
|
1407
|
-
"
|
|
1425
|
+
"QmP29cmhkiQnAdzXZJdYRKCw1ckdDj7RLEsLjzJD3udFQc"
|
|
1408
1426
|
),
|
|
1409
1427
|
name: "Process Payment Validator",
|
|
1410
1428
|
description: "Production Process Payment Validator",
|
|
1411
|
-
version: "1.
|
|
1429
|
+
version: "1.3.3",
|
|
1412
1430
|
deployed: true,
|
|
1413
|
-
deployedAt:
|
|
1414
|
-
size:
|
|
1415
|
-
hash: "
|
|
1431
|
+
deployedAt: 1792436900605,
|
|
1432
|
+
size: 86589,
|
|
1433
|
+
hash: "e77c8cc4f8564376610110ec29f3663481d04bc677a21671aa0a68b73b866630",
|
|
1416
1434
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1417
1435
|
pkp: {
|
|
1418
1436
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
@@ -1420,17 +1438,17 @@ var require_pkg_src = __commonJS({
|
|
|
1420
1438
|
}
|
|
1421
1439
|
},
|
|
1422
1440
|
extendPositionValidator: {
|
|
1423
|
-
cid: "
|
|
1441
|
+
cid: "QmZyaWht2hgzfPAzPnCXFhA7K8isENaDFLUXrG5n3d296o",
|
|
1424
1442
|
authorizedCidHex: cidToHex(
|
|
1425
|
-
"
|
|
1443
|
+
"QmZyaWht2hgzfPAzPnCXFhA7K8isENaDFLUXrG5n3d296o"
|
|
1426
1444
|
),
|
|
1427
1445
|
name: "Extend Position Validator",
|
|
1428
1446
|
description: "Production Extend Position Validator",
|
|
1429
|
-
version: "1.
|
|
1447
|
+
version: "1.3.3",
|
|
1430
1448
|
deployed: true,
|
|
1431
|
-
deployedAt:
|
|
1432
|
-
size:
|
|
1433
|
-
hash: "
|
|
1449
|
+
deployedAt: 1792436909143,
|
|
1450
|
+
size: 83869,
|
|
1451
|
+
hash: "14bf14bcd7befa91da34565df7a579b63920d339ab8e1c7a89e937493b119ac5",
|
|
1434
1452
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1435
1453
|
pkp: {
|
|
1436
1454
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
@@ -1438,17 +1456,17 @@ var require_pkg_src = __commonJS({
|
|
|
1438
1456
|
}
|
|
1439
1457
|
},
|
|
1440
1458
|
btcWithdrawal: {
|
|
1441
|
-
cid: "
|
|
1459
|
+
cid: "QmadaqN59k7yBkA5vnpgp1rWv4uv11Yg6dxGLvfuBXnv64",
|
|
1442
1460
|
authorizedCidHex: cidToHex(
|
|
1443
|
-
"
|
|
1461
|
+
"QmadaqN59k7yBkA5vnpgp1rWv4uv11Yg6dxGLvfuBXnv64"
|
|
1444
1462
|
),
|
|
1445
1463
|
name: "Btc Withdrawal",
|
|
1446
1464
|
description: "Production Btc Withdrawal",
|
|
1447
|
-
version: "1.
|
|
1465
|
+
version: "1.3.3",
|
|
1448
1466
|
deployed: true,
|
|
1449
|
-
deployedAt:
|
|
1450
|
-
size:
|
|
1451
|
-
hash: "
|
|
1467
|
+
deployedAt: 1792436917612,
|
|
1468
|
+
size: 102257,
|
|
1469
|
+
hash: "3d6861750ab93776e4e904d9027a25f16ac5eb65628c3c614635151e79f0fee7",
|
|
1452
1470
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1453
1471
|
pkp: {
|
|
1454
1472
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
@@ -1456,17 +1474,17 @@ var require_pkg_src = __commonJS({
|
|
|
1456
1474
|
}
|
|
1457
1475
|
},
|
|
1458
1476
|
liquidationValidator: {
|
|
1459
|
-
cid: "
|
|
1477
|
+
cid: "QmVNXP64dMe78KVEbgk1BiAo24ztEPW4JGvbRUzbfh3z8a",
|
|
1460
1478
|
authorizedCidHex: cidToHex(
|
|
1461
|
-
"
|
|
1479
|
+
"QmVNXP64dMe78KVEbgk1BiAo24ztEPW4JGvbRUzbfh3z8a"
|
|
1462
1480
|
),
|
|
1463
1481
|
name: "Liquidation Validator",
|
|
1464
1482
|
description: "Production Liquidation Validator",
|
|
1465
|
-
version: "1.
|
|
1483
|
+
version: "1.3.3",
|
|
1466
1484
|
deployed: true,
|
|
1467
|
-
deployedAt:
|
|
1468
|
-
size:
|
|
1469
|
-
hash: "
|
|
1485
|
+
deployedAt: 1792436926170,
|
|
1486
|
+
size: 71333,
|
|
1487
|
+
hash: "6171de135d55e8ab2e7486cebefb5597ac233a0d196e0ded87c14e3ff2c371d5",
|
|
1470
1488
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1471
1489
|
pkp: {
|
|
1472
1490
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
@@ -1492,17 +1510,17 @@ var require_pkg_src = __commonJS({
|
|
|
1492
1510
|
}
|
|
1493
1511
|
},
|
|
1494
1512
|
loanVaultBtcBalance: {
|
|
1495
|
-
cid: "
|
|
1513
|
+
cid: "QmYnNTLtiogDfMYdL9ZxrP3Y55f798toxeZxn9LFNJgmSc",
|
|
1496
1514
|
authorizedCidHex: cidToHex(
|
|
1497
|
-
"
|
|
1515
|
+
"QmYnNTLtiogDfMYdL9ZxrP3Y55f798toxeZxn9LFNJgmSc"
|
|
1498
1516
|
),
|
|
1499
1517
|
name: "Loan Vault Btc Balance",
|
|
1500
1518
|
description: "Production Loan Vault Btc Balance",
|
|
1501
|
-
version: "1.
|
|
1519
|
+
version: "1.3.3",
|
|
1502
1520
|
deployed: true,
|
|
1503
|
-
deployedAt:
|
|
1504
|
-
size:
|
|
1505
|
-
hash: "
|
|
1521
|
+
deployedAt: 1792436934787,
|
|
1522
|
+
size: 61051,
|
|
1523
|
+
hash: "df6a49194000ad68a93694cc5b2601d0e3c04bccf773deb0bd4c95803fe1a760",
|
|
1506
1524
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1507
1525
|
pkp: {
|
|
1508
1526
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
@@ -1516,17 +1534,17 @@ var require_pkg_src = __commonJS({
|
|
|
1516
1534
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
1517
1535
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
1518
1536
|
btcAddressBalance: {
|
|
1519
|
-
cid: "
|
|
1537
|
+
cid: "QmYqAW1sDqPEos5KhhLkRXsgKUEScxM9cpeNnLkHusEMpF",
|
|
1520
1538
|
authorizedCidHex: cidToHex(
|
|
1521
|
-
"
|
|
1539
|
+
"QmYqAW1sDqPEos5KhhLkRXsgKUEScxM9cpeNnLkHusEMpF"
|
|
1522
1540
|
),
|
|
1523
1541
|
name: "Btc Address Balance",
|
|
1524
1542
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
1525
|
-
version: "0.2
|
|
1543
|
+
version: "0.3.2",
|
|
1526
1544
|
deployed: true,
|
|
1527
|
-
deployedAt:
|
|
1528
|
-
size:
|
|
1529
|
-
hash: "
|
|
1545
|
+
deployedAt: 1792360075629,
|
|
1546
|
+
size: 31909,
|
|
1547
|
+
hash: "2297c7b625340f048b5926325a14c958016594b77f4c4270ef413b164a8ac975",
|
|
1530
1548
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1531
1549
|
pkp: {
|
|
1532
1550
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
@@ -1560,30 +1578,30 @@ var require_pkg_src = __commonJS({
|
|
|
1560
1578
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
1561
1579
|
},
|
|
1562
1580
|
agentModuleExecutor: {
|
|
1563
|
-
cid: "
|
|
1581
|
+
cid: "QmPTQm5CtKnN3PLAitDRNQCuAeegATMWVWQbRrKiMCTz6V",
|
|
1564
1582
|
authorizedCidHex: cidToHex(
|
|
1565
|
-
"
|
|
1583
|
+
"QmPTQm5CtKnN3PLAitDRNQCuAeegATMWVWQbRrKiMCTz6V"
|
|
1566
1584
|
),
|
|
1567
1585
|
name: "Agent Module Executor",
|
|
1568
1586
|
description: "Production Agent Module Executor",
|
|
1569
|
-
version: "1.
|
|
1587
|
+
version: "1.3.0",
|
|
1570
1588
|
deployed: true,
|
|
1571
|
-
deployedAt:
|
|
1572
|
-
size:
|
|
1573
|
-
hash: "
|
|
1589
|
+
deployedAt: 1792419196606,
|
|
1590
|
+
size: 17562,
|
|
1591
|
+
hash: "a10d463ffd48f2392401efe3dde566faa1869e5e089db830632873a5b9528ee0"
|
|
1574
1592
|
},
|
|
1575
1593
|
staleSpendRecoveryValidator: {
|
|
1576
|
-
cid: "
|
|
1594
|
+
cid: "QmYnD65RjagWkv2eLz117GBfNfPwB7Dy1e8WXFe7yGWrt3",
|
|
1577
1595
|
authorizedCidHex: cidToHex(
|
|
1578
|
-
"
|
|
1596
|
+
"QmYnD65RjagWkv2eLz117GBfNfPwB7Dy1e8WXFe7yGWrt3"
|
|
1579
1597
|
),
|
|
1580
1598
|
name: "Stale Spend Recovery Validator",
|
|
1581
1599
|
description: "Production Stale Spend Recovery Validator",
|
|
1582
|
-
version: "1.
|
|
1600
|
+
version: "1.2.3",
|
|
1583
1601
|
deployed: true,
|
|
1584
|
-
deployedAt:
|
|
1585
|
-
size:
|
|
1586
|
-
hash: "
|
|
1602
|
+
deployedAt: 1792436943524,
|
|
1603
|
+
size: 49866,
|
|
1604
|
+
hash: "8f66007ed73c0a969051bbb8fec1cc51d119ecd01748eed4cdc59b3b1e4597fa",
|
|
1587
1605
|
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1588
1606
|
pkp: {
|
|
1589
1607
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
@@ -1591,30 +1609,30 @@ var require_pkg_src = __commonJS({
|
|
|
1591
1609
|
}
|
|
1592
1610
|
},
|
|
1593
1611
|
btcUtxoInvalidator: {
|
|
1594
|
-
cid: "
|
|
1612
|
+
cid: "QmSnXqdDt92epKi9zD7P1KqGMSzBLzCp2x4a34gHkyXvmi",
|
|
1595
1613
|
authorizedCidHex: cidToHex(
|
|
1596
|
-
"
|
|
1614
|
+
"QmSnXqdDt92epKi9zD7P1KqGMSzBLzCp2x4a34gHkyXvmi"
|
|
1597
1615
|
),
|
|
1598
1616
|
name: "Btc Utxo Invalidator",
|
|
1599
1617
|
description: "Production Btc Utxo Invalidator",
|
|
1600
|
-
version: "1.
|
|
1618
|
+
version: "1.2.1",
|
|
1601
1619
|
deployed: true,
|
|
1602
|
-
deployedAt:
|
|
1603
|
-
size:
|
|
1604
|
-
hash: "
|
|
1620
|
+
deployedAt: 1792436952354,
|
|
1621
|
+
size: 73451,
|
|
1622
|
+
hash: "a04848a16b411362aa7a5ff05ad7c93adc6a1368ef2c5f25dcfbe7c225ff5d1f"
|
|
1605
1623
|
},
|
|
1606
1624
|
carryCollateralAttestation: {
|
|
1607
|
-
cid: "
|
|
1625
|
+
cid: "QmQxCUv2ihnGbQ95dxkjZUaSB8fvg6ri4LN8UQdHTeGWvo",
|
|
1608
1626
|
authorizedCidHex: cidToHex(
|
|
1609
|
-
"
|
|
1627
|
+
"QmQxCUv2ihnGbQ95dxkjZUaSB8fvg6ri4LN8UQdHTeGWvo"
|
|
1610
1628
|
),
|
|
1611
1629
|
name: "Carry Collateral Attestation",
|
|
1612
1630
|
description: "LoanCarryVault collateral attestation (borrower, BTC vault, confirmed BTC)",
|
|
1613
|
-
version: "1.
|
|
1631
|
+
version: "1.1.3",
|
|
1614
1632
|
deployed: true,
|
|
1615
|
-
deployedAt:
|
|
1616
|
-
size:
|
|
1617
|
-
hash: "
|
|
1633
|
+
deployedAt: 1792436994070,
|
|
1634
|
+
size: 22131,
|
|
1635
|
+
hash: "bad8d5ce3c87985f7b6e6b74581e3e7eb0a9c6ddf4856e460d3e0b2adce00be5"
|
|
1618
1636
|
},
|
|
1619
1637
|
carryFundingAttestation: {
|
|
1620
1638
|
cid: "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W",
|
|
@@ -2373,7 +2391,7 @@ ${errorReport}`);
|
|
|
2373
2391
|
}
|
|
2374
2392
|
init_debug_logger();
|
|
2375
2393
|
init_session_signature_cache();
|
|
2376
|
-
var
|
|
2394
|
+
var import_ethers25 = require("ethers");
|
|
2377
2395
|
var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
|
|
2378
2396
|
var GRACE_PERIOD_DAYS = 30;
|
|
2379
2397
|
var SATOSHIS_PER_BITCOIN = 100000000n;
|
|
@@ -2611,6 +2629,87 @@ ${errorReport}`);
|
|
|
2611
2629
|
);
|
|
2612
2630
|
return newCollateralRatioBps >= requiredRatioBps;
|
|
2613
2631
|
}
|
|
2632
|
+
var DRPC_DOMAINS = ["drpc.org", "drpc.live"];
|
|
2633
|
+
var DRPC_KEY_HEADER = "Drpc-Key";
|
|
2634
|
+
var DRPC_KEY_PATTERN = /^[A-Za-z0-9_-]{16,128}$/;
|
|
2635
|
+
function isDrpcHost(hostname) {
|
|
2636
|
+
return DRPC_DOMAINS.some(
|
|
2637
|
+
(domain) => hostname === domain || hostname.endsWith(`.${domain}`)
|
|
2638
|
+
);
|
|
2639
|
+
}
|
|
2640
|
+
function assertKeyFormat(key, label) {
|
|
2641
|
+
if (typeof key !== "string" || !DRPC_KEY_PATTERN.test(key)) {
|
|
2642
|
+
throw new Error(
|
|
2643
|
+
`Invalid ${label}: expected 16-128 characters of [A-Za-z0-9_-]`
|
|
2644
|
+
);
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
function assertHttps(url) {
|
|
2648
|
+
if (url.protocol !== "https:") {
|
|
2649
|
+
throw new Error(
|
|
2650
|
+
`A dRPC key is only sent over https, but the RPC URL scheme is "${url.protocol}"`
|
|
2651
|
+
);
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
function resolveDrpcKey(rpcUrl, drpcKey) {
|
|
2655
|
+
if (drpcKey === void 0) {
|
|
2656
|
+
return void 0;
|
|
2657
|
+
}
|
|
2658
|
+
assertKeyFormat(drpcKey, '"drpcKey"');
|
|
2659
|
+
const url = new URL(rpcUrl);
|
|
2660
|
+
if (!isDrpcHost(url.hostname)) {
|
|
2661
|
+
throw new Error(
|
|
2662
|
+
`"drpcKey" is only sent to dRPC, but the RPC host is "${url.hostname}" (expected ${DRPC_DOMAINS.join(" or ")})`
|
|
2663
|
+
);
|
|
2664
|
+
}
|
|
2665
|
+
assertHttps(url);
|
|
2666
|
+
if (url.searchParams.has("dkey")) {
|
|
2667
|
+
throw new Error(
|
|
2668
|
+
'"drpcKey" and a keyed rpcUrl (?dkey=) are mutually exclusive \u2014 send one'
|
|
2669
|
+
);
|
|
2670
|
+
}
|
|
2671
|
+
return drpcKey;
|
|
2672
|
+
}
|
|
2673
|
+
async function litNodeRpcUrl(chain, drpcKey) {
|
|
2674
|
+
if (drpcKey !== void 0) {
|
|
2675
|
+
throw new Error(
|
|
2676
|
+
`"drpcKey" was supplied without an "rpcUrl" \u2014 the key only authenticates a caller-supplied dRPC rpcUrl, never the Lit node's own endpoint`
|
|
2677
|
+
);
|
|
2678
|
+
}
|
|
2679
|
+
return Lit.Actions.getRpcUrl({ chain });
|
|
2680
|
+
}
|
|
2681
|
+
function evmRpcConnection(rpcUrl, drpcKey, timeout) {
|
|
2682
|
+
const connection = { url: rpcUrl };
|
|
2683
|
+
const key = resolveDrpcKey(rpcUrl, drpcKey);
|
|
2684
|
+
if (key !== void 0) {
|
|
2685
|
+
connection.headers = { [DRPC_KEY_HEADER]: key };
|
|
2686
|
+
} else {
|
|
2687
|
+
const url = new URL(rpcUrl);
|
|
2688
|
+
const legacyKeys = url.searchParams.getAll("dkey");
|
|
2689
|
+
if (legacyKeys.length > 1) {
|
|
2690
|
+
throw new Error(
|
|
2691
|
+
`rpcUrl carries ${legacyKeys.length} "dkey" parameters \u2014 send exactly one dRPC key`
|
|
2692
|
+
);
|
|
2693
|
+
}
|
|
2694
|
+
if (legacyKeys.length === 1 && !isDrpcHost(url.hostname)) {
|
|
2695
|
+
throw new Error(
|
|
2696
|
+
`rpcUrl carries a dRPC key (?dkey=) but the RPC host is "${url.hostname}" \u2014 a dRPC key is only sent to ${DRPC_DOMAINS.join(" or ")}`
|
|
2697
|
+
);
|
|
2698
|
+
}
|
|
2699
|
+
if (legacyKeys.length === 1) {
|
|
2700
|
+
const legacyKey = legacyKeys[0];
|
|
2701
|
+
assertKeyFormat(legacyKey, "dRPC key in rpcUrl (?dkey=)");
|
|
2702
|
+
assertHttps(url);
|
|
2703
|
+
url.searchParams.delete("dkey");
|
|
2704
|
+
connection.url = url.toString();
|
|
2705
|
+
connection.headers = { [DRPC_KEY_HEADER]: legacyKey };
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
if (timeout !== void 0) {
|
|
2709
|
+
connection.timeout = timeout;
|
|
2710
|
+
}
|
|
2711
|
+
return connection;
|
|
2712
|
+
}
|
|
2614
2713
|
var ProtocolParametersModule = class {
|
|
2615
2714
|
constructor(config) {
|
|
2616
2715
|
this.termManagerAddress = config.termManagerAddress;
|
|
@@ -2619,6 +2718,7 @@ ${errorReport}`);
|
|
|
2619
2718
|
this.chain = config.chain;
|
|
2620
2719
|
this.chainId = config.chainId;
|
|
2621
2720
|
this.rpcUrl = config.rpcUrl;
|
|
2721
|
+
this.drpcKey = config.drpcKey;
|
|
2622
2722
|
}
|
|
2623
2723
|
/**
|
|
2624
2724
|
* Get liquidation threshold from LoanOperationsManager
|
|
@@ -2631,10 +2731,10 @@ ${errorReport}`);
|
|
|
2631
2731
|
if (this.rpcUrl) {
|
|
2632
2732
|
rpcUrl = this.rpcUrl;
|
|
2633
2733
|
} else {
|
|
2634
|
-
rpcUrl = await
|
|
2734
|
+
rpcUrl = await litNodeRpcUrl(this.chain, this.drpcKey);
|
|
2635
2735
|
}
|
|
2636
2736
|
const provider = new ethers.providers.StaticJsonRpcProvider(
|
|
2637
|
-
|
|
2737
|
+
evmRpcConnection(rpcUrl, this.drpcKey, LIT_ACTION_ETH_RPC_TIMEOUT_MS),
|
|
2638
2738
|
{
|
|
2639
2739
|
name: "any",
|
|
2640
2740
|
chainId: this.chainId
|
|
@@ -2678,10 +2778,10 @@ ${errorReport}`);
|
|
|
2678
2778
|
if (this.rpcUrl) {
|
|
2679
2779
|
rpcUrl = this.rpcUrl;
|
|
2680
2780
|
} else {
|
|
2681
|
-
rpcUrl = await
|
|
2781
|
+
rpcUrl = await litNodeRpcUrl(this.chain, this.drpcKey);
|
|
2682
2782
|
}
|
|
2683
2783
|
const provider = new ethers.providers.StaticJsonRpcProvider(
|
|
2684
|
-
|
|
2784
|
+
evmRpcConnection(rpcUrl, this.drpcKey, LIT_ACTION_ETH_RPC_TIMEOUT_MS),
|
|
2685
2785
|
{
|
|
2686
2786
|
name: "any",
|
|
2687
2787
|
chainId: this.chainId
|
|
@@ -2734,9 +2834,9 @@ ${errorReport}`);
|
|
|
2734
2834
|
*/
|
|
2735
2835
|
async getAuthorizedSpendsHash(positionId) {
|
|
2736
2836
|
try {
|
|
2737
|
-
const rpcUrl = this.rpcUrl || await
|
|
2837
|
+
const rpcUrl = this.rpcUrl || await litNodeRpcUrl(this.chain, this.drpcKey);
|
|
2738
2838
|
const provider = new ethers.providers.StaticJsonRpcProvider(
|
|
2739
|
-
|
|
2839
|
+
evmRpcConnection(rpcUrl, this.drpcKey, LIT_ACTION_ETH_RPC_TIMEOUT_MS),
|
|
2740
2840
|
{
|
|
2741
2841
|
name: "any",
|
|
2742
2842
|
chainId: this.chainId
|
|
@@ -2782,10 +2882,10 @@ ${errorReport}`);
|
|
|
2782
2882
|
if (this.rpcUrl) {
|
|
2783
2883
|
rpcUrl = this.rpcUrl;
|
|
2784
2884
|
} else {
|
|
2785
|
-
rpcUrl = await
|
|
2885
|
+
rpcUrl = await litNodeRpcUrl(this.chain, this.drpcKey);
|
|
2786
2886
|
}
|
|
2787
2887
|
const provider = new ethers.providers.StaticJsonRpcProvider(
|
|
2788
|
-
|
|
2888
|
+
evmRpcConnection(rpcUrl, this.drpcKey, LIT_ACTION_ETH_RPC_TIMEOUT_MS),
|
|
2789
2889
|
{
|
|
2790
2890
|
name: "any",
|
|
2791
2891
|
chainId: this.chainId
|
|
@@ -2827,14 +2927,14 @@ ${errorReport}`);
|
|
|
2827
2927
|
if (typeof parsed === "object" && parsed !== null) {
|
|
2828
2928
|
const chainLower = chain.toLowerCase();
|
|
2829
2929
|
if (chainLower === "sepolia") {
|
|
2830
|
-
return parsed.regtest || parsed.testnet ||
|
|
2930
|
+
return parsed.regtest || parsed.testnet || void 0;
|
|
2831
2931
|
}
|
|
2832
2932
|
const bitcoinNetwork = getBitcoinNetworkForChain(chain);
|
|
2833
2933
|
if (bitcoinNetwork === "regtest") {
|
|
2834
|
-
return parsed.regtest || parsed.testnet ||
|
|
2934
|
+
return parsed.regtest || parsed.testnet || void 0;
|
|
2835
2935
|
}
|
|
2836
2936
|
if (bitcoinNetwork === "testnet") {
|
|
2837
|
-
return parsed.testnet || parsed.regtest ||
|
|
2937
|
+
return parsed.testnet || parsed.regtest || void 0;
|
|
2838
2938
|
}
|
|
2839
2939
|
return parsed.mainnet;
|
|
2840
2940
|
}
|
|
@@ -2860,8 +2960,7 @@ ${errorReport}`);
|
|
|
2860
2960
|
console.log(
|
|
2861
2961
|
`[Vault Snapshot] Raw vault address from contract: "${positionState.vaultAddress}"`
|
|
2862
2962
|
);
|
|
2863
|
-
const
|
|
2864
|
-
const [balanceResult, btcPriceUsd] = useStubbedBtcData ? this.buildStubbedBtcSnapshotInputs(positionState) : await Promise.all([
|
|
2963
|
+
const [balanceResult, btcPriceUsd] = await Promise.all([
|
|
2865
2964
|
this.config.vaultBalance.calculateTrustedBalance(
|
|
2866
2965
|
positionId,
|
|
2867
2966
|
positionState.vaultAddress
|
|
@@ -2875,7 +2974,8 @@ ${errorReport}`);
|
|
|
2875
2974
|
chain: this.config.chain,
|
|
2876
2975
|
chainId: this.config.chainId || 1,
|
|
2877
2976
|
// Default to mainnet if not provided
|
|
2878
|
-
rpcUrl: this.config.rpcUrl
|
|
2977
|
+
rpcUrl: this.config.rpcUrl,
|
|
2978
|
+
drpcKey: this.config.drpcKey
|
|
2879
2979
|
});
|
|
2880
2980
|
const termForFees = this.config.termOverride ?? positionState.selectedTerm;
|
|
2881
2981
|
const [liquidationThresholdBps, maxEscalatedThresholdBps, termFees] = await Promise.all([
|
|
@@ -2954,34 +3054,6 @@ ${errorReport}`);
|
|
|
2954
3054
|
// a snapshot whose balance skipped UTXO validation + consensus must never
|
|
2955
3055
|
// exist within reach of a signing flow. Every snapshot now runs the full
|
|
2956
3056
|
// validation path above.
|
|
2957
|
-
buildStubbedBtcSnapshotInputs(positionState) {
|
|
2958
|
-
const stubbedAvailableBtcSats = BigInt(
|
|
2959
|
-
this.config.debugOverrides?.stubbedAvailableBtcSats ?? "10000000"
|
|
2960
|
-
);
|
|
2961
|
-
const stubbedBtcPriceUsd = BigInt(
|
|
2962
|
-
this.config.debugOverrides?.stubbedBtcPriceUsd ?? "5000000000000"
|
|
2963
|
-
);
|
|
2964
|
-
const stubbedAuthorizedSpendsHash = this.config.debugOverrides?.stubbedAuthorizedSpendsHash ?? // keccak256(abi.encode(positionId, []))
|
|
2965
|
-
ethers.utils.keccak256(
|
|
2966
|
-
ethers.utils.defaultAbiCoder.encode(
|
|
2967
|
-
["bytes32", "bytes32[]"],
|
|
2968
|
-
[positionState.positionId, []]
|
|
2969
|
-
)
|
|
2970
|
-
);
|
|
2971
|
-
const balanceResult = {
|
|
2972
|
-
totalUTXOs: [],
|
|
2973
|
-
totalBalance: stubbedAvailableBtcSats,
|
|
2974
|
-
authorizedUTXOs: [],
|
|
2975
|
-
authorizedBalance: 0n,
|
|
2976
|
-
authorizedSpendsHash: stubbedAuthorizedSpendsHash,
|
|
2977
|
-
availableUTXOs: [],
|
|
2978
|
-
availableBalance: stubbedAvailableBtcSats,
|
|
2979
|
-
vaultAddress: positionState.vaultAddress,
|
|
2980
|
-
positionId: positionState.positionId,
|
|
2981
|
-
timestamp: Date.now()
|
|
2982
|
-
};
|
|
2983
|
-
return [balanceResult, stubbedBtcPriceUsd];
|
|
2984
|
-
}
|
|
2985
3057
|
/**
|
|
2986
3058
|
* Query position state from smart contract
|
|
2987
3059
|
*
|
|
@@ -2998,10 +3070,10 @@ ${errorReport}`);
|
|
|
2998
3070
|
if (this.config.rpcUrl) {
|
|
2999
3071
|
rpcUrl = this.config.rpcUrl;
|
|
3000
3072
|
} else {
|
|
3001
|
-
rpcUrl = await
|
|
3073
|
+
rpcUrl = await litNodeRpcUrl(this.config.chain, this.config.drpcKey);
|
|
3002
3074
|
}
|
|
3003
3075
|
const provider = new ethers.providers.StaticJsonRpcProvider(
|
|
3004
|
-
|
|
3076
|
+
evmRpcConnection(rpcUrl, this.config.drpcKey, LIT_ACTION_ETH_RPC_TIMEOUT_MS),
|
|
3005
3077
|
this.config.chainId
|
|
3006
3078
|
);
|
|
3007
3079
|
const diamondContract = new ethers.Contract(
|
|
@@ -5210,10 +5282,10 @@ ${auth.clientId}`;
|
|
|
5210
5282
|
if (this.config.rpcUrl) {
|
|
5211
5283
|
rpcUrl = this.config.rpcUrl;
|
|
5212
5284
|
} else {
|
|
5213
|
-
rpcUrl = await
|
|
5285
|
+
rpcUrl = await litNodeRpcUrl(this.config.chain, this.config.drpcKey);
|
|
5214
5286
|
}
|
|
5215
5287
|
const provider = new ethers.providers.StaticJsonRpcProvider(
|
|
5216
|
-
|
|
5288
|
+
evmRpcConnection(rpcUrl, this.config.drpcKey, LIT_ACTION_ETH_RPC_TIMEOUT_MS),
|
|
5217
5289
|
this.config.chainId
|
|
5218
5290
|
);
|
|
5219
5291
|
const contract = new ethers.Contract(
|
|
@@ -5381,12 +5453,12 @@ ${auth.clientId}`;
|
|
|
5381
5453
|
}
|
|
5382
5454
|
async function executeVaultSnapshot(params) {
|
|
5383
5455
|
global.ethers = {
|
|
5384
|
-
...
|
|
5456
|
+
...import_ethers25.ethers,
|
|
5385
5457
|
providers: {
|
|
5386
|
-
StaticJsonRpcProvider:
|
|
5458
|
+
StaticJsonRpcProvider: import_ethers25.ethers.JsonRpcProvider
|
|
5387
5459
|
},
|
|
5388
|
-
Contract:
|
|
5389
|
-
utils:
|
|
5460
|
+
Contract: import_ethers25.ethers.Contract,
|
|
5461
|
+
utils: import_ethers25.ethers
|
|
5390
5462
|
// v6 moved utils to top level
|
|
5391
5463
|
};
|
|
5392
5464
|
global.Lit = {
|
|
@@ -5497,6 +5569,79 @@ ${auth.clientId}`;
|
|
|
5497
5569
|
version: "2.0.0"
|
|
5498
5570
|
}
|
|
5499
5571
|
};
|
|
5572
|
+
var BTC_SPEND_REQUEST_PRIMARY_TYPES = {
|
|
5573
|
+
EXECUTE: "ExecuteBtcWithdrawalRequest",
|
|
5574
|
+
INVALIDATE: "InvalidateStaleSpendRequest"
|
|
5575
|
+
};
|
|
5576
|
+
var BTC_SPEND_REQUEST_FIELDS = {
|
|
5577
|
+
ExecuteBtcWithdrawalRequest: [
|
|
5578
|
+
{ name: "positionId", type: "bytes32" },
|
|
5579
|
+
{ name: "withdrawalAddress", type: "string" },
|
|
5580
|
+
{ name: "recipientAmount", type: "uint256" },
|
|
5581
|
+
{ name: "networkFee", type: "uint256" },
|
|
5582
|
+
{ name: "totalDeduction", type: "uint256" },
|
|
5583
|
+
{ name: "spendTxid", type: "string" },
|
|
5584
|
+
{ name: "spendVout", type: "uint32" },
|
|
5585
|
+
{ name: "inputSetHash", type: "bytes32" },
|
|
5586
|
+
{ name: "quantumTimestamp", type: "uint256" }
|
|
5587
|
+
],
|
|
5588
|
+
InvalidateStaleSpendRequest: [
|
|
5589
|
+
{ name: "positionId", type: "bytes32" },
|
|
5590
|
+
{ name: "spendTxid", type: "string" },
|
|
5591
|
+
{ name: "spendVout", type: "uint32" },
|
|
5592
|
+
{ name: "quantumTimestamp", type: "uint256" }
|
|
5593
|
+
]
|
|
5594
|
+
};
|
|
5595
|
+
var BTC_SPEND_REQUEST_ENCODE_TYPES = {
|
|
5596
|
+
ExecuteBtcWithdrawalRequest: "ExecuteBtcWithdrawalRequest(bytes32 positionId,string withdrawalAddress,uint256 recipientAmount,uint256 networkFee,uint256 totalDeduction,string spendTxid,uint32 spendVout,bytes32 inputSetHash,uint256 quantumTimestamp)",
|
|
5597
|
+
InvalidateStaleSpendRequest: "InvalidateStaleSpendRequest(bytes32 positionId,string spendTxid,uint32 spendVout,uint256 quantumTimestamp)"
|
|
5598
|
+
};
|
|
5599
|
+
function btcSpendRequestTypes(primaryType) {
|
|
5600
|
+
const fields = BTC_SPEND_REQUEST_FIELDS[primaryType];
|
|
5601
|
+
if (!fields) {
|
|
5602
|
+
throw new Error(
|
|
5603
|
+
`Unknown BTC spend request primary type "${primaryType}"; expected one of ${Object.keys(BTC_SPEND_REQUEST_FIELDS).join(", ")}`
|
|
5604
|
+
);
|
|
5605
|
+
}
|
|
5606
|
+
return { [primaryType]: fields.map((field) => ({ ...field })) };
|
|
5607
|
+
}
|
|
5608
|
+
function buildBtcSpendRequestDomain(chainId, verifyingContractOverride) {
|
|
5609
|
+
if (!Number.isInteger(chainId) || chainId <= 0) {
|
|
5610
|
+
throw new Error(
|
|
5611
|
+
`BTC spend request domain requires a positive integer chainId, got ${String(chainId)}`
|
|
5612
|
+
);
|
|
5613
|
+
}
|
|
5614
|
+
const pinned = getPinnedContractAddresses(chainId);
|
|
5615
|
+
const pinnedAuthorizer = pinned?.BTCSpendAuthorizer;
|
|
5616
|
+
if (pinnedAuthorizer && verifyingContractOverride) {
|
|
5617
|
+
if (pinnedAuthorizer.toLowerCase() !== verifyingContractOverride.toLowerCase()) {
|
|
5618
|
+
throw new Error(
|
|
5619
|
+
`Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${chainId}: caller ${verifyingContractOverride}, pinned ${pinnedAuthorizer}`
|
|
5620
|
+
);
|
|
5621
|
+
}
|
|
5622
|
+
}
|
|
5623
|
+
const verifyingContract = pinnedAuthorizer ?? verifyingContractOverride;
|
|
5624
|
+
if (!verifyingContract) {
|
|
5625
|
+
throw new Error(
|
|
5626
|
+
`No pinned BTCSpendAuthorizer for chainId ${chainId} and no verifyingContract supplied; refusing to build a BTC spend request domain without one`
|
|
5627
|
+
);
|
|
5628
|
+
}
|
|
5629
|
+
return {
|
|
5630
|
+
name: PROTOCOL_EIP712_DOMAIN_NAME,
|
|
5631
|
+
version: PROTOCOL_EIP712_DOMAIN_VERSION,
|
|
5632
|
+
chainId,
|
|
5633
|
+
verifyingContract
|
|
5634
|
+
};
|
|
5635
|
+
}
|
|
5636
|
+
function canonicalBtcTxid2(txid) {
|
|
5637
|
+
const canonical = String(txid).toLowerCase().replace(/^0x/, "");
|
|
5638
|
+
if (!/^[0-9a-f]{64}$/.test(canonical)) {
|
|
5639
|
+
throw new Error(
|
|
5640
|
+
`Invalid Bitcoin txid "${String(txid)}": expected 64 hex characters (optionally 0x-prefixed)`
|
|
5641
|
+
);
|
|
5642
|
+
}
|
|
5643
|
+
return canonical;
|
|
5644
|
+
}
|
|
5500
5645
|
}
|
|
5501
5646
|
});
|
|
5502
5647
|
|
|
@@ -5736,7 +5881,7 @@ function getMainnetConfig() {
|
|
|
5736
5881
|
function getLocalhostConfig() {
|
|
5737
5882
|
const deployment = loadDeploymentData("localhost");
|
|
5738
5883
|
const contracts = deployment?.contracts || {};
|
|
5739
|
-
const
|
|
5884
|
+
const getAddress2 = (envKey, contractKey) => {
|
|
5740
5885
|
return process.env[envKey] || contracts[contractKey] || "";
|
|
5741
5886
|
};
|
|
5742
5887
|
logNetworkConfig(
|
|
@@ -5745,17 +5890,17 @@ function getLocalhostConfig() {
|
|
|
5745
5890
|
deployment ? "YES" : "NO"
|
|
5746
5891
|
);
|
|
5747
5892
|
logNetworkConfig("log", "[NetworkConfig] Localhost contracts:", {
|
|
5748
|
-
PositionManager:
|
|
5749
|
-
PositionManagerCore:
|
|
5893
|
+
PositionManager: getAddress2("POSITION_MANAGER_ADDRESS", "PositionManager"),
|
|
5894
|
+
PositionManagerCore: getAddress2(
|
|
5750
5895
|
"POSITION_MANAGER_CORE_ADDRESS",
|
|
5751
5896
|
"PositionManagerCoreModule"
|
|
5752
5897
|
),
|
|
5753
|
-
LoanOperationsManagerModule:
|
|
5898
|
+
LoanOperationsManagerModule: getAddress2(
|
|
5754
5899
|
"LOAN_OPERATIONS_MANAGER_ADDRESS",
|
|
5755
5900
|
"LoanOperationsManagerModule"
|
|
5756
5901
|
),
|
|
5757
|
-
TermManagerModule:
|
|
5758
|
-
UCDToken:
|
|
5902
|
+
TermManagerModule: getAddress2("TERM_MANAGER_ADDRESS", "TermManagerModule"),
|
|
5903
|
+
UCDToken: getAddress2("UCD_TOKEN_ADDRESS", "UCDToken")
|
|
5759
5904
|
});
|
|
5760
5905
|
return {
|
|
5761
5906
|
mode: "service",
|
|
@@ -5764,43 +5909,43 @@ function getLocalhostConfig() {
|
|
|
5764
5909
|
name: "localhost",
|
|
5765
5910
|
rpcUrls: ["http://localhost:8545"],
|
|
5766
5911
|
contractAddresses: {
|
|
5767
|
-
positionManager:
|
|
5912
|
+
positionManager: getAddress2(
|
|
5768
5913
|
"POSITION_MANAGER_ADDRESS",
|
|
5769
5914
|
"PositionManager"
|
|
5770
5915
|
),
|
|
5771
|
-
positionManagerCore:
|
|
5916
|
+
positionManagerCore: getAddress2(
|
|
5772
5917
|
"POSITION_MANAGER_CORE_ADDRESS",
|
|
5773
5918
|
"PositionManagerCoreModule"
|
|
5774
5919
|
),
|
|
5775
|
-
positionManagerViews:
|
|
5920
|
+
positionManagerViews: getAddress2(
|
|
5776
5921
|
"POSITION_MANAGER_VIEWS_ADDRESS",
|
|
5777
5922
|
"PositionManagerViews"
|
|
5778
5923
|
),
|
|
5779
|
-
simplePsmV2:
|
|
5780
|
-
loanOperationsManager:
|
|
5924
|
+
simplePsmV2: getAddress2("SIMPLE_PSM_V2_ADDRESS", "SimplePSMV2"),
|
|
5925
|
+
loanOperationsManager: getAddress2(
|
|
5781
5926
|
"LOAN_OPERATIONS_MANAGER_ADDRESS",
|
|
5782
5927
|
"LoanOperationsManagerModule"
|
|
5783
5928
|
),
|
|
5784
|
-
termManager:
|
|
5785
|
-
circuitBreaker:
|
|
5929
|
+
termManager: getAddress2("TERM_MANAGER_ADDRESS", "TermManagerModule"),
|
|
5930
|
+
circuitBreaker: getAddress2(
|
|
5786
5931
|
"CIRCUIT_BREAKER_ADDRESS",
|
|
5787
5932
|
"CircuitBreakerModule"
|
|
5788
5933
|
),
|
|
5789
|
-
liquidationManager:
|
|
5934
|
+
liquidationManager: getAddress2(
|
|
5790
5935
|
"LIQUIDATION_MANAGER_ADDRESS",
|
|
5791
5936
|
"LiquidationManagerModule"
|
|
5792
5937
|
),
|
|
5793
|
-
ucdToken:
|
|
5794
|
-
ucdController:
|
|
5795
|
-
priceFeedConsumer:
|
|
5938
|
+
ucdToken: getAddress2("UCD_TOKEN_ADDRESS", "UCDToken"),
|
|
5939
|
+
ucdController: getAddress2("UCD_CONTROLLER_ADDRESS", "UCDController"),
|
|
5940
|
+
priceFeedConsumer: getAddress2(
|
|
5796
5941
|
"PRICE_FEED_CONSUMER_ADDRESS",
|
|
5797
5942
|
"PriceFeedConsumer"
|
|
5798
5943
|
),
|
|
5799
|
-
operationAuthorizationRegistry:
|
|
5944
|
+
operationAuthorizationRegistry: getAddress2(
|
|
5800
5945
|
"OPERATION_AUTHORIZATION_REGISTRY_ADDRESS",
|
|
5801
5946
|
"OperationAuthorizationRegistry"
|
|
5802
5947
|
),
|
|
5803
|
-
btcSpendAuthorizer:
|
|
5948
|
+
btcSpendAuthorizer: getAddress2(
|
|
5804
5949
|
"BTC_SPEND_AUTHORIZER_ADDRESS",
|
|
5805
5950
|
"BTCSpendAuthorizer"
|
|
5806
5951
|
)
|
|
@@ -5874,6 +6019,11 @@ __export(src_exports, {
|
|
|
5874
6019
|
ALL_DEPLOYMENTS: () => ALL_DEPLOYMENTS,
|
|
5875
6020
|
AuthParamsValidation: () => AuthParamsValidation,
|
|
5876
6021
|
BPSConversions: () => BPSConversions,
|
|
6022
|
+
BTC_SPEND_QUANTUM_SECONDS: () => BTC_SPEND_QUANTUM_SECONDS,
|
|
6023
|
+
BTC_SPEND_RELAY_DEADLINE_SECONDS: () => BTC_SPEND_RELAY_DEADLINE_SECONDS,
|
|
6024
|
+
BTC_SPEND_REQUEST_712_DOMAIN_NAME: () => BTC_SPEND_REQUEST_712_DOMAIN_NAME,
|
|
6025
|
+
BTC_SPEND_REQUEST_712_DOMAIN_VERSION: () => BTC_SPEND_REQUEST_712_DOMAIN_VERSION,
|
|
6026
|
+
BTC_SPEND_REQUEST_712_FIELDS: () => BTC_SPEND_REQUEST_712_FIELDS,
|
|
5877
6027
|
BitcoinOperations: () => BitcoinOperations,
|
|
5878
6028
|
CacheManager: () => CacheManager,
|
|
5879
6029
|
ContractManager: () => ContractManager,
|
|
@@ -5907,9 +6057,15 @@ __export(src_exports, {
|
|
|
5907
6057
|
andThen: () => andThen,
|
|
5908
6058
|
assertProtocolNotPaused: () => assertProtocolNotPaused,
|
|
5909
6059
|
assertSafeServiceEndpoint: () => assertSafeServiceEndpoint,
|
|
6060
|
+
btcSpendAuthorizerAddress: () => btcSpendAuthorizerAddress,
|
|
6061
|
+
btcSpendRequest712Digest: () => btcSpendRequest712Digest,
|
|
6062
|
+
btcSpendRequest712Types: () => btcSpendRequest712Types,
|
|
5910
6063
|
buildBtcExecuteEnvelope: () => buildBtcExecuteEnvelope,
|
|
6064
|
+
buildBtcSpendRequest712Domain: () => buildBtcSpendRequest712Domain,
|
|
6065
|
+
buildExecuteBtcWithdrawalTypedData: () => buildExecuteBtcWithdrawalTypedData,
|
|
5911
6066
|
buildInvalidateMessageHash: () => buildInvalidateMessageHash,
|
|
5912
6067
|
buildInvalidateStaleSpendEnvelope: () => buildInvalidateStaleSpendEnvelope,
|
|
6068
|
+
buildInvalidateStaleSpendTypedData: () => buildInvalidateStaleSpendTypedData,
|
|
5913
6069
|
buildLoginDomain: () => buildLoginDomain,
|
|
5914
6070
|
buildSignedLoginPayload: () => buildSignedLoginPayload,
|
|
5915
6071
|
collectFailures: () => collectFailures,
|
|
@@ -5951,8 +6107,10 @@ __export(src_exports, {
|
|
|
5951
6107
|
mapError: () => mapError,
|
|
5952
6108
|
match: () => match,
|
|
5953
6109
|
numericToPositionStatus: () => numericToPositionStatus,
|
|
6110
|
+
readAuthorizedSpend: () => readAuthorizedSpend,
|
|
5954
6111
|
reconcileAuthorizedSpend: () => reconcileAuthorizedSpend,
|
|
5955
6112
|
setPositionDelegate: () => setPositionDelegate,
|
|
6113
|
+
signBtcSpendRequest712: () => signBtcSpendRequest712,
|
|
5956
6114
|
success: () => success,
|
|
5957
6115
|
toPromise: () => toPromise,
|
|
5958
6116
|
tryCatch: () => tryCatch,
|
|
@@ -5966,7 +6124,7 @@ __export(src_exports, {
|
|
|
5966
6124
|
module.exports = __toCommonJS(src_exports);
|
|
5967
6125
|
|
|
5968
6126
|
// src/modules/diamond-hands-sdk.ts
|
|
5969
|
-
var
|
|
6127
|
+
var import_ethers23 = require("ethers");
|
|
5970
6128
|
|
|
5971
6129
|
// src/types/result.ts
|
|
5972
6130
|
function success(value) {
|
|
@@ -8036,17 +8194,209 @@ async function reconcileAuthorizedSpend(spend, esploraBaseUrl, httpGetJson = def
|
|
|
8036
8194
|
}
|
|
8037
8195
|
|
|
8038
8196
|
// src/utils/stale-spend-invalidate-message.ts
|
|
8197
|
+
var import_ethers8 = require("ethers");
|
|
8198
|
+
|
|
8199
|
+
// src/utils/btc-spend-request-712.ts
|
|
8039
8200
|
var import_ethers7 = require("ethers");
|
|
8201
|
+
init_deployment_addresses();
|
|
8202
|
+
var BTC_SPEND_REQUEST_712_DOMAIN_NAME = "DiamondHands.Protocol";
|
|
8203
|
+
var BTC_SPEND_REQUEST_712_DOMAIN_VERSION = "1";
|
|
8204
|
+
var BTC_SPEND_REQUEST_712_FIELDS = {
|
|
8205
|
+
ExecuteBtcWithdrawalRequest: [
|
|
8206
|
+
{ name: "positionId", type: "bytes32" },
|
|
8207
|
+
{ name: "withdrawalAddress", type: "string" },
|
|
8208
|
+
{ name: "recipientAmount", type: "uint256" },
|
|
8209
|
+
{ name: "networkFee", type: "uint256" },
|
|
8210
|
+
{ name: "totalDeduction", type: "uint256" },
|
|
8211
|
+
{ name: "spendTxid", type: "string" },
|
|
8212
|
+
{ name: "spendVout", type: "uint32" },
|
|
8213
|
+
{ name: "inputSetHash", type: "bytes32" },
|
|
8214
|
+
{ name: "quantumTimestamp", type: "uint256" }
|
|
8215
|
+
],
|
|
8216
|
+
InvalidateStaleSpendRequest: [
|
|
8217
|
+
{ name: "positionId", type: "bytes32" },
|
|
8218
|
+
{ name: "spendTxid", type: "string" },
|
|
8219
|
+
{ name: "spendVout", type: "uint32" },
|
|
8220
|
+
{ name: "quantumTimestamp", type: "uint256" }
|
|
8221
|
+
]
|
|
8222
|
+
};
|
|
8223
|
+
function btcSpendRequest712Types(primaryType) {
|
|
8224
|
+
const fields = BTC_SPEND_REQUEST_712_FIELDS[primaryType];
|
|
8225
|
+
if (!fields) {
|
|
8226
|
+
throw new Error(
|
|
8227
|
+
`Unknown BTC spend request primary type "${primaryType}"; expected one of ` + Object.keys(BTC_SPEND_REQUEST_712_FIELDS).join(", ")
|
|
8228
|
+
);
|
|
8229
|
+
}
|
|
8230
|
+
return { [primaryType]: fields.map((field) => ({ ...field })) };
|
|
8231
|
+
}
|
|
8232
|
+
function btcSpendAuthorizerAddress(chainId) {
|
|
8233
|
+
if (!Number.isInteger(chainId) || chainId <= 0) {
|
|
8234
|
+
throw new Error(
|
|
8235
|
+
`BTC spend request domain requires a positive integer chainId, got ${String(chainId)}`
|
|
8236
|
+
);
|
|
8237
|
+
}
|
|
8238
|
+
const deployment = chainId === 31337 ? ALL_DEPLOYMENTS["localhost"] : Object.values(ALL_DEPLOYMENTS).find((d) => d.chainId === chainId);
|
|
8239
|
+
const address = deployment?.contracts?.BTCSpendAuthorizer;
|
|
8240
|
+
if (!address) {
|
|
8241
|
+
throw new Error(
|
|
8242
|
+
`No BTCSpendAuthorizer deployment known for chainId ${chainId}; refusing to build a BTC spend request domain without one`
|
|
8243
|
+
);
|
|
8244
|
+
}
|
|
8245
|
+
return address;
|
|
8246
|
+
}
|
|
8247
|
+
function buildBtcSpendRequest712Domain(chainId) {
|
|
8248
|
+
return {
|
|
8249
|
+
name: BTC_SPEND_REQUEST_712_DOMAIN_NAME,
|
|
8250
|
+
version: BTC_SPEND_REQUEST_712_DOMAIN_VERSION,
|
|
8251
|
+
chainId,
|
|
8252
|
+
verifyingContract: btcSpendAuthorizerAddress(chainId)
|
|
8253
|
+
};
|
|
8254
|
+
}
|
|
8255
|
+
function canonicalBtcTxid(txid) {
|
|
8256
|
+
const canonical = String(txid).toLowerCase().replace(/^0x/, "");
|
|
8257
|
+
if (!/^[0-9a-f]{64}$/.test(canonical)) {
|
|
8258
|
+
throw new Error(
|
|
8259
|
+
`Invalid Bitcoin txid "${String(txid)}": expected 64 hex characters (optionally 0x-prefixed)`
|
|
8260
|
+
);
|
|
8261
|
+
}
|
|
8262
|
+
return canonical;
|
|
8263
|
+
}
|
|
8264
|
+
function toBytes32PositionId(positionId) {
|
|
8265
|
+
const hex = positionId.startsWith("0x") ? positionId : `0x${positionId}`;
|
|
8266
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(hex)) {
|
|
8267
|
+
throw new Error(`positionId must be a bytes32 hex string, got "${positionId}"`);
|
|
8268
|
+
}
|
|
8269
|
+
return hex;
|
|
8270
|
+
}
|
|
8271
|
+
var GET_AUTHORIZED_SPENDS_ABI = [
|
|
8272
|
+
"function getAuthorizedSpends(bytes32 positionId) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"
|
|
8273
|
+
];
|
|
8274
|
+
async function readAuthorizedSpend(params) {
|
|
8275
|
+
const authorizer = new import_ethers7.Contract(
|
|
8276
|
+
btcSpendAuthorizerAddress(params.chainId),
|
|
8277
|
+
GET_AUTHORIZED_SPENDS_ABI,
|
|
8278
|
+
params.runner
|
|
8279
|
+
);
|
|
8280
|
+
const positionId = toBytes32PositionId(params.positionId);
|
|
8281
|
+
const wanted = canonicalBtcTxid(params.txid);
|
|
8282
|
+
const spends = await authorizer.getFunction("getAuthorizedSpends").staticCall(positionId);
|
|
8283
|
+
const match2 = spends.find(
|
|
8284
|
+
(s) => String(s.txid).toLowerCase().replace(/^0x/, "") === wanted && Number(s.vout) === Number(params.vout)
|
|
8285
|
+
);
|
|
8286
|
+
if (!match2) {
|
|
8287
|
+
throw new Error(
|
|
8288
|
+
`No on-chain authorized spend for ${params.txid}:${params.vout} under position ${positionId}`
|
|
8289
|
+
);
|
|
8290
|
+
}
|
|
8291
|
+
return {
|
|
8292
|
+
txid: String(match2.txid),
|
|
8293
|
+
vout: Number(match2.vout),
|
|
8294
|
+
satoshis: BigInt(match2.satoshis),
|
|
8295
|
+
targetAddress: String(match2.targetAddress),
|
|
8296
|
+
targetAmount: BigInt(match2.targetAmount),
|
|
8297
|
+
authorizedAt: BigInt(match2.authorizedAt)
|
|
8298
|
+
};
|
|
8299
|
+
}
|
|
8300
|
+
function assertRecordIsOutpoint(record, txid, vout) {
|
|
8301
|
+
if (canonicalBtcTxid(record.txid) !== canonicalBtcTxid(txid) || Number(record.vout) !== Number(vout)) {
|
|
8302
|
+
throw new Error(
|
|
8303
|
+
`The authorized spend record is for ${record.txid}:${record.vout}, not ${txid}:${vout}; refusing to sign`
|
|
8304
|
+
);
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
function buildExecuteBtcWithdrawalTypedData(params) {
|
|
8308
|
+
const { networkFee } = params;
|
|
8309
|
+
if (!Number.isSafeInteger(networkFee) || networkFee < 0) {
|
|
8310
|
+
throw new Error(
|
|
8311
|
+
`networkFee must be a non-negative integer number of satoshis, got ${String(networkFee)}`
|
|
8312
|
+
);
|
|
8313
|
+
}
|
|
8314
|
+
const totalDeduction = BigInt(params.record.targetAmount);
|
|
8315
|
+
if (BigInt(networkFee) >= totalDeduction) {
|
|
8316
|
+
throw new Error(
|
|
8317
|
+
`Network fee ${networkFee} sats must be below the authorized total ${totalDeduction.toString()} sats`
|
|
8318
|
+
);
|
|
8319
|
+
}
|
|
8320
|
+
const primaryType = "ExecuteBtcWithdrawalRequest";
|
|
8321
|
+
return {
|
|
8322
|
+
domain: buildBtcSpendRequest712Domain(params.chainId),
|
|
8323
|
+
types: btcSpendRequest712Types(primaryType),
|
|
8324
|
+
primaryType,
|
|
8325
|
+
message: {
|
|
8326
|
+
positionId: toBytes32PositionId(params.positionId),
|
|
8327
|
+
withdrawalAddress: params.record.targetAddress,
|
|
8328
|
+
recipientAmount: (totalDeduction - BigInt(networkFee)).toString(),
|
|
8329
|
+
networkFee: String(networkFee),
|
|
8330
|
+
totalDeduction: totalDeduction.toString(),
|
|
8331
|
+
spendTxid: canonicalBtcTxid(params.record.txid),
|
|
8332
|
+
spendVout: Number(params.record.vout),
|
|
8333
|
+
inputSetHash: params.inputSetHash,
|
|
8334
|
+
quantumTimestamp: String(params.quantumTimestamp)
|
|
8335
|
+
}
|
|
8336
|
+
};
|
|
8337
|
+
}
|
|
8338
|
+
function buildInvalidateStaleSpendTypedData(params) {
|
|
8339
|
+
const primaryType = "InvalidateStaleSpendRequest";
|
|
8340
|
+
return {
|
|
8341
|
+
domain: buildBtcSpendRequest712Domain(params.chainId),
|
|
8342
|
+
types: btcSpendRequest712Types(primaryType),
|
|
8343
|
+
primaryType,
|
|
8344
|
+
message: {
|
|
8345
|
+
positionId: toBytes32PositionId(params.positionId),
|
|
8346
|
+
spendTxid: canonicalBtcTxid(params.record.txid),
|
|
8347
|
+
spendVout: Number(params.record.vout),
|
|
8348
|
+
quantumTimestamp: String(params.quantumTimestamp)
|
|
8349
|
+
}
|
|
8350
|
+
};
|
|
8351
|
+
}
|
|
8352
|
+
function btcSpendRequest712Digest(payload) {
|
|
8353
|
+
return import_ethers7.TypedDataEncoder.hash(payload.domain, payload.types, payload.message);
|
|
8354
|
+
}
|
|
8355
|
+
var BTC_SPEND_QUANTUM_SECONDS = 60;
|
|
8356
|
+
var BTC_SPEND_RELAY_DEADLINE_SECONDS = 90;
|
|
8357
|
+
function quantumStart(nowMs) {
|
|
8358
|
+
return Math.floor(nowMs / 1e3 / BTC_SPEND_QUANTUM_SECONDS) * BTC_SPEND_QUANTUM_SECONDS;
|
|
8359
|
+
}
|
|
8360
|
+
async function signBtcSpendRequest712(signer, build) {
|
|
8361
|
+
let signature;
|
|
8362
|
+
let quantumTimestamp;
|
|
8363
|
+
const restamp = signer.dhRestampTypedData;
|
|
8364
|
+
if (typeof restamp === "function") {
|
|
8365
|
+
({ signature, quantumTimestamp } = await restamp.call(signer, build));
|
|
8366
|
+
} else {
|
|
8367
|
+
const signTypedData = signer.signTypedData;
|
|
8368
|
+
if (typeof signTypedData !== "function") {
|
|
8369
|
+
throw new Error(
|
|
8370
|
+
`Signer has no signTypedData \u2014 cannot produce an EIP-712 BTC spend request. Wallets without typed-data support must supply the signature via an authorizationProvider instead of a connected signer.`
|
|
8371
|
+
);
|
|
8372
|
+
}
|
|
8373
|
+
quantumTimestamp = quantumStart(Date.now());
|
|
8374
|
+
const payload = build(quantumTimestamp);
|
|
8375
|
+
signature = await signTypedData.call(signer, payload.domain, payload.types, payload.message);
|
|
8376
|
+
}
|
|
8377
|
+
const nowMs = Date.now();
|
|
8378
|
+
if (quantumTimestamp > quantumStart(nowMs)) {
|
|
8379
|
+
throw new Error(
|
|
8380
|
+
`The signature is stamped ${quantumTimestamp}, in a quantum that has not started; the Bitcoin signer refuses future stamps. Nothing was submitted.`
|
|
8381
|
+
);
|
|
8382
|
+
}
|
|
8383
|
+
if (nowMs / 1e3 - quantumTimestamp > BTC_SPEND_RELAY_DEADLINE_SECONDS) {
|
|
8384
|
+
throw new Error(
|
|
8385
|
+
`Signed too late: the signature is stamped ${quantumTimestamp}, more than ${BTC_SPEND_RELAY_DEADLINE_SECONDS} s ago, so the Bitcoin signer would refuse it. Nothing was submitted; retry and approve promptly.`
|
|
8386
|
+
);
|
|
8387
|
+
}
|
|
8388
|
+
return { signature, quantumTimestamp, payload: build(quantumTimestamp) };
|
|
8389
|
+
}
|
|
8390
|
+
|
|
8391
|
+
// src/utils/stale-spend-invalidate-message.ts
|
|
8040
8392
|
var RECOVERY_INVALIDATE_ACTION = "btc-utxo-invalidator";
|
|
8041
|
-
var QUANTUM_SECONDS = 60;
|
|
8042
|
-
var QUANTUM_SAFE_THRESHOLD = 40;
|
|
8043
8393
|
function buildInvalidateMessageHash(params) {
|
|
8044
|
-
const positionIdBytes32 = (0,
|
|
8394
|
+
const positionIdBytes32 = (0, import_ethers8.zeroPadValue)(
|
|
8045
8395
|
params.positionId.startsWith("0x") ? params.positionId : `0x${params.positionId}`,
|
|
8046
8396
|
32
|
|
8047
8397
|
);
|
|
8048
|
-
const actionHash = (0,
|
|
8049
|
-
return (0,
|
|
8398
|
+
const actionHash = (0, import_ethers8.keccak256)((0, import_ethers8.toUtf8Bytes)(RECOVERY_INVALIDATE_ACTION));
|
|
8399
|
+
return (0, import_ethers8.solidityPackedKeccak256)(
|
|
8050
8400
|
[
|
|
8051
8401
|
"bytes32",
|
|
8052
8402
|
// positionId
|
|
@@ -8073,32 +8423,29 @@ function buildInvalidateMessageHash(params) {
|
|
|
8073
8423
|
}
|
|
8074
8424
|
async function buildInvalidateStaleSpendEnvelope(params) {
|
|
8075
8425
|
const { positionId, utxoTxid, utxoVout, chainId, signer } = params;
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
if (secsIntoQuantum > QUANTUM_SAFE_THRESHOLD) {
|
|
8081
|
-
const nextQuantumStart = currentQuantumStart + QUANTUM_SECONDS;
|
|
8082
|
-
const waitMs = Math.max(0, (nextQuantumStart - nowSec) * 1e3 + 500);
|
|
8083
|
-
await new Promise((r) => setTimeout(r, waitMs));
|
|
8084
|
-
timestamp = nextQuantumStart;
|
|
8085
|
-
} else {
|
|
8086
|
-
timestamp = currentQuantumStart;
|
|
8426
|
+
if (params.provider === void 0 === (params.authorizedSpend === void 0)) {
|
|
8427
|
+
throw new Error(
|
|
8428
|
+
"buildInvalidateStaleSpendEnvelope: supply exactly one of `provider` or `authorizedSpend` so the outpoint comes from the on-chain record"
|
|
8429
|
+
);
|
|
8087
8430
|
}
|
|
8088
|
-
const
|
|
8089
|
-
|
|
8090
|
-
timestamp,
|
|
8431
|
+
const record = params.authorizedSpend ?? await readAuthorizedSpend({
|
|
8432
|
+
runner: params.provider,
|
|
8091
8433
|
chainId,
|
|
8092
|
-
|
|
8093
|
-
|
|
8434
|
+
positionId,
|
|
8435
|
+
txid: utxoTxid,
|
|
8436
|
+
vout: utxoVout
|
|
8094
8437
|
});
|
|
8095
|
-
|
|
8438
|
+
assertRecordIsOutpoint(record, utxoTxid, utxoVout);
|
|
8439
|
+
const { signature, quantumTimestamp } = await signBtcSpendRequest712(
|
|
8440
|
+
signer,
|
|
8441
|
+
(stamp) => buildInvalidateStaleSpendTypedData({ chainId, positionId, record, quantumTimestamp: stamp })
|
|
8442
|
+
);
|
|
8096
8443
|
const borrowerAddress = await signer.getAddress();
|
|
8097
8444
|
return {
|
|
8098
8445
|
positionId,
|
|
8099
8446
|
utxoTxid,
|
|
8100
8447
|
utxoVout,
|
|
8101
|
-
timestamp,
|
|
8448
|
+
timestamp: quantumTimestamp,
|
|
8102
8449
|
chainId,
|
|
8103
8450
|
action: RECOVERY_INVALIDATE_ACTION,
|
|
8104
8451
|
signature,
|
|
@@ -8107,9 +8454,7 @@ async function buildInvalidateStaleSpendEnvelope(params) {
|
|
|
8107
8454
|
}
|
|
8108
8455
|
|
|
8109
8456
|
// src/utils/btc-withdrawal-message.ts
|
|
8110
|
-
var
|
|
8111
|
-
var QUANTUM_SECONDS2 = 60;
|
|
8112
|
-
var QUANTUM_SAFE_THRESHOLD2 = 40;
|
|
8457
|
+
var import_ethers9 = require("ethers");
|
|
8113
8458
|
function hashBtcInputSet(utxos) {
|
|
8114
8459
|
if (!Array.isArray(utxos) || utxos.length === 0) {
|
|
8115
8460
|
throw new Error("hashBtcInputSet: at least one input is required");
|
|
@@ -8138,26 +8483,31 @@ function hashBtcInputSet(utxos) {
|
|
|
8138
8483
|
seen.add(key);
|
|
8139
8484
|
}
|
|
8140
8485
|
const canonical = normalized.sort((a, b) => a.txid < b.txid ? -1 : a.txid > b.txid ? 1 : a.vout - b.vout).map((u) => `${u.txid}:${u.vout}:${u.value}`).join("|");
|
|
8141
|
-
return (0,
|
|
8486
|
+
return (0, import_ethers9.keccak256)((0, import_ethers9.toUtf8Bytes)(canonical));
|
|
8142
8487
|
}
|
|
8143
8488
|
async function buildBtcExecuteEnvelope(params) {
|
|
8144
|
-
const {
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
targetAddress,
|
|
8150
|
-
targetAmount,
|
|
8151
|
-
networkFee,
|
|
8152
|
-
chainId,
|
|
8153
|
-
signer
|
|
8154
|
-
} = params;
|
|
8155
|
-
if (!targetAddress || typeof targetAddress !== "string") {
|
|
8156
|
-
throw new Error("buildBtcExecuteEnvelope: targetAddress is required");
|
|
8489
|
+
const { positionId, txid, vout, satoshis, networkFee, chainId, signer } = params;
|
|
8490
|
+
if (params.provider === void 0 === (params.authorizedSpend === void 0)) {
|
|
8491
|
+
throw new Error(
|
|
8492
|
+
"buildBtcExecuteEnvelope: supply exactly one of `provider` or `authorizedSpend` so the destination and amount come from the on-chain record"
|
|
8493
|
+
);
|
|
8157
8494
|
}
|
|
8158
|
-
|
|
8495
|
+
const record = params.authorizedSpend ?? await readAuthorizedSpend({ runner: params.provider, chainId, positionId, txid, vout });
|
|
8496
|
+
assertRecordIsOutpoint(record, txid, vout);
|
|
8497
|
+
if (params.targetAddress !== void 0 && params.targetAddress !== record.targetAddress) {
|
|
8159
8498
|
throw new Error(
|
|
8160
|
-
|
|
8499
|
+
`buildBtcExecuteEnvelope: destination "${params.targetAddress}" disagrees with the on-chain authorized spend "${record.targetAddress}"; refusing to sign`
|
|
8500
|
+
);
|
|
8501
|
+
}
|
|
8502
|
+
if (params.targetAmount !== void 0 && BigInt(params.targetAmount) !== record.targetAmount) {
|
|
8503
|
+
throw new Error(
|
|
8504
|
+
`buildBtcExecuteEnvelope: amount ${params.targetAmount} sats disagrees with the on-chain authorized spend ${record.targetAmount.toString()} sats; refusing to sign`
|
|
8505
|
+
);
|
|
8506
|
+
}
|
|
8507
|
+
const targetAmount = Number(record.targetAmount);
|
|
8508
|
+
if (!Number.isSafeInteger(targetAmount) || targetAmount <= 0) {
|
|
8509
|
+
throw new Error(
|
|
8510
|
+
`buildBtcExecuteEnvelope: on-chain targetAmount ${record.targetAmount.toString()} is not a positive safe integer`
|
|
8161
8511
|
);
|
|
8162
8512
|
}
|
|
8163
8513
|
const utxos = params.utxos && params.utxos.length > 0 ? params.utxos : [{ txid, vout, value: satoshis }];
|
|
@@ -8170,73 +8520,30 @@ async function buildBtcExecuteEnvelope(params) {
|
|
|
8170
8520
|
`buildBtcExecuteEnvelope: the authorized UTXO ${txid}:${vout} must be part of utxos[]`
|
|
8171
8521
|
);
|
|
8172
8522
|
}
|
|
8173
|
-
const
|
|
8174
|
-
const
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
let timestamp;
|
|
8178
|
-
if (secsIntoQuantum > QUANTUM_SAFE_THRESHOLD2) {
|
|
8179
|
-
const nextQuantumStart = currentQuantumStart + QUANTUM_SECONDS2;
|
|
8180
|
-
const waitMs = Math.max(0, (nextQuantumStart - nowSec) * 1e3 + 500);
|
|
8181
|
-
await new Promise((r) => setTimeout(r, waitMs));
|
|
8182
|
-
timestamp = nextQuantumStart;
|
|
8183
|
-
} else {
|
|
8184
|
-
timestamp = currentQuantumStart;
|
|
8185
|
-
}
|
|
8186
|
-
const actionHash = (0, import_ethers8.keccak256)(
|
|
8187
|
-
(0, import_ethers8.toUtf8Bytes)("execute-btc-withdrawal")
|
|
8188
|
-
);
|
|
8189
|
-
const utxoIdentifier = `${txid}:${vout}`;
|
|
8190
|
-
const positionIdBytes32 = (0, import_ethers8.zeroPadValue)(
|
|
8191
|
-
positionId.startsWith("0x") ? positionId : `0x${positionId}`,
|
|
8192
|
-
32
|
|
8193
|
-
);
|
|
8194
|
-
const messageHash = (0, import_ethers8.solidityPackedKeccak256)(
|
|
8195
|
-
[
|
|
8196
|
-
"bytes32",
|
|
8197
|
-
// positionId
|
|
8198
|
-
"uint256",
|
|
8199
|
-
// timestamp
|
|
8200
|
-
"uint256",
|
|
8201
|
-
// chainId
|
|
8202
|
-
"string",
|
|
8203
|
-
// utxoIdentifier ("txid:vout")
|
|
8204
|
-
"uint256",
|
|
8205
|
-
// networkFee
|
|
8206
|
-
"string",
|
|
8207
|
-
// targetAddress (BTC destination)
|
|
8208
|
-
"uint256",
|
|
8209
|
-
// targetAmount (sats authorized to recipient)
|
|
8210
|
-
"bytes32",
|
|
8211
|
-
// utxosHash (canonical hash of the FULL input set — P6/#8)
|
|
8212
|
-
"bytes32"
|
|
8213
|
-
// actionHash
|
|
8214
|
-
],
|
|
8215
|
-
[
|
|
8216
|
-
positionIdBytes32,
|
|
8217
|
-
timestamp,
|
|
8523
|
+
const inputSetHash = hashBtcInputSet(utxos);
|
|
8524
|
+
const { signature, quantumTimestamp } = await signBtcSpendRequest712(
|
|
8525
|
+
signer,
|
|
8526
|
+
(stamp) => buildExecuteBtcWithdrawalTypedData({
|
|
8218
8527
|
chainId,
|
|
8219
|
-
|
|
8528
|
+
positionId,
|
|
8529
|
+
record,
|
|
8220
8530
|
networkFee,
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
actionHash
|
|
8225
|
-
]
|
|
8531
|
+
inputSetHash,
|
|
8532
|
+
quantumTimestamp: stamp
|
|
8533
|
+
})
|
|
8226
8534
|
);
|
|
8227
|
-
const userSignature = await signer.signMessage((0, import_ethers8.getBytes)(messageHash));
|
|
8228
8535
|
const borrowerAddress = await signer.getAddress();
|
|
8229
8536
|
return {
|
|
8230
8537
|
positionId,
|
|
8231
8538
|
txid,
|
|
8232
8539
|
vout,
|
|
8233
8540
|
satoshis,
|
|
8234
|
-
targetAddress,
|
|
8541
|
+
targetAddress: record.targetAddress,
|
|
8235
8542
|
targetAmount,
|
|
8236
8543
|
networkFee,
|
|
8237
8544
|
chainId,
|
|
8238
|
-
timestamp,
|
|
8239
|
-
userSignature,
|
|
8545
|
+
timestamp: quantumTimestamp,
|
|
8546
|
+
userSignature: signature,
|
|
8240
8547
|
borrowerAddress,
|
|
8241
8548
|
utxos
|
|
8242
8549
|
};
|
|
@@ -8288,7 +8595,7 @@ function maybeTemperSignature(signature, shouldTemper, operationName) {
|
|
|
8288
8595
|
}
|
|
8289
8596
|
|
|
8290
8597
|
// src/utils/address-conversion.utils.ts
|
|
8291
|
-
var
|
|
8598
|
+
var import_ethers10 = require("ethers");
|
|
8292
8599
|
|
|
8293
8600
|
// src/utils/chunks/bitcoin-utils.ts
|
|
8294
8601
|
var import_sha256 = require("@noble/hashes/sha256");
|
|
@@ -8479,6 +8786,8 @@ function isValidBech32Address(address) {
|
|
|
8479
8786
|
const witnessVersion = decoded.words[0];
|
|
8480
8787
|
if (witnessVersion < 0 || witnessVersion > 16)
|
|
8481
8788
|
return false;
|
|
8789
|
+
if (witnessVersion === 0 !== (codec === import_bech32.bech32))
|
|
8790
|
+
return false;
|
|
8482
8791
|
const program = import_bech32.bech32.fromWords(decoded.words.slice(1));
|
|
8483
8792
|
if (program.length < 2 || program.length > 40)
|
|
8484
8793
|
return false;
|
|
@@ -8575,18 +8884,27 @@ function safeValidateBitcoinAddress(address, network) {
|
|
|
8575
8884
|
}
|
|
8576
8885
|
return address;
|
|
8577
8886
|
}
|
|
8887
|
+
var BECH32_PREFIX = /^(bc1|tb1|bcrt1)/i;
|
|
8888
|
+
function bitcoinAddressCaseError(address) {
|
|
8889
|
+
const trimmed = address.trim();
|
|
8890
|
+
if (!BECH32_PREFIX.test(trimmed))
|
|
8891
|
+
return null;
|
|
8892
|
+
if (trimmed === trimmed.toLowerCase() || trimmed === trimmed.toUpperCase())
|
|
8893
|
+
return null;
|
|
8894
|
+
return `Bitcoin address ${trimmed} mixes upper and lower case \u2014 a bech32 address must be entirely one case (BIP-173). Re-copy it from the source.`;
|
|
8895
|
+
}
|
|
8578
8896
|
function normalizeBitcoinAddress(address) {
|
|
8579
8897
|
if (!address || typeof address !== "string")
|
|
8580
8898
|
return address;
|
|
8581
8899
|
const trimmed = address.trim();
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
return trimmed;
|
|
8900
|
+
const caseError = bitcoinAddressCaseError(trimmed);
|
|
8901
|
+
if (caseError)
|
|
8902
|
+
throw new Error(caseError);
|
|
8903
|
+
return BECH32_PREFIX.test(trimmed) ? trimmed.toLowerCase() : trimmed;
|
|
8586
8904
|
}
|
|
8587
8905
|
|
|
8588
8906
|
// src/protocol/protocol-pause.ts
|
|
8589
|
-
var
|
|
8907
|
+
var import_ethers11 = require("ethers");
|
|
8590
8908
|
var GET_PROTOCOL_PAUSE_STATUS_ABI = [
|
|
8591
8909
|
"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))"
|
|
8592
8910
|
];
|
|
@@ -8608,7 +8926,7 @@ function rowToStatus(row) {
|
|
|
8608
8926
|
return row;
|
|
8609
8927
|
}
|
|
8610
8928
|
async function fetchProtocolPauseStatus(provider, positionManagerAddress) {
|
|
8611
|
-
const iface = new
|
|
8929
|
+
const iface = new import_ethers11.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
|
|
8612
8930
|
const data = iface.encodeFunctionData("getProtocolPauseStatus", []);
|
|
8613
8931
|
const raw = await provider.call({ to: positionManagerAddress, data });
|
|
8614
8932
|
const decoded = iface.decodeFunctionResult("getProtocolPauseStatus", raw);
|
|
@@ -8741,7 +9059,7 @@ function extractOptionalLitSignature(raw) {
|
|
|
8741
9059
|
}
|
|
8742
9060
|
|
|
8743
9061
|
// src/modules/contract/contract-manager.module.ts
|
|
8744
|
-
var
|
|
9062
|
+
var import_ethers12 = require("ethers");
|
|
8745
9063
|
init_deployment_addresses();
|
|
8746
9064
|
var POSITION_MANAGER_ABI = [
|
|
8747
9065
|
"function createPosition(bytes32 pkpId, bytes calldata validatorSignature, string mainnetVaultAddress, string regtestVaultAddress, uint256 selectedTermMonths, uint256 validatorVersion, bytes calldata pkpPublicKey) external returns (bytes32 positionId)",
|
|
@@ -8815,38 +9133,38 @@ var ContractManager = class {
|
|
|
8815
9133
|
}
|
|
8816
9134
|
const contractRunner = runner;
|
|
8817
9135
|
const contracts = {
|
|
8818
|
-
positionManager: new
|
|
9136
|
+
positionManager: new import_ethers12.Contract(
|
|
8819
9137
|
contractAddresses.positionManager,
|
|
8820
9138
|
POSITION_MANAGER_ABI,
|
|
8821
9139
|
contractRunner
|
|
8822
9140
|
),
|
|
8823
|
-
loanOperationsManager: new
|
|
8824
|
-
contractAddresses.loanOperationsManager ||
|
|
9141
|
+
loanOperationsManager: new import_ethers12.Contract(
|
|
9142
|
+
contractAddresses.loanOperationsManager || import_ethers12.ZeroAddress,
|
|
8825
9143
|
LOAN_OPS_ABI,
|
|
8826
9144
|
contractRunner
|
|
8827
9145
|
),
|
|
8828
|
-
ucdController: new
|
|
9146
|
+
ucdController: new import_ethers12.Contract(
|
|
8829
9147
|
contractAddresses.ucdToken,
|
|
8830
9148
|
UCD_CONTROLLER_ABI,
|
|
8831
9149
|
contractRunner
|
|
8832
9150
|
),
|
|
8833
|
-
termManager: new
|
|
8834
|
-
contractAddresses.termManager ||
|
|
9151
|
+
termManager: new import_ethers12.Contract(
|
|
9152
|
+
contractAddresses.termManager || import_ethers12.ZeroAddress,
|
|
8835
9153
|
TERM_MANAGER_ABI,
|
|
8836
9154
|
contractRunner
|
|
8837
9155
|
),
|
|
8838
|
-
circuitBreaker: new
|
|
8839
|
-
contractAddresses.circuitBreaker ||
|
|
9156
|
+
circuitBreaker: new import_ethers12.Contract(
|
|
9157
|
+
contractAddresses.circuitBreaker || import_ethers12.ZeroAddress,
|
|
8840
9158
|
CIRCUIT_BREAKER_ABI,
|
|
8841
9159
|
contractRunner
|
|
8842
9160
|
),
|
|
8843
|
-
liquidationManager: new
|
|
8844
|
-
contractAddresses.liquidationManager ||
|
|
9161
|
+
liquidationManager: new import_ethers12.Contract(
|
|
9162
|
+
contractAddresses.liquidationManager || import_ethers12.ZeroAddress,
|
|
8845
9163
|
LIQUIDATION_MANAGER_ABI,
|
|
8846
9164
|
contractRunner
|
|
8847
9165
|
),
|
|
8848
|
-
bitcoinWithdrawalAddressRegistry: new
|
|
8849
|
-
contractAddresses.bitcoinWithdrawalAddressRegistry ||
|
|
9166
|
+
bitcoinWithdrawalAddressRegistry: new import_ethers12.Contract(
|
|
9167
|
+
contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers12.ZeroAddress,
|
|
8850
9168
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_ABI,
|
|
8851
9169
|
contractRunner
|
|
8852
9170
|
)
|
|
@@ -8895,13 +9213,13 @@ var ContractManager = class {
|
|
|
8895
9213
|
const address = addresses[key];
|
|
8896
9214
|
if (!address) {
|
|
8897
9215
|
missing.push(String(key));
|
|
8898
|
-
} else if (!(0,
|
|
9216
|
+
} else if (!(0, import_ethers12.isAddress)(address)) {
|
|
8899
9217
|
invalid.push(String(key));
|
|
8900
9218
|
}
|
|
8901
9219
|
}
|
|
8902
9220
|
for (const key of optionalAddresses) {
|
|
8903
9221
|
const address = addresses[key];
|
|
8904
|
-
if (address && !(0,
|
|
9222
|
+
if (address && !(0, import_ethers12.isAddress)(address)) {
|
|
8905
9223
|
invalid.push(String(key));
|
|
8906
9224
|
}
|
|
8907
9225
|
}
|
|
@@ -9867,7 +10185,7 @@ function createPKPManager(config) {
|
|
|
9867
10185
|
}
|
|
9868
10186
|
|
|
9869
10187
|
// src/modules/loan/loan-creator.module.ts
|
|
9870
|
-
var
|
|
10188
|
+
var import_ethers13 = require("ethers");
|
|
9871
10189
|
var import_dh_lit_actions = __toESM(require_pkg_src());
|
|
9872
10190
|
|
|
9873
10191
|
// src/utils/contract-wallet.utils.ts
|
|
@@ -10226,11 +10544,11 @@ var LoanCreator = class {
|
|
|
10226
10544
|
try {
|
|
10227
10545
|
const mainnetVaultAddress = bitcoinAddresses.mainnet;
|
|
10228
10546
|
const regtestVaultAddress = bitcoinAddresses.regtest;
|
|
10229
|
-
const pkpIdBytes32 = (0,
|
|
10230
|
-
(0,
|
|
10547
|
+
const pkpIdBytes32 = (0, import_ethers13.zeroPadValue)(
|
|
10548
|
+
(0, import_ethers13.toBeHex)(BigInt(pkpData.tokenId)),
|
|
10231
10549
|
32
|
|
10232
10550
|
);
|
|
10233
|
-
const pkpPublicKeyUncompressed =
|
|
10551
|
+
const pkpPublicKeyUncompressed = import_ethers13.SigningKey.computePublicKey(
|
|
10234
10552
|
pkpData.publicKey,
|
|
10235
10553
|
false
|
|
10236
10554
|
);
|
|
@@ -10243,7 +10561,7 @@ var LoanCreator = class {
|
|
|
10243
10561
|
);
|
|
10244
10562
|
log.debug(`BigInt conversion: ${BigInt(pkpData.tokenId).toString()}`);
|
|
10245
10563
|
log.debug(
|
|
10246
|
-
`Hex from BigInt: ${(0,
|
|
10564
|
+
`Hex from BigInt: ${(0, import_ethers13.toBeHex)(BigInt(pkpData.tokenId))}`
|
|
10247
10565
|
);
|
|
10248
10566
|
log.debug(`Final bytes32 (zero-padded): ${pkpIdBytes32}`);
|
|
10249
10567
|
log.debug(
|
|
@@ -10415,8 +10733,8 @@ var LoanCreator = class {
|
|
|
10415
10733
|
}
|
|
10416
10734
|
}
|
|
10417
10735
|
if (this.config.debug) {
|
|
10418
|
-
const pkpIdBytes32Check = (0,
|
|
10419
|
-
(0,
|
|
10736
|
+
const pkpIdBytes32Check = (0, import_ethers13.zeroPadValue)(
|
|
10737
|
+
(0, import_ethers13.toBeHex)(BigInt(pkpData.tokenId)),
|
|
10420
10738
|
32
|
|
10421
10739
|
);
|
|
10422
10740
|
log.error("\u274C Loan creation transaction failed", {
|
|
@@ -10577,7 +10895,7 @@ var LoanCreator = class {
|
|
|
10577
10895
|
const coreAddress = this.config.contractManager.getContractAddresses().positionManagerCore;
|
|
10578
10896
|
if (coreAddress) {
|
|
10579
10897
|
try {
|
|
10580
|
-
const core = new
|
|
10898
|
+
const core = new import_ethers13.Contract(
|
|
10581
10899
|
coreAddress,
|
|
10582
10900
|
[
|
|
10583
10901
|
"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))"
|
|
@@ -10619,8 +10937,8 @@ var LoanCreator = class {
|
|
|
10619
10937
|
const newEventAbi = [
|
|
10620
10938
|
"event PositionCreated(bytes32 indexed positionId, bytes32 indexed pkpId, address indexed borrower, uint256 requestedCollateralRatio, uint256 selectedTerm, uint256 expiryAt)"
|
|
10621
10939
|
];
|
|
10622
|
-
const oldIface = new
|
|
10623
|
-
const newIface = new
|
|
10940
|
+
const oldIface = new import_ethers13.Interface(oldEventAbi);
|
|
10941
|
+
const newIface = new import_ethers13.Interface(newEventAbi);
|
|
10624
10942
|
let positionId;
|
|
10625
10943
|
if (this.config.debug) {
|
|
10626
10944
|
log.info("\u{1F50D} Parsing transaction receipt logs", {
|
|
@@ -10714,7 +11032,7 @@ var LoanStatus = /* @__PURE__ */ ((LoanStatus2) => {
|
|
|
10714
11032
|
})(LoanStatus || {});
|
|
10715
11033
|
|
|
10716
11034
|
// src/modules/loan/loan-query.module.ts
|
|
10717
|
-
var
|
|
11035
|
+
var import_ethers14 = require("ethers");
|
|
10718
11036
|
|
|
10719
11037
|
// src/constants/chunks/sdk-limits.ts
|
|
10720
11038
|
var THE_GRAPH_MAX_BATCH_SIZE = 1e3;
|
|
@@ -11111,7 +11429,7 @@ var LoanQuery = class {
|
|
|
11111
11429
|
const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
|
|
11112
11430
|
if (isChipotlePkpId2) {
|
|
11113
11431
|
if (this.config.positionManagerCoreAddress && this.config.provider) {
|
|
11114
|
-
const pmContract = new
|
|
11432
|
+
const pmContract = new import_ethers14.Contract(
|
|
11115
11433
|
this.config.positionManagerCoreAddress,
|
|
11116
11434
|
POSITION_CORE_ABI,
|
|
11117
11435
|
this.config.provider
|
|
@@ -11214,7 +11532,7 @@ var LoanQuery = class {
|
|
|
11214
11532
|
*/
|
|
11215
11533
|
async getBorrowerUcdDebtSummary(borrower) {
|
|
11216
11534
|
const trimmed = typeof borrower === "string" ? borrower.trim() : "";
|
|
11217
|
-
if (!(0,
|
|
11535
|
+
if (!(0, import_ethers14.isAddress)(trimmed)) {
|
|
11218
11536
|
return failure(
|
|
11219
11537
|
new SDKError({
|
|
11220
11538
|
message: `Borrower must be an EVM address for a UCD debt summary, got "${trimmed}"`,
|
|
@@ -11471,7 +11789,7 @@ function createLoanQuery(config) {
|
|
|
11471
11789
|
}
|
|
11472
11790
|
|
|
11473
11791
|
// src/modules/withdrawal-address/withdrawal-address.module.ts
|
|
11474
|
-
var
|
|
11792
|
+
var import_ethers15 = require("ethers");
|
|
11475
11793
|
var STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS = 5e3;
|
|
11476
11794
|
var WithdrawalAddressModule = class {
|
|
11477
11795
|
config;
|
|
@@ -11489,7 +11807,7 @@ var WithdrawalAddressModule = class {
|
|
|
11489
11807
|
if (!res.success)
|
|
11490
11808
|
return res;
|
|
11491
11809
|
const target = res.value.target;
|
|
11492
|
-
if (!target || target ===
|
|
11810
|
+
if (!target || target === import_ethers15.ZeroAddress) {
|
|
11493
11811
|
return failure(
|
|
11494
11812
|
new SDKError({
|
|
11495
11813
|
code: "SDK_WITHDRAWAL_REGISTRY_NOT_CONFIGURED",
|
|
@@ -11505,9 +11823,31 @@ var WithdrawalAddressModule = class {
|
|
|
11505
11823
|
isConfigured() {
|
|
11506
11824
|
return this.getRegistry().success;
|
|
11507
11825
|
}
|
|
11508
|
-
/**
|
|
11826
|
+
/**
|
|
11827
|
+
* keccak256 of the canonicalized address — matches the on-chain key.
|
|
11828
|
+
* @throws on mixed-case bech32, which has no canonical spelling (BIP-173).
|
|
11829
|
+
*/
|
|
11509
11830
|
static addressHash(btcAddress) {
|
|
11510
|
-
return (0,
|
|
11831
|
+
return (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress)));
|
|
11832
|
+
}
|
|
11833
|
+
/**
|
|
11834
|
+
* The canonical spelling the registry keys on, or a VALIDATION failure for mixed-case
|
|
11835
|
+
* bech32 — reported as a value, like every other failure of this module, never thrown.
|
|
11836
|
+
*/
|
|
11837
|
+
canonicalAddress(btcAddress) {
|
|
11838
|
+
const caseError = bitcoinAddressCaseError(btcAddress);
|
|
11839
|
+
if (caseError) {
|
|
11840
|
+
return failure(
|
|
11841
|
+
new SDKError({
|
|
11842
|
+
code: "SDK_INVALID_BITCOIN_ADDRESS",
|
|
11843
|
+
message: caseError,
|
|
11844
|
+
category: "VALIDATION" /* VALIDATION */,
|
|
11845
|
+
severity: "MEDIUM" /* MEDIUM */,
|
|
11846
|
+
context: { btcAddress }
|
|
11847
|
+
})
|
|
11848
|
+
);
|
|
11849
|
+
}
|
|
11850
|
+
return success(normalizeBitcoinAddress(btcAddress));
|
|
11511
11851
|
}
|
|
11512
11852
|
/**
|
|
11513
11853
|
* Add a Bitcoin address to the caller's allowlist. It becomes usable only
|
|
@@ -11517,7 +11857,10 @@ var WithdrawalAddressModule = class {
|
|
|
11517
11857
|
const reg = this.getRegistry();
|
|
11518
11858
|
if (!reg.success)
|
|
11519
11859
|
return reg;
|
|
11520
|
-
const
|
|
11860
|
+
const canonical = this.canonicalAddress(btcAddress);
|
|
11861
|
+
if (!canonical.success)
|
|
11862
|
+
return canonical;
|
|
11863
|
+
const normalized = canonical.value;
|
|
11521
11864
|
try {
|
|
11522
11865
|
const tx = await reg.value.addAddress(normalized);
|
|
11523
11866
|
return success(tx);
|
|
@@ -11535,7 +11878,10 @@ var WithdrawalAddressModule = class {
|
|
|
11535
11878
|
const reg = this.getRegistry();
|
|
11536
11879
|
if (!reg.success)
|
|
11537
11880
|
return reg;
|
|
11538
|
-
const
|
|
11881
|
+
const canonical = this.canonicalAddress(btcAddress);
|
|
11882
|
+
if (!canonical.success)
|
|
11883
|
+
return canonical;
|
|
11884
|
+
const normalized = canonical.value;
|
|
11539
11885
|
try {
|
|
11540
11886
|
const tx = await reg.value.removeAddress(normalized);
|
|
11541
11887
|
return success(tx);
|
|
@@ -11556,11 +11902,11 @@ var WithdrawalAddressModule = class {
|
|
|
11556
11902
|
const reg = this.getRegistry();
|
|
11557
11903
|
if (!reg.success)
|
|
11558
11904
|
return reg;
|
|
11905
|
+
const canonical = this.canonicalAddress(btcAddress);
|
|
11906
|
+
if (!canonical.success)
|
|
11907
|
+
return canonical;
|
|
11559
11908
|
try {
|
|
11560
|
-
const ok = await reg.value.isApproved(
|
|
11561
|
-
user,
|
|
11562
|
-
normalizeBitcoinAddress(btcAddress)
|
|
11563
|
-
);
|
|
11909
|
+
const ok = await reg.value.isApproved(user, canonical.value);
|
|
11564
11910
|
return success(ok);
|
|
11565
11911
|
} catch (error) {
|
|
11566
11912
|
return this.txFailure("isApproved", error, btcAddress);
|
|
@@ -14973,7 +15319,7 @@ var DiamondHandsGraph = class {
|
|
|
14973
15319
|
};
|
|
14974
15320
|
|
|
14975
15321
|
// src/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.ts
|
|
14976
|
-
var
|
|
15322
|
+
var import_ethers16 = require("ethers");
|
|
14977
15323
|
var _abi = [
|
|
14978
15324
|
{
|
|
14979
15325
|
inputs: [],
|
|
@@ -17541,7 +17887,7 @@ var _abi = [
|
|
|
17541
17887
|
];
|
|
17542
17888
|
var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161485a90816100f0823960805181818161278e01526128870152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c8062f7fce91461384657806301ffc9a7146137d5578063021d28931461377c5780630871b20614613743578063114249d214610f6157806311d954f81461371a57806313da3166146136e15780631d44a904146136385780631f77bf65146135ff578063248a9ca3146135e05780632b83cccd146131205780632f2ff15d146130ee57806334bac370146130b557806334e181251461307c57806336568abe14613037578063373c86b614612ffe5780633f4ba83a14612f375780634373b57214612f0e5780634451e89b14612b3a5780634ebd25a514612b015780634f1ef2861461280c5780635273b6f6146127e357806352d1902d1461277b578063568fafca146126ed57806359d5d02a146124205780635bc26aea146123eb5780635c975abb146123bb5780635ecc27081461229d5780638456cb59146121a257806385c15d9a1461216957806389d3ad00146120a25780638bff608e146120695780639010d07c1461201657806390ad8b4014611ffa57806391d1485414611fa15780639b759bf714611f5e5780639baf58d214611f415780639f1d0f59146118a8578063a217fddf1461188c578063a3246ad3146117cf578063ad3cb1cc14611788578063b492fc691461168e578063b9f637af14611463578063bf7d911914611424578063c4c5f62414611371578063c55f15ea1461134e578063ca15c87314611317578063ca2ce65d146112de578063cc1f8ffa146112ac578063cf46075e146111a2578063d21a74ff14611165578063d2f8253614611142578063d547741f14611107578063d5d3f78b14610f9a578063d66bd52414610f61578063e1f1c4a714610f44578063e1f3962c14610f18578063ec2f96fe14610ef4578063eda5a26a14610af7578063f1a1eb8414610ab4578063f385116d14610a7b578063f77c479114610a54578063f8c8765e14610661578063faaebd2114610628578063facdfb5e14610488578063fc99bd9a14610377578063fe32e7281461033e5763ffa1ad741461030857600080fd5b3461033b578060031936011261033b57610337610323613a68565b604051918291602083526020830190613a17565b0390f35b80fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361036661392e565b168152601283522054604051908152f35b503461033b57604036600319011261033b5761039161392e565b6010546024359291906001600160a01b03163303610479576001600160a01b03168082526002602052604082205490929060ff16156104665780156104575782825260076020526040822054926103e88285613cb0565b848110610448576001600160ff1b0381116104395760008051602061482e833981519152604085968493846104369852600760205280838a205582519182526020820152a23090339061421c565b80f35b630700fcb360e11b8452600484fd5b63446c8cc960e01b8452600484fd5b63162908e360e11b8252600482fd5b506024916374ed46ad60e01b8252600452fd5b6349db3bd360e01b8252600482fd5b503461033b57602036600319011261033b576104a261392e565b6104aa613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b5784916105d4575b50818111156105c5576105248282613b6c565b8215908115610570575b505060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b61271081029080820461271014901517156105b157606484029184830460641417156105b157116105a257388061052e565b63a73af74d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b6105cf8183613b6c565b610524565b90506020813d602011610603575b816105ef602093836139c3565b810103126105fe575138610511565b600080fd5b3d91506105e2565b6040513d86823e3d90fd5b6374ed46ad60e01b8252600452602490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361065061392e565b168152600483522054604051908152f35b503461033b57608036600319011261033b5761067b61392e565b610683613944565b6044356001600160a01b03811690818103610a50576064356001600160a01b0381169390849003610a4c5760008051602061480e83398151915254604081901c60ff161595906001600160401b031680159081610a44575b6001149081610a3a575b159081610a31575b50610a225760008051602061480e83398151915280546001600160401b0319166001179055856109fd575b6001600160a01b03169081156109ee576001600160a01b03169081156109df5783156109d05761074661448a565b61074e61448a565b61075661448a565b61075e61448a565b60016000805160206147ce8339815191525561077861448a565b61078061448a565b86546001600160a01b0319908116919091178755600180549182168317905560405163313ce56760e01b8152909190602081600481855afa88918161099f575b506107d457633a24e95b60e11b8852600488fd5b6001600160a81b03199092161760a091821b60ff60a01b16176001819055901c60ff16601119810161098d575061080b8186614348565b80610965575b156109205761082e816000805160206147ee833981519152614348565b8061092f575b15610920576108519060008051602061470e833981519152614348565b90816108e9575b50156108da57806108af575b5061086c5780f35b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160018152a180f35b601080546001600160a01b031916821790558260008051602061474e8339815191528180a338610864565b63cf5a8e3360e01b8352600483fd5b6109199060008051602061470e83398151915286526000805160206146ae833981519152602052604086206144d0565b5038610858565b63cf5a8e3360e01b8552600485fd5b6000805160206147ee83398151915286526000805160206146ae83398151915260205261095f83604088206144d0565b50610834565b8580526000805160206146ae83398151915260205261098783604088206144d0565b50610811565b63167738cf60e21b8652600452602485fd5b6109c291925060203d6020116109c9575b6109ba81836139c3565b810190613ba9565b90386107c0565b503d6109b0565b630b5eba9f60e41b8752600487fd5b63c1ab6dc160e01b8752600487fd5b6336abb4df60e11b8752600487fd5b60008051602061480e833981519152805460ff60401b1916600160401b179055610718565b63f92ee8a960e01b8752600487fd5b905015386106ed565b303b1591506106e5565b8791506106db565b8580fd5b8480fd5b503461033b578060031936011261033b57546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b03610aa361392e565b168152600a83522054604051908152f35b503461033b57604036600319011261033b576020906040906001600160a01b03610adc61392e565b16815260158352818120602435825283522054604051908152f35b503461033b5761016036600319011261033b57610b1261392e565b90606435604435602435610b24613a58565b9160a4359160c43560e43561010435916101243595610144359760018060a01b03601054163303610ee5576001600160a01b038c16808c52600260205260408c2054909a9060ff16610ed1578a15610ec2578615610eb3576127108811610e99576103e88111610e815760ff82169c60128e118e8115610e76575b50610e6257803b15610e4e578915610e3a578a15610e265782610bc191614260565b84151580610e1d575b610e065785151580610dfd575b610de6578b9c602460208d9e9d604051928380926370a0823160e01b82523060048301525afa9c8d15610dda579c610da6575b506001600160ff1b038c11610d97578a8d8f9760408f97838f918f8f8f8f90859f988f99879f9660008051602061476e8339815191529f978b9f988f8d6000805160206146ce8339815191529f988e8e610d4f9b60008051602061468e8339815191529f8f8f8487526002602052878720600160ff198254161790558487526003602052878720558386526004602052868620558285526006602052878686205582855260056020528585209060ff19825416179055818452600c6020528885852055818452600d6020528985852055818452600e6020528a85852055818452600f6020528b8585205581845260076020528484205582526012602052828220558d8152601360205220558a7f991d1ef1b5c0820d213328cba6682059e00a50e49c469a454eb3557e78eaf6668e80518b81528c6020820152a28c5198899889613cbd565b0390a28151908b82526020820152a28151908782526020820152a280610d73578280f35b604060008051602061482e833981519152918151908582526020820152a281808280f35b63556e7a8160e01b8e5260048efd5b909b506020813d602011610dd2575b81610dc2602093836139c3565b810103126105fe57519a38610c0a565b3d9150610db5565b604051903d90823e3d90fd5b60448c858863dd85772b60e01b8352600452602452fd5b50838610610bd7565b60448c8487637449915760e01b8352600452602452fd5b50828510610bca565b636835314760e11b8d52600160045260248dfd5b636835314760e11b8d5260048d905260248dfd5b63377e3f9960e21b8d5260048c905260248dfd5b63ca95039160e01b8d5260048e905260248dfd5b60069150108e610b9f565b631051834f60e11b8c526004526103e860245260448bfd5b63c1e9a14160e01b8c52600488905261271060245260448cfd5b63a2ec3a5560e01b8c5260048cfd5b63df407ac560e01b8c5260048cfd5b6317f4215b60e21b8c5260048b905260248cfd5b6349db3bd360e01b8b5260048bfd5b503461033b578060031936011261033b57602060ff60015460a01c16604051908152f35b503461033b57602036600319011261033b576020610f3c610f3761392e565b613df5565b604051908152f35b503461033b578060031936011261033b5760206040516127108152f35b503461033b57602036600319011261033b576020906040906001600160a01b03610f8961392e565b168152600783522054604051908152f35b503461033b57602036600319011261033b57610fb461392e565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff16156106165780825260076020526040822054806110f1575080825260026020526040822060ff1981541690558082526003602052816040812055808252600460205281604081205580825260056020526040822060ff198154169055808252600c602052816040812055808252600d602052816040812055808252600e602052816040812055808252600f602052816040812055808252600660205281604081205580825260076020526040822054818352600760205282604081205560405190827f3302a1b37f04242bb55603f5449e7ecd690a35eef08ba1353c48c20e2aae9cda8580a2806110ce578380f35b8160409160008051602061482e8339815191529352846020820152a23880808380f35b604492916376bc059760e11b8352600452602452fd5b503461033b57604036600319011261033b5761113e600435611127613944565b9061113961113482613b79565b614088565b61411a565b5080f35b503461033b578060031936011261033b57602060ff600854166040519015158152f35b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361119061392e565b16815260058452205416604051908152f35b503461033b57602036600319011261033b576111bc61392e565b6111c4613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b57849161126c575b5060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b90506020813d6020116112a4575b81611287602093836139c3565b810103126105fe575160008051602061482e83398151915261122b565b3d915061127a565b503461033b57604036600319011261033b5760206112d46112cb61392e565b60243590613cf6565b6040519015158152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361130661392e565b168152601383522054604051908152f35b503461033b57602036600319011261033b57604060209160043581526000805160206146ae83398151915283522054604051908152f35b503461033b578060031936011261033b576020604051670de0b6b3a76400008152f35b503461033b57604036600319011261033b5761138b61392e565b6010546024359291906001600160a01b03163303610479576001600160a01b031680825260076020526040822054929081841061140d578060008051602061482e8339815191526040866113e3866104369899613b6c565b84895260076020528289205583885260076020528188205482519182526020820152a2339061404c565b5091604492633cb8e07360e01b8352600452602452fd5b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361144f61392e565b168152600284522054166040519015158152f35b503461033b5761012036600319011261033b5761147e61392e565b6064359190604435602435611491613a58565b601054610104359660e4359260c4359260a43592906001600160a01b0316330361167f576001600160a01b038816808a52600260205260408a205490989060ff161561166b57861561165c576127108811611642576103e882116116285760ff83169060128211801561161e575b61160a578361150d91614260565b85151580611601575b6115ea578a1515806115e1575b6115ca579260008051602061468e83398151915297969592828c956115c4979460408e8e80825260036020528c8383205580825260046020528d838320558152600660205220558b8d52600560205260408d209060ff198254161790558a8c52600c6020528260408d20558a8c52600d6020528360408d20558a8c52600e6020528460408d20558a8c52600f6020528560408d205560405198899889613cbd565b0390a280f35b60448a868d63dd85772b60e01b8352600452602452fd5b50848b10611523565b60448a8588637449915760e01b8352600452602452fd5b50838610611516565b63ca95039160e01b8b52600482905260248bfd5b50600682106114ff565b631051834f60e11b8a5260048290526103e860245260448afd5b63c1e9a14160e01b8a52600488905261271060245260448afd5b63a2ec3a5560e01b8a5260048afd5b6374ed46ad60e01b8a52600489905260248afd5b6349db3bd360e01b8952600489fd5b503461033b57604036600319011261033b576116a861392e565b6001600160a01b0316808252600260205260408220546024359060ff16156117745780156117655761271061172a604085670de0b6b3a76400006117196117329688859a52600560205260ff85852054169080916012811061173f575b505088845260036020528484205490613a8b565b049581526004602052205484613a8b565b048092613b6c565b9082519182526020820152f35b61175e925060ff61175261175892613ad4565b16613ae5565b90613a8b565b3880611705565b63162908e360e11b8352600483fd5b6374ed46ad60e01b83526004829052602483fd5b503461033b578060031936011261033b5761033760408051906117ab81836139c3565b60058252640352e302e360dc1b602083015251918291602083526020830190613a17565b503461033b57602036600319011261033b5760043581526000805160206146ae83398151915260205260408120604051908160208254918281520190819285526020852090855b818110611876575050508261182c9103836139c3565b604051928392602084019060208552518091526040840192915b818110611854575050500390f35b82516001600160a01b0316845285945060209384019390920191600101611846565b8254845260209093019260019283019201611816565b503461033b578060031936011261033b57602090604051908152f35b503461033b576118b736613969565b9190926118c2613f12565b6118ca613f4e565b338152600960205260408120544303611f1f57338152600a602052600360408220541015611f1057338152600a602052604081206119088154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16611e6f575b828252600260205260ff60408320541615610466578415610457578315611e6057828252600c60205260408220548510611e3b57828252600e60205260408220548015611e2c57808611611e155750846119869161415e565b6040516370a0823160e01b8152306004820152602081602481865afa908115611e0a578291611dd8575b506119bd8530338661421c565b6040516370a0823160e01b8152306004820152602081602481875afa908115611cef57908692918491611d9f575b50906119f691613b6c565b10611d905781815260076020526040812054611a128582613cb0565b818110611d81576001600160ff1b038111611d72576040849260008051602061482e833981519152928486526007602052808387205582519182526020820152a2818152600560205260ff604082205416849060128110611d11575b50611a8f670de0b6b3a7640000918484526003602052604084205490613a8b565b04908281526004602052612710611aaa604083205484613a8b565b0491611ab68382613b6c565b94808610611cfa57506001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611cef578391611cbd575b5082546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523360048401528c60248401528b60448401528d60648401525af1801561060b57908491611ca8575b505083611c34575b6001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa801561060b578490611c00575b611b8a9250613b6c565b90808203611bea575050507fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b611bcd602095604051918291339588429285613bdd565b0390a360016000805160206147ce83398151915255604051908152f35b632d8562a360e11b835260045260245260449150fd5b506020823d602011611c2c575b81611c1a602093836139c3565b810103126105fe57611b8a9151611b80565b3d9150611c0d565b82546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523060048401528a60248401528b60448401528160648401525af1801561060b57908491611c8b575b5050611b4c565b81611c95916139c3565b611ca0578238611c84565b8280fd5b8380fd5b81611cb2916139c3565b611ca0578238611b44565b90506020813d602011611ce7575b81611cd8602093836139c3565b810103126105fe575138611af3565b3d9150611ccb565b6040513d85823e3d90fd5b6371c4efed60e01b83526004869052602452604482fd5b611d21915061175260ff91613ad4565b8015611d5e5780600019048511611d4f57611a8f611d48670de0b6b3a76400009287613a8b565b9150611a6e565b63035fc53d60e41b8252600482fd5b634e487b7160e01b82526012600452602482fd5b630700fcb360e11b8352600483fd5b63446c8cc960e01b8352600483fd5b639bfa3c1760e01b8152600490fd5b919250506020813d602011611dd0575b81611dbc602093836139c3565b810103126105fe57518591906119f66119eb565b3d9150611daf565b90506020813d602011611e02575b81611df3602093836139c3565b810103126105fe5751386119b0565b3d9150611de6565b6040513d84823e3d90fd5b631d7f2ac360e01b83526004869052602452604482fd5b633b5db2f360e11b8352600483fd5b50908152600c6020526040812054630d54e9e160e01b82526004849052602452604490fd5b632cd84af360e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa859181611eef575b50611ea55763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec9575061192d565b90506044928252600560205260ff604083205416631e43476360e11b8352600452602452fd5b611f0991925060203d6020116109c9576109ba81836139c3565b9038611e91565b63a74c1c5f60e01b8152600490fd5b3381526009602052436040822055338152600a6020526001604082205561190b565b503461033b578060031936011261033b5760206040516103e88152f35b503461033b57604036600319011261033b576020906040906001600160a01b03611f8661392e565b16815260148352818120602435825283522054604051908152f35b503461033b57604036600319011261033b576040611fbd613944565b91600435815260008051602061478e833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b503461033b578060031936011261033b57602060405160648152f35b503461033b57604036600319011261033b5761205060209160043581526000805160206146ae8339815191528352604060243591206144b8565b905460405160039290921b1c6001600160a01b03168152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361209161392e565b168152600983522054604051908152f35b503461033b57604036600319011261033b576120bc61392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b57604060008051602061476e8339815191529183855260136020528185205490848652601360205280838720558486526015602052828620438752602052828620548587526019602052838720558486526017602052438387205582519182526020820152a280f35b63df407ac560e01b8352600483fd5b6349db3bd360e01b8352600483fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361219161392e565b168152600383522054604051908152f35b503461033b578060031936011261033b5760008051602061470e833981519152815260008051602061478e83398151915260209081526040808320336000908152925290205460ff1615612278576121f8613f4e565b600160ff196000805160206147ae8339815191525416176000805160206147ae833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a280f35b63e2517d3f60e01b81523360045260008051602061470e833981519152602452604490fd5b503461033b57602036600319011261033b576122b761392e565b60008051602061480e8339815191525460ff8160401c169081156123a3575b506123945760008051602061480e83398151915280546001600160481b0319166003600160401b0117905581805260008051602061478e83398151915260209081526040808420336000908152925290205460ff161561237c5761233990613c5e565b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160038152a180f35b63e2517d3f60e01b8252336004526024829052604482fd5b63f92ee8a960e01b8252600482fd5b60036001600160401b039190911610159050386122d6565b503461033b578060031936011261033b57602060ff6000805160206147ae83398151915254166040519015158152f35b503461033b57602036600319011261033b5761240561392e565b6010546001600160a01b031633036104795761043690613c5e565b503461033b57606036600319011261033b5761243a61392e565b612442613944565b60105490926044359290916001600160a01b0316330361047957612464613f4e565b6011546001600160a01b03169182156126de5760405163babcc53960e01b81526001600160a01b0386166004820181905293602090829060249082905afa908115611e0a57829161269f575b5015612690578215612681576001546001600160a01b03928316921682036125d1576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161259f575b50935b841561259057600019810361258a5750835b841561257b5780851161256357505061252d836020958361404c565b7f0bf519e4b3821615dbdd874fa1a5fbb4bb651b4e6beabedd4ac318e770233b2c604080518581524287820152a3604051908152f35b630555ed4f60e31b8252600485905260245260449150fd5b632e11316f60e11b8252600482fd5b93612511565b63f09872eb60e01b8252600482fd5b90506020813d6020116125c9575b816125ba602093836139c3565b810103126105fe5751386124fc565b3d91506125ad565b8181526002602052604081205460ff161561266f576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161263d575b5082825260076020526040822054808211156126355761262f91613b6c565b936124ff565b50508061262f565b90506020813d602011612667575b81612658602093836139c3565b810103126105fe575138612610565b3d915061264b565b60249163eef7849760e01b8252600452fd5b634e46966960e11b8152600490fd5b63133307bb60e21b8152600490fd5b90506020813d6020116126d6575b816126ba602093836139c3565b810103126126d2575180151581036126d257386124b0565b5080fd5b3d91506126ad565b630e048e7160e41b8152600490fd5b503461033b57602036600319011261033b5761270761392e565b6010546001600160a01b03163303610479576001600160a01b0316801561276c57601180546001600160a01b0319811683179091556001600160a01b03167f1e9c406f2707909cfd9f61e744f73bcab77e5997d063276f67883c5257d51cf08380a380f35b634e46966960e11b8252600482fd5b503461033b578060031936011261033b577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036127d457602060405160008051602061472e8339815191528152f35b63703e46dd60e11b8152600490fd5b503461033b578060031936011261033b576010546040516001600160a01b039091168152602090f35b50604036600319011261033b5761282161392e565b602435906001600160401b038211611ca05736602383011215611ca0578160040135908361284e836139fc565b9361285c60405195866139c3565b83855260208501933660248284010111611ca057806024602093018637850101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115612ade575b50612acf576010546001600160a01b03163303612ac0576001600160a01b038116928315612ab157813b15612aa25760008051602061472e83398151915254846128fa613a68565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f61293060405192604084526040840190613a17565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa879181612a6a575b5061297e57634c9c8ce360e01b87526004869052602487fd5b908160008051602061472e83398151915288979303612a585750833b15612a44576001600160a01b031916811760008051602061472e833981519152558491907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a2805115612a295761113e9382915190845af43d15612a21573d91612a05836139fc565b92612a1360405194856139c3565b83523d85602085013e61460c565b60609161460c565b5050505034612a355780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b86526004829052602486fd5b632a87526960e21b8752600452602486fd5b9091506020813d602011612a9a575b81612a86602093836139c3565b81010312612a9657519038612965565b8780fd5b3d9150612a79565b636f7c43f160e01b8552600485fd5b63e6c4247b60e01b8552600485fd5b6349db3bd360e01b8452600484fd5b63703e46dd60e11b8452600484fd5b60008051602061472e833981519152546001600160a01b031614159050386128b2565b503461033b57602036600319011261033b576020906040906001600160a01b03612b2961392e565b168152600e83522054604051908152f35b503461033b57606036600319011261033b57612b5461395a565b6024356001600160401b038111611ca057612b73903690600401613993565b916044356001600160401b038111610a5057612b93903690600401613993565b60008051602061480e8339815191529291925460ff8160401c16908115612ef6575b50612ee75760008051602061480e83398151915280546001600160481b0319166002600160401b011790556000805160206147ee833981519152865260008051602061478e83398151915260209081526040808820336000908152925290205460ff1615612ec257612c2561448a565b612c2d61448a565b60016000805160206147ce83398151915255600b549160ff8316612eb357818603612ea457612c5b86613bf9565b92612c6960405194856139c3565b868452601f19612c7888613bf9565b01366020860137875b878110612daf575060019060ff191617600b5515159460ff196008541660ff871617600855865b818110612d0c578760008051602061466e833981519152602089604051908152a160ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160028152a180f35b808860008051602061482e8339815191526040612d34612d2f600196888d613c10565b613c36565b612d3f85898c613c10565b357f8f955fa878b4aae8b1ac37b1ab715307470f2822ceff87e23d33ef1e044814a783612d6c888d613c4a565b5193898060a01b0316968793848252600660205280838320558482526007602052858383205582519182526020820152a28151908d82526020820152a201612ca8565b612dbd612d2f828a8a613c10565b612dc8828689613c10565b6001600160a01b03909116808b52600260205260408b20549091359060ff1615612e90576103e88111612e785750906020602492604051938480926370a0823160e01b82523060048301525afa8015612e6d578a90612e37575b60019250612e308288613c4a565b5201612c81565b509060203d8111612e66575b612e4d81836139c3565b6020826000928101031261033b57509060019151612e22565b503d612e43565b6040513d8c823e3d90fd5b631051834f60e11b8b526004526103e860245260448afd5b6351104c5960e01b8b52600482905260248bfd5b63512509d360e11b8752600487fd5b6324d0d1fd60e01b8752600487fd5b63e2517d3f60e01b8652336004526000805160206147ee833981519152602452604486fd5b63f92ee8a960e01b8652600486fd5b60026001600160401b03919091161015905038612bb5565b503461033b578060031936011261033b576011546040516001600160a01b039091168152602090f35b503461033b578060031936011261033b576010546001600160a01b03163303612fef576000805160206147ae8339815191525460ff811615612fe05760ff19166000805160206147ae833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a280f35b638dfc202b60e01b8252600482fd5b6349db3bd360e01b8152600490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361302661392e565b168152601683522054604051908152f35b503461033b57604036600319011261033b57613051613944565b336001600160a01b0382160361306d5761113e9060043561411a565b63334bd91960e11b8252600482fd5b503461033b57602036600319011261033b576020906040906001600160a01b036130a461392e565b168152600c83522054604051908152f35b503461033b57602036600319011261033b576020906040906001600160a01b036130dd61392e565b168152601783522054604051908152f35b503461033b57604036600319011261033b5761113e60043561310e613944565b9061311b61113482613b79565b6140d2565b503461033b5761312f36613969565b91909261313a613f12565b613142613f4e565b3381526009602052604081205443036135be57338152600a602052600360408220541015611f1057338152600a602052604081206131808154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16613543575b828252600260205260ff604083205416156104665760ff6008541615613534578415610457578315611e6057828252600d602052604082205480861061351d5750828252600f6020526040822054801561350e578086116134f857508461320b91613f78565b670de0b6b3a76400008402848104670de0b6b3a7640000036134e4578282526003602052604082205461323d91613ab4565b90828152600560205260ff604082205416601281106134c4575b50828152600660205261327c612710613274604084205485613a8b565b048093613b6c565b938085106134ac575082815260076020528360408220541061348857828152600760205260408120548481106134795760008051602061482e8339815191526040826132c9888895613b6c565b8486526007602052808387205582519182526020820152a26001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611e0a578291613447575b5081546001600160a01b0316803b15611ca057826040518092633a52b90760e11b82528183816133498d3360048401613bc2565b03925af18015611cef57613432575b506001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa908115611cef5783916133fc575b6133989250613b6c565b8581036133e45750507f8caf04742286d017f9ac3924388e188c73e6e5094311c5e59a61a7ef86dda8bf611bcd6020956133d386338761404c565b604051918291339588429285613bdd565b635ab6e2db60e01b8252600486905260245260449150fd5b90506020823d60201161342a575b81613417602093836139c3565b810103126105fe5761339891519061338e565b3d915061340a565b9161344081600493946139c3565b9190613358565b90506020813d602011613471575b81613462602093836139c3565b810103126126d2575138613315565b3d9150613455565b6308aed4ef60e31b8252600482fd5b82815260076020526040812054635960d22160e01b82526004526024849052604490fd5b6371c4efed60e01b8252600485905260245260449150fd5b916134d760ff6117526134dd9495613ad4565b90613ab4565b9038613257565b634e487b7160e01b82526011600452602482fd5b625502a360e91b83526004869052602452604482fd5b636c6ff70d60e11b8352600483fd5b6361767b8560e01b83526004869052602452604482fd5b630df65d9f60e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa85918161359d575b506135795763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec957506131a5565b6135b791925060203d6020116109c9576109ba81836139c3565b9038613565565b3381526009602052436040822055338152600a60205260016040822055613183565b503461033b57602036600319011261033b576020610f3c600435613b79565b503461033b57602036600319011261033b576020906040906001600160a01b0361362761392e565b168152600f83522054604051908152f35b503461033b57604036600319011261033b5761365261392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b5760406000805160206146ce8339815191529183855260126020528185205490848652601260205280838720558486526014602052828620438752602052828620548587526018602052838720558486526016602052438387205582519182526020820152a280f35b503461033b57602036600319011261033b576020906040906001600160a01b0361370961392e565b168152600683522054604051908152f35b503461033b578060031936011261033b576001546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b0361376b61392e565b168152600d83522054604051908152f35b503461033b57602036600319011261033b5761379661395a565b6010546001600160a01b0316330361047957602060008051602061466e83398151915291151560ff196008541660ff821617600855604051908152a180f35b503461033b57602036600319011261033b5760043563ffffffff60e01b81168091036126d257602090635a05180f60e01b811490811561381b575b506040519015158152f35b637965db0b60e01b811491508115613835575b5082613810565b6301ffc9a760e01b1490508261382e565b503461033b57604036600319011261033b5761386061392e565b6001600160a01b0316808252600260205260408220546024359060ff161561177457670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561391a57916138bc60409383835260036020528483205490613ab4565b91808252600560205260ff8483205416601281106138f1575b5061172a84836127109361173295526006602052205484613a8b565b846117329361390f61271094966134d760ff61175261172a97613ad4565b9593509350506138d5565b634e487b7160e01b83526011600452602483fd5b600435906001600160a01b03821682036105fe57565b602435906001600160a01b03821682036105fe57565b6004359081151582036105fe57565b60609060031901126105fe576004356001600160a01b03811681036105fe57906024359060443590565b9181601f840112156105fe578235916001600160401b0383116105fe576020808501948460051b0101116105fe57565b601f909101601f19168101906001600160401b038211908210176139e657604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116139e657601f01601f191660200190565b919082519283825260005b848110613a43575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201613a22565b6084359060ff821682036105fe57565b60405190613a776040836139c3565b6005825264322e332e3360d81b6020830152565b81810292918115918404141715613a9e57565b634e487b7160e01b600052601160045260246000fd5b8115613abe570490565b634e487b7160e01b600052601260045260246000fd5b60ff166012039060ff8211613a9e57565b8015613b665760009060208110600116604e821060011617613b5e57600a916001915b60018111613b35575082600019048211613b2157500290565b634e487b7160e01b81526011600452602490fd5b92806000190481116134e45760018416613b55575b80029260011c613b08565b80920291613b4a565b9050600a0a90565b50600190565b91908203918211613a9e57565b60005260008051602061478e83398151915260205260016040600020015490565b6000198114613a9e5760010190565b908160209103126105fe575160ff811681036105fe5790565b6001600160a01b039091168152602081019190915260400190565b9094939260609260808301968352602083015260408201520152565b6001600160401b0381116139e65760051b60200190565b9190811015613c205760051b0190565b634e487b7160e01b600052603260045260246000fd5b356001600160a01b03811681036105fe5790565b8051821015613c205760209160051b010190565b6001600160a01b03168015613c9f57601080546001600160a01b0319811683179091556001600160a01b031660008051602061474e833981519152600080a3565b63e6c4247b60e01b60005260046000fd5b91908201809211613a9e57565b94919360e0969360ff929a99989561010088019b885260208801526040870152166060850152608084015260a083015260c08201520152565b6001600160a01b03811660008181526002602052604090205490919060ff16158015613de8575b8015613de0575b613dce5781600052600f6020526040600020548015908115613dd6575b50613dce57613d66926040918251948592839262f7fce960e01b845260048401613bc2565b0381305afa918215613dc257600092613d8e575b506000526007602052604060002054101590565b9091506040813d604011613dba575b81613daa604093836139c3565b810103126105fe57519038613d7a565b3d9150613d9d565b6040513d6000823e3d90fd5b505050600090565b9050831138613d41565b508215613d24565b5060ff6008541615613d1d565b6001546001600160a01b0391821691168103613e6a576020602491604051928380926370a0823160e01b82523060048301525afa908115613dc257600091613e3b575090565b90506020813d602011613e62575b81613e56602093836139c3565b810103126105fe575190565b3d9150613e49565b80600052600260205260ff60406000205416613e865750600090565b6040516370a0823160e01b815230600482015290602082602481845afa918215613dc257600092613ede575b506000526007602052604060002054808211600014613ed757613ed491613b6c565b90565b5050600090565b90916020823d602011613f0a575b81613ef9602093836139c3565b8101031261033b5750519038613eb2565b3d9150613eec565b60026000805160206147ce8339815191525414613f3d5760026000805160206147ce83398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206147ae8339815191525416613f6757565b63d93c066560e01b60005260046000fd5b6001600160a01b0316600081815260136020526040902054801561404757816000526015602052604060002043600052602052613fbb6040600020549384613cb0565b92831061403657808260005260176020524360406000205414614018575b8311613ffc57506000526015602052604060002043600052602052604060002055565b925063029359d560e41b60005260045260245260445260646000fd5b5081600052601960205261403160406000205482613cb0565b613fd9565b63446c8cc960e01b60005260046000fd5b505050565b614081614086939261407360405194859263a9059cbb60e01b602085015260248401613bc2565b03601f1981018452836139c3565b6142ed565b565b600081815260008051602061478e8339815191526020908152604080832033845290915290205460ff16156140ba5750565b63e2517d3f60e01b6000523360045260245260446000fd5b6140dc8282614348565b91826140e757505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b0316906144d0565b5090565b61412482826143ea565b918261412f57505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b031690614539565b6001600160a01b03166000818152601260205260409020548015614047578160005260146020526040600020436000526020526141a16040600020549384613cb0565b928310614036578082600052601660205243604060002054146141fe575b83116141e257506000526014602052604060002043600052602052604060002055565b92506319a4e2a760e01b60005260045260245260445260646000fd5b5081600052601860205261421760406000205482613cb0565b6141bf565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152614086916140816084836139c3565b60405163313ce56760e01b81529190602090839060049082906001600160a01b03165afa600092816142cc575b506142a357631eecbb6560e01b60005260046000fd5b60ff91821691168082036142b5575050565b631e43476360e11b60005260045260245260446000fd5b6142e691935060203d6020116109c9576109ba81836139c3565b913861428d565b906000602091828151910182855af115613dc2576000513d61433f57506001600160a01b0381163b155b61431e5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415614317565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff16613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff1615613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b60ff60008051602061480e8339815191525460401c16156144a757565b631afcd79f60e31b60005260046000fd5b8054821015613c205760005260206000200190600090565b6001810190826000528160205260406000205415600014613dce578054600160401b8110156139e65761452461450d8260018794018555846144b8565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b9060018201918160005282602052604060002054801515600014614603576000198101818111613a9e578254600019810191908211613a9e578181036145cc575b505050805480156145b657600019019061459482826144b8565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b6145ec6145dc61450d93866144b8565b90549060031b1c928392866144b8565b90556000528360205260406000205538808061457a565b50505050600090565b90614632575080511561462157602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580614664575b614643575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561463b56fe2c0a5f5ab0ba371221bb3612c2d2f90d36566279309f526000c5b354efd1b0658c67aaac7f77de07240e5a9b36dfdccb2a89c438635abbb27a73142d2aa0f629c1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200048b07fab687f450848f1df8a96db08fef7840f53415f18fdc2ec8e9f810f0930c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc17dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846c4460507c21097c15f6883572ebd157a9ee4b1d989a312314e93afd9d2ecd494002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a006d129bd71f2401cbe77f49f546d7d5f58992faecfca6e51ba06b50b261e83331a164736f6c6343000822000a";
|
|
17543
17889
|
var isSuperArgs = (xs) => xs.length > 1;
|
|
17544
|
-
var SimplePSMV2__factory = class extends
|
|
17890
|
+
var SimplePSMV2__factory = class extends import_ethers16.ContractFactory {
|
|
17545
17891
|
constructor(...args) {
|
|
17546
17892
|
if (isSuperArgs(args)) {
|
|
17547
17893
|
super(...args);
|
|
@@ -17561,15 +17907,15 @@ var SimplePSMV2__factory = class extends import_ethers15.ContractFactory {
|
|
|
17561
17907
|
static bytecode = _bytecode;
|
|
17562
17908
|
static abi = _abi;
|
|
17563
17909
|
static createInterface() {
|
|
17564
|
-
return new
|
|
17910
|
+
return new import_ethers16.Interface(_abi);
|
|
17565
17911
|
}
|
|
17566
17912
|
static connect(address, runner) {
|
|
17567
|
-
return new
|
|
17913
|
+
return new import_ethers16.Contract(address, _abi, runner);
|
|
17568
17914
|
}
|
|
17569
17915
|
};
|
|
17570
17916
|
|
|
17571
17917
|
// src/contracts/typechain-contracts/factories/src/agent/AgentDelegationRegistry__factory.ts
|
|
17572
|
-
var
|
|
17918
|
+
var import_ethers17 = require("ethers");
|
|
17573
17919
|
var _abi2 = [
|
|
17574
17920
|
{
|
|
17575
17921
|
inputs: [],
|
|
@@ -17679,6 +18025,11 @@ var _abi2 = [
|
|
|
17679
18025
|
name: "InvalidAddress",
|
|
17680
18026
|
type: "error"
|
|
17681
18027
|
},
|
|
18028
|
+
{
|
|
18029
|
+
inputs: [],
|
|
18030
|
+
name: "InvalidAgentConsent",
|
|
18031
|
+
type: "error"
|
|
18032
|
+
},
|
|
17682
18033
|
{
|
|
17683
18034
|
inputs: [],
|
|
17684
18035
|
name: "InvalidFloor",
|
|
@@ -18132,6 +18483,12 @@ var _abi2 = [
|
|
|
18132
18483
|
name: "ContractUpgraded",
|
|
18133
18484
|
type: "event"
|
|
18134
18485
|
},
|
|
18486
|
+
{
|
|
18487
|
+
anonymous: false,
|
|
18488
|
+
inputs: [],
|
|
18489
|
+
name: "EIP712DomainChanged",
|
|
18490
|
+
type: "event"
|
|
18491
|
+
},
|
|
18135
18492
|
{
|
|
18136
18493
|
anonymous: false,
|
|
18137
18494
|
inputs: [
|
|
@@ -18303,6 +18660,19 @@ var _abi2 = [
|
|
|
18303
18660
|
name: "Upgraded",
|
|
18304
18661
|
type: "event"
|
|
18305
18662
|
},
|
|
18663
|
+
{
|
|
18664
|
+
inputs: [],
|
|
18665
|
+
name: "AGENT_BINDING_CONSENT_TYPEHASH",
|
|
18666
|
+
outputs: [
|
|
18667
|
+
{
|
|
18668
|
+
internalType: "bytes32",
|
|
18669
|
+
name: "",
|
|
18670
|
+
type: "bytes32"
|
|
18671
|
+
}
|
|
18672
|
+
],
|
|
18673
|
+
stateMutability: "view",
|
|
18674
|
+
type: "function"
|
|
18675
|
+
},
|
|
18306
18676
|
{
|
|
18307
18677
|
inputs: [],
|
|
18308
18678
|
name: "DEFAULT_ADMIN_ROLE",
|
|
@@ -18433,6 +18803,30 @@ var _abi2 = [
|
|
|
18433
18803
|
stateMutability: "view",
|
|
18434
18804
|
type: "function"
|
|
18435
18805
|
},
|
|
18806
|
+
{
|
|
18807
|
+
inputs: [
|
|
18808
|
+
{
|
|
18809
|
+
internalType: "address",
|
|
18810
|
+
name: "user",
|
|
18811
|
+
type: "address"
|
|
18812
|
+
},
|
|
18813
|
+
{
|
|
18814
|
+
internalType: "address",
|
|
18815
|
+
name: "agent",
|
|
18816
|
+
type: "address"
|
|
18817
|
+
}
|
|
18818
|
+
],
|
|
18819
|
+
name: "agentBindingConsentDigest",
|
|
18820
|
+
outputs: [
|
|
18821
|
+
{
|
|
18822
|
+
internalType: "bytes32",
|
|
18823
|
+
name: "",
|
|
18824
|
+
type: "bytes32"
|
|
18825
|
+
}
|
|
18826
|
+
],
|
|
18827
|
+
stateMutability: "view",
|
|
18828
|
+
type: "function"
|
|
18829
|
+
},
|
|
18436
18830
|
{
|
|
18437
18831
|
inputs: [],
|
|
18438
18832
|
name: "agentMintFloorMinBps",
|
|
@@ -18683,6 +19077,49 @@ var _abi2 = [
|
|
|
18683
19077
|
stateMutability: "nonpayable",
|
|
18684
19078
|
type: "function"
|
|
18685
19079
|
},
|
|
19080
|
+
{
|
|
19081
|
+
inputs: [],
|
|
19082
|
+
name: "eip712Domain",
|
|
19083
|
+
outputs: [
|
|
19084
|
+
{
|
|
19085
|
+
internalType: "bytes1",
|
|
19086
|
+
name: "fields",
|
|
19087
|
+
type: "bytes1"
|
|
19088
|
+
},
|
|
19089
|
+
{
|
|
19090
|
+
internalType: "string",
|
|
19091
|
+
name: "name",
|
|
19092
|
+
type: "string"
|
|
19093
|
+
},
|
|
19094
|
+
{
|
|
19095
|
+
internalType: "string",
|
|
19096
|
+
name: "version",
|
|
19097
|
+
type: "string"
|
|
19098
|
+
},
|
|
19099
|
+
{
|
|
19100
|
+
internalType: "uint256",
|
|
19101
|
+
name: "chainId",
|
|
19102
|
+
type: "uint256"
|
|
19103
|
+
},
|
|
19104
|
+
{
|
|
19105
|
+
internalType: "address",
|
|
19106
|
+
name: "verifyingContract",
|
|
19107
|
+
type: "address"
|
|
19108
|
+
},
|
|
19109
|
+
{
|
|
19110
|
+
internalType: "bytes32",
|
|
19111
|
+
name: "salt",
|
|
19112
|
+
type: "bytes32"
|
|
19113
|
+
},
|
|
19114
|
+
{
|
|
19115
|
+
internalType: "uint256[]",
|
|
19116
|
+
name: "extensions",
|
|
19117
|
+
type: "uint256[]"
|
|
19118
|
+
}
|
|
19119
|
+
],
|
|
19120
|
+
stateMutability: "view",
|
|
19121
|
+
type: "function"
|
|
19122
|
+
},
|
|
18686
19123
|
{
|
|
18687
19124
|
inputs: [
|
|
18688
19125
|
{
|
|
@@ -19055,6 +19492,11 @@ var _abi2 = [
|
|
|
19055
19492
|
internalType: "uint64",
|
|
19056
19493
|
name: "validUntil",
|
|
19057
19494
|
type: "uint64"
|
|
19495
|
+
},
|
|
19496
|
+
{
|
|
19497
|
+
internalType: "bytes",
|
|
19498
|
+
name: "agentConsent",
|
|
19499
|
+
type: "bytes"
|
|
19058
19500
|
}
|
|
19059
19501
|
],
|
|
19060
19502
|
name: "registerAgent",
|
|
@@ -19132,6 +19574,11 @@ var _abi2 = [
|
|
|
19132
19574
|
internalType: "uint64",
|
|
19133
19575
|
name: "validUntil",
|
|
19134
19576
|
type: "uint64"
|
|
19577
|
+
},
|
|
19578
|
+
{
|
|
19579
|
+
internalType: "bytes",
|
|
19580
|
+
name: "agentConsent",
|
|
19581
|
+
type: "bytes"
|
|
19135
19582
|
}
|
|
19136
19583
|
],
|
|
19137
19584
|
name: "rotateAgent",
|
|
@@ -19260,9 +19707,9 @@ var _abi2 = [
|
|
|
19260
19707
|
type: "function"
|
|
19261
19708
|
}
|
|
19262
19709
|
];
|
|
19263
|
-
var _bytecode2 = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161304c90816100f0823960805181818161114401526113290152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714611ff7575080630d33f3c214611fd35780630f3f4a9414611f885780631459457a14611be257806318c38b8914611ad15780631d44454114611a005780632106764c146119d9578063248a9ca3146119b35780632ec22d4c146118f25780632f0647ce146118775780632f2ff15d14611846578063324207441461177257806336568abe1461172c578063392f1087146116f65780633f4ba83a146115fe5780633f5aadc91461158f5780634f1ef286146112ad57806352340363146111c45780635273b6f61461119b57806352d1902d14611131578063554c4f4b146110a1578063561b7f8a14610f755780635bc26aea14610ee85780635c975abb14610eb85780636289d18c14610e375780636711cc0b14610e1b5780636e852a7814610d1a5780637e35bf6e14610ce65780638343f67414610cb95780638456cb5914610bc35780638f33527f14610b895780639010d07c14610b3557806391d1485414610adb5780639b9d30c114610ab2578063a19af3f614610a01578063a217fddf146109e5578063a3246ad314610923578063a878086414610907578063ac3c0e30146107fa578063ad3cb1cc146107b3578063b3fad6381461070e578063c34e9c26146106f2578063c86deb31146106d6578063ca15c8731461069d578063d547741f14610665578063dd71d99a14610623578063e0922fa114610576578063efa9b4ae14610507578063f2f4eb26146104de578063f68e9553146104b5578063f94f67ab146103de578063fd437d391461029f5763ffa1ad741461026657600080fd5b3461029a57600036600319011261029a576102966102826121ed565b6040519182916020835260208301906121c8565b0390f35b600080fd5b3461029a57606036600319011261029a576102b861207a565b6102c0612064565b906102c961218f565b906102d2612795565b6001600160a01b0316338190036103ce5780600052600160205260406000209283549360ff8560e01c1660038110156103b8576001036103a75781600160209261033e877fc5d5c5bbf10444998e0ea6d4725e79027b574e1c14ec929279e8a9a95c6c6e919688612c43565b818060a01b038316828060a01b031982541617815561035d878261239f565b0180546001600160401b031916426001600160401b03908116919091179091556001600160a01b0391821660008181526002855260409081902087905551969091168652951693a4005b632437e77160e11b60005260046000fd5b634e487b7160e01b600052602160045260246000fd5b62fca64560e31b60005260046000fd5b3461029a57604036600319011261029a576004356103fa6120c9565b90610403612795565b63ffffffff600554169163ffffffff8116928084109081156104ac575b5061049b5760207f6b7727cc9c3df4a29acf0afe01594c1b7e845d20f40f4a14e4c292164a9ed8e191610452846127e0565b9161046a600863ffffffff845460a01c1617836122e3565b81546001600160e01b031660e09190911b6001600160e01b0319161790556040519485526001600160a01b031693a3005b634346c13160e01b60005260046000fd5b90501584610420565b3461029a57600036600319011261029a576020604051600080516020612fe08339815191528152f35b3461029a57600036600319011261029a576003546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435610523612795565b61054561052f826127e0565b9190600163ffffffff825460a01c1617906122e3565b6001600160a01b0316907f812690e0a9dff5bf3add998111b8af5c8299608d859025bfe35662060ab4267d600080a3005b3461029a57602036600319011261029a576004356001600160401b0381169081810361029a576000546001600160a01b038116330361061257600160a01b600160e01b0319811660a092831b600160a01b600160e01b031617600055604080519190921c6001600160401b0316815260208101929092527f9c195448332abd01f716db873b329752ea02f19d33f7e311fb0daf082c4edd0391a1005b6349db3bd360e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b0361064461207a565b166000526002602052602060018060a01b0360406000205416604051908152f35b3461029a57604036600319011261029a5761069b600435610684612064565b90610696610691826122c2565b6126bf565b612751565b005b3461029a57602036600319011261029a57600435600052600080516020612ee08339815191526020526020604060002054604051908152f35b3461029a57600036600319011261029a57602060405160088152f35b3461029a57600036600319011261029a57602060405160028152f35b3461029a57602036600319011261029a576000606060405161072f81612136565b828152826020820152826040820152015260043560005260046020526080604060002063ffffffff6040519161076483612136565b548160018060a01b038216938481528160208201818560a01c16815260606040840193838760c01c168552019460e01c8552604051968752511660208601525116604084015251166060820152f35b3461029a57600036600319011261029a5761029660408051906107d68183612151565b60058252640352e302e360dc1b6020830152519182916020835260208301906121c8565b3461029a57602036600319011261029a5761081361207a565b6000608060405161082381612105565b828152826020820152826040820152826060820152015260018060a01b03166000526001602052604060002060405161085b81612105565b81546001600160a01b038116825260a081901c6001600160401b03166020830190815292604083019160e01c60ff169060038210156103b857908252600101546001600160401b0380821660608501908152604092831c821660808601908152925194516001600160a01b03168552945116602084015290519260038410156103b857604083019390935291516001600160401b0390811660608301529151909116608082015260a090f35b3461029a57600036600319011261029a57602060405160018152f35b3461029a57602036600319011261029a57600435600052600080516020612ee083398151915260205260406000206040518060208354918281520190819360005260206000209060005b8181106109cf5750505081610983910382612151565b6040519182916020830190602084525180915260408301919060005b8181106109ad575050500390f35b82516001600160a01b031684528594506020938401939092019160010161099f565b825484526020909301926001928301920161096d565b3461029a57600036600319011261029a57602060405160008152f35b3461029a57604036600319011261029a57600435610a1d6120c9565b90610a26612795565b63ffffffff600554169163ffffffff811692808410908115610aa9575b5061049b5760207f1da95b87b4c773f68c1447ffc5644e41a8a8887d55065beb64852014cf7140be91610a96610a78856127e0565b9290610a91600463ffffffff835460a01c1617826122e3565b612210565b6040519485526001600160a01b031693a3005b90501584610a43565b3461029a57600036600319011261029a576020604051600080516020612f208339815191528152f35b3461029a57604036600319011261029a57610af4612064565b600435600052600080516020612fc083398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b3461029a57604036600319011261029a57600435600052600080516020612ee08339815191526020526020610b706024356040600020612d0c565b905460405160039290921b1c6001600160a01b03168152f35b3461029a57602036600319011261029a576001600160a01b03610baa61207a565b1660005260026020526020604060002054604051908152f35b3461029a57600036600319011261029a573360009081527f0ac8cc3d209806126662940717264973110c39045b305f6ba49613325a615e09602052604090205460ff1615610c9257610c13612795565b600160ff19600080516020613000833981519152541617600080516020613000833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a2005b63e2517d3f60e01b60005233600452600080516020612f2083398151915260245260446000fd5b3461029a57600036600319011261029a5760005460405160a09190911c6001600160401b03168152602090f35b3461029a57604036600319011261029a57610d0a610d02612064565b60043561236c565b906102966040519283928361209a565b3461029a57604036600319011261029a57610d3361207a565b336000908152600080516020612f60833981519152602052604090205460ff161580610e08575b6103ce576001600160a01b03166000818152600160205260409020805460e01c60ff1660038110156103b8576001036103a757805460ff60e01b198116600160e11b1782556001919091018054600160401b600160801b03191642604090811b600160401b600160801b0316919091179091555160243581526001600160a01b0390911691907fc0499cc07ed9d734deec6857802d3f0fa8d5afaf79a7008beb8ba7bef62a271b90602090a3005b50336001600160a01b0382161415610d5a565b3461029a57600036600319011261029a57602060405160048152f35b3461029a57602036600319011261029a57610e506120b6565b6000546001600160a01b031633036106125763ffffffff8116908115610ea757600080516020612fa083398151915291610ea263ffffffff926005549284198416176005556040519384931683612233565b0390a1005b6338f3377360e21b60005260046000fd5b3461029a57600036600319011261029a57602060ff60008051602061300083398151915254166040519015158152f35b3461029a57602036600319011261029a57610f0161207a565b6000546001600160a01b0381169033829003610612576001600160a01b038316928315610f64573b15610f53576001600160a01b03191682176000908155600080516020612f808339815191529080a3005b636f7c43f160e01b60005260046000fd5b63e6c4247b60e01b60005260046000fd5b3461029a57606036600319011261029a57610f8e61207a565b610f96612064565b610f9e61218f565b91610fa7612795565b6001600160a01b031690338290036103ce57816000526001602052604060002060ff815460e01c1660038110156103b857600114611090578160209161100f867ff223dc085722c94c84dcf67427e225799be616382a2a484d378f8921c69a20339587612c43565b80546001600160a01b0319166001600160a01b038316178155611032868261239f565b6001810180546001600160801b031916426001600160401b0390811691909117909155815460ff60e01b1916600160e01b179091556001600160a01b03919091166000818152600284526040908190208690555195909116855293a3005b639d2c8fdf60e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b036110c261207a565b166000526001602052604060002060ff60008051602061300083398151915254161580611115575b602091816110fe575b506040519015158152f35b5460a01c6001600160401b031642109050826110f3565b5060ff815460e01c169060038210156103b857906001146110ea565b3461029a57600036600319011261029a577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316300361118a576020604051600080516020612f408339815191528152f35b63703e46dd60e11b60005260046000fd5b3461029a57600036600319011261029a576000546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b03831692831590811561129e575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580611283575b611272578061124563fffffffe61124b935460a01c16826122e3565b8261269b565b7fa5ffbdba01b15df97334e34ad816b9986b6057a5ddc97aba93b7e8ccd21759ed600080a3005b630a606ec360e11b60005260046000fd5b5082331415611229565b6360eb6c2360e01b60005260046000fd5b6001915060a01c1615846111fd565b604036600319011261029a576112c161207a565b602435906001600160401b03821161029a573660238301121561029a578160040135906112ed82612174565b916112fb6040519384612151565b8083526020830193366024838301011161029a57816000926024602093018737840101526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630811490811561156c575b5061118a576000546001600160a01b03163303610612576001600160a01b038116928315610f6457813b1561155b5730841461154c57600080516020612f4083398151915254846113a36121ed565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f6113d9604051926040845260408401906121c8565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa60009181611518575b506114295785634c9c8ce360e01b60005260045260246000fd5b9081600080516020612f408339815191528793036115045750833b156114ef576001600160a01b0319168117600080516020612f40833981519152557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156114d4576000809161069b945190845af43d156114cc573d916114af83612174565b926114bd6040519485612151565b83523d6000602085013e612e7e565b606091612e7e565b505050346114de57005b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d602011611544575b8161153460209383612151565b8101031261029a5751908761140f565b3d9150611527565b614e8d60eb1b60005260046000fd5b632e07c4bd60e11b60005260046000fd5b600080516020612f40833981519152546001600160a01b03161415905084611354565b3461029a57602036600319011261029a576004356115ab612795565b6115cd6115b7826127e0565b9190600263ffffffff825460a01c1617906122e3565b6001600160a01b0316907fc2713e691344add4705edc62a0ee5aede95ba66ad68f97316efef9cb50644edd600080a3005b3461029a57600036600319011261029a57336000908152600080516020612f60833981519152602052604090205460ff1615806116e1575b6116d0576000805160206130008339815191525460ff8116156116bf5760ff1916600080516020613000833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a2005b638dfc202b60e01b60005260046000fd5b63659a07b360e11b60005260046000fd5b506000546001600160a01b0316331415611636565b3461029a57604036600319011261029a5761029661171d611715612064565b600435612306565b604093919351938493846120dc565b3461029a57604036600319011261029a57611745612064565b336001600160a01b038216036117615761069b90600435612751565b63334bd91960e11b60005260046000fd5b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b038316928315908115611837575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061182d575b61127257806117f363fffffff7611806935460a01c16826122e3565b80546001600160e01b031681558261269b565b7f054490ec6650e07db9b97a06ea31d44cebd44b390c9975a380055e1b4d3cac21600080a3005b50823314156117d7565b6008915060a01c1615846117ab565b3461029a57604036600319011261029a5761069b600435611865612064565b90611872610691826122c2565b612709565b3461029a57602036600319011261029a576004356118c161189782612629565b91906118ad63fffffffb825460a01c16826122e3565b805463ffffffff60c01b191681558361269b565b6001600160a01b0316907f09cb4ec44cdef8489412844b9682f87f7900758fa2bd7e039113e9125e538e0f600080a3005b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b0383169283159081156119a4575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061199a575b611272578061124563fffffffd611973935460a01c16826122e3565b7fb390ab029eab314bd18190ebe73d7e5c1c336beaa5c83ac22578378dc9ccc405600080a3005b5082331415611957565b6002915060a01c16158461192b565b3461029a57602036600319011261029a5760206119d16004356122c2565b604051908152f35b3461029a57604036600319011261029a5761029661171d6119f8612064565b60043561224a565b3461029a57604036600319011261029a57600435611a1c6120c9565b63ffffffff600554169063ffffffff811691808310908115611ac8575b5061049b57611a4783612629565b909263ffffffff845460c01c16809260018060a01b03163314159182611abd575b5050611aac57611a98827e8a218591d4362499c38c38eb1c12e7a7cc97a9068818d1fe6046a42ba4a5ba94612210565b611aa760405192839283612233565b0390a2005b634e80a40760e11b60005260046000fd5b111590508186611a68565b90501584611a39565b3461029a57602036600319011261029a57611aea6120b6565b6000805160206130208339815191525460ff8160401c16908115611bca575b50611bb957600080516020613020833981519152805460026001600160401b0319821681179092556000546001600160481b031990911690911791906001600160a01b031633036106125763ffffffff168015610ea757604081600080516020612fa08339815191529263ffffffff196005541617600555815190600082526020820152a160008051602061302083398151915255600080516020612f00833981519152602060405160028152a1005b63f92ee8a960e01b60005260046000fd5b60026001600160401b03919091161015905082611b09565b3461029a5760a036600319011261029a57611bfb61207a565b611c03612064565b906044356001600160a01b03811680820361029a576064356001600160a01b0381169182820361029a576084356001600160a01b038116949085900361029a5760008051602061302083398151915254604081901c60ff161596906001600160401b031680159081611f80575b6001149081611f76575b159081611f6d575b50611bb95760008051602061302083398151915280546001600160401b031916600117905586611f48575b611cb5612acc565b611cbd612acc565b611cc5612acc565b611ccd612acc565b6001600160a01b038116908115610f64578315610f64578515610f64576001600160a01b038916988915610f64573b15610f5357858414611f375762aa36a746148015611f2c575b8015611f21575b1580611f0f575b610f5357611d32906000612afa565b9081611ec8575b5015611e0d57611d5790600080516020612fe0833981519152612afa565b9081611e73575b5015611e0d57611d7c90600080516020612f20833981519152612afa565b9081611e1e575b5015611e0d57600080546001600160a01b031916841781556040519390600080516020612f808339815191528180a38015610f6457803b15610f5357600380546001600160a01b031916919091179055611dd957005b600080516020613020833981519152805460ff60401b1916905560018152600080516020612f0083398151915290602090a1005b63cf5a8e3360e01b60005260046000fd5b600080516020612f20833981519152600052600080516020612ee0833981519152602052611e6c907ffff5b43478fa6840382eb63777e0da6941d320b940e3f70f0ea4780feff95827612d3a565b5084611d83565b600080516020612fe0833981519152600052600080516020612ee0833981519152602052611ec1907f32d31393d541a265984ec379cddd8b1fcbe5f2b0eb8ad81dddfead454f135eaa612d3a565b5086611d5e565b60008052600080516020612ee0833981519152602052611f08907f615f0f9e84155bea8cc509fe18befeb1baf65611e38a6ba60964480fb29dfd44612d3a565b5088611d39565b50823b1580611d235750843b15611d23565b50617a694614611d1c565b506105394614611d15565b638135316560e01b60005260046000fd5b600080516020613020833981519152805460ff60401b1916600160401b179055611cad565b90501589611c82565b303b159150611c7a565b889150611c70565b3461029a57604036600319011261029a57610296611fbc611fa7612064565b600435600052600460205260406000206123c8565b611fc581612090565b60405191818392158361209a565b3461029a57600036600319011261029a57602063ffffffff60055416604051908152f35b3461029a57602036600319011261029a576004359063ffffffff60e01b821680920361029a57602091635a05180f60e01b8114908115612039575b5015158152f35b637965db0b60e01b811491508115612053575b5083612032565b6301ffc9a760e01b1490508361204c565b602435906001600160a01b038216820361029a57565b600435906001600160a01b038216820361029a57565b600811156103b857565b9015158152604081019291906020906120b283612090565b0152565b6004359063ffffffff8216820361029a57565b6024359063ffffffff8216820361029a57565b91604091949363ffffffff916060850196151585526120fa81612090565b602085015216910152565b60a081019081106001600160401b0382111761212057604052565b634e487b7160e01b600052604160045260246000fd5b608081019081106001600160401b0382111761212057604052565b601f909101601f19168101906001600160401b0382119082101761212057604052565b6001600160401b03811161212057601f01601f191660200190565b604435906001600160401b038216820361029a57565b60005b8381106121b85750506000910152565b81810151838201526020016121a8565b906020916121e1815180928185528580860191016121a5565b601f01601f1916010190565b604051906121fc604083612151565b60058252640322e312e360dc1b6020830152565b805463ffffffff60c01b191660c09290921b63ffffffff60c01b16919091179055565b63ffffffff91821681529116602082015260400190565b600052600460205261226160406000209182612485565b61226a81612090565b806122b857505460e01c63ffffffff60055416811580156122b0575b6122a35780821061229c57505b60019160009190565b9050612293565b5050600090600390600090565b508015612286565b6000929091508290565b600052600080516020612fc083398151915260205260016040600020015490565b805463ffffffff60a01b191660a09290921b63ffffffff60a01b16919091179055565b919091600052600460205261232060406000209283612511565b9161232a83612090565b826123625763ffffffff9192505460c01c1663ffffffff60055416811580156122b0576122a35780821061229c575060019160009190565b5060009190600090565b90612383916000526004602052604060002061259d565b61238c81612090565b8061239a5750600190600090565b600091565b8054600160a01b600160e01b03191660a09290921b600160a01b600160e01b0316919091179055565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6002161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b600790565b5050600690565b5050600590565b505050600490565b5050600390565b505050600290565b5050600190565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6008161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6004161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6001161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b6000908152600460205260409020805490916001600160a01b03821691821590811561268c575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580612682575b61127257565b508133141561267c565b6004915060a01c161538612650565b905460a01c63ffffffff16156126ae5750565b600052600460205260006040812055565b6000818152600080516020612fc08339815191526020908152604080832033845290915290205460ff16156126f15750565b63e2517d3f60e01b6000523360045260245260446000fd5b6127138282612afa565b918261271e57505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612d3a565b5090565b61275b8282612ba3565b918261276657505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612dab565b60ff60008051602061300083398151915254166127ae57565b63d93c066560e01b60005260046000fd5b519064ffffffffff8216820361029a57565b519061ffff8216820361029a57565b8015612abb57600354604051638d34875560e01b8152600481018390529190600090839060249082906001600160a01b03165afa918215612aaf57600092612904575b5060808201516001600160a01b0316913383900361127257610120015161284981612090565b61285281612090565b600381149081156128ef575b81156128db575b506128ca5781600052600160205260ff60406000205460e01c1660038110156103b8576001036128b957600090815260046020526040902080546001600160a01b0319166001600160a01b03831617815591565b632e68d1d360e21b60005260046000fd5b63e9f6db8560e01b60005260046000fd5b600791506128e881612090565b1438612865565b90506128fa81612090565b600581149061285e565b90913d8082843e6129158184612151565b820191602081840312612a8f578051906001600160401b038211612a975701906101a082840312612a8c57604051926101a084016001600160401b03811185821017612a9b5760409081528351855260208085015190860152838101519085015260608301516001600160401b038111612a9757830181601f82011215612a97578051906129a282612174565b926129b06040519485612151565b82845260208383010111612a9357906129cf91602080850191016121a5565b606084015260808201516001600160a01b0381168103612a8f5760808401526129fa60a083016127bf565b60a0840152612a0b60c083016127bf565b60c0840152612a1c60e083016127d1565b60e0840152612a2e61010083016127bf565b610100840152610120820151906008821015612a8c5750612a7f9161018091610120850152612a6061014082016127bf565b610140850152612a7361016082016127d1565b610160850152016127bf565b6101808201529038612823565b80fd5b5080fd5b8380fd5b8280fd5b634e487b7160e01b83526041600452602483fd5b6040513d6000823e3d90fd5b637bb0b62160e01b60005260046000fd5b60ff6000805160206130208339815191525460401c1615612ae957565b631afcd79f60e31b60005260046000fd5b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff16612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff1615612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b158015612cfb575b610f64576001600160a01b0316600090815260026020526040902054612cea576001600160401b031642811115612cd95760005460a01c6001600160401b03168015159182612cae575b5050612c9d57565b63e774e7b560e01b60005260046000fd5b909150428103908111612cc357113880612c95565b634e487b7160e01b600052601160045260246000fd5b63efa7aefd60e01b60005260046000fd5b633b53f64f60e21b60005260046000fd5b506001600160a01b03811615612c4b565b8054821015612d245760005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b6001810190826000528160205260406000205415600014612da3578054600160401b81101561212057612d8e612d77826001879401855584612d0c565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014612e75576000198101818111612cc3578254600019810191908211612cc357818103612e3e575b50505080548015612e28576000190190612e068282612d0c565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b612e5e612e4e612d779386612d0c565b90549060031b1c92839286612d0c565b905560005283602052604060002055388080612dec565b50505050600090565b90612ea45750805115612e9357602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580612ed6575b612eb5575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b15612ead56fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc07966f2ab141347034724e9b2a472c2f77f5cd745aeba27cacba797b8fcb708617dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846cd37bc77615afefc793aa17d75d4249a9b517ba91b0e54a49c9c4a44b3d7e228302dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800edcc084d3dcd65a1f7f23c65c46722faca6953d28e43150a467cf43e5c309238cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c6343000822000a";
|
|
19710
|
+
var _bytecode2 = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161394690816100f082396080518181816112d4015261148b0152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a7146124f5575080630d33f3c2146124d15780630f3f4a94146124865780631459457a14611d3e57806318c38b8914611c2d5780631d44454114611b5c5780632106764c14611b35578063248a9ca314611b175780632ec22d4c14611a565780632f0647ce146119db5780632f2ff15d146119aa57806332420744146118d657806336568abe14611890578063392f10871461185a5780633f4ba83a146117625780633f5aadc9146116f35780634f1ef2861461143d57806352340363146113545780635273b6f61461132b57806352d1902d146112c1578063554c4f4b146112315780635bc26aea146111a45780635c975abb146111745780636289d18c146110f35780636711cc0b146110d75780636e852a7814610fd65780637e35bf6e14610fa25780638343f67414610f755780638456cb5914610e7f57806384b0196e14610d545780638c02cabd14610d2b5780638f33527f14610cf15780639010d07c14610c9d57806391d1485414610c435780639b9d30c114610c1a578063a19af3f614610b69578063a217fddf14610b4d578063a3246ad314610a8b578063a878086414610a6f578063ac3c0e3014610962578063ad3cb1cc1461091b578063b3fad63814610876578063b48d36de14610842578063c040b8ae14610726578063c34e9c261461070a578063c86deb31146106ee578063ca15c873146106b5578063d547741f1461067d578063dd71d99a1461063b578063e0922fa11461058e578063efa9b4ae1461051f578063f2f4eb26146104f6578063f68e9553146104cd578063f94f67ab146103f6578063fcc1f21a146102c05763ffa1ad741461028757600080fd5b346102bb5760003660031901126102bb576102b76102a3612780565b6040519182916020835260208301906126d1565b0390f35b600080fd5b346102bb576102ce366126f6565b91926102d8612e42565b6001600160a01b03851692338490036103e657836000526001602052604060002080549160ff8360e01c1660038110156103d0576001036103bf577fc5d5c5bbf10444998e0ea6d4725e79027b574e1c14ec929279e8a9a95c6c6e91948460016103a2946103498b6020998c613385565b818060a01b038316828060a01b03198254161781556103688b82612a4c565b0180546001600160401b031916426001600160401b03161790556001600160a01b0381166000818152600288526040902089905599613179565b6040516001600160401b0390951685526001600160a01b031693a4005b632437e77160e11b60005260046000fd5b634e487b7160e01b600052602160045260246000fd5b62fca64560e31b60005260046000fd5b346102bb5760403660031901126102bb576004356104126125c7565b9061041b612e42565b63ffffffff600554169163ffffffff8116928084109081156104c4575b506104b35760207f6b7727cc9c3df4a29acf0afe01594c1b7e845d20f40f4a14e4c292164a9ed8e19161046a84612e8d565b91610482600863ffffffff845460a01c1617836128c8565b81546001600160e01b031660e09190911b6001600160e01b0319161790556040519485526001600160a01b031693a3005b634346c13160e01b60005260046000fd5b90501584610438565b346102bb5760003660031901126102bb5760206040516000805160206138ba8339815191528152f35b346102bb5760003660031901126102bb576003546040516001600160a01b039091168152602090f35b346102bb5760203660031901126102bb5760043561053b612e42565b61055d61054782612e8d565b9190600163ffffffff825460a01c1617906128c8565b6001600160a01b0316907f812690e0a9dff5bf3add998111b8af5c8299608d859025bfe35662060ab4267d600080a3005b346102bb5760203660031901126102bb576004356001600160401b038116908181036102bb576000546001600160a01b038116330361062a57600160a01b600160e01b0319811660a092831b600160a01b600160e01b031617600055604080519190921c6001600160401b0316815260208101929092527f9c195448332abd01f716db873b329752ea02f19d33f7e311fb0daf082c4edd0391a1005b6349db3bd360e01b60005260046000fd5b346102bb5760203660031901126102bb576001600160a01b0361065c612578565b166000526002602052602060018060a01b0360406000205416604051908152f35b346102bb5760403660031901126102bb576106b360043561069c612562565b906106ae6106a9826128a7565b612d6c565b612dfe565b005b346102bb5760203660031901126102bb5760043560005260008051602061373a8339815191526020526020604060002054604051908152f35b346102bb5760003660031901126102bb57602060405160088152f35b346102bb5760003660031901126102bb57602060405160028152f35b346102bb57610734366126f6565b92909161073f612e42565b6001600160a01b03851693338590036103e65784600052600160205260406000209060ff825460e01c1660038110156103d057600114610831577ff223dc085722c94c84dcf67427e225799be616382a2a484d378f8921c69a2033948461081e936107ad866020988b613385565b80546001600160a01b0319166001600160a01b0383161781556107d08682612a4c565b6001810180546001600160801b031916426001600160401b0316179055805460ff60e01b1916600160e01b1790556001600160a01b0381166000818152600288526040902089905598613179565b6040516001600160401b039091168152a3005b639d2c8fdf60e01b60005260046000fd5b346102bb5760403660031901126102bb57602061086e610860612578565b610868612562565b90612984565b604051908152f35b346102bb5760203660031901126102bb57600060606040516108978161261e565b828152826020820152826040820152015260043560005260046020526080604060002063ffffffff604051916108cc8361261e565b548160018060a01b038216938481528160208201818560a01c16815260606040840193838760c01c168552019460e01c8552604051968752511660208601525116604084015251166060820152f35b346102bb5760003660031901126102bb576102b7604080519061093e8183612639565b60058252640352e302e360dc1b6020830152519182916020835260208301906126d1565b346102bb5760203660031901126102bb5761097b612578565b6000608060405161098b81612603565b828152826020820152826040820152826060820152015260018060a01b0316600052600160205260406000206040516109c381612603565b81546001600160a01b038116825260a081901c6001600160401b03166020830190815292604083019160e01c60ff169060038210156103d057908252600101546001600160401b0380821660608501908152604092831c821660808601908152925194516001600160a01b03168552945116602084015290519260038410156103d057604083019390935291516001600160401b0390811660608301529151909116608082015260a090f35b346102bb5760003660031901126102bb57602060405160018152f35b346102bb5760203660031901126102bb5760043560005260008051602061373a83398151915260205260406000206040518060208354918281520190819360005260206000209060005b818110610b375750505081610aeb910382612639565b6040519182916020830190602084525180915260408301919060005b818110610b15575050500390f35b82516001600160a01b0316845285945060209384019390920191600101610b07565b8254845260209093019260019283019201610ad5565b346102bb5760003660031901126102bb57602060405160008152f35b346102bb5760403660031901126102bb57600435610b856125c7565b90610b8e612e42565b63ffffffff600554169163ffffffff811692808410908115610c11575b506104b35760207f1da95b87b4c773f68c1447ffc5644e41a8a8887d55065beb64852014cf7140be91610bfe610be085612e8d565b9290610bf9600463ffffffff835460a01c1617826128c8565b6127f5565b6040519485526001600160a01b031693a3005b90501584610bab565b346102bb5760003660031901126102bb5760206040516000805160206137fa8339815191528152f35b346102bb5760403660031901126102bb57610c5c612562565b60043560005260008051602061389a83398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b346102bb5760403660031901126102bb5760043560005260008051602061373a8339815191526020526020610cd86024356040600020613357565b905460405160039290921b1c6001600160a01b03168152f35b346102bb5760203660031901126102bb576001600160a01b03610d12612578565b1660005260026020526020604060002054604051908152f35b346102bb5760003660031901126102bb5760206040516000805160206137da8339815191528152f35b346102bb5760003660031901126102bb576000805160206137ba833981519152541580610e68575b15610e2b57610dcd610d8c6127a3565b610d946127d6565b6020610ddb60405192610da78385612639565b600084526000368137604051958695600f60f81b875260e08588015260e08701906126d1565b9085820360408701526126d1565b466060850152306080850152600060a085015283810360c085015281808451928381520193019160005b828110610e1457505050500390f35b835185528695509381019392810192600101610e05565b60405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b6044820152606490fd5b5060008051602061391a8339815191525415610d7c565b346102bb5760003660031901126102bb573360009081527f0ac8cc3d209806126662940717264973110c39045b305f6ba49613325a615e09602052604090205460ff1615610f4e57610ecf612e42565b600160ff196000805160206138da8339815191525416176000805160206138da833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a2005b63e2517d3f60e01b600052336004526000805160206137fa83398151915260245260446000fd5b346102bb5760003660031901126102bb5760005460405160a09190911c6001600160401b03168152602090f35b346102bb5760403660031901126102bb57610fc6610fbe612562565b600435612951565b906102b760405192839283612598565b346102bb5760403660031901126102bb57610fef612578565b33600090815260008051602061383a833981519152602052604090205460ff1615806110c4575b6103e6576001600160a01b03166000818152600160205260409020805460e01c60ff1660038110156103d0576001036103bf57805460ff60e01b198116600160e11b1782556001919091018054600160401b600160801b03191642604090811b600160401b600160801b0316919091179091555160243581526001600160a01b0390911691907fc0499cc07ed9d734deec6857802d3f0fa8d5afaf79a7008beb8ba7bef62a271b90602090a3005b50336001600160a01b0382161415611016565b346102bb5760003660031901126102bb57602060405160048152f35b346102bb5760203660031901126102bb5761110c6125b4565b6000546001600160a01b0316330361062a5763ffffffff81169081156111635760008051602061387a8339815191529161115e63ffffffff926005549284198416176005556040519384931683612818565b0390a1005b6338f3377360e21b60005260046000fd5b346102bb5760003660031901126102bb57602060ff6000805160206138da83398151915254166040519015158152f35b346102bb5760203660031901126102bb576111bd612578565b6000546001600160a01b038116903382900361062a576001600160a01b038316928315611220573b1561120f576001600160a01b0319168217600090815560008051602061385a8339815191529080a3005b636f7c43f160e01b60005260046000fd5b63e6c4247b60e01b60005260046000fd5b346102bb5760203660031901126102bb576001600160a01b03611252612578565b166000526001602052604060002060ff6000805160206138da833981519152541615806112a5575b6020918161128e575b506040519015158152f35b5460a01c6001600160401b03164210905082611283565b5060ff815460e01c169060038210156103d0579060011461127a565b346102bb5760003660031901126102bb577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316300361131a57602060405160008051602061381a8339815191528152f35b63703e46dd60e11b60005260046000fd5b346102bb5760003660031901126102bb576000546040516001600160a01b039091168152602090f35b346102bb5760203660031901126102bb57600435604060008281526004602052209081549160018060a01b03831692831590811561142e575b5061141d5733600090815260008051602061383a833981519152602052604090205460ff161580611413575b61140257806113d563fffffffe6113db935460a01c16826128c8565b82612d48565b7fa5ffbdba01b15df97334e34ad816b9986b6057a5ddc97aba93b7e8ccd21759ed600080a3005b630a606ec360e11b60005260046000fd5b50823314156113b9565b6360eb6c2360e01b60005260046000fd5b6001915060a01c16158461138d565b60403660031901126102bb57611451612578565b6024356001600160401b0381116102bb57366023820112156102bb57611481903690602481600401359101612677565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163081149081156116d0575b5061131a576000546001600160a01b0316330361062a576001600160a01b03821691821561122057803b156116bf573083146116b05760008051602061381a8339815191525483611505612780565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f61153b604051926040845260408401906126d1565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481885afa6000918161167c575b5061158b5784634c9c8ce360e01b60005260045260246000fd5b908160008051602061381a8339815191528693036116685750823b15611653576001600160a01b031916811760008051602061381a833981519152557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2815115611639576000808360206106b395519101845af43d15611631573d916116148361265c565b926116226040519485612639565b83523d6000602085013e61364d565b60609161364d565b50503461164257005b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d6020116116a8575b8161169860209383612639565b810103126102bb57519086611571565b3d915061168b565b614e8d60eb1b60005260046000fd5b632e07c4bd60e11b60005260046000fd5b60008051602061381a833981519152546001600160a01b031614159050836114b6565b346102bb5760203660031901126102bb5760043561170f612e42565b61173161171b82612e8d565b9190600263ffffffff825460a01c1617906128c8565b6001600160a01b0316907fc2713e691344add4705edc62a0ee5aede95ba66ad68f97316efef9cb50644edd600080a3005b346102bb5760003660031901126102bb5733600090815260008051602061383a833981519152602052604090205460ff161580611845575b611834576000805160206138da8339815191525460ff8116156118235760ff19166000805160206138da833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a2005b638dfc202b60e01b60005260046000fd5b63659a07b360e11b60005260046000fd5b506000546001600160a01b031633141561179a565b346102bb5760403660031901126102bb576102b7611881611879612562565b6004356128eb565b604093919351938493846125da565b346102bb5760403660031901126102bb576118a9612562565b336001600160a01b038216036118c5576106b390600435612dfe565b63334bd91960e11b60005260046000fd5b346102bb5760203660031901126102bb57600435604060008281526004602052209081549160018060a01b03831692831590811561199b575b5061141d5733600090815260008051602061383a833981519152602052604090205460ff161580611991575b611402578061195763fffffff761196a935460a01c16826128c8565b80546001600160e01b0316815582612d48565b7f054490ec6650e07db9b97a06ea31d44cebd44b390c9975a380055e1b4d3cac21600080a3005b508233141561193b565b6008915060a01c16158461190f565b346102bb5760403660031901126102bb576106b36004356119c9612562565b906119d66106a9826128a7565b612db6565b346102bb5760203660031901126102bb57600435611a256119fb82612cd6565b9190611a1163fffffffb825460a01c16826128c8565b805463ffffffff60c01b1916815583612d48565b6001600160a01b0316907f09cb4ec44cdef8489412844b9682f87f7900758fa2bd7e039113e9125e538e0f600080a3005b346102bb5760203660031901126102bb57600435604060008281526004602052209081549160018060a01b038316928315908115611b08575b5061141d5733600090815260008051602061383a833981519152602052604090205460ff161580611afe575b61140257806113d563fffffffd611ad7935460a01c16826128c8565b7fb390ab029eab314bd18190ebe73d7e5c1c336beaa5c83ac22578378dc9ccc405600080a3005b5082331415611abb565b6002915060a01c161584611a8f565b346102bb5760203660031901126102bb57602061086e6004356128a7565b346102bb5760403660031901126102bb576102b7611881611b54612562565b60043561282f565b346102bb5760403660031901126102bb57600435611b786125c7565b63ffffffff600554169063ffffffff811691808310908115611c24575b506104b357611ba383612cd6565b909263ffffffff845460c01c16809260018060a01b03163314159182611c19575b5050611c0857611bf4827e8a218591d4362499c38c38eb1c12e7a7cc97a9068818d1fe6046a42ba4a5ba946127f5565b611c0360405192839283612818565b0390a2005b634e80a40760e11b60005260046000fd5b111590508186611bc4565b90501584611b95565b346102bb5760203660031901126102bb57611c466125b4565b6000805160206138fa8339815191525460ff8160401c16908115611d26575b50611d15576000805160206138fa833981519152805460026001600160401b0319821681179092556000546001600160481b031990911690911791906001600160a01b0316330361062a5763ffffffff1680156111635760408160008051602061387a8339815191529263ffffffff196005541617600555815190600082526020820152a16000805160206138fa8339815191525560008051602061377a833981519152602060405160028152a1005b63f92ee8a960e01b60005260046000fd5b60026001600160401b03919091161015905082611c65565b346102bb5760a03660031901126102bb57611d57612578565b611d5f612562565b604435906001600160a01b0382168083036102bb576064356001600160a01b038116918282036102bb576084356001600160a01b03811695908690036102bb576000805160206138fa83398151915254604081901c60ff161597906001600160401b03168015908161247e575b6001149081612474575b15908161246b575b50611d15576000805160206138fa83398151915280546001600160401b031916600117905587612446575b611e116131e0565b611e196131e0565b611e216131e0565b611e296131e0565b6001600160a01b038116908115611220578315611220578515611220576001600160a01b038716968715611220573b1561120f578584146124355762aa36a74614801561242a575b801561241f575b158061240d575b61120f57611e8e90600061320e565b90816123c6575b501561230b57611eb3906000805160206138ba83398151915261320e565b9081612371575b501561230b57611ed8906000805160206137fa83398151915261320e565b908161231c575b501561230b57600080546001600160a01b0319168217815560008051602061385a8339815191528180a3611f116127a3565b91611f1a6127d6565b91611f236131e0565b611f2b6131e0565b83516001600160401b0381116121e05760008051602061375a83398151915254600181811c91168015612301575b60208210146121c057601f8111612282575b50602094601f8211600114612201579481929394956000926121f6575b50508160011b916000199060031b1c19161760008051602061375a833981519152555b82516001600160401b0381116121e05760008051602061379a83398151915254600181811c911680156121d6575b60208210146121c057601f8111612141575b506020601f82116001146120c057819293946000926120b5575b50508160011b916000199060031b1c19161760008051602061379a833981519152555b60006000805160206137ba83398151915255600060008051602061391a83398151915255801561122057803b1561120f57600380546001600160a01b03191691909117905561207357005b60ff60401b196000805160206138fa83398151915254166000805160206138fa8339815191525560008051602061377a833981519152602060405160018152a1005b015190508480612005565b601f1982169060008051602061379a833981519152600052806000209160005b81811061212957509583600195969710612110575b505050811b0160008051602061379a83398151915255612028565b015160001960f88460031b161c191690558480806120f5565b9192602060018192868b0151815501940192016120e0565b81811115611feb5760008051602061379a833981519152600052601f820160051c7f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b75602084106121b7575b81601f9101920160051c039060005b8281106121a9575050611feb565b60008282015560010161219b565b6000915061218c565b634e487b7160e01b600052602260045260246000fd5b90607f1690611fd9565b634e487b7160e01b600052604160045260246000fd5b015190508580611f88565b601f1982169560008051602061375a833981519152600052806000209160005b88811061226a57508360019596979810612251575b505050811b0160008051602061375a83398151915255611fab565b015160001960f88460031b161c19169055858080612236565b91926020600181928685015181550194019201612221565b81811115611f6b5760008051602061375a833981519152600052601f820160051c7f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d602084106122f8575b81601f9101920160051c039060005b8281106122ea575050611f6b565b6000828201556001016122dc565b600091506122cd565b90607f1690611f59565b63cf5a8e3360e01b60005260046000fd5b6000805160206137fa83398151915260005260008051602061373a83398151915260205261236a907ffff5b43478fa6840382eb63777e0da6941d320b940e3f70f0ea4780feff9582761348a565b5084611edf565b6000805160206138ba83398151915260005260008051602061373a8339815191526020526123bf907f32d31393d541a265984ec379cddd8b1fcbe5f2b0eb8ad81dddfead454f135eaa61348a565b5086611eba565b6000805260008051602061373a833981519152602052612406907f615f0f9e84155bea8cc509fe18befeb1baf65611e38a6ba60964480fb29dfd4461348a565b5088611e95565b50823b1580611e7f5750843b15611e7f565b50617a694614611e78565b506105394614611e71565b638135316560e01b60005260046000fd5b6000805160206138fa833981519152805460ff60401b1916600160401b179055611e09565b90501589611dde565b303b159150611dd6565b899150611dcc565b346102bb5760403660031901126102bb576102b76124ba6124a5612562565b60043560005260046020526040600020612a75565b6124c38161258e565b604051918183921583612598565b346102bb5760003660031901126102bb57602063ffffffff60055416604051908152f35b346102bb5760203660031901126102bb576004359063ffffffff60e01b82168092036102bb57602091635a05180f60e01b8114908115612537575b5015158152f35b637965db0b60e01b811491508115612551575b5083612530565b6301ffc9a760e01b1490508361254a565b602435906001600160a01b03821682036102bb57565b600435906001600160a01b03821682036102bb57565b600811156103d057565b9015158152604081019291906020906125b08361258e565b0152565b6004359063ffffffff821682036102bb57565b6024359063ffffffff821682036102bb57565b91604091949363ffffffff916060850196151585526125f88161258e565b602085015216910152565b60a081019081106001600160401b038211176121e057604052565b608081019081106001600160401b038211176121e057604052565b601f909101601f19168101906001600160401b038211908210176121e057604052565b6001600160401b0381116121e057601f01601f191660200190565b9291926126838261265c565b916126916040519384612639565b8294818452818301116102bb578281602093846000960137010152565b60005b8381106126c15750506000910152565b81810151838201526020016126b1565b906020916126ea815180928185528580860191016126ae565b601f01601f1916010190565b60806003198201126102bb576004356001600160a01b03811681036102bb57916024356001600160a01b03811681036102bb57916044356001600160401b03811681036102bb57916064356001600160401b0381116102bb57826023820112156102bb576004810135926001600160401b0384116102bb57602484830101116102bb576024019190565b6040519061278f604083612639565b60058252640332e302e360dc1b6020830152565b604051906127b2604083612639565b6015825274111a585b5bdb9912185b991ccb941c9bdd1bd8dbdb605a1b6020830152565b604051906127e5604083612639565b60018252603160f81b6020830152565b805463ffffffff60c01b191660c09290921b63ffffffff60c01b16919091179055565b63ffffffff91821681529116602082015260400190565b600052600460205261284660406000209182612b32565b61284f8161258e565b8061289d57505460e01c63ffffffff6005541681158015612895575b6128885780821061288157505b60019160009190565b9050612878565b5050600090600390600090565b50801561286b565b6000929091508290565b60005260008051602061389a83398151915260205260016040600020015490565b805463ffffffff60a01b191660a09290921b63ffffffff60a01b16919091179055565b919091600052600460205261290560406000209283612bbe565b9161290f8361258e565b826129475763ffffffff9192505460c01c1663ffffffff60055416811580156128955761288857808210612881575060019160009190565b5060009190600090565b906129689160005260046020526040600020612c4a565b6129718161258e565b8061297f5750600190600090565b600091565b6042916040519060208201926000805160206137da833981519152845260018060a01b0316604083015260018060a01b03166060820152606081526129ca608082612639565b5190206129d56136ae565b6129dd613706565b6040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a08152612a2e60c082612639565b519020906040519161190160f01b8352600283015260228201522090565b8054600160a01b600160e01b03191660a09290921b600160a01b600160e01b0316919091179055565b60ff6000805160206138da8339815191525416612b2b57546001600160a01b038116908115612b235760a01c60021615612b1c5760005260016020526040600020549060ff8260e01c1660038110156103d0578015612b1457600214612b0d574260a083901c6001600160401b03161115612b06576001600160a01b03908116911603612b0157600090565b600790565b5050600690565b5050600590565b505050600490565b5050600390565b505050600290565b5050600190565b60ff6000805160206138da8339815191525416612b2b57546001600160a01b038116908115612b235760a01c60081615612b1c5760005260016020526040600020549060ff8260e01c1660038110156103d0578015612b1457600214612b0d574260a083901c6001600160401b03161115612b06576001600160a01b03908116911603612b0157600090565b60ff6000805160206138da8339815191525416612b2b57546001600160a01b038116908115612b235760a01c60041615612b1c5760005260016020526040600020549060ff8260e01c1660038110156103d0578015612b1457600214612b0d574260a083901c6001600160401b03161115612b06576001600160a01b03908116911603612b0157600090565b60ff6000805160206138da8339815191525416612b2b57546001600160a01b038116908115612b235760a01c60011615612b1c5760005260016020526040600020549060ff8260e01c1660038110156103d0578015612b1457600214612b0d574260a083901c6001600160401b03161115612b06576001600160a01b03908116911603612b0157600090565b6000908152600460205260409020805490916001600160a01b038216918215908115612d39575b5061141d5733600090815260008051602061383a833981519152602052604090205460ff161580612d2f575b61140257565b5081331415612d29565b6004915060a01c161538612cfd565b905460a01c63ffffffff1615612d5b5750565b600052600460205260006040812055565b600081815260008051602061389a8339815191526020908152604080832033845290915290205460ff1615612d9e5750565b63e2517d3f60e01b6000523360045260245260446000fd5b612dc0828261320e565b9182612dcb57505090565b600091825260008051602061373a8339815191526020526040909120612dfa916001600160a01b03169061348a565b5090565b612e0882826132b7565b9182612e1357505090565b600091825260008051602061373a8339815191526020526040909120612dfa916001600160a01b0316906134fb565b60ff6000805160206138da8339815191525416612e5b57565b63d93c066560e01b60005260046000fd5b519064ffffffffff821682036102bb57565b519061ffff821682036102bb57565b801561316857600354604051638d34875560e01b8152600481018390529190600090839060249082906001600160a01b03165afa91821561315c57600092612fb1575b5060808201516001600160a01b03169133839003611402576101200151612ef68161258e565b612eff8161258e565b60038114908115612f9c575b8115612f88575b50612f775781600052600160205260ff60406000205460e01c1660038110156103d057600103612f6657600090815260046020526040902080546001600160a01b0319166001600160a01b03831617815591565b632e68d1d360e21b60005260046000fd5b63e9f6db8560e01b60005260046000fd5b60079150612f958161258e565b1438612f12565b9050612fa78161258e565b6005811490612f0b565b90913d8082843e612fc28184612639565b82019160208184031261313c578051906001600160401b0382116131445701906101a08284031261313957604051926101a084016001600160401b038111858210176131485760409081528351855260208085015190860152838101519085015260608301516001600160401b03811161314457830181601f820112156131445780519061304f8261265c565b9261305d6040519485612639565b82845260208383010111613140579061307c91602080850191016126ae565b606084015260808201516001600160a01b038116810361313c5760808401526130a760a08301612e6c565b60a08401526130b860c08301612e6c565b60c08401526130c960e08301612e7e565b60e08401526130db6101008301612e6c565b610100840152610120820151906008821015613139575061312c916101809161012085015261310d6101408201612e6c565b6101408501526131206101608201612e7e565b61016085015201612e6c565b6101808201529038612ed0565b80fd5b5080fd5b8380fd5b8280fd5b634e487b7160e01b83526041600452602483fd5b6040513d6000823e3d90fd5b637bb0b62160e01b60005260046000fd5b61319b9261318d8361319593969496612984565b923691612677565b9061344e565b5060048110156103d05715918215926131c8575b50506131b757565b63cacba36560e01b60005260046000fd5b6001600160a01b0391821691161415905038806131af565b60ff6000805160206138fa8339815191525460401c16156131fd57565b631afcd79f60e31b60005260046000fd5b600081815260008051602061389a833981519152602090815260408083206001600160a01b038616845290915290205460ff166132b057600081815260008051602061389a833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b600081815260008051602061389a833981519152602090815260408083206001600160a01b038616845290915290205460ff16156132b057600081815260008051602061389a833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b805482101561336f5760005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b15801561343d575b611220576001600160a01b031660009081526002602052604090205461342c576001600160401b03164281111561341b5760005460a01c6001600160401b031680151591826133f0575b50506133df57565b63e774e7b560e01b60005260046000fd5b909150428103908111613405571138806133d7565b634e487b7160e01b600052601160045260246000fd5b63efa7aefd60e01b60005260046000fd5b633b53f64f60e21b60005260046000fd5b506001600160a01b0381161561338d565b815191906041830361347f5761347892506020820151906060604084015193015160001a906135ce565b9192909190565b505060009160029190565b60018101908260005281602052604060002054156000146134f3578054600160401b8110156121e0576134de6134c7826001879401855584613357565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b90600182019181600052826020526040600020548015156000146135c55760001981018181116134055782546000198101919082116134055781810361358e575b505050805480156135785760001901906135568282613357565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b6135ae61359e6134c79386613357565b90549060031b1c92839286613357565b90556000528360205260406000205538808061353c565b50505050600090565b91906fa2a8918ca85bafe22016d0b997e4df60600160ff1b038411613641579160209360809260ff60009560405194855216868401526040830152606082015282805260015afa1561315c576000516001600160a01b038116156136355790600090600090565b50600090600190600090565b50505060009160039190565b90613673575080511561366257602081519101fd5b63d6bda27560e01b60005260046000fd5b815115806136a5575b613684575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561367c565b6136b66127a3565b80519081156136c6576020012090565b50506000805160206137ba8339815191525480156136e15790565b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47090565b61370e6127d6565b805190811561371e576020012090565b505060008051602061391a8339815191525480156136e1579056fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000a16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d102c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2a16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d103a16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1002b26bde9d050a2447879fc2826d068ca8d51a693da5ddde56556964c09fea96875027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc07966f2ab141347034724e9b2a472c2f77f5cd745aeba27cacba797b8fcb708617dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846cd37bc77615afefc793aa17d75d4249a9b517ba91b0e54a49c9c4a44b3d7e228302dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800edcc084d3dcd65a1f7f23c65c46722faca6953d28e43150a467cf43e5c309238cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d101a164736f6c6343000822000a";
|
|
19264
19711
|
var isSuperArgs2 = (xs) => xs.length > 1;
|
|
19265
|
-
var AgentDelegationRegistry__factory = class extends
|
|
19712
|
+
var AgentDelegationRegistry__factory = class extends import_ethers17.ContractFactory {
|
|
19266
19713
|
constructor(...args) {
|
|
19267
19714
|
if (isSuperArgs2(args)) {
|
|
19268
19715
|
super(...args);
|
|
@@ -19282,10 +19729,10 @@ var AgentDelegationRegistry__factory = class extends import_ethers16.ContractFac
|
|
|
19282
19729
|
static bytecode = _bytecode2;
|
|
19283
19730
|
static abi = _abi2;
|
|
19284
19731
|
static createInterface() {
|
|
19285
|
-
return new
|
|
19732
|
+
return new import_ethers17.Interface(_abi2);
|
|
19286
19733
|
}
|
|
19287
19734
|
static connect(address, runner) {
|
|
19288
|
-
return new
|
|
19735
|
+
return new import_ethers17.Contract(
|
|
19289
19736
|
address,
|
|
19290
19737
|
_abi2,
|
|
19291
19738
|
runner
|
|
@@ -19294,7 +19741,7 @@ var AgentDelegationRegistry__factory = class extends import_ethers16.ContractFac
|
|
|
19294
19741
|
};
|
|
19295
19742
|
|
|
19296
19743
|
// src/utils/position-delegate.utils.ts
|
|
19297
|
-
var
|
|
19744
|
+
var import_ethers18 = require("ethers");
|
|
19298
19745
|
var POSITION_DELEGATE_REGISTRY_ABI = [
|
|
19299
19746
|
"function positionDelegate(bytes32 positionId) view returns (address)",
|
|
19300
19747
|
"function isDelegate(bytes32 positionId, address delegate) view returns (bool)",
|
|
@@ -19313,7 +19760,7 @@ var DELEGATE_STATUS_ABI = [
|
|
|
19313
19760
|
"function delegateStatus(bytes32 positionId, address delegate) view returns (bool ok, uint8 reason)"
|
|
19314
19761
|
];
|
|
19315
19762
|
async function setPositionDelegate(positionId, delegate, signer, registryAddress) {
|
|
19316
|
-
const registry = new
|
|
19763
|
+
const registry = new import_ethers18.Contract(
|
|
19317
19764
|
registryAddress,
|
|
19318
19765
|
POSITION_DELEGATE_REGISTRY_ABI,
|
|
19319
19766
|
signer
|
|
@@ -19321,7 +19768,7 @@ async function setPositionDelegate(positionId, delegate, signer, registryAddress
|
|
|
19321
19768
|
return registry["setPositionDelegate"](positionId, delegate);
|
|
19322
19769
|
}
|
|
19323
19770
|
async function getPositionDelegate(positionId, provider, registryAddress) {
|
|
19324
|
-
const registry = new
|
|
19771
|
+
const registry = new import_ethers18.Contract(
|
|
19325
19772
|
registryAddress,
|
|
19326
19773
|
POSITION_DELEGATE_REGISTRY_ABI,
|
|
19327
19774
|
provider
|
|
@@ -19329,7 +19776,7 @@ async function getPositionDelegate(positionId, provider, registryAddress) {
|
|
|
19329
19776
|
return registry["positionDelegate"](positionId);
|
|
19330
19777
|
}
|
|
19331
19778
|
async function isPositionDelegate(positionId, delegate, provider, registryAddress) {
|
|
19332
|
-
const registry = new
|
|
19779
|
+
const registry = new import_ethers18.Contract(
|
|
19333
19780
|
registryAddress,
|
|
19334
19781
|
POSITION_DELEGATE_REGISTRY_ABI,
|
|
19335
19782
|
provider
|
|
@@ -19337,7 +19784,7 @@ async function isPositionDelegate(positionId, delegate, provider, registryAddres
|
|
|
19337
19784
|
return registry["isDelegate"](positionId, delegate);
|
|
19338
19785
|
}
|
|
19339
19786
|
async function getDelegateStatus(positionId, delegate, provider, registryAddress) {
|
|
19340
|
-
const registry = new
|
|
19787
|
+
const registry = new import_ethers18.Contract(
|
|
19341
19788
|
registryAddress,
|
|
19342
19789
|
DELEGATE_STATUS_ABI,
|
|
19343
19790
|
provider
|
|
@@ -19352,6 +19799,12 @@ async function getDelegateStatus(positionId, delegate, provider, registryAddress
|
|
|
19352
19799
|
}
|
|
19353
19800
|
|
|
19354
19801
|
// src/utils/agent-delegation.utils.ts
|
|
19802
|
+
var AGENT_BINDING_CONSENT_TYPES = {
|
|
19803
|
+
AgentBindingConsent: [
|
|
19804
|
+
{ name: "user", type: "address" },
|
|
19805
|
+
{ name: "agent", type: "address" }
|
|
19806
|
+
]
|
|
19807
|
+
};
|
|
19355
19808
|
async function mintAgentPkp(params) {
|
|
19356
19809
|
const { serviceEndpoint, authHeader, timeoutMs = 3e4 } = params;
|
|
19357
19810
|
if (!serviceEndpoint) {
|
|
@@ -19384,7 +19837,12 @@ async function mintAgentPkp(params) {
|
|
|
19384
19837
|
`Agent PKP mint returned no address: ${data.error ?? JSON.stringify(data)}`
|
|
19385
19838
|
);
|
|
19386
19839
|
}
|
|
19387
|
-
|
|
19840
|
+
if (typeof data.agentConsent !== "string" || !/^0x[0-9a-fA-F]{130}$/.test(data.agentConsent)) {
|
|
19841
|
+
throw new Error(
|
|
19842
|
+
`Agent PKP mint returned no binding consent for ${data.walletAddress} \u2014 the server predates AgentDelegationRegistry 3.0.0, which cannot bind an agent without one`
|
|
19843
|
+
);
|
|
19844
|
+
}
|
|
19845
|
+
return { walletAddress: data.walletAddress, agentConsent: data.agentConsent };
|
|
19388
19846
|
} finally {
|
|
19389
19847
|
clearTimeout(timeout);
|
|
19390
19848
|
}
|
|
@@ -19426,7 +19884,7 @@ async function describeProviderChainMismatch(provider, chainId) {
|
|
|
19426
19884
|
}
|
|
19427
19885
|
|
|
19428
19886
|
// src/utils/sign-guard/psm-exchange.ts
|
|
19429
|
-
var
|
|
19887
|
+
var import_ethers21 = require("ethers");
|
|
19430
19888
|
|
|
19431
19889
|
// src/utils/sign-guard/errors.ts
|
|
19432
19890
|
var TxValidationError = class extends Error {
|
|
@@ -19441,7 +19899,7 @@ var TxValidationError = class extends Error {
|
|
|
19441
19899
|
};
|
|
19442
19900
|
|
|
19443
19901
|
// src/utils/sign-guard/signable-functions.ts
|
|
19444
|
-
var
|
|
19902
|
+
var import_ethers19 = require("ethers");
|
|
19445
19903
|
var SIGNABLE_FUNCTIONS = [
|
|
19446
19904
|
"function mintUCD(bytes32 positionId, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractHash, uint256 quantumTimestamp, bytes calldata mintValidatorSignature) external returns (bool)",
|
|
19447
19905
|
// `makePayment` is the ONLY repayment entry point. A `repayPosition` entry
|
|
@@ -19478,7 +19936,7 @@ var SIGNABLE_FUNCTIONS = [
|
|
|
19478
19936
|
// this too is client-only and never module-whitelisted.
|
|
19479
19937
|
"function addAddress(string btcAddress) external"
|
|
19480
19938
|
];
|
|
19481
|
-
var IFACE = new
|
|
19939
|
+
var IFACE = new import_ethers19.ethers.Interface(SIGNABLE_FUNCTIONS);
|
|
19482
19940
|
function encodeSignable(fn, args) {
|
|
19483
19941
|
return IFACE.encodeFunctionData(fn, args);
|
|
19484
19942
|
}
|
|
@@ -19501,12 +19959,12 @@ function decodeSignable(data) {
|
|
|
19501
19959
|
}
|
|
19502
19960
|
|
|
19503
19961
|
// src/utils/sign-guard/tx-validator.ts
|
|
19504
|
-
var
|
|
19962
|
+
var import_ethers20 = require("ethers");
|
|
19505
19963
|
function eqAddr(a, b) {
|
|
19506
19964
|
if (!a || !b)
|
|
19507
19965
|
return false;
|
|
19508
19966
|
try {
|
|
19509
|
-
return
|
|
19967
|
+
return import_ethers20.ethers.getAddress(a) === import_ethers20.ethers.getAddress(b);
|
|
19510
19968
|
} catch {
|
|
19511
19969
|
return false;
|
|
19512
19970
|
}
|
|
@@ -19572,7 +20030,7 @@ function readValue(tx) {
|
|
|
19572
20030
|
}
|
|
19573
20031
|
function normalizePositionId(id) {
|
|
19574
20032
|
const hex = id.startsWith("0x") ? id : `0x${id}`;
|
|
19575
|
-
return
|
|
20033
|
+
return import_ethers20.ethers.zeroPadValue(hex, 32).toLowerCase();
|
|
19576
20034
|
}
|
|
19577
20035
|
function requirePositionId(actual, expected) {
|
|
19578
20036
|
const txPositionId = String(actual).toLowerCase();
|
|
@@ -19866,18 +20324,18 @@ function buildPsmRedeemTx(p) {
|
|
|
19866
20324
|
var PSM_READS_ABI = ["function supportedStablecoins(address) view returns (bool)"];
|
|
19867
20325
|
var ERC20_READS_ABI = ["function allowance(address owner, address spender) view returns (uint256)"];
|
|
19868
20326
|
function psmExchangeReadsFromProvider(provider, psmAddress) {
|
|
19869
|
-
const psm = new
|
|
20327
|
+
const psm = new import_ethers21.ethers.Contract(psmAddress, PSM_READS_ABI, provider);
|
|
19870
20328
|
return {
|
|
19871
20329
|
isStablecoinSupported: async (stablecoin) => await psm.getFunction("supportedStablecoins")(stablecoin),
|
|
19872
|
-
allowance: async (token, owner, spender) => await new
|
|
20330
|
+
allowance: async (token, owner, spender) => await new import_ethers21.ethers.Contract(token, ERC20_READS_ABI, provider).getFunction("allowance")(owner, spender)
|
|
19873
20331
|
};
|
|
19874
20332
|
}
|
|
19875
20333
|
var refuse = (direction, msg) => new TxValidationError(msg, `PSM ${direction}`);
|
|
19876
20334
|
function requireAddress(direction, label, value) {
|
|
19877
|
-
if (!value || !
|
|
20335
|
+
if (!value || !import_ethers21.ethers.isAddress(value)) {
|
|
19878
20336
|
throw refuse(direction, `${label} address is missing or invalid (${String(value)})`);
|
|
19879
20337
|
}
|
|
19880
|
-
return
|
|
20338
|
+
return import_ethers21.ethers.getAddress(value);
|
|
19881
20339
|
}
|
|
19882
20340
|
async function planPsmExchange(params) {
|
|
19883
20341
|
const { direction, amountIn, minOut, vctx, reads } = params;
|
|
@@ -20205,7 +20663,7 @@ function formatLiquidationFailureMessage(loanId, errorMessage, btcVault, btcVaul
|
|
|
20205
20663
|
}
|
|
20206
20664
|
|
|
20207
20665
|
// src/utils/contract-error-decoder.ts
|
|
20208
|
-
var
|
|
20666
|
+
var import_ethers22 = require("ethers");
|
|
20209
20667
|
|
|
20210
20668
|
// src/constants/chunks/contract-errors.generated.ts
|
|
20211
20669
|
var CONTRACT_ERROR_FRAGMENTS = [
|
|
@@ -20458,7 +20916,7 @@ function contractErrorTable() {
|
|
|
20458
20916
|
if (TABLE)
|
|
20459
20917
|
return TABLE;
|
|
20460
20918
|
const table = /* @__PURE__ */ new Map();
|
|
20461
|
-
const iface = new
|
|
20919
|
+
const iface = new import_ethers22.Interface(CONTRACT_ERROR_FRAGMENTS.map((e) => e.fragment));
|
|
20462
20920
|
const contractsByName = new Map(
|
|
20463
20921
|
CONTRACT_ERROR_FRAGMENTS.map((e) => [e.fragment.slice("error ".length, e.fragment.indexOf("(")), e.contracts])
|
|
20464
20922
|
);
|
|
@@ -20551,7 +21009,7 @@ function decodeContractError(error) {
|
|
|
20551
21009
|
const contract = entry.contracts.join(" | ");
|
|
20552
21010
|
let args = [];
|
|
20553
21011
|
try {
|
|
20554
|
-
const decoded = new
|
|
21012
|
+
const decoded = new import_ethers22.Interface([entry.fragment]).decodeErrorResult(entry.fragment, errorData);
|
|
20555
21013
|
args = Array.from(decoded);
|
|
20556
21014
|
} catch {
|
|
20557
21015
|
args = [];
|
|
@@ -20875,10 +21333,11 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
20875
21333
|
* from live chain state so a half-done ceremony resumes.
|
|
20876
21334
|
*
|
|
20877
21335
|
* Service-mode only — the server holds the Chipotle account that mints the
|
|
20878
|
-
* PKP and it gates the route to current Safe owners. `knownAgentAddress`
|
|
20879
|
-
* the caller-persisted agent
|
|
20880
|
-
*
|
|
20881
|
-
* restart.
|
|
21336
|
+
* PKP and it gates the route to current Safe owners. `knownAgentAddress` +
|
|
21337
|
+
* `knownAgentConsent` are the caller-persisted agent and its binding consent
|
|
21338
|
+
* from an earlier prepare whose ceremony has not landed yet; echoing them back
|
|
21339
|
+
* prevents a duplicate mint after a server restart. The server reuses an
|
|
21340
|
+
* address only with a consent that verifies for this Safe (issue #1197).
|
|
20882
21341
|
*/
|
|
20883
21342
|
async prepareSafeAgentModule(request) {
|
|
20884
21343
|
if (this.config.mode !== "service") {
|
|
@@ -20902,7 +21361,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
20902
21361
|
signal: abort.signal,
|
|
20903
21362
|
body: JSON.stringify({
|
|
20904
21363
|
safeAddress: request.safeAddress,
|
|
20905
|
-
...request.knownAgentAddress ? { knownAgentAddress: request.knownAgentAddress } : {}
|
|
21364
|
+
...request.knownAgentAddress ? { knownAgentAddress: request.knownAgentAddress } : {},
|
|
21365
|
+
...request.knownAgentConsent ? { knownAgentConsent: request.knownAgentConsent } : {}
|
|
20906
21366
|
})
|
|
20907
21367
|
}
|
|
20908
21368
|
);
|
|
@@ -20919,9 +21379,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
20919
21379
|
`prepareSafeAgentModule failed (${resp.status}): ${data?.error ?? "no error detail from server"}`
|
|
20920
21380
|
);
|
|
20921
21381
|
}
|
|
21382
|
+
const selectors = data.calls.map((c) => c.data.slice(0, 10).toLowerCase());
|
|
21383
|
+
if (selectors.some((s) => s === "0x561b7f8a" || s === "0xfd437d39")) {
|
|
21384
|
+
throw new Error(
|
|
21385
|
+
"prepareSafeAgentModule returned a 3-argument registerAgent/rotateAgent \u2014 the delegation server predates AgentDelegationRegistry 3.0.0, which would revert it"
|
|
21386
|
+
);
|
|
21387
|
+
}
|
|
21388
|
+
if (selectors.some((s) => s === "0xc040b8ae" || s === "0xfcc1f21a") && typeof data.agentConsent !== "string") {
|
|
21389
|
+
throw new Error(
|
|
21390
|
+
"prepareSafeAgentModule returned a registration without the agent's binding consent"
|
|
21391
|
+
);
|
|
21392
|
+
}
|
|
20922
21393
|
return {
|
|
20923
21394
|
status: data.status,
|
|
20924
21395
|
agentAddress: data.agentAddress,
|
|
21396
|
+
agentConsent: data.agentConsent ?? null,
|
|
20925
21397
|
moduleAddress: data.moduleAddress,
|
|
20926
21398
|
validUntil: data.validUntil,
|
|
20927
21399
|
calls: data.calls
|
|
@@ -21114,7 +21586,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
21114
21586
|
*/
|
|
21115
21587
|
constructor(config) {
|
|
21116
21588
|
if (!config.provider && config.ethRpcUrl) {
|
|
21117
|
-
config.provider = new
|
|
21589
|
+
config.provider = new import_ethers23.JsonRpcProvider(config.ethRpcUrl);
|
|
21118
21590
|
}
|
|
21119
21591
|
this.config = config;
|
|
21120
21592
|
if (config.debug) {
|
|
@@ -21406,7 +21878,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
21406
21878
|
const network = await config.provider.getNetwork();
|
|
21407
21879
|
chainId = Number(network.chainId);
|
|
21408
21880
|
} else if (config.ethRpcUrl) {
|
|
21409
|
-
const tempProvider = new
|
|
21881
|
+
const tempProvider = new import_ethers23.JsonRpcProvider(
|
|
21410
21882
|
config.ethRpcUrl
|
|
21411
21883
|
);
|
|
21412
21884
|
const network = await tempProvider.getNetwork();
|
|
@@ -21934,6 +22406,14 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
21934
22406
|
}
|
|
21935
22407
|
}
|
|
21936
22408
|
async _requestMintUCDAttempt(request) {
|
|
22409
|
+
if (request.debugOverrides !== void 0) {
|
|
22410
|
+
throw new SDKError({
|
|
22411
|
+
code: "SDK_DEBUG_OVERRIDES_REMOVED",
|
|
22412
|
+
message: "debugOverrides is not supported: BTC stub mode was removed from the mint validator",
|
|
22413
|
+
category: "VALIDATION" /* VALIDATION */,
|
|
22414
|
+
severity: "MEDIUM" /* MEDIUM */
|
|
22415
|
+
});
|
|
22416
|
+
}
|
|
21937
22417
|
try {
|
|
21938
22418
|
if (this.config.debug) {
|
|
21939
22419
|
log.info("\u{1FA99} Requesting UCD minting...", {});
|
|
@@ -21942,7 +22422,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
21942
22422
|
}
|
|
21943
22423
|
const loanOps = this.loanOps();
|
|
21944
22424
|
const protocolConfig = await loanOps.getProtocolConfig();
|
|
21945
|
-
const requestAmountWei = (0,
|
|
22425
|
+
const requestAmountWei = (0, import_ethers23.parseEther)(
|
|
21946
22426
|
request.amount.toString()
|
|
21947
22427
|
);
|
|
21948
22428
|
const minLoanValueWei = BigInt(protocolConfig.minimumLoanValueWei);
|
|
@@ -22044,12 +22524,12 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22044
22524
|
);
|
|
22045
22525
|
return {
|
|
22046
22526
|
success: false,
|
|
22047
|
-
error: `Amount ${request.amount} UCD plus the ${positionTerm.originationFeeBps / 100}% origination fee (${(0,
|
|
22527
|
+
error: `Amount ${request.amount} UCD plus the ${positionTerm.originationFeeBps / 100}% origination fee (${(0, import_ethers23.formatEther)(baseFeeWei)} UCD) would take this loan's debt to ${(0, import_ethers23.formatEther)(debtAfterWei)} UCD, above the protocol maximum of ${(0, import_ethers23.formatEther)(maxLoanValueWei)} UCD. The largest amount you can mint now is ${maxPrincipalUcd} UCD.`
|
|
22048
22528
|
};
|
|
22049
22529
|
}
|
|
22050
22530
|
if (this.config.debug) {
|
|
22051
22531
|
log.info(
|
|
22052
|
-
`\u2705 Fee-inclusive loan cap check passed: ${(0,
|
|
22532
|
+
`\u2705 Fee-inclusive loan cap check passed: ${(0, import_ethers23.formatEther)(currentDebtWei + requestAmountWei + baseFeeWei)} UCD <= ${(0, import_ethers23.formatEther)(maxLoanValueWei)} UCD`,
|
|
22053
22533
|
{}
|
|
22054
22534
|
);
|
|
22055
22535
|
}
|
|
@@ -22080,7 +22560,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22080
22560
|
pkpNftAddress,
|
|
22081
22561
|
this.getChipotlePublicKeyFallback()
|
|
22082
22562
|
);
|
|
22083
|
-
pkpEthAddress = (0,
|
|
22563
|
+
pkpEthAddress = (0, import_ethers23.computeAddress)(pkpPublicKey);
|
|
22084
22564
|
pkpCache.set(request.positionId, {
|
|
22085
22565
|
publicKey: pkpPublicKey,
|
|
22086
22566
|
ethAddress: pkpEthAddress,
|
|
@@ -22211,9 +22691,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22211
22691
|
} : {},
|
|
22212
22692
|
rpcUrl: request.rpcUrl || this.config.ethRpcUrl,
|
|
22213
22693
|
// Pass RPC URL to LIT Action (ngrok for Hardhat)
|
|
22214
|
-
...request.debugOverrides && {
|
|
22215
|
-
debugOverrides: request.debugOverrides
|
|
22216
|
-
},
|
|
22217
22694
|
...this.config.priceProviders && {
|
|
22218
22695
|
priceProviders: this.config.priceProviders
|
|
22219
22696
|
}
|
|
@@ -22423,8 +22900,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22423
22900
|
throw new Error(`Position not found: ${request.positionId}`);
|
|
22424
22901
|
}
|
|
22425
22902
|
const currentDebt = position.ucdDebt.toString();
|
|
22426
|
-
const ucdDebtHash = (0,
|
|
22427
|
-
const contractHash = (0,
|
|
22903
|
+
const ucdDebtHash = (0, import_ethers23.keccak256)(import_ethers23.AbiCoder.defaultAbiCoder().encode(["uint256"], [currentDebt]));
|
|
22904
|
+
const contractHash = (0, import_ethers23.keccak256)(import_ethers23.AbiCoder.defaultAbiCoder().encode(
|
|
22428
22905
|
["address", "address", "address", "address"],
|
|
22429
22906
|
[
|
|
22430
22907
|
positionManagerAddress,
|
|
@@ -22493,7 +22970,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22493
22970
|
const coreAbi = [
|
|
22494
22971
|
"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))"
|
|
22495
22972
|
];
|
|
22496
|
-
const positionCore = new
|
|
22973
|
+
const positionCore = new import_ethers23.Contract(
|
|
22497
22974
|
coreAddress,
|
|
22498
22975
|
coreAbi,
|
|
22499
22976
|
this.getSignerOrThrow().provider
|
|
@@ -22501,8 +22978,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22501
22978
|
const currentPosition = await positionCore["getPositionDetails"](
|
|
22502
22979
|
positionIdBytes32
|
|
22503
22980
|
);
|
|
22504
|
-
const currentDebtHash = (0,
|
|
22505
|
-
|
|
22981
|
+
const currentDebtHash = (0, import_ethers23.keccak256)(
|
|
22982
|
+
import_ethers23.AbiCoder.defaultAbiCoder().encode(
|
|
22506
22983
|
["uint256"],
|
|
22507
22984
|
[currentPosition.ucdDebt]
|
|
22508
22985
|
)
|
|
@@ -22549,7 +23026,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22549
23026
|
"function getCurrentQuantum() view returns (uint256)",
|
|
22550
23027
|
"function isQuantumValid(bytes32,uint256) view returns (bool)"
|
|
22551
23028
|
];
|
|
22552
|
-
const registry = new
|
|
23029
|
+
const registry = new import_ethers23.Contract(
|
|
22553
23030
|
registryAddress,
|
|
22554
23031
|
registryAbi,
|
|
22555
23032
|
this.getSignerOrThrow().provider
|
|
@@ -22665,7 +23142,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22665
23142
|
});
|
|
22666
23143
|
}
|
|
22667
23144
|
const signatureHexMint = finalSignature.startsWith("0x") ? finalSignature : "0x" + finalSignature;
|
|
22668
|
-
const mintIface = new
|
|
23145
|
+
const mintIface = new import_ethers23.Interface(positionManagerAbi);
|
|
22669
23146
|
const mintCalldata = mintIface.encodeFunctionData("mintUCD", [
|
|
22670
23147
|
positionIdBytes32,
|
|
22671
23148
|
validationResponse.mintAmount,
|
|
@@ -22701,7 +23178,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
22701
23178
|
if (viewsAddress) {
|
|
22702
23179
|
let diagnosis = null;
|
|
22703
23180
|
try {
|
|
22704
|
-
const views = new
|
|
23181
|
+
const views = new import_ethers23.Contract(
|
|
22705
23182
|
viewsAddress,
|
|
22706
23183
|
[
|
|
22707
23184
|
"function diagnoseMintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes) view returns (string)"
|
|
@@ -22759,7 +23236,7 @@ MintGuardFailed(${guardCode}): ${guardMeaning}
|
|
|
22759
23236
|
Lit mintAmount: ${validationResponse.mintAmount}
|
|
22760
23237
|
Lit mintFee: ${validationResponse.mintFee}
|
|
22761
23238
|
Lit newDebt: ${validationResponse.newDebt}
|
|
22762
|
-
Protocol maximum: ${(0,
|
|
23239
|
+
Protocol maximum: ${(0, import_ethers23.formatEther)(maxLoanValueWei)} UCD (fee-inclusive)`;
|
|
22763
23240
|
}
|
|
22764
23241
|
const mintDebtDiagnostics = selector === "0xb9d419a7" || // DebtUpdateVerificationFailed()
|
|
22765
23242
|
selector === "0xc7e20553" || // DebtUpdateVerificationFailedDetailed(...)
|
|
@@ -22830,7 +23307,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
22830
23307
|
if (receipt.logs && receipt.logs.length > 0) {
|
|
22831
23308
|
for (const receiptLog of receipt.logs) {
|
|
22832
23309
|
if (receiptLog.topics && receiptLog.topics[0] === "0x08c379a0") {
|
|
22833
|
-
const iface = new
|
|
23310
|
+
const iface = new import_ethers23.Interface([
|
|
22834
23311
|
"error Error(string)"
|
|
22835
23312
|
]);
|
|
22836
23313
|
const decoded = iface.decodeErrorResult("Error", receiptLog.data);
|
|
@@ -22847,7 +23324,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
22847
23324
|
const minimalAbi = [
|
|
22848
23325
|
"event UCDMintedWithAuthorization(bytes32 indexed positionId, address indexed borrower, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, uint256 quantumTimestamp, bytes32 authorizedSpendsHash)"
|
|
22849
23326
|
];
|
|
22850
|
-
const iface = new
|
|
23327
|
+
const iface = new import_ethers23.Interface(minimalAbi);
|
|
22851
23328
|
for (const receiptLog of receipt.logs) {
|
|
22852
23329
|
const parsed = (() => {
|
|
22853
23330
|
const logIface = iface;
|
|
@@ -23015,7 +23492,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
23015
23492
|
pkpNftAddress,
|
|
23016
23493
|
this.getChipotlePublicKeyFallback()
|
|
23017
23494
|
);
|
|
23018
|
-
const pkpEthAddress = (0,
|
|
23495
|
+
const pkpEthAddress = (0, import_ethers23.computeAddress)(pkpPublicKey);
|
|
23019
23496
|
pkpData = {
|
|
23020
23497
|
publicKey: pkpPublicKey,
|
|
23021
23498
|
ethAddress: pkpEthAddress,
|
|
@@ -23413,7 +23890,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
23413
23890
|
}
|
|
23414
23891
|
const loanOpsForUcd = loanOpsForUcdResult.value;
|
|
23415
23892
|
const ucdTokenAddress = await loanOpsForUcd.ucdToken();
|
|
23416
|
-
const ucdToken = new
|
|
23893
|
+
const ucdToken = new import_ethers23.Contract(
|
|
23417
23894
|
ucdTokenAddress,
|
|
23418
23895
|
[
|
|
23419
23896
|
"function balanceOf(address) view returns (uint256)",
|
|
@@ -23429,9 +23906,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
23429
23906
|
if (ucdBalance < debtWei) {
|
|
23430
23907
|
return {
|
|
23431
23908
|
success: false,
|
|
23432
|
-
error: `Insufficient UCD balance for liquidation: ${(0,
|
|
23909
|
+
error: `Insufficient UCD balance for liquidation: ${(0, import_ethers23.formatEther)(
|
|
23433
23910
|
ucdBalance
|
|
23434
|
-
)} UCD (need ${(0,
|
|
23911
|
+
)} UCD (need ${(0, import_ethers23.formatEther)(debtWei)} UCD)`,
|
|
23435
23912
|
positionId: request.positionId,
|
|
23436
23913
|
wasLiquidated: false
|
|
23437
23914
|
};
|
|
@@ -23440,7 +23917,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
23440
23917
|
if (request.skipUcdApproval) {
|
|
23441
23918
|
return {
|
|
23442
23919
|
success: false,
|
|
23443
|
-
error: `Insufficient UCD allowance for UCDController: need at least ${(0,
|
|
23920
|
+
error: `Insufficient UCD allowance for UCDController: need at least ${(0, import_ethers23.formatEther)(
|
|
23444
23921
|
debtWei
|
|
23445
23922
|
)} UCD, or omit skipUcdApproval to let the SDK submit approve`,
|
|
23446
23923
|
positionId: request.positionId,
|
|
@@ -23965,7 +24442,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
23965
24442
|
if (typeof signatureBytes === "string" && signatureBytes.startsWith("{")) {
|
|
23966
24443
|
try {
|
|
23967
24444
|
const parsed = JSON.parse(signatureBytes);
|
|
23968
|
-
signatureBytes = parsed.signature ?? (parsed.r && parsed.s && parsed.v ?
|
|
24445
|
+
signatureBytes = parsed.signature ?? (parsed.r && parsed.s && parsed.v ? import_ethers23.Signature.from({
|
|
23969
24446
|
r: parsed.r,
|
|
23970
24447
|
s: parsed.s,
|
|
23971
24448
|
v: parsed.v
|
|
@@ -23976,7 +24453,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
23976
24453
|
if (!signatureBytes.startsWith("0x")) {
|
|
23977
24454
|
signatureBytes = "0x" + signatureBytes;
|
|
23978
24455
|
}
|
|
23979
|
-
const extendIface = new
|
|
24456
|
+
const extendIface = new import_ethers23.Interface([
|
|
23980
24457
|
"function extendPosition(bytes32 positionId, uint256 selectedTerm, uint256 quantumTimestamp, uint256 btcPrice, uint256 availableBTCBalance, uint256 proRataRenewalFee, bytes calldata extensionValidatorSignature) external returns (bool)"
|
|
23981
24458
|
]);
|
|
23982
24459
|
const extendCalldata = extendIface.encodeFunctionData("extendPosition", [
|
|
@@ -24525,7 +25002,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
24525
25002
|
` Converting payment amount: ${request.paymentAmount} (type: ${typeof request.paymentAmount})`
|
|
24526
25003
|
);
|
|
24527
25004
|
}
|
|
24528
|
-
const paymentAmountWei = (0,
|
|
25005
|
+
const paymentAmountWei = (0, import_ethers23.parseEther)(
|
|
24529
25006
|
request.paymentAmount.toString()
|
|
24530
25007
|
);
|
|
24531
25008
|
if (this.config.debug) {
|
|
@@ -24592,7 +25069,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
24592
25069
|
};
|
|
24593
25070
|
}
|
|
24594
25071
|
const ucdTokenAddress = await loanOps.ucdToken();
|
|
24595
|
-
const ucdToken = new
|
|
25072
|
+
const ucdToken = new import_ethers23.Contract(
|
|
24596
25073
|
ucdTokenAddress,
|
|
24597
25074
|
[
|
|
24598
25075
|
"function balanceOf(address) view returns (uint256)",
|
|
@@ -24616,14 +25093,14 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
24616
25093
|
]);
|
|
24617
25094
|
if (this.config.debug) {
|
|
24618
25095
|
log.info(` UCD funds source: ${fundsSource}${isSelfRepay ? " (self)" : " (borrower; agent submitting)"}`);
|
|
24619
|
-
log.info(` UCD Balance: ${(0,
|
|
24620
|
-
log.info(` UCD Allowance: ${(0,
|
|
25096
|
+
log.info(` UCD Balance: ${(0, import_ethers23.formatEther)(balance)} UCD`);
|
|
25097
|
+
log.info(` UCD Allowance: ${(0, import_ethers23.formatEther)(allowance)} UCD`);
|
|
24621
25098
|
log.info(` Required: ${request.paymentAmount} UCD`);
|
|
24622
25099
|
}
|
|
24623
25100
|
if (balance < paymentAmountWei) {
|
|
24624
25101
|
return {
|
|
24625
25102
|
success: false,
|
|
24626
|
-
error: `Insufficient UCD balance: ${(0,
|
|
25103
|
+
error: `Insufficient UCD balance: ${(0, import_ethers23.formatEther)(
|
|
24627
25104
|
balance
|
|
24628
25105
|
)} UCD (need ${request.paymentAmount} UCD)${isSelfRepay ? "" : ` \u2014 borrower ${fundsSource} lacks funds`}`
|
|
24629
25106
|
};
|
|
@@ -24632,7 +25109,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
24632
25109
|
if (!isSelfRepay) {
|
|
24633
25110
|
return {
|
|
24634
25111
|
success: false,
|
|
24635
|
-
error: `Borrower ${fundsSource} has insufficient UCD allowance to PositionManager (${(0,
|
|
25112
|
+
error: `Borrower ${fundsSource} has insufficient UCD allowance to PositionManager (${(0, import_ethers23.formatEther)(allowance)} UCD, need ${request.paymentAmount}). The borrower must approve PositionManager before a delegated agent can repay.`
|
|
24636
25113
|
};
|
|
24637
25114
|
}
|
|
24638
25115
|
if (this.config.debug) {
|
|
@@ -24901,7 +25378,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
24901
25378
|
const paymentSigner = this.getSignerOrThrow();
|
|
24902
25379
|
const paymentFrom = await paymentSigner.getAddress();
|
|
24903
25380
|
const paymentProvider = contractManager.getProvider();
|
|
24904
|
-
const paymentIface = new
|
|
25381
|
+
const paymentIface = new import_ethers23.Interface([
|
|
24905
25382
|
"function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)"
|
|
24906
25383
|
]);
|
|
24907
25384
|
const paymentCalldata = paymentIface.encodeFunctionData("makePayment", [
|
|
@@ -25201,6 +25678,11 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25201
25678
|
error: "Invalid withdrawal address"
|
|
25202
25679
|
};
|
|
25203
25680
|
}
|
|
25681
|
+
const caseError = bitcoinAddressCaseError(withdrawalAddress);
|
|
25682
|
+
if (caseError) {
|
|
25683
|
+
return { success: false, error: caseError };
|
|
25684
|
+
}
|
|
25685
|
+
withdrawalAddress = normalizeBitcoinAddress(withdrawalAddress);
|
|
25204
25686
|
try {
|
|
25205
25687
|
const btcNetwork = this.bitcoinOperations.getNetwork();
|
|
25206
25688
|
safeValidateBitcoinAddress(withdrawalAddress.trim(), btcNetwork);
|
|
@@ -25250,7 +25732,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25250
25732
|
const pkpId = position.pkpId;
|
|
25251
25733
|
if (litValidatorAddr && pkpId) {
|
|
25252
25734
|
try {
|
|
25253
|
-
const litValidator = new
|
|
25735
|
+
const litValidator = new import_ethers23.Contract(
|
|
25254
25736
|
litValidatorAddr,
|
|
25255
25737
|
["function pkpOwners(bytes32) view returns (address)"],
|
|
25256
25738
|
this.getProviderOrThrow()
|
|
@@ -25258,7 +25740,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25258
25740
|
const owner = await litValidator.pkpOwners(
|
|
25259
25741
|
pkpId
|
|
25260
25742
|
);
|
|
25261
|
-
if (owner && owner !==
|
|
25743
|
+
if (owner && owner !== import_ethers23.ZeroAddress) {
|
|
25262
25744
|
controller = owner;
|
|
25263
25745
|
}
|
|
25264
25746
|
} catch {
|
|
@@ -25310,7 +25792,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25310
25792
|
pkpNftAddress,
|
|
25311
25793
|
this.getChipotlePublicKeyFallback()
|
|
25312
25794
|
);
|
|
25313
|
-
pkpEthAddress = (0,
|
|
25795
|
+
pkpEthAddress = (0, import_ethers23.computeAddress)(pkpPublicKey);
|
|
25314
25796
|
pkpCache.set(positionId, {
|
|
25315
25797
|
publicKey: pkpPublicKey,
|
|
25316
25798
|
ethAddress: pkpEthAddress,
|
|
@@ -25683,7 +26165,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25683
26165
|
utxoVout: withdrawalParams.utxoVout
|
|
25684
26166
|
});
|
|
25685
26167
|
}
|
|
25686
|
-
const withdrawIface = new
|
|
26168
|
+
const withdrawIface = new import_ethers23.Interface([
|
|
25687
26169
|
"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)"
|
|
25688
26170
|
]);
|
|
25689
26171
|
const withdrawCalldata = withdrawIface.encodeFunctionData("withdrawBTC", [
|
|
@@ -25914,7 +26396,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25914
26396
|
}
|
|
25915
26397
|
const pkpId = positionDetails.pkpId;
|
|
25916
26398
|
const vaultAddress = positionDetails.vaultAddress;
|
|
25917
|
-
if (!pkpId || pkpId ===
|
|
26399
|
+
if (!pkpId || pkpId === import_ethers23.ZeroHash) {
|
|
25918
26400
|
return { success: false, error: "Position has no PKP" };
|
|
25919
26401
|
}
|
|
25920
26402
|
if (!vaultAddress) {
|
|
@@ -25934,7 +26416,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25934
26416
|
if (!publicKey) {
|
|
25935
26417
|
return { success: false, error: "Failed to resolve PKP public key" };
|
|
25936
26418
|
}
|
|
25937
|
-
const chipotlePkpAddress = (0,
|
|
26419
|
+
const chipotlePkpAddress = (0, import_ethers23.computeAddress)(publicKey);
|
|
25938
26420
|
const chainName = LIT_ACTION_CHAIN_NAMES[chainId];
|
|
25939
26421
|
if (!chainName) {
|
|
25940
26422
|
return {
|
|
@@ -26154,6 +26636,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26154
26636
|
networkFee: request.networkFee,
|
|
26155
26637
|
chainId,
|
|
26156
26638
|
signer,
|
|
26639
|
+
provider: this.getProviderOrThrow(),
|
|
26157
26640
|
...executionUtxos ? { utxos: executionUtxos } : {}
|
|
26158
26641
|
});
|
|
26159
26642
|
if (this.config.mode !== "service") {
|
|
@@ -26306,8 +26789,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26306
26789
|
});
|
|
26307
26790
|
}
|
|
26308
26791
|
const contractAddresses = this.getContractAddressesOrThrow();
|
|
26309
|
-
const
|
|
26310
|
-
if (!
|
|
26792
|
+
const btcSpendAuthorizerAddress2 = contractAddresses.btcSpendAuthorizer;
|
|
26793
|
+
if (!btcSpendAuthorizerAddress2) {
|
|
26311
26794
|
return [
|
|
26312
26795
|
{
|
|
26313
26796
|
success: false,
|
|
@@ -26318,8 +26801,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26318
26801
|
const btcSpendAuthorizerAbi = [
|
|
26319
26802
|
"function getAuthorizedSpends(bytes32) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"
|
|
26320
26803
|
];
|
|
26321
|
-
const btcSpendAuthorizer = new
|
|
26322
|
-
|
|
26804
|
+
const btcSpendAuthorizer = new import_ethers23.Contract(
|
|
26805
|
+
btcSpendAuthorizerAddress2,
|
|
26323
26806
|
btcSpendAuthorizerAbi,
|
|
26324
26807
|
this.getProviderOrThrow()
|
|
26325
26808
|
);
|
|
@@ -26391,8 +26874,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26391
26874
|
async getPendingWithdrawals(positionId) {
|
|
26392
26875
|
this.ensureInitialized();
|
|
26393
26876
|
const contractAddresses = this.getContractAddressesOrThrow();
|
|
26394
|
-
const
|
|
26395
|
-
if (!
|
|
26877
|
+
const btcSpendAuthorizerAddress2 = contractAddresses.btcSpendAuthorizer;
|
|
26878
|
+
if (!btcSpendAuthorizerAddress2) {
|
|
26396
26879
|
throw new SDKError({
|
|
26397
26880
|
code: "SDK_CONTRACT_ADDRESSES_NOT_CONFIGURED",
|
|
26398
26881
|
message: "BTCSpendAuthorizer address not configured",
|
|
@@ -26404,8 +26887,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26404
26887
|
const abi = [
|
|
26405
26888
|
"function getAuthorizedSpends(bytes32) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"
|
|
26406
26889
|
];
|
|
26407
|
-
const contract = new
|
|
26408
|
-
|
|
26890
|
+
const contract = new import_ethers23.Contract(
|
|
26891
|
+
btcSpendAuthorizerAddress2,
|
|
26409
26892
|
abi,
|
|
26410
26893
|
this.getProviderOrThrow()
|
|
26411
26894
|
);
|
|
@@ -26418,7 +26901,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26418
26901
|
targetAddress: spend.targetAddress,
|
|
26419
26902
|
targetAmount: Number(spend.targetAmount),
|
|
26420
26903
|
authorizedAt: Number(spend.authorizedAt),
|
|
26421
|
-
utxoKey: (0,
|
|
26904
|
+
utxoKey: (0, import_ethers23.solidityPackedKeccak256)(
|
|
26422
26905
|
["string", "uint32"],
|
|
26423
26906
|
[spend.txid, Number(spend.vout)]
|
|
26424
26907
|
)
|
|
@@ -26507,8 +26990,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26507
26990
|
this.ensureInitialized();
|
|
26508
26991
|
try {
|
|
26509
26992
|
const contractAddresses = this.getContractAddressesOrThrow();
|
|
26510
|
-
const
|
|
26511
|
-
if (!
|
|
26993
|
+
const btcSpendAuthorizerAddress2 = contractAddresses.btcSpendAuthorizer;
|
|
26994
|
+
if (!btcSpendAuthorizerAddress2) {
|
|
26512
26995
|
return {
|
|
26513
26996
|
success: false,
|
|
26514
26997
|
failedStep: "config",
|
|
@@ -26598,7 +27081,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26598
27081
|
invalidatorTxid: params.invalidatorTxid,
|
|
26599
27082
|
contractAddresses: {
|
|
26600
27083
|
PositionManager: contractAddresses.positionManager,
|
|
26601
|
-
BTCSpendAuthorizer:
|
|
27084
|
+
BTCSpendAuthorizer: btcSpendAuthorizerAddress2,
|
|
26602
27085
|
...contractAddresses.bitcoinProviderRegistry && {
|
|
26603
27086
|
BitcoinProviderRegistry: contractAddresses.bitcoinProviderRegistry
|
|
26604
27087
|
}
|
|
@@ -26624,8 +27107,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26624
27107
|
error: attRes.error ?? attRes.reason ?? `LIT recovery attestation rejected${attRes.failedStep ? ` at step ${attRes.failedStep}` : ""}`
|
|
26625
27108
|
};
|
|
26626
27109
|
}
|
|
26627
|
-
const btcSpendAuthorizer = new
|
|
26628
|
-
|
|
27110
|
+
const btcSpendAuthorizer = new import_ethers23.Contract(
|
|
27111
|
+
btcSpendAuthorizerAddress2,
|
|
26629
27112
|
[
|
|
26630
27113
|
"function cancelStaleSpendWithProof(bytes32 positionId, bytes32 utxoKey, uint256 authorizedAt, string calldata invalidatorTxid, uint256 attestationTimestamp, bytes calldata litSignature) external"
|
|
26631
27114
|
],
|
|
@@ -26679,7 +27162,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26679
27162
|
utxoTxid: params.utxoTxid,
|
|
26680
27163
|
utxoVout: params.utxoVout,
|
|
26681
27164
|
chainId,
|
|
26682
|
-
signer
|
|
27165
|
+
signer,
|
|
27166
|
+
provider: this.getProviderOrThrow()
|
|
26683
27167
|
});
|
|
26684
27168
|
if (this.config.mode === "service" && this.config.serviceEndpoint) {
|
|
26685
27169
|
const headers = {
|
|
@@ -26721,7 +27205,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26721
27205
|
const positionDetails = await this.getPositionDetailsView(
|
|
26722
27206
|
params.positionId
|
|
26723
27207
|
);
|
|
26724
|
-
if (!positionDetails?.pkpId || positionDetails.pkpId ===
|
|
27208
|
+
if (!positionDetails?.pkpId || positionDetails.pkpId === import_ethers23.ZeroHash) {
|
|
26725
27209
|
return { success: false, error: "Position has no PKP" };
|
|
26726
27210
|
}
|
|
26727
27211
|
const pkpCache = this.cacheManager.getCache("pkp-data", {
|
|
@@ -26738,7 +27222,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26738
27222
|
if (!publicKey) {
|
|
26739
27223
|
return { success: false, error: "Failed to resolve PKP public key" };
|
|
26740
27224
|
}
|
|
26741
|
-
const chipotlePkpAddress = (0,
|
|
27225
|
+
const chipotlePkpAddress = (0, import_ethers23.computeAddress)(publicKey);
|
|
26742
27226
|
const dc = this.config.contractAddresses || {};
|
|
26743
27227
|
const chainName = chainId === 1 ? "ethereum" : chainId === 11155111 ? "sepolia" : chainId === 1337 || chainId === 31337 ? "hardhat" : void 0;
|
|
26744
27228
|
if (!chainName) {
|
|
@@ -26924,6 +27408,14 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
26924
27408
|
if (typeof positionId !== "string" || !positionId) {
|
|
26925
27409
|
return { success: false, error: "positionId is required" };
|
|
26926
27410
|
}
|
|
27411
|
+
if (typeof withdrawalAddress !== "string" || withdrawalAddress.trim().length === 0) {
|
|
27412
|
+
return { success: false, error: "withdrawalAddress is required" };
|
|
27413
|
+
}
|
|
27414
|
+
const destinationCaseError = bitcoinAddressCaseError(withdrawalAddress);
|
|
27415
|
+
if (destinationCaseError) {
|
|
27416
|
+
return { success: false, error: destinationCaseError };
|
|
27417
|
+
}
|
|
27418
|
+
withdrawalAddress = normalizeBitcoinAddress(withdrawalAddress);
|
|
26927
27419
|
const lockFailure = this.tryAcquireWriteLock(positionId);
|
|
26928
27420
|
if (lockFailure)
|
|
26929
27421
|
return lockFailure;
|
|
@@ -27437,7 +27929,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
27437
27929
|
*
|
|
27438
27930
|
* Deliberately omits `minWithdrawRatioBps` — see {@link readLoanGrant}.
|
|
27439
27931
|
*/
|
|
27440
|
-
static LOAN_GRANT_PREFIX_IFACE = new
|
|
27932
|
+
static LOAN_GRANT_PREFIX_IFACE = new import_ethers23.Interface([
|
|
27441
27933
|
"function getLoanGrant(bytes32 positionId) view returns (address borrower, uint32 scopeBits, uint32 minCollateralRatioBps)"
|
|
27442
27934
|
]);
|
|
27443
27935
|
/**
|
|
@@ -27458,9 +27950,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
27458
27950
|
to: registryAddress,
|
|
27459
27951
|
data: iface.encodeFunctionData("getLoanGrant", [pid])
|
|
27460
27952
|
});
|
|
27461
|
-
if ((0,
|
|
27953
|
+
if ((0, import_ethers23.getBytes)(data).length < 96) {
|
|
27462
27954
|
throw new SDKError({
|
|
27463
|
-
message: `AgentDelegationRegistry at ${registryAddress} returned ${(0,
|
|
27955
|
+
message: `AgentDelegationRegistry at ${registryAddress} returned ${(0, import_ethers23.getBytes)(data).length} bytes for getLoanGrant(bytes32) \u2014 expected at least 96. Wrong address, or a registry version this SDK does not support.`,
|
|
27464
27956
|
category: "CONTRACT" /* CONTRACT */,
|
|
27465
27957
|
severity: "HIGH" /* HIGH */
|
|
27466
27958
|
});
|
|
@@ -27469,10 +27961,10 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
27469
27961
|
"getLoanGrant",
|
|
27470
27962
|
data
|
|
27471
27963
|
);
|
|
27472
|
-
const raw = (0,
|
|
27964
|
+
const raw = (0, import_ethers23.getBytes)(data);
|
|
27473
27965
|
const withdrawScopeSupported = raw.length >= 128;
|
|
27474
27966
|
const minWithdrawRatioBps = withdrawScopeSupported ? Number(
|
|
27475
|
-
|
|
27967
|
+
import_ethers23.AbiCoder.defaultAbiCoder().decode(["uint32"], raw.slice(96, 128))[0]
|
|
27476
27968
|
) : 0;
|
|
27477
27969
|
return {
|
|
27478
27970
|
borrower,
|
|
@@ -27588,13 +28080,32 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
27588
28080
|
if (plan.kind === "reuse") {
|
|
27589
28081
|
agentAddress = plan.agent;
|
|
27590
28082
|
} else {
|
|
27591
|
-
|
|
28083
|
+
const minted = await mintAgentPkp({
|
|
27592
28084
|
serviceEndpoint: this.config.serviceEndpoint,
|
|
27593
28085
|
authHeader: this.serverSession ? () => this.serverSession.getAuthHeader() : void 0
|
|
27594
28086
|
});
|
|
28087
|
+
agentAddress = minted.walletAddress;
|
|
28088
|
+
const consentSigner = (0, import_ethers23.verifyTypedData)(
|
|
28089
|
+
{
|
|
28090
|
+
name: "DiamondHands.Protocol",
|
|
28091
|
+
version: "1",
|
|
28092
|
+
chainId: (await this.getProviderOrThrow().getNetwork()).chainId,
|
|
28093
|
+
verifyingContract: addr
|
|
28094
|
+
},
|
|
28095
|
+
AGENT_BINDING_CONSENT_TYPES,
|
|
28096
|
+
{ user, agent: agentAddress },
|
|
28097
|
+
minted.agentConsent
|
|
28098
|
+
);
|
|
28099
|
+
if ((0, import_ethers23.getAddress)(consentSigner) !== (0, import_ethers23.getAddress)(agentAddress)) {
|
|
28100
|
+
throw new SDKError({
|
|
28101
|
+
message: `Agent ${agentAddress}'s binding consent is not for ${user} on registry ${addr} \u2014 the lit-ops session must be signed in as the same wallet that binds the agent`,
|
|
28102
|
+
category: "AUTHORIZATION" /* AUTHORIZATION */,
|
|
28103
|
+
severity: "HIGH" /* HIGH */
|
|
28104
|
+
});
|
|
28105
|
+
}
|
|
27595
28106
|
const validitySeconds = options?.agentValiditySeconds ?? 90 * 24 * 60 * 60;
|
|
27596
28107
|
const validUntil = latestBlock.timestamp + validitySeconds;
|
|
27597
|
-
const bindTx = plan.kind === "rotate" ? await registry.rotateAgent(user, agentAddress, validUntil) : await registry.registerAgent(user, agentAddress, validUntil);
|
|
28108
|
+
const bindTx = plan.kind === "rotate" ? await registry.rotateAgent(user, agentAddress, validUntil, minted.agentConsent) : await registry.registerAgent(user, agentAddress, validUntil, minted.agentConsent);
|
|
27598
28109
|
await bindTx.wait();
|
|
27599
28110
|
}
|
|
27600
28111
|
const currentDelegate = await getPositionDelegate(pid, signer, pdrAddr).catch(
|
|
@@ -27634,7 +28145,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
27634
28145
|
getPositionDelegate(pid, signer, pdrAddr),
|
|
27635
28146
|
registry.agentOf(user).then((a) => a.agent)
|
|
27636
28147
|
]);
|
|
27637
|
-
if (currentDelegate !==
|
|
28148
|
+
if (currentDelegate !== import_ethers23.ZeroAddress && currentDelegate.toLowerCase() === userAgent.toLowerCase()) {
|
|
27638
28149
|
const clearTx = await setPositionDelegate(
|
|
27639
28150
|
pid,
|
|
27640
28151
|
"0x0000000000000000000000000000000000000000",
|
|
@@ -28026,7 +28537,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28026
28537
|
const maxUcdWhole = BigInt(result[3].toString());
|
|
28027
28538
|
return success({
|
|
28028
28539
|
liquidationThreshold: result[0].toString(),
|
|
28029
|
-
minimumLoanValueUcd: (0,
|
|
28540
|
+
minimumLoanValueUcd: (0, import_ethers23.formatUnits)(result[2], 18),
|
|
28030
28541
|
minimumLoanValueWei: result[2].toString(),
|
|
28031
28542
|
maxSingleLoanValueUcd: maxUcdWhole.toString(),
|
|
28032
28543
|
maxSingleLoanValueWei: (maxUcdWhole * 10n ** 18n).toString()
|
|
@@ -28063,7 +28574,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28063
28574
|
const balanceWei = await provider.getBalance(address);
|
|
28064
28575
|
return success({
|
|
28065
28576
|
balanceWei: balanceWei.toString(),
|
|
28066
|
-
balanceEth: (0,
|
|
28577
|
+
balanceEth: (0, import_ethers23.formatEther)(balanceWei)
|
|
28067
28578
|
});
|
|
28068
28579
|
} catch (error) {
|
|
28069
28580
|
return failure(new SDKError({
|
|
@@ -28472,7 +28983,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28472
28983
|
* Convert decimal position ID to bytes32 format
|
|
28473
28984
|
*/
|
|
28474
28985
|
toBytes32(value) {
|
|
28475
|
-
return (0,
|
|
28986
|
+
return (0, import_ethers23.zeroPadValue)((0, import_ethers23.toBeHex)(BigInt(value)), 32);
|
|
28476
28987
|
}
|
|
28477
28988
|
/**
|
|
28478
28989
|
* Check if an error indicates a technical failure vs business logic rejection
|
|
@@ -28513,7 +29024,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28513
29024
|
const coreModuleAbi = [
|
|
28514
29025
|
"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))"
|
|
28515
29026
|
];
|
|
28516
|
-
const coreModule = new
|
|
29027
|
+
const coreModule = new import_ethers23.Contract(
|
|
28517
29028
|
coreModuleAddress,
|
|
28518
29029
|
coreModuleAbi,
|
|
28519
29030
|
provider
|
|
@@ -28580,7 +29091,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28580
29091
|
const corePositionAbi = [
|
|
28581
29092
|
"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))"
|
|
28582
29093
|
];
|
|
28583
|
-
const corePositionContract = new
|
|
29094
|
+
const corePositionContract = new import_ethers23.Contract(
|
|
28584
29095
|
coreAddress,
|
|
28585
29096
|
corePositionAbi,
|
|
28586
29097
|
provider
|
|
@@ -28591,7 +29102,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28591
29102
|
positionIdBytes32
|
|
28592
29103
|
);
|
|
28593
29104
|
const positionIdFromCore = corePosition?.positionId || corePosition?.[0] || null;
|
|
28594
|
-
if (positionIdFromCore && positionIdFromCore !==
|
|
29105
|
+
if (positionIdFromCore && positionIdFromCore !== import_ethers23.ZeroHash && positionIdFromCore !== "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
28595
29106
|
if (this.config.debug) {
|
|
28596
29107
|
log.info("Position exists in core contract", {
|
|
28597
29108
|
positionId,
|
|
@@ -28659,7 +29170,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28659
29170
|
throw new Error("loanOperationsManager address not configured");
|
|
28660
29171
|
}
|
|
28661
29172
|
const runner = this.config.contractSigner || this.getProviderOrThrow();
|
|
28662
|
-
const contract = new
|
|
29173
|
+
const contract = new import_ethers23.Contract(
|
|
28663
29174
|
addr.loanOperationsManager,
|
|
28664
29175
|
[
|
|
28665
29176
|
"function getProtocolConfig() external view returns (uint256 liquidationThreshold, uint256 minimumLoanValueUcd, uint256 minimumLoanValueWei, uint256 maxSingleLoanValueUcd)"
|
|
@@ -28672,7 +29183,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28672
29183
|
const maxUcdWhole = BigInt(result[3].toString());
|
|
28673
29184
|
return {
|
|
28674
29185
|
liquidationThreshold: result[0].toString(),
|
|
28675
|
-
minimumLoanValueUcd: (0,
|
|
29186
|
+
minimumLoanValueUcd: (0, import_ethers23.formatUnits)(result[2], 18),
|
|
28676
29187
|
minimumLoanValueWei: result[2].toString(),
|
|
28677
29188
|
maxSingleLoanValueUcd: maxUcdWhole.toString(),
|
|
28678
29189
|
maxSingleLoanValueWei: (maxUcdWhole * 10n ** 18n).toString()
|
|
@@ -28690,8 +29201,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28690
29201
|
const MIN_REVEAL_DELAY = 60;
|
|
28691
29202
|
const MAX_RANDOM_DELAY = 240;
|
|
28692
29203
|
const entropyInput = positionId + quantumTimestamp.toString();
|
|
28693
|
-
const hash = (0,
|
|
28694
|
-
(0,
|
|
29204
|
+
const hash = (0, import_ethers23.keccak256)(
|
|
29205
|
+
(0, import_ethers23.toUtf8Bytes)(entropyInput)
|
|
28695
29206
|
);
|
|
28696
29207
|
const randomValue = BigInt(hash);
|
|
28697
29208
|
const randomDelay = Number(randomValue % BigInt(MAX_RANDOM_DELAY));
|
|
@@ -28716,12 +29227,12 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28716
29227
|
const rawPositionId = /^0x/i.test(params.positionId.trim()) ? params.positionId.trim().slice(2) : params.positionId.trim();
|
|
28717
29228
|
const canonicalPositionId = "0x" + rawPositionId.padStart(64, "0").toLowerCase();
|
|
28718
29229
|
const intentTimestamp = Math.floor(Date.now() / 1e3);
|
|
28719
|
-
const intentActionHash = (0,
|
|
28720
|
-
const intentHash = (0,
|
|
29230
|
+
const intentActionHash = (0, import_ethers23.keccak256)((0, import_ethers23.toUtf8Bytes)("liquidate-position"));
|
|
29231
|
+
const intentHash = (0, import_ethers23.solidityPackedKeccak256)(
|
|
28721
29232
|
["bytes32", "uint256", "uint256", "address", "bytes32"],
|
|
28722
29233
|
[canonicalPositionId, intentTimestamp, chainId, intentSigner, intentActionHash]
|
|
28723
29234
|
);
|
|
28724
|
-
const intentSignature = await signer.signMessage((0,
|
|
29235
|
+
const intentSignature = await signer.signMessage((0, import_ethers23.getBytes)(intentHash));
|
|
28725
29236
|
const response = await fetch(endpoint, {
|
|
28726
29237
|
method: "POST",
|
|
28727
29238
|
headers: { "Content-Type": "application/json" },
|
|
@@ -28773,7 +29284,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
28773
29284
|
const vrfSeedRaw = await lmResult.value["vrfSeeds"](positionId);
|
|
28774
29285
|
const vrfSeed = BigInt(vrfSeedRaw.toString());
|
|
28775
29286
|
if (vrfSeed !== 0n) {
|
|
28776
|
-
const finalEntropy = (0,
|
|
29287
|
+
const finalEntropy = (0, import_ethers23.solidityPackedKeccak256)(
|
|
28777
29288
|
["uint256", "uint256", "bytes32"],
|
|
28778
29289
|
[vrfSeed, BigInt(quantumTimestamp.toString()), positionId]
|
|
28779
29290
|
);
|
|
@@ -29051,7 +29562,7 @@ var EventHelpers = {
|
|
|
29051
29562
|
};
|
|
29052
29563
|
|
|
29053
29564
|
// src/utils/safe-agent-delegation.utils.ts
|
|
29054
|
-
var
|
|
29565
|
+
var import_ethers24 = require("ethers");
|
|
29055
29566
|
init_deployment_addresses();
|
|
29056
29567
|
var SAFE_ABI = [
|
|
29057
29568
|
"function getModulesPaginated(address start, uint256 pageSize) view returns (address[] modules, address next)"
|
|
@@ -29069,7 +29580,7 @@ var MODULE_LIST_SENTINEL = "0x0000000000000000000000000000000000000001";
|
|
|
29069
29580
|
var MODULE_PAGE_SIZE = 50;
|
|
29070
29581
|
var lower = (v) => v.trim().toLowerCase();
|
|
29071
29582
|
async function classifyModule(provider, moduleAddress, safeAddress, positionManager, factoryAddress) {
|
|
29072
|
-
const module2 = new
|
|
29583
|
+
const module2 = new import_ethers24.Contract(moduleAddress, MODULE_ABI, provider);
|
|
29073
29584
|
let boundSafe;
|
|
29074
29585
|
try {
|
|
29075
29586
|
boundSafe = await module2.safe();
|
|
@@ -29089,7 +29600,7 @@ async function classifyModule(provider, moduleAddress, safeAddress, positionMana
|
|
|
29089
29600
|
if (!factoryAddress)
|
|
29090
29601
|
return null;
|
|
29091
29602
|
try {
|
|
29092
|
-
const factory = new
|
|
29603
|
+
const factory = new import_ethers24.Contract(factoryAddress, FACTORY_ABI, provider);
|
|
29093
29604
|
return await factory.isFromFactory(moduleAddress) === true;
|
|
29094
29605
|
} catch {
|
|
29095
29606
|
return null;
|
|
@@ -29118,7 +29629,7 @@ async function getSafeAgentDelegation(params) {
|
|
|
29118
29629
|
let modules;
|
|
29119
29630
|
let next;
|
|
29120
29631
|
try {
|
|
29121
|
-
const safe = new
|
|
29632
|
+
const safe = new import_ethers24.Contract(safeAddress, SAFE_ABI, provider);
|
|
29122
29633
|
const page = await safe.getModulesPaginated(
|
|
29123
29634
|
MODULE_LIST_SENTINEL,
|
|
29124
29635
|
MODULE_PAGE_SIZE
|
|
@@ -29146,7 +29657,7 @@ async function getSafeAgentDelegation(params) {
|
|
|
29146
29657
|
continue;
|
|
29147
29658
|
let agentAddress = null;
|
|
29148
29659
|
try {
|
|
29149
|
-
agentAddress = await new
|
|
29660
|
+
agentAddress = await new import_ethers24.Contract(
|
|
29150
29661
|
moduleAddress,
|
|
29151
29662
|
MODULE_ABI,
|
|
29152
29663
|
provider
|
|
@@ -29160,7 +29671,7 @@ async function getSafeAgentDelegation(params) {
|
|
|
29160
29671
|
let validUntil;
|
|
29161
29672
|
let status;
|
|
29162
29673
|
try {
|
|
29163
|
-
const record = await new
|
|
29674
|
+
const record = await new import_ethers24.Contract(
|
|
29164
29675
|
registryAddress,
|
|
29165
29676
|
REGISTRY_ABI,
|
|
29166
29677
|
provider
|
|
@@ -29195,6 +29706,11 @@ async function getSafeAgentDelegation(params) {
|
|
|
29195
29706
|
ALL_DEPLOYMENTS,
|
|
29196
29707
|
AuthParamsValidation,
|
|
29197
29708
|
BPSConversions,
|
|
29709
|
+
BTC_SPEND_QUANTUM_SECONDS,
|
|
29710
|
+
BTC_SPEND_RELAY_DEADLINE_SECONDS,
|
|
29711
|
+
BTC_SPEND_REQUEST_712_DOMAIN_NAME,
|
|
29712
|
+
BTC_SPEND_REQUEST_712_DOMAIN_VERSION,
|
|
29713
|
+
BTC_SPEND_REQUEST_712_FIELDS,
|
|
29198
29714
|
BitcoinOperations,
|
|
29199
29715
|
CacheManager,
|
|
29200
29716
|
ContractManager,
|
|
@@ -29228,9 +29744,15 @@ async function getSafeAgentDelegation(params) {
|
|
|
29228
29744
|
andThen,
|
|
29229
29745
|
assertProtocolNotPaused,
|
|
29230
29746
|
assertSafeServiceEndpoint,
|
|
29747
|
+
btcSpendAuthorizerAddress,
|
|
29748
|
+
btcSpendRequest712Digest,
|
|
29749
|
+
btcSpendRequest712Types,
|
|
29231
29750
|
buildBtcExecuteEnvelope,
|
|
29751
|
+
buildBtcSpendRequest712Domain,
|
|
29752
|
+
buildExecuteBtcWithdrawalTypedData,
|
|
29232
29753
|
buildInvalidateMessageHash,
|
|
29233
29754
|
buildInvalidateStaleSpendEnvelope,
|
|
29755
|
+
buildInvalidateStaleSpendTypedData,
|
|
29234
29756
|
buildLoginDomain,
|
|
29235
29757
|
buildSignedLoginPayload,
|
|
29236
29758
|
collectFailures,
|
|
@@ -29271,8 +29793,10 @@ async function getSafeAgentDelegation(params) {
|
|
|
29271
29793
|
mapError,
|
|
29272
29794
|
match,
|
|
29273
29795
|
numericToPositionStatus,
|
|
29796
|
+
readAuthorizedSpend,
|
|
29274
29797
|
reconcileAuthorizedSpend,
|
|
29275
29798
|
setPositionDelegate,
|
|
29799
|
+
signBtcSpendRequest712,
|
|
29276
29800
|
success,
|
|
29277
29801
|
toPromise,
|
|
29278
29802
|
tryCatch,
|