@gvnrdao/dh-sdk 0.0.342 → 0.0.343
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/dist/browser.js +1 -1
- package/dist/constants/chunks/deployment-addresses.d.ts +0 -2
- package/dist/constants/chunks/network-configs.d.ts +0 -2
- package/dist/deployments.js +0 -4
- package/dist/deployments.mjs +0 -4
- package/dist/index.js +327 -166
- package/dist/index.mjs +327 -166
- package/dist/safe-delegation.js +0 -3
- package/dist/safe-delegation.mjs +0 -3
- package/dist/sign-guard.js +7 -3
- package/dist/sign-guard.mjs +7 -3
- package/dist/utils/agent-delegation.utils.d.ts +10 -3
- package/dist/utils/btc-dust.utils.d.ts +25 -0
- package/dist/utils/loan-helpers.utils.d.ts +26 -3
- package/dist/utils/sign-guard/extend-fee-bound.d.ts +5 -0
- package/dist/utils/sign-guard/op-envelope.d.ts +7 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -94,7 +94,6 @@ var init_deployment_addresses = __esm({
|
|
|
94
94
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
95
95
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
96
96
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
97
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
98
97
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
99
98
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
100
99
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -364,8 +363,6 @@ var init_deployment_addresses = __esm({
|
|
|
364
363
|
OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0xe0D981B60351f0f8fFDA2b50C8180Fb37CeF3883",
|
|
365
364
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
366
365
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
|
|
367
|
-
CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
368
|
-
CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
|
|
369
366
|
AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
370
367
|
AGENT_DELEGATION_REGISTRY_IMPL: "0xE931E4b9ceF2A48Ac7D57192da4B523756cFC310",
|
|
371
368
|
DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
|
|
@@ -397,7 +394,6 @@ var init_deployment_addresses = __esm({
|
|
|
397
394
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
398
395
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
399
396
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
400
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
401
397
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
402
398
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
403
399
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -1374,113 +1370,113 @@ var require_pkg_src = __commonJS({
|
|
|
1374
1370
|
deployedAt: 1784569687492,
|
|
1375
1371
|
size: 4140,
|
|
1376
1372
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
1377
|
-
validatorWalletAddress: "
|
|
1373
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
1378
1374
|
pkp: {
|
|
1379
1375
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
1380
|
-
ethAddress: "
|
|
1376
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1381
1377
|
}
|
|
1382
1378
|
},
|
|
1383
1379
|
btcTransactionSigner: {
|
|
1384
|
-
cid: "
|
|
1380
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
1385
1381
|
authorizedCidHex: cidToHex(
|
|
1386
|
-
"
|
|
1382
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
1387
1383
|
),
|
|
1388
1384
|
name: "Btc Transaction Signer",
|
|
1389
1385
|
description: "Production Btc Transaction Signer",
|
|
1390
1386
|
version: "1.1.1",
|
|
1391
1387
|
deployed: true,
|
|
1392
|
-
deployedAt:
|
|
1393
|
-
size:
|
|
1394
|
-
hash: "
|
|
1388
|
+
deployedAt: 1790246185256,
|
|
1389
|
+
size: 73313,
|
|
1390
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
1395
1391
|
},
|
|
1396
1392
|
ucdMintValidator: {
|
|
1397
|
-
cid: "
|
|
1393
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
1398
1394
|
authorizedCidHex: cidToHex(
|
|
1399
|
-
"
|
|
1395
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
1400
1396
|
),
|
|
1401
1397
|
name: "Ucd Mint Validator",
|
|
1402
1398
|
description: "Production Ucd Mint Validator",
|
|
1403
|
-
version: "1.
|
|
1399
|
+
version: "1.3.0",
|
|
1404
1400
|
deployed: true,
|
|
1405
|
-
deployedAt:
|
|
1406
|
-
size:
|
|
1407
|
-
hash: "
|
|
1408
|
-
validatorWalletAddress: "
|
|
1401
|
+
deployedAt: 1790246219868,
|
|
1402
|
+
size: 90022,
|
|
1403
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
1404
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1409
1405
|
pkp: {
|
|
1410
1406
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
1411
|
-
ethAddress: "
|
|
1407
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1412
1408
|
}
|
|
1413
1409
|
},
|
|
1414
1410
|
processPaymentValidator: {
|
|
1415
|
-
cid: "
|
|
1411
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
1416
1412
|
authorizedCidHex: cidToHex(
|
|
1417
|
-
"
|
|
1413
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
1418
1414
|
),
|
|
1419
1415
|
name: "Process Payment Validator",
|
|
1420
1416
|
description: "Production Process Payment Validator",
|
|
1421
1417
|
version: "1.2.1",
|
|
1422
1418
|
deployed: true,
|
|
1423
|
-
deployedAt:
|
|
1424
|
-
size:
|
|
1425
|
-
hash: "
|
|
1426
|
-
validatorWalletAddress: "
|
|
1419
|
+
deployedAt: 1790246225795,
|
|
1420
|
+
size: 85107,
|
|
1421
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
1422
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1427
1423
|
pkp: {
|
|
1428
1424
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
1429
|
-
ethAddress: "
|
|
1425
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1430
1426
|
}
|
|
1431
1427
|
},
|
|
1432
1428
|
extendPositionValidator: {
|
|
1433
|
-
cid: "
|
|
1429
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
1434
1430
|
authorizedCidHex: cidToHex(
|
|
1435
|
-
"
|
|
1431
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
1436
1432
|
),
|
|
1437
1433
|
name: "Extend Position Validator",
|
|
1438
1434
|
description: "Production Extend Position Validator",
|
|
1439
1435
|
version: "1.2.1",
|
|
1440
1436
|
deployed: true,
|
|
1441
|
-
deployedAt:
|
|
1442
|
-
size:
|
|
1443
|
-
hash: "
|
|
1444
|
-
validatorWalletAddress: "
|
|
1437
|
+
deployedAt: 1790246231975,
|
|
1438
|
+
size: 82853,
|
|
1439
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
1440
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1445
1441
|
pkp: {
|
|
1446
1442
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
1447
|
-
ethAddress: "
|
|
1443
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1448
1444
|
}
|
|
1449
1445
|
},
|
|
1450
1446
|
btcWithdrawal: {
|
|
1451
|
-
cid: "
|
|
1447
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
1452
1448
|
authorizedCidHex: cidToHex(
|
|
1453
|
-
"
|
|
1449
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
1454
1450
|
),
|
|
1455
1451
|
name: "Btc Withdrawal",
|
|
1456
1452
|
description: "Production Btc Withdrawal",
|
|
1457
1453
|
version: "1.2.7",
|
|
1458
1454
|
deployed: true,
|
|
1459
|
-
deployedAt:
|
|
1460
|
-
size:
|
|
1461
|
-
hash: "
|
|
1462
|
-
validatorWalletAddress: "
|
|
1455
|
+
deployedAt: 1790246239599,
|
|
1456
|
+
size: 101228,
|
|
1457
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
1458
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1463
1459
|
pkp: {
|
|
1464
1460
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
1465
|
-
ethAddress: "
|
|
1461
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1466
1462
|
}
|
|
1467
1463
|
},
|
|
1468
1464
|
liquidationValidator: {
|
|
1469
|
-
cid: "
|
|
1465
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
1470
1466
|
authorizedCidHex: cidToHex(
|
|
1471
|
-
"
|
|
1467
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
1472
1468
|
),
|
|
1473
1469
|
name: "Liquidation Validator",
|
|
1474
1470
|
description: "Production Liquidation Validator",
|
|
1475
1471
|
version: "1.2.1",
|
|
1476
1472
|
deployed: true,
|
|
1477
|
-
deployedAt:
|
|
1478
|
-
size:
|
|
1479
|
-
hash: "
|
|
1480
|
-
validatorWalletAddress: "
|
|
1473
|
+
deployedAt: 1790246247904,
|
|
1474
|
+
size: 70308,
|
|
1475
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
1476
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1481
1477
|
pkp: {
|
|
1482
1478
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
1483
|
-
ethAddress: "
|
|
1479
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1484
1480
|
}
|
|
1485
1481
|
},
|
|
1486
1482
|
priceOracle: {
|
|
@@ -1495,28 +1491,28 @@ var require_pkg_src = __commonJS({
|
|
|
1495
1491
|
deployedAt: 1781116663270,
|
|
1496
1492
|
size: 8695,
|
|
1497
1493
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
1498
|
-
validatorWalletAddress: "
|
|
1494
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
1499
1495
|
pkp: {
|
|
1500
1496
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
1501
|
-
ethAddress: "
|
|
1497
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1502
1498
|
}
|
|
1503
1499
|
},
|
|
1504
1500
|
loanVaultBtcBalance: {
|
|
1505
|
-
cid: "
|
|
1501
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
1506
1502
|
authorizedCidHex: cidToHex(
|
|
1507
|
-
"
|
|
1503
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
1508
1504
|
),
|
|
1509
1505
|
name: "Loan Vault Btc Balance",
|
|
1510
1506
|
description: "Production Loan Vault Btc Balance",
|
|
1511
1507
|
version: "1.2.1",
|
|
1512
1508
|
deployed: true,
|
|
1513
|
-
deployedAt:
|
|
1514
|
-
size:
|
|
1515
|
-
hash: "
|
|
1516
|
-
validatorWalletAddress: "
|
|
1509
|
+
deployedAt: 1790179961079,
|
|
1510
|
+
size: 60046,
|
|
1511
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
1512
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1517
1513
|
pkp: {
|
|
1518
1514
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
1519
|
-
ethAddress: "
|
|
1515
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1520
1516
|
}
|
|
1521
1517
|
},
|
|
1522
1518
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -1526,21 +1522,21 @@ var require_pkg_src = __commonJS({
|
|
|
1526
1522
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
1527
1523
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
1528
1524
|
btcAddressBalance: {
|
|
1529
|
-
cid: "
|
|
1525
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
1530
1526
|
authorizedCidHex: cidToHex(
|
|
1531
|
-
"
|
|
1527
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
1532
1528
|
),
|
|
1533
1529
|
name: "Btc Address Balance",
|
|
1534
1530
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
1535
1531
|
version: "0.2.1",
|
|
1536
1532
|
deployed: true,
|
|
1537
|
-
deployedAt:
|
|
1538
|
-
size:
|
|
1539
|
-
hash: "
|
|
1540
|
-
validatorWalletAddress: "
|
|
1533
|
+
deployedAt: 1790179971315,
|
|
1534
|
+
size: 30295,
|
|
1535
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
1536
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1541
1537
|
pkp: {
|
|
1542
1538
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
1543
|
-
ethAddress: "
|
|
1539
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1544
1540
|
}
|
|
1545
1541
|
},
|
|
1546
1542
|
alwaysSigner: {
|
|
@@ -1570,48 +1566,48 @@ var require_pkg_src = __commonJS({
|
|
|
1570
1566
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
1571
1567
|
},
|
|
1572
1568
|
agentModuleExecutor: {
|
|
1573
|
-
cid: "
|
|
1569
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
1574
1570
|
authorizedCidHex: cidToHex(
|
|
1575
|
-
"
|
|
1571
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
1576
1572
|
),
|
|
1577
1573
|
name: "Agent Module Executor",
|
|
1578
1574
|
description: "Production Agent Module Executor",
|
|
1579
1575
|
version: "1.1.1",
|
|
1580
1576
|
deployed: true,
|
|
1581
|
-
deployedAt:
|
|
1582
|
-
size:
|
|
1583
|
-
hash: "
|
|
1577
|
+
deployedAt: 1790179978959,
|
|
1578
|
+
size: 14688,
|
|
1579
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
1584
1580
|
},
|
|
1585
1581
|
staleSpendRecoveryValidator: {
|
|
1586
|
-
cid: "
|
|
1582
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
1587
1583
|
authorizedCidHex: cidToHex(
|
|
1588
|
-
"
|
|
1584
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
1589
1585
|
),
|
|
1590
1586
|
name: "Stale Spend Recovery Validator",
|
|
1591
1587
|
description: "Production Stale Spend Recovery Validator",
|
|
1592
1588
|
version: "1.1.2",
|
|
1593
1589
|
deployed: true,
|
|
1594
|
-
deployedAt:
|
|
1595
|
-
size:
|
|
1596
|
-
hash: "
|
|
1597
|
-
validatorWalletAddress: "
|
|
1590
|
+
deployedAt: 1790246256280,
|
|
1591
|
+
size: 48143,
|
|
1592
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
1593
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
1598
1594
|
pkp: {
|
|
1599
1595
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
1600
|
-
ethAddress: "
|
|
1596
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
1601
1597
|
}
|
|
1602
1598
|
},
|
|
1603
1599
|
btcUtxoInvalidator: {
|
|
1604
|
-
cid: "
|
|
1600
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
1605
1601
|
authorizedCidHex: cidToHex(
|
|
1606
|
-
"
|
|
1602
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
1607
1603
|
),
|
|
1608
1604
|
name: "Btc Utxo Invalidator",
|
|
1609
1605
|
description: "Production Btc Utxo Invalidator",
|
|
1610
1606
|
version: "1.0.0",
|
|
1611
1607
|
deployed: true,
|
|
1612
|
-
deployedAt:
|
|
1613
|
-
size:
|
|
1614
|
-
hash: "
|
|
1608
|
+
deployedAt: 1790246264563,
|
|
1609
|
+
size: 69219,
|
|
1610
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
1615
1611
|
}
|
|
1616
1612
|
};
|
|
1617
1613
|
function getDeploymentsForNetwork(network) {
|
|
@@ -2379,7 +2375,10 @@ ${errorReport}`);
|
|
|
2379
2375
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
2380
2376
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
2381
2377
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
2382
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
2378
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
2379
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
2380
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
2381
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
2383
2382
|
},
|
|
2384
2383
|
11155111: {
|
|
2385
2384
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -2387,7 +2386,10 @@ ${errorReport}`);
|
|
|
2387
2386
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
2388
2387
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
2389
2388
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
2390
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
2389
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
2390
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
2391
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
2392
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
2391
2393
|
}
|
|
2392
2394
|
};
|
|
2393
2395
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -2573,10 +2575,10 @@ ${errorReport}`);
|
|
|
2573
2575
|
};
|
|
2574
2576
|
}
|
|
2575
2577
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
2576
|
-
const
|
|
2578
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
2577
2579
|
return {
|
|
2578
2580
|
collateralValueUsd,
|
|
2579
|
-
collateralRatioBps
|
|
2581
|
+
collateralRatioBps: collateralRatioBps2
|
|
2580
2582
|
};
|
|
2581
2583
|
}
|
|
2582
2584
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -3430,6 +3432,17 @@ ${auth.clientId}`;
|
|
|
3430
3432
|
);
|
|
3431
3433
|
}
|
|
3432
3434
|
}
|
|
3435
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
3436
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
3437
|
+
constructor(message) {
|
|
3438
|
+
super(message);
|
|
3439
|
+
this.isBitcoinTipUnreadable = true;
|
|
3440
|
+
this.name = "BitcoinTipUnreadableError";
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
function isBitcoinTipUnreadableError(error) {
|
|
3444
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
3445
|
+
}
|
|
3433
3446
|
var BitcoinDataProvider = class {
|
|
3434
3447
|
constructor(config) {
|
|
3435
3448
|
this.config = config;
|
|
@@ -3881,27 +3894,12 @@ ${auth.clientId}`;
|
|
|
3881
3894
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
3882
3895
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
3883
3896
|
}
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
3891
|
-
}
|
|
3892
|
-
const tipBody = (await tipResp.text()).trim();
|
|
3893
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
3894
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
3895
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
3896
|
-
}
|
|
3897
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
3898
|
-
return {
|
|
3899
|
-
txid: data.txid ?? txid,
|
|
3900
|
-
confirmations: depth > 0 ? depth : 0
|
|
3901
|
-
};
|
|
3902
|
-
} catch {
|
|
3903
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
3904
|
-
}
|
|
3897
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
3898
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
3899
|
+
return {
|
|
3900
|
+
txid: data.txid ?? txid,
|
|
3901
|
+
confirmations: depth > 0 ? depth : 0
|
|
3902
|
+
};
|
|
3905
3903
|
}
|
|
3906
3904
|
return null;
|
|
3907
3905
|
} catch (error) {
|
|
@@ -3909,12 +3907,55 @@ ${auth.clientId}`;
|
|
|
3909
3907
|
if (isAbortError(error)) {
|
|
3910
3908
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
3911
3909
|
}
|
|
3910
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
3911
|
+
throw error;
|
|
3912
|
+
}
|
|
3912
3913
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
3913
3914
|
return null;
|
|
3914
3915
|
}
|
|
3915
3916
|
throw error;
|
|
3916
3917
|
}
|
|
3917
3918
|
}
|
|
3919
|
+
/**
|
|
3920
|
+
* Current chain tip height from THIS provider — or throw.
|
|
3921
|
+
*
|
|
3922
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
3923
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
3924
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
3925
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
3926
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
3927
|
+
* this case by the Batch 2 plan, §C2.
|
|
3928
|
+
*
|
|
3929
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
3930
|
+
* timeout budget as the transaction fetch it serves.
|
|
3931
|
+
*/
|
|
3932
|
+
async fetchTipHeight(signal) {
|
|
3933
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
3934
|
+
let tipResp;
|
|
3935
|
+
try {
|
|
3936
|
+
tipResp = await fetch(endpoint, {
|
|
3937
|
+
signal,
|
|
3938
|
+
headers: await this.withAuth()
|
|
3939
|
+
});
|
|
3940
|
+
} catch (error) {
|
|
3941
|
+
throw new BitcoinTipUnreadableError(
|
|
3942
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
3943
|
+
);
|
|
3944
|
+
}
|
|
3945
|
+
if (!tipResp.ok) {
|
|
3946
|
+
throw new BitcoinTipUnreadableError(
|
|
3947
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
3948
|
+
);
|
|
3949
|
+
}
|
|
3950
|
+
const tipBody = (await tipResp.text()).trim();
|
|
3951
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
3952
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
3953
|
+
throw new BitcoinTipUnreadableError(
|
|
3954
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
3955
|
+
);
|
|
3956
|
+
}
|
|
3957
|
+
return tipHeight;
|
|
3958
|
+
}
|
|
3918
3959
|
/**
|
|
3919
3960
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
3920
3961
|
*
|
|
@@ -4552,10 +4593,13 @@ ${auth.clientId}`;
|
|
|
4552
4593
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
4553
4594
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
4554
4595
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
4555
|
-
* and inflate the signed balance. Any
|
|
4556
|
-
*
|
|
4557
|
-
*
|
|
4558
|
-
*
|
|
4596
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
4597
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
4598
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
4599
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
4600
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
4601
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
4602
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
4559
4603
|
*
|
|
4560
4604
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
4561
4605
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -4650,10 +4694,26 @@ ${auth.clientId}`;
|
|
|
4650
4694
|
}
|
|
4651
4695
|
/**
|
|
4652
4696
|
* Run the self-spend proof against every configured provider and require
|
|
4653
|
-
* unanimity
|
|
4654
|
-
*
|
|
4697
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
4698
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
4655
4699
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
4656
4700
|
*
|
|
4701
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
4702
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
4703
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
4704
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
4705
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
4706
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
4707
|
+
* every provider that dropped out.
|
|
4708
|
+
*
|
|
4709
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
4710
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
4711
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
4712
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
4713
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
4714
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
4715
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
4716
|
+
*
|
|
4657
4717
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
4658
4718
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
4659
4719
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -4678,32 +4738,52 @@ ${auth.clientId}`;
|
|
|
4678
4738
|
)
|
|
4679
4739
|
)
|
|
4680
4740
|
);
|
|
4681
|
-
const
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4741
|
+
const answered = [];
|
|
4742
|
+
const absences = [];
|
|
4743
|
+
const failures = [];
|
|
4744
|
+
settled.forEach((result, i) => {
|
|
4745
|
+
if (result.status === "fulfilled") {
|
|
4746
|
+
answered.push({ index: i, evaluation: result.value });
|
|
4747
|
+
return;
|
|
4748
|
+
}
|
|
4749
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
4750
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
4751
|
+
absences.push(described);
|
|
4752
|
+
return;
|
|
4753
|
+
}
|
|
4754
|
+
failures.push(described);
|
|
4755
|
+
});
|
|
4686
4756
|
if (failures.length > 0) {
|
|
4687
4757
|
throw new Error(
|
|
4688
4758
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
4689
4759
|
);
|
|
4690
4760
|
}
|
|
4691
|
-
const
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4761
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
4762
|
+
if (answered.length < floor) {
|
|
4763
|
+
throw new Error(
|
|
4764
|
+
`Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
|
|
4765
|
+
);
|
|
4766
|
+
}
|
|
4767
|
+
if (absences.length > 0) {
|
|
4768
|
+
litDebugLog(
|
|
4769
|
+
`[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
|
|
4770
|
+
);
|
|
4771
|
+
}
|
|
4772
|
+
const first = answered[0];
|
|
4773
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
4774
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
4697
4775
|
);
|
|
4698
4776
|
if (disagreements.length > 0) {
|
|
4699
4777
|
throw new Error(
|
|
4700
4778
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
4701
4779
|
);
|
|
4702
4780
|
}
|
|
4703
|
-
if (!
|
|
4781
|
+
if (!first.evaluation.selfSpend) {
|
|
4704
4782
|
return false;
|
|
4705
4783
|
}
|
|
4706
|
-
const outputMismatches =
|
|
4784
|
+
const outputMismatches = answered.map(
|
|
4785
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
4786
|
+
).filter((m) => m !== null);
|
|
4707
4787
|
if (outputMismatches.length > 0) {
|
|
4708
4788
|
throw new Error(
|
|
4709
4789
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -4946,16 +5026,6 @@ ${auth.clientId}`;
|
|
|
4946
5026
|
minConfirmations
|
|
4947
5027
|
);
|
|
4948
5028
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
4949
|
-
for (const spend of authorizedSpends) {
|
|
4950
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
4951
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
4952
|
-
);
|
|
4953
|
-
if (utxoStillExists) {
|
|
4954
|
-
throw new Error(
|
|
4955
|
-
`Authorized UTXO ${spend.txid}:${spend.vout} not yet spent. Transaction was authorized in smart contract but not signed and broadcasted to Bitcoin network. Complete the transaction by signing and broadcasting it.`
|
|
4956
|
-
);
|
|
4957
|
-
}
|
|
4958
|
-
}
|
|
4959
5029
|
const authorizedBalance = authorizedSpends.reduce(
|
|
4960
5030
|
(sum, spend) => sum + spend.satoshis,
|
|
4961
5031
|
0n
|
|
@@ -5251,7 +5321,13 @@ ${auth.clientId}`;
|
|
|
5251
5321
|
allowDevSinglePriceProvider: false,
|
|
5252
5322
|
minBitcoinBalanceConfirmations: 1,
|
|
5253
5323
|
minBitcoinSpendConfirmations: 1,
|
|
5254
|
-
|
|
5324
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
5325
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
5326
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
5327
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
5328
|
+
// and balance paths rely on — the one environment where that logic is
|
|
5329
|
+
// supposed to be proved before mainnet.
|
|
5330
|
+
minConsensusProviders: 2
|
|
5255
5331
|
},
|
|
5256
5332
|
[
|
|
5257
5333
|
"ethereum"
|
|
@@ -5562,7 +5638,6 @@ function getSepoliaConfig() {
|
|
|
5562
5638
|
feeRecipientRegistry: SEPOLIA_CONTRACTS.FeeRecipientRegistry || "",
|
|
5563
5639
|
positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || "",
|
|
5564
5640
|
bitcoinWithdrawalAddressRegistry: SEPOLIA_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
5565
|
-
carryAgentRegistry: SEPOLIA_CONTRACTS.CarryAgentRegistry || "",
|
|
5566
5641
|
agentDelegationRegistry: SEPOLIA_CONTRACTS.AgentDelegationRegistry || "",
|
|
5567
5642
|
dhAgentDelegate: SEPOLIA_CONTRACTS.DHAgentDelegate || "",
|
|
5568
5643
|
agentModuleFactory: SEPOLIA_CONTRACTS.AgentModuleFactory || ""
|
|
@@ -5616,7 +5691,6 @@ function getMainnetConfig() {
|
|
|
5616
5691
|
feeRecipientRegistry: MAINNET_CONTRACTS.FeeRecipientRegistry || "",
|
|
5617
5692
|
positionDelegateRegistry: MAINNET_CONTRACTS.PositionDelegateRegistry || "",
|
|
5618
5693
|
bitcoinWithdrawalAddressRegistry: MAINNET_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
5619
|
-
carryAgentRegistry: MAINNET_CONTRACTS.CarryAgentRegistry || "",
|
|
5620
5694
|
agentDelegationRegistry: MAINNET_CONTRACTS.AgentDelegationRegistry || "",
|
|
5621
5695
|
dhAgentDelegate: MAINNET_CONTRACTS.DHAgentDelegate || "",
|
|
5622
5696
|
// Empty on mainnet until the factory is deployed there — the ceremony is Sepolia-only.
|
|
@@ -6816,7 +6890,54 @@ async function resolveAuthorizationInput(provider, signer, ctx) {
|
|
|
6816
6890
|
return { timestamp: result.timestamp, signature: result.signature };
|
|
6817
6891
|
}
|
|
6818
6892
|
|
|
6893
|
+
// src/utils/btc-dust.utils.ts
|
|
6894
|
+
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
6895
|
+
function segwitProgramShape(address) {
|
|
6896
|
+
const lower2 = address.trim().toLowerCase();
|
|
6897
|
+
if (!/^(bc1|tb1|bcrt1)/.test(lower2))
|
|
6898
|
+
return null;
|
|
6899
|
+
const sep = lower2.lastIndexOf("1");
|
|
6900
|
+
const data = lower2.slice(sep + 1);
|
|
6901
|
+
if (data.length < 8)
|
|
6902
|
+
return null;
|
|
6903
|
+
const version = BECH32_CHARSET.indexOf(data[0]);
|
|
6904
|
+
if (version < 0)
|
|
6905
|
+
return null;
|
|
6906
|
+
const programChars = data.length - 1 - 6;
|
|
6907
|
+
return { version, programBytes: Math.floor(programChars * 5 / 8) };
|
|
6908
|
+
}
|
|
6909
|
+
function dustLimitForAddress(address) {
|
|
6910
|
+
const shape = segwitProgramShape(address);
|
|
6911
|
+
if (shape === null)
|
|
6912
|
+
return 546;
|
|
6913
|
+
if (shape.version === 0 && shape.programBytes === 20)
|
|
6914
|
+
return 294;
|
|
6915
|
+
if (shape.version === 0 && shape.programBytes === 32)
|
|
6916
|
+
return 330;
|
|
6917
|
+
if (shape.version === 1 && shape.programBytes === 32)
|
|
6918
|
+
return 330;
|
|
6919
|
+
return 546;
|
|
6920
|
+
}
|
|
6921
|
+
function destinationDustShortfall(targetAmount, networkFee, destination) {
|
|
6922
|
+
const limit = dustLimitForAddress(destination);
|
|
6923
|
+
return targetAmount - networkFee < limit ? limit : null;
|
|
6924
|
+
}
|
|
6925
|
+
|
|
6819
6926
|
// src/utils/loan-helpers.utils.ts
|
|
6927
|
+
function calculateMintFee(params) {
|
|
6928
|
+
const { mintAmount, mintTimestamp, originationFeeBps, previousExpiryAt, selectedTerm, totalTerm } = params;
|
|
6929
|
+
let mintFee = mintAmount * BigInt(originationFeeBps) / 10000n;
|
|
6930
|
+
if (previousExpiryAt > 0 && mintTimestamp < previousExpiryAt) {
|
|
6931
|
+
const tailSeconds = BigInt(previousExpiryAt) - BigInt(mintTimestamp);
|
|
6932
|
+
const originalTermMonths = totalTerm - selectedTerm;
|
|
6933
|
+
const originalTermSeconds = BigInt(
|
|
6934
|
+
originalTermMonths === 12 ? 365 * 86400 : originalTermMonths * 30 * 86400
|
|
6935
|
+
);
|
|
6936
|
+
const tailFee = tailSeconds * BigInt(originationFeeBps) * mintAmount / (10000n * originalTermSeconds);
|
|
6937
|
+
mintFee = mintFee + tailFee;
|
|
6938
|
+
}
|
|
6939
|
+
return mintFee;
|
|
6940
|
+
}
|
|
6820
6941
|
function baseMintFeeWei(mintAmountWei, originationFeeBps) {
|
|
6821
6942
|
if (mintAmountWei < 0n)
|
|
6822
6943
|
throw new Error("baseMintFeeWei: mintAmountWei cannot be negative");
|
|
@@ -6835,20 +6956,34 @@ function debtAfterMintExceedsLoanCap(params) {
|
|
|
6835
6956
|
}
|
|
6836
6957
|
return currentDebtWei + mintAmountWei + mintFeeWei > maxLoanWei;
|
|
6837
6958
|
}
|
|
6838
|
-
function
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
throw new Error("maxPrincipalWithinLoanCap: amounts cannot be negative");
|
|
6959
|
+
function collateralRatioBps(sats, price8, debtWei) {
|
|
6960
|
+
if (sats < 0n || price8 < 0n) {
|
|
6961
|
+
throw new Error("collateralRatioBps: sats and price cannot be negative");
|
|
6842
6962
|
}
|
|
6843
|
-
if (
|
|
6844
|
-
throw new Error(
|
|
6845
|
-
`maxPrincipalWithinLoanCap: originationFeeBps must be an integer in [0, 10000] (got ${String(originationFeeBps)})`
|
|
6846
|
-
);
|
|
6963
|
+
if (debtWei <= 0n) {
|
|
6964
|
+
throw new Error("collateralRatioBps: debt must be positive");
|
|
6847
6965
|
}
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6966
|
+
return sats * price8 * 100n * 10000n / debtWei;
|
|
6967
|
+
}
|
|
6968
|
+
function collateralRatioPercentString(sats, price8, debtWei) {
|
|
6969
|
+
const bps = collateralRatioBps(sats, price8, debtWei);
|
|
6970
|
+
return `${bps / 100n}.${(bps % 100n).toString().padStart(2, "0")}`;
|
|
6971
|
+
}
|
|
6972
|
+
function maxPrincipalForFee(room, fee) {
|
|
6973
|
+
if (room < 0n)
|
|
6974
|
+
throw new Error("maxPrincipalForFee: room cannot be negative");
|
|
6975
|
+
if (fee(0n) !== 0n)
|
|
6976
|
+
throw new Error("maxPrincipalForFee: fee(0) must be 0");
|
|
6977
|
+
let lo = 0n;
|
|
6978
|
+
let hi = room;
|
|
6979
|
+
while (lo < hi) {
|
|
6980
|
+
const mid = (lo + hi + 1n) / 2n;
|
|
6981
|
+
if (mid + fee(mid) <= room)
|
|
6982
|
+
lo = mid;
|
|
6983
|
+
else
|
|
6984
|
+
hi = mid - 1n;
|
|
6985
|
+
}
|
|
6986
|
+
return lo;
|
|
6852
6987
|
}
|
|
6853
6988
|
|
|
6854
6989
|
// src/utils/eip712-login.ts
|
|
@@ -19155,9 +19290,17 @@ async function mintAgentPkp(params) {
|
|
|
19155
19290
|
}
|
|
19156
19291
|
var AGENT_STATUS = { None: 0, Active: 1, Revoked: 2 };
|
|
19157
19292
|
function planAgentBinding(params) {
|
|
19158
|
-
const { isActive, record, nowSeconds } = params;
|
|
19293
|
+
const { isActive, paused, record, nowSeconds } = params;
|
|
19294
|
+
if (typeof paused !== "boolean") {
|
|
19295
|
+
throw new Error("planAgentBinding: `paused` must be read from the registry (boolean required)");
|
|
19296
|
+
}
|
|
19159
19297
|
if (isActive)
|
|
19160
19298
|
return { kind: "reuse", agent: record.agent };
|
|
19299
|
+
if (paused) {
|
|
19300
|
+
throw new Error(
|
|
19301
|
+
"AgentDelegationRegistry is paused \u2014 agent delegation cannot be changed until it is unpaused."
|
|
19302
|
+
);
|
|
19303
|
+
}
|
|
19161
19304
|
const status = Number(record.status);
|
|
19162
19305
|
if (status === AGENT_STATUS.None || status === AGENT_STATUS.Revoked) {
|
|
19163
19306
|
return { kind: "register" };
|
|
@@ -19167,7 +19310,7 @@ function planAgentBinding(params) {
|
|
|
19167
19310
|
}
|
|
19168
19311
|
if (Number(record.validUntil) > nowSeconds) {
|
|
19169
19312
|
throw new Error(
|
|
19170
|
-
"AgentDelegationRegistry
|
|
19313
|
+
"AgentDelegationRegistry returned an inconsistent read (an unexpired, unpaused Active agent reported inactive); retry."
|
|
19171
19314
|
);
|
|
19172
19315
|
}
|
|
19173
19316
|
return { kind: "rotate" };
|
|
@@ -20369,7 +20512,7 @@ function normalizeBigNumberish(value) {
|
|
|
20369
20512
|
}
|
|
20370
20513
|
return value;
|
|
20371
20514
|
}
|
|
20372
|
-
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function") {
|
|
20515
|
+
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
20373
20516
|
const result = value.toString();
|
|
20374
20517
|
if (typeof result === "object" && result !== null && "_hex" in result) {
|
|
20375
20518
|
const resultObj = result;
|
|
@@ -21782,12 +21925,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
21782
21925
|
maxLoanWei: maxLoanValueWei
|
|
21783
21926
|
})) {
|
|
21784
21927
|
const debtAfterWei = currentDebtWei + requestAmountWei + baseFeeWei;
|
|
21928
|
+
const suggestionStamp = calculateNextQuantumTimestamp();
|
|
21929
|
+
const room = maxLoanValueWei > currentDebtWei ? maxLoanValueWei - currentDebtWei : 0n;
|
|
21785
21930
|
const maxPrincipalUcd = Number(
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
|
|
21789
|
-
|
|
21790
|
-
|
|
21931
|
+
maxPrincipalForFee(
|
|
21932
|
+
room,
|
|
21933
|
+
(principal) => calculateMintFee({
|
|
21934
|
+
mintAmount: principal,
|
|
21935
|
+
mintTimestamp: suggestionStamp,
|
|
21936
|
+
originationFeeBps: positionTerm.originationFeeBps,
|
|
21937
|
+
expiryAt: Number(position2.expiryAt),
|
|
21938
|
+
previousExpiryAt: Number(position2.previousExpiryAt),
|
|
21939
|
+
selectedTerm: Number(position2.selectedTerm),
|
|
21940
|
+
totalTerm: Number(position2.totalTerm)
|
|
21941
|
+
})
|
|
21942
|
+
) / BigInt(10 ** 18)
|
|
21791
21943
|
);
|
|
21792
21944
|
return {
|
|
21793
21945
|
success: false,
|
|
@@ -22865,11 +23017,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
22865
23017
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
22866
23018
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
22867
23019
|
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
22868
|
-
const
|
|
22869
|
-
const btcAmount = Number(btcVaultBalance) / 1e8;
|
|
22870
|
-
const btcValueUSD = btcAmount * usdPricePerBTC;
|
|
22871
|
-
const debtUSD = Number(debt) / 1e18;
|
|
22872
|
-
const ratio = debtUSD > 0 ? (btcValueUSD / debtUSD * 100).toFixed(2) : "0.00";
|
|
23020
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
22873
23021
|
const message = formatLiquidationSkippedMessage(
|
|
22874
23022
|
request.positionId,
|
|
22875
23023
|
ratio,
|
|
@@ -23358,14 +23506,15 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
23358
23506
|
}
|
|
23359
23507
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
23360
23508
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
23361
|
-
const
|
|
23509
|
+
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
23510
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
23362
23511
|
const message = formatLiquidationSuccessMessage(
|
|
23363
23512
|
request.positionId,
|
|
23364
23513
|
ratio,
|
|
23365
23514
|
`${liquidationThreshold / 100}`,
|
|
23366
23515
|
// Convert to percentage
|
|
23367
23516
|
positionDetails.btcVault || "unknown",
|
|
23368
|
-
|
|
23517
|
+
btcVaultBalance,
|
|
23369
23518
|
debt,
|
|
23370
23519
|
btcPrice2
|
|
23371
23520
|
);
|
|
@@ -25838,6 +25987,17 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
25838
25987
|
error: `networkFee=${request.networkFee} is \u2265 50% of targetAmount=${request.targetAmount}. Refusing to broadcast \u2014 real Bitcoin fees are typically <1% of value.`
|
|
25839
25988
|
};
|
|
25840
25989
|
}
|
|
25990
|
+
const destinationDustLimit = destinationDustShortfall(
|
|
25991
|
+
request.targetAmount,
|
|
25992
|
+
request.networkFee,
|
|
25993
|
+
request.destination
|
|
25994
|
+
);
|
|
25995
|
+
if (destinationDustLimit !== null) {
|
|
25996
|
+
return {
|
|
25997
|
+
success: false,
|
|
25998
|
+
error: `Destination would receive ${request.targetAmount - request.networkFee} sats (targetAmount=${request.targetAmount} \u2212 networkFee=${request.networkFee}), below the ${destinationDustLimit}-sat dust limit for ${request.destination}; the transaction would not relay.`
|
|
25999
|
+
};
|
|
26000
|
+
}
|
|
25841
26001
|
const [txid, voutStr] = request.utxoIdentifier.split(":");
|
|
25842
26002
|
const vout = parseInt(voutStr || "0", 10);
|
|
25843
26003
|
if (!txid || isNaN(vout)) {
|
|
@@ -27310,8 +27470,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
27310
27470
|
const user = await signer.getAddress();
|
|
27311
27471
|
const registry = AgentDelegationRegistry__factory.connect(addr, signer);
|
|
27312
27472
|
let agentAddress;
|
|
27313
|
-
const [isActive, record, latestBlock] = await Promise.all([
|
|
27473
|
+
const [isActive, paused, record, latestBlock] = await Promise.all([
|
|
27314
27474
|
registry.isAgentActive(user),
|
|
27475
|
+
registry.paused(),
|
|
27315
27476
|
registry.agentOf(user),
|
|
27316
27477
|
this.getProviderOrThrow().getBlock("latest")
|
|
27317
27478
|
]);
|
|
@@ -27322,7 +27483,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
27322
27483
|
severity: "HIGH" /* HIGH */
|
|
27323
27484
|
});
|
|
27324
27485
|
}
|
|
27325
|
-
const plan = planAgentBinding({ isActive, record, nowSeconds: latestBlock.timestamp });
|
|
27486
|
+
const plan = planAgentBinding({ isActive, paused, record, nowSeconds: latestBlock.timestamp });
|
|
27326
27487
|
if (plan.kind === "reuse") {
|
|
27327
27488
|
agentAddress = plan.agent;
|
|
27328
27489
|
} else {
|