@fepvenancio/stela-sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +438 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +228 -2
- package/dist/index.d.ts +228 -2
- package/dist/index.js +429 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/stela.json +63 -78
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var STATUS_LABELS = {
|
|
|
22
22
|
|
|
23
23
|
// src/constants/addresses.ts
|
|
24
24
|
var STELA_ADDRESS = {
|
|
25
|
-
sepolia: "
|
|
25
|
+
sepolia: "0x0109c6caae0c5b4da6e063ed6c02ae784be05aa90806501a48dcfbb213bd7c03",
|
|
26
26
|
mainnet: "0x0"
|
|
27
27
|
};
|
|
28
28
|
var VALID_NETWORKS = ["sepolia", "mainnet"];
|
|
@@ -56,6 +56,10 @@ var ASSET_TYPE_NAMES = {
|
|
|
56
56
|
2: "ERC1155",
|
|
57
57
|
3: "ERC4626"
|
|
58
58
|
};
|
|
59
|
+
var GRACE_PERIOD = 86400n;
|
|
60
|
+
var AUCTION_DURATION = 86400n;
|
|
61
|
+
var AUCTION_PENALTY_BPS = 500n;
|
|
62
|
+
var AUCTION_RESERVE_BPS = 1000n;
|
|
59
63
|
var U128_MAX = (1n << 128n) - 1n;
|
|
60
64
|
var U256_MAX = (1n << 256n) - 1n;
|
|
61
65
|
var toU256 = (n) => {
|
|
@@ -566,6 +570,185 @@ function getBatchLendOfferTypedData(params) {
|
|
|
566
570
|
}
|
|
567
571
|
};
|
|
568
572
|
}
|
|
573
|
+
function u256Message(value) {
|
|
574
|
+
return {
|
|
575
|
+
low: (value & (1n << 128n) - 1n).toString(),
|
|
576
|
+
high: (value >> 128n).toString()
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
var STARKNET_DOMAIN_TYPE = [
|
|
580
|
+
{ name: "name", type: "shortstring" },
|
|
581
|
+
{ name: "version", type: "shortstring" },
|
|
582
|
+
{ name: "chainId", type: "shortstring" },
|
|
583
|
+
{ name: "revision", type: "shortstring" }
|
|
584
|
+
];
|
|
585
|
+
var U256_TYPE = [
|
|
586
|
+
{ name: "low", type: "u128" },
|
|
587
|
+
{ name: "high", type: "u128" }
|
|
588
|
+
];
|
|
589
|
+
function getCollectionLendOfferTypedData(params) {
|
|
590
|
+
return {
|
|
591
|
+
types: {
|
|
592
|
+
StarknetDomain: STARKNET_DOMAIN_TYPE,
|
|
593
|
+
CollectionLendOffer: [
|
|
594
|
+
{ name: "lender", type: "ContractAddress" },
|
|
595
|
+
{ name: "debt_hash", type: "felt" },
|
|
596
|
+
{ name: "interest_hash", type: "felt" },
|
|
597
|
+
{ name: "debt_count", type: "u128" },
|
|
598
|
+
{ name: "interest_count", type: "u128" },
|
|
599
|
+
{ name: "collection_address", type: "ContractAddress" },
|
|
600
|
+
{ name: "duration", type: "u128" },
|
|
601
|
+
{ name: "deadline", type: "u128" },
|
|
602
|
+
{ name: "nonce", type: "felt" }
|
|
603
|
+
]
|
|
604
|
+
},
|
|
605
|
+
primaryType: "CollectionLendOffer",
|
|
606
|
+
domain: { ...STELA_DOMAIN, chainId: params.chainId },
|
|
607
|
+
message: {
|
|
608
|
+
lender: params.lender,
|
|
609
|
+
debt_hash: hashAssets(params.debtAssets),
|
|
610
|
+
interest_hash: hashAssets(params.interestAssets),
|
|
611
|
+
debt_count: params.debtCount.toString(),
|
|
612
|
+
interest_count: params.interestCount.toString(),
|
|
613
|
+
collection_address: params.collectionAddress,
|
|
614
|
+
duration: params.duration.toString(),
|
|
615
|
+
deadline: params.deadline.toString(),
|
|
616
|
+
nonce: params.nonce.toString()
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function getCollectionBorrowAcceptanceTypedData(params) {
|
|
621
|
+
return {
|
|
622
|
+
types: {
|
|
623
|
+
StarknetDomain: STARKNET_DOMAIN_TYPE,
|
|
624
|
+
CollectionBorrowAcceptance: [
|
|
625
|
+
{ name: "offer_hash", type: "felt" },
|
|
626
|
+
{ name: "borrower", type: "ContractAddress" },
|
|
627
|
+
{ name: "token_id", type: "u256" },
|
|
628
|
+
{ name: "nonce", type: "felt" }
|
|
629
|
+
],
|
|
630
|
+
u256: U256_TYPE
|
|
631
|
+
},
|
|
632
|
+
primaryType: "CollectionBorrowAcceptance",
|
|
633
|
+
domain: { ...STELA_DOMAIN, chainId: params.chainId },
|
|
634
|
+
message: {
|
|
635
|
+
offer_hash: params.offerHash,
|
|
636
|
+
borrower: params.borrower,
|
|
637
|
+
token_id: u256Message(params.tokenId),
|
|
638
|
+
nonce: params.nonce.toString()
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function getRenegotiationProposalTypedData(params) {
|
|
643
|
+
return {
|
|
644
|
+
types: {
|
|
645
|
+
StarknetDomain: STARKNET_DOMAIN_TYPE,
|
|
646
|
+
RenegotiationProposal: [
|
|
647
|
+
{ name: "inscription_id", type: "u256" },
|
|
648
|
+
{ name: "proposer", type: "ContractAddress" },
|
|
649
|
+
{ name: "new_duration", type: "u128" },
|
|
650
|
+
{ name: "new_interest_hash", type: "felt" },
|
|
651
|
+
{ name: "new_interest_count", type: "u128" },
|
|
652
|
+
{ name: "proposal_deadline", type: "u128" },
|
|
653
|
+
{ name: "nonce", type: "felt" }
|
|
654
|
+
],
|
|
655
|
+
u256: U256_TYPE
|
|
656
|
+
},
|
|
657
|
+
primaryType: "RenegotiationProposal",
|
|
658
|
+
domain: { ...STELA_DOMAIN, chainId: params.chainId },
|
|
659
|
+
message: {
|
|
660
|
+
inscription_id: u256Message(params.inscriptionId),
|
|
661
|
+
proposer: params.proposer,
|
|
662
|
+
new_duration: params.newDuration.toString(),
|
|
663
|
+
new_interest_hash: hashAssets(params.newInterestAssets),
|
|
664
|
+
new_interest_count: params.newInterestCount.toString(),
|
|
665
|
+
proposal_deadline: params.proposalDeadline.toString(),
|
|
666
|
+
nonce: params.nonce.toString()
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
function getCollateralSaleOfferTypedData(params) {
|
|
671
|
+
return {
|
|
672
|
+
types: {
|
|
673
|
+
StarknetDomain: STARKNET_DOMAIN_TYPE,
|
|
674
|
+
CollateralSaleOffer: [
|
|
675
|
+
{ name: "inscription_id", type: "u256" },
|
|
676
|
+
{ name: "borrower", type: "ContractAddress" },
|
|
677
|
+
{ name: "min_price", type: "u256" },
|
|
678
|
+
{ name: "payment_token", type: "ContractAddress" },
|
|
679
|
+
{ name: "allowed_buyer", type: "ContractAddress" },
|
|
680
|
+
{ name: "deadline", type: "u128" },
|
|
681
|
+
{ name: "nonce", type: "felt" }
|
|
682
|
+
],
|
|
683
|
+
u256: U256_TYPE
|
|
684
|
+
},
|
|
685
|
+
primaryType: "CollateralSaleOffer",
|
|
686
|
+
domain: { ...STELA_DOMAIN, chainId: params.chainId },
|
|
687
|
+
message: {
|
|
688
|
+
inscription_id: u256Message(params.inscriptionId),
|
|
689
|
+
borrower: params.borrower,
|
|
690
|
+
min_price: u256Message(params.minPrice),
|
|
691
|
+
payment_token: params.paymentToken,
|
|
692
|
+
allowed_buyer: params.allowedBuyer,
|
|
693
|
+
deadline: params.deadline.toString(),
|
|
694
|
+
nonce: params.nonce.toString()
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
function getRefinanceOfferTypedData(params) {
|
|
699
|
+
return {
|
|
700
|
+
types: {
|
|
701
|
+
StarknetDomain: STARKNET_DOMAIN_TYPE,
|
|
702
|
+
RefinanceOffer: [
|
|
703
|
+
{ name: "inscription_id", type: "u256" },
|
|
704
|
+
{ name: "new_lender", type: "ContractAddress" },
|
|
705
|
+
{ name: "new_debt_hash", type: "felt" },
|
|
706
|
+
{ name: "new_interest_hash", type: "felt" },
|
|
707
|
+
{ name: "new_debt_count", type: "u128" },
|
|
708
|
+
{ name: "new_interest_count", type: "u128" },
|
|
709
|
+
{ name: "new_duration", type: "u128" },
|
|
710
|
+
{ name: "deadline", type: "u128" },
|
|
711
|
+
{ name: "nonce", type: "felt" }
|
|
712
|
+
],
|
|
713
|
+
u256: U256_TYPE
|
|
714
|
+
},
|
|
715
|
+
primaryType: "RefinanceOffer",
|
|
716
|
+
domain: { ...STELA_DOMAIN, chainId: params.chainId },
|
|
717
|
+
message: {
|
|
718
|
+
inscription_id: u256Message(params.inscriptionId),
|
|
719
|
+
new_lender: params.newLender,
|
|
720
|
+
new_debt_hash: hashAssets(params.newDebtAssets),
|
|
721
|
+
new_interest_hash: hashAssets(params.newInterestAssets),
|
|
722
|
+
new_debt_count: params.newDebtCount.toString(),
|
|
723
|
+
new_interest_count: params.newInterestCount.toString(),
|
|
724
|
+
new_duration: params.newDuration.toString(),
|
|
725
|
+
deadline: params.deadline.toString(),
|
|
726
|
+
nonce: params.nonce.toString()
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
function getRefinanceApprovalTypedData(params) {
|
|
731
|
+
return {
|
|
732
|
+
types: {
|
|
733
|
+
StarknetDomain: STARKNET_DOMAIN_TYPE,
|
|
734
|
+
RefinanceApproval: [
|
|
735
|
+
{ name: "inscription_id", type: "u256" },
|
|
736
|
+
{ name: "offer_hash", type: "felt" },
|
|
737
|
+
{ name: "borrower", type: "ContractAddress" },
|
|
738
|
+
{ name: "nonce", type: "felt" }
|
|
739
|
+
],
|
|
740
|
+
u256: U256_TYPE
|
|
741
|
+
},
|
|
742
|
+
primaryType: "RefinanceApproval",
|
|
743
|
+
domain: { ...STELA_DOMAIN, chainId: params.chainId },
|
|
744
|
+
message: {
|
|
745
|
+
inscription_id: u256Message(params.inscriptionId),
|
|
746
|
+
offer_hash: params.offerHash,
|
|
747
|
+
borrower: params.borrower,
|
|
748
|
+
nonce: params.nonce.toString()
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
}
|
|
569
752
|
|
|
570
753
|
// src/offchain/signature.ts
|
|
571
754
|
function serializeSignature(sig) {
|
|
@@ -1157,17 +1340,6 @@ var stela_default = [
|
|
|
1157
1340
|
],
|
|
1158
1341
|
state_mutability: "view"
|
|
1159
1342
|
},
|
|
1160
|
-
{
|
|
1161
|
-
type: "function",
|
|
1162
|
-
name: "is_paused",
|
|
1163
|
-
inputs: [],
|
|
1164
|
-
outputs: [
|
|
1165
|
-
{
|
|
1166
|
-
type: "core::bool"
|
|
1167
|
-
}
|
|
1168
|
-
],
|
|
1169
|
-
state_mutability: "view"
|
|
1170
|
-
},
|
|
1171
1343
|
{
|
|
1172
1344
|
type: "function",
|
|
1173
1345
|
name: "is_order_registered",
|
|
@@ -1353,36 +1525,55 @@ var stela_default = [
|
|
|
1353
1525
|
},
|
|
1354
1526
|
{
|
|
1355
1527
|
type: "function",
|
|
1356
|
-
name: "
|
|
1357
|
-
inputs: [
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1528
|
+
name: "set_governance_target",
|
|
1529
|
+
inputs: [
|
|
1530
|
+
{
|
|
1531
|
+
name: "target",
|
|
1532
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
name: "whitelisted",
|
|
1536
|
+
type: "core::bool"
|
|
1537
|
+
}
|
|
1538
|
+
],
|
|
1365
1539
|
outputs: [],
|
|
1366
1540
|
state_mutability: "external"
|
|
1367
1541
|
},
|
|
1368
1542
|
{
|
|
1369
1543
|
type: "function",
|
|
1370
|
-
name: "
|
|
1371
|
-
inputs: [
|
|
1372
|
-
outputs: [
|
|
1544
|
+
name: "is_governance_target_whitelisted",
|
|
1545
|
+
inputs: [
|
|
1373
1546
|
{
|
|
1547
|
+
name: "target",
|
|
1374
1548
|
type: "core::starknet::contract_address::ContractAddress"
|
|
1375
1549
|
}
|
|
1376
1550
|
],
|
|
1551
|
+
outputs: [
|
|
1552
|
+
{
|
|
1553
|
+
type: "core::bool"
|
|
1554
|
+
}
|
|
1555
|
+
],
|
|
1377
1556
|
state_mutability: "view"
|
|
1378
1557
|
},
|
|
1379
1558
|
{
|
|
1380
1559
|
type: "function",
|
|
1381
|
-
name: "
|
|
1560
|
+
name: "set_locker_allowed_selector",
|
|
1382
1561
|
inputs: [
|
|
1383
1562
|
{
|
|
1384
|
-
name: "
|
|
1563
|
+
name: "locker",
|
|
1564
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1565
|
+
},
|
|
1566
|
+
{
|
|
1567
|
+
name: "target",
|
|
1385
1568
|
type: "core::starknet::contract_address::ContractAddress"
|
|
1569
|
+
},
|
|
1570
|
+
{
|
|
1571
|
+
name: "selector",
|
|
1572
|
+
type: "core::felt252"
|
|
1573
|
+
},
|
|
1574
|
+
{
|
|
1575
|
+
name: "allowed",
|
|
1576
|
+
type: "core::bool"
|
|
1386
1577
|
}
|
|
1387
1578
|
],
|
|
1388
1579
|
outputs: [],
|
|
@@ -1390,11 +1581,11 @@ var stela_default = [
|
|
|
1390
1581
|
},
|
|
1391
1582
|
{
|
|
1392
1583
|
type: "function",
|
|
1393
|
-
name: "
|
|
1584
|
+
name: "set_borrower_governance_selector",
|
|
1394
1585
|
inputs: [
|
|
1395
1586
|
{
|
|
1396
|
-
name: "
|
|
1397
|
-
type: "core::
|
|
1587
|
+
name: "inscription_id",
|
|
1588
|
+
type: "core::integer::u256"
|
|
1398
1589
|
},
|
|
1399
1590
|
{
|
|
1400
1591
|
name: "target",
|
|
@@ -1848,10 +2039,6 @@ var stela_default = [
|
|
|
1848
2039
|
{
|
|
1849
2040
|
name: "implementation_hash",
|
|
1850
2041
|
type: "core::felt252"
|
|
1851
|
-
},
|
|
1852
|
-
{
|
|
1853
|
-
name: "pauser",
|
|
1854
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
1855
2042
|
}
|
|
1856
2043
|
]
|
|
1857
2044
|
},
|
|
@@ -2048,47 +2235,6 @@ var stela_default = [
|
|
|
2048
2235
|
kind: "enum",
|
|
2049
2236
|
variants: []
|
|
2050
2237
|
},
|
|
2051
|
-
{
|
|
2052
|
-
type: "event",
|
|
2053
|
-
name: "openzeppelin_security::pausable::PausableComponent::Paused",
|
|
2054
|
-
kind: "struct",
|
|
2055
|
-
members: [
|
|
2056
|
-
{
|
|
2057
|
-
name: "account",
|
|
2058
|
-
type: "core::starknet::contract_address::ContractAddress",
|
|
2059
|
-
kind: "data"
|
|
2060
|
-
}
|
|
2061
|
-
]
|
|
2062
|
-
},
|
|
2063
|
-
{
|
|
2064
|
-
type: "event",
|
|
2065
|
-
name: "openzeppelin_security::pausable::PausableComponent::Unpaused",
|
|
2066
|
-
kind: "struct",
|
|
2067
|
-
members: [
|
|
2068
|
-
{
|
|
2069
|
-
name: "account",
|
|
2070
|
-
type: "core::starknet::contract_address::ContractAddress",
|
|
2071
|
-
kind: "data"
|
|
2072
|
-
}
|
|
2073
|
-
]
|
|
2074
|
-
},
|
|
2075
|
-
{
|
|
2076
|
-
type: "event",
|
|
2077
|
-
name: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
2078
|
-
kind: "enum",
|
|
2079
|
-
variants: [
|
|
2080
|
-
{
|
|
2081
|
-
name: "Paused",
|
|
2082
|
-
type: "openzeppelin_security::pausable::PausableComponent::Paused",
|
|
2083
|
-
kind: "nested"
|
|
2084
|
-
},
|
|
2085
|
-
{
|
|
2086
|
-
name: "Unpaused",
|
|
2087
|
-
type: "openzeppelin_security::pausable::PausableComponent::Unpaused",
|
|
2088
|
-
kind: "nested"
|
|
2089
|
-
}
|
|
2090
|
-
]
|
|
2091
|
-
},
|
|
2092
2238
|
{
|
|
2093
2239
|
type: "event",
|
|
2094
2240
|
name: "openzeppelin_utils::cryptography::nonces::NoncesComponent::Event",
|
|
@@ -2320,6 +2466,28 @@ var stela_default = [
|
|
|
2320
2466
|
}
|
|
2321
2467
|
]
|
|
2322
2468
|
},
|
|
2469
|
+
{
|
|
2470
|
+
type: "event",
|
|
2471
|
+
name: "stela::stela::StelaProtocol::CollateralReturned",
|
|
2472
|
+
kind: "struct",
|
|
2473
|
+
members: [
|
|
2474
|
+
{
|
|
2475
|
+
name: "inscription_id",
|
|
2476
|
+
type: "core::integer::u256",
|
|
2477
|
+
kind: "key"
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
name: "borrower",
|
|
2481
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2482
|
+
kind: "data"
|
|
2483
|
+
},
|
|
2484
|
+
{
|
|
2485
|
+
name: "asset_count",
|
|
2486
|
+
type: "core::integer::u32",
|
|
2487
|
+
kind: "data"
|
|
2488
|
+
}
|
|
2489
|
+
]
|
|
2490
|
+
},
|
|
2323
2491
|
{
|
|
2324
2492
|
type: "event",
|
|
2325
2493
|
name: "stela::stela::StelaProtocol::Event",
|
|
@@ -2345,11 +2513,6 @@ var stela_default = [
|
|
|
2345
2513
|
type: "openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event",
|
|
2346
2514
|
kind: "flat"
|
|
2347
2515
|
},
|
|
2348
|
-
{
|
|
2349
|
-
name: "PausableEvent",
|
|
2350
|
-
type: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
2351
|
-
kind: "flat"
|
|
2352
|
-
},
|
|
2353
2516
|
{
|
|
2354
2517
|
name: "NoncesEvent",
|
|
2355
2518
|
type: "openzeppelin_utils::cryptography::nonces::NoncesComponent::Event",
|
|
@@ -2404,6 +2567,11 @@ var stela_default = [
|
|
|
2404
2567
|
name: "OrdersBulkCancelled",
|
|
2405
2568
|
type: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2406
2569
|
kind: "nested"
|
|
2570
|
+
},
|
|
2571
|
+
{
|
|
2572
|
+
name: "CollateralReturned",
|
|
2573
|
+
type: "stela::stela::StelaProtocol::CollateralReturned",
|
|
2574
|
+
kind: "nested"
|
|
2407
2575
|
}
|
|
2408
2576
|
]
|
|
2409
2577
|
}
|
|
@@ -2624,6 +2792,155 @@ var InscriptionClient = class {
|
|
|
2624
2792
|
calldata: [minNonce]
|
|
2625
2793
|
};
|
|
2626
2794
|
}
|
|
2795
|
+
// ── T1 Call Builders ─────────────────────────────────────────────────
|
|
2796
|
+
/** T1-2: Settle a collection-wide lend offer */
|
|
2797
|
+
buildSettleCollection(params) {
|
|
2798
|
+
const calldata = [
|
|
2799
|
+
// CollectionLendOffer struct (9 fields)
|
|
2800
|
+
params.offer.lender,
|
|
2801
|
+
params.offer.debtHash,
|
|
2802
|
+
params.offer.interestHash,
|
|
2803
|
+
String(params.offer.debtCount),
|
|
2804
|
+
String(params.offer.interestCount),
|
|
2805
|
+
params.offer.collectionAddress,
|
|
2806
|
+
params.offer.duration.toString(),
|
|
2807
|
+
params.offer.deadline.toString(),
|
|
2808
|
+
params.offer.nonce.toString(),
|
|
2809
|
+
// CollectionBorrowAcceptance struct (4 fields)
|
|
2810
|
+
params.acceptance.offerHash,
|
|
2811
|
+
params.acceptance.borrower,
|
|
2812
|
+
...toU256(params.acceptance.tokenId),
|
|
2813
|
+
params.acceptance.nonce.toString(),
|
|
2814
|
+
// debt_assets array
|
|
2815
|
+
...serializeAssets(params.debtAssets),
|
|
2816
|
+
// interest_assets array
|
|
2817
|
+
...serializeAssets(params.interestAssets),
|
|
2818
|
+
// lender_sig array
|
|
2819
|
+
String(params.lenderSig.length),
|
|
2820
|
+
...params.lenderSig,
|
|
2821
|
+
// borrower_sig array
|
|
2822
|
+
String(params.borrowerSig.length),
|
|
2823
|
+
...params.borrowerSig
|
|
2824
|
+
];
|
|
2825
|
+
return { contractAddress: this.address, entrypoint: "settle_collection", calldata };
|
|
2826
|
+
}
|
|
2827
|
+
/** T1-4: Commit a renegotiation proposal hash on-chain */
|
|
2828
|
+
buildCommitRenegotiation(inscriptionId, proposalHash) {
|
|
2829
|
+
return {
|
|
2830
|
+
contractAddress: this.address,
|
|
2831
|
+
entrypoint: "commit_renegotiation",
|
|
2832
|
+
calldata: [...toU256(inscriptionId), proposalHash]
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
/** T1-4: Execute a committed renegotiation proposal */
|
|
2836
|
+
buildExecuteRenegotiation(params) {
|
|
2837
|
+
const calldata = [
|
|
2838
|
+
...toU256(params.inscriptionId),
|
|
2839
|
+
// RenegotiationProposal struct (7 fields)
|
|
2840
|
+
...toU256(params.proposal.inscriptionId),
|
|
2841
|
+
params.proposal.proposer,
|
|
2842
|
+
params.proposal.newDuration.toString(),
|
|
2843
|
+
params.proposal.newInterestHash,
|
|
2844
|
+
String(params.proposal.newInterestCount),
|
|
2845
|
+
params.proposal.proposalDeadline.toString(),
|
|
2846
|
+
params.proposal.nonce.toString(),
|
|
2847
|
+
// proposer_sig array
|
|
2848
|
+
String(params.proposerSig.length),
|
|
2849
|
+
...params.proposerSig,
|
|
2850
|
+
// new_interest_assets array
|
|
2851
|
+
...serializeAssets(params.newInterestAssets)
|
|
2852
|
+
];
|
|
2853
|
+
return { contractAddress: this.address, entrypoint: "execute_renegotiation", calldata };
|
|
2854
|
+
}
|
|
2855
|
+
/** T1-5: Buy collateral from a borrower's sale offer */
|
|
2856
|
+
buildBuyCollateral(params) {
|
|
2857
|
+
const calldata = [
|
|
2858
|
+
...toU256(params.inscriptionId),
|
|
2859
|
+
// CollateralSaleOffer struct (7 fields)
|
|
2860
|
+
...toU256(params.offer.inscriptionId),
|
|
2861
|
+
params.offer.borrower,
|
|
2862
|
+
...toU256(params.offer.minPrice),
|
|
2863
|
+
params.offer.paymentToken,
|
|
2864
|
+
params.offer.allowedBuyer,
|
|
2865
|
+
params.offer.deadline.toString(),
|
|
2866
|
+
params.offer.nonce.toString(),
|
|
2867
|
+
// borrower_sig array
|
|
2868
|
+
String(params.borrowerSig.length),
|
|
2869
|
+
...params.borrowerSig,
|
|
2870
|
+
// sale_price
|
|
2871
|
+
...toU256(params.salePrice)
|
|
2872
|
+
];
|
|
2873
|
+
return { contractAddress: this.address, entrypoint: "buy_collateral", calldata };
|
|
2874
|
+
}
|
|
2875
|
+
/** T1-1: Refinance an existing loan with a new lender */
|
|
2876
|
+
buildRefinance(params) {
|
|
2877
|
+
const calldata = [
|
|
2878
|
+
// RefinanceOffer struct (9 fields)
|
|
2879
|
+
...toU256(params.offer.inscriptionId),
|
|
2880
|
+
params.offer.newLender,
|
|
2881
|
+
params.offer.newDebtHash,
|
|
2882
|
+
params.offer.newInterestHash,
|
|
2883
|
+
String(params.offer.newDebtCount),
|
|
2884
|
+
String(params.offer.newInterestCount),
|
|
2885
|
+
params.offer.newDuration.toString(),
|
|
2886
|
+
params.offer.deadline.toString(),
|
|
2887
|
+
params.offer.nonce.toString(),
|
|
2888
|
+
// new_debt_assets array
|
|
2889
|
+
...serializeAssets(params.newDebtAssets),
|
|
2890
|
+
// new_interest_assets array
|
|
2891
|
+
...serializeAssets(params.newInterestAssets),
|
|
2892
|
+
// new_lender_sig array
|
|
2893
|
+
String(params.newLenderSig.length),
|
|
2894
|
+
...params.newLenderSig,
|
|
2895
|
+
// RefinanceApproval struct (4 fields)
|
|
2896
|
+
...toU256(params.approval.inscriptionId),
|
|
2897
|
+
params.approval.offerHash,
|
|
2898
|
+
params.approval.borrower,
|
|
2899
|
+
params.approval.nonce.toString(),
|
|
2900
|
+
// borrower_sig array
|
|
2901
|
+
String(params.borrowerSig.length),
|
|
2902
|
+
...params.borrowerSig
|
|
2903
|
+
];
|
|
2904
|
+
return { contractAddress: this.address, entrypoint: "refinance", calldata };
|
|
2905
|
+
}
|
|
2906
|
+
/** T1-3: Start a Dutch auction on an expired, unfilled inscription */
|
|
2907
|
+
buildStartAuction(inscriptionId) {
|
|
2908
|
+
return {
|
|
2909
|
+
contractAddress: this.address,
|
|
2910
|
+
entrypoint: "start_auction",
|
|
2911
|
+
calldata: [...toU256(inscriptionId)]
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
/** T1-3: Bid on an active Dutch auction */
|
|
2915
|
+
buildBid(inscriptionId) {
|
|
2916
|
+
return {
|
|
2917
|
+
contractAddress: this.address,
|
|
2918
|
+
entrypoint: "bid",
|
|
2919
|
+
calldata: [...toU256(inscriptionId)]
|
|
2920
|
+
};
|
|
2921
|
+
}
|
|
2922
|
+
/** T1-3: Claim collateral after an auction expires with no bids */
|
|
2923
|
+
buildClaimCollateral(inscriptionId) {
|
|
2924
|
+
return {
|
|
2925
|
+
contractAddress: this.address,
|
|
2926
|
+
entrypoint: "claim_collateral",
|
|
2927
|
+
calldata: [...toU256(inscriptionId)]
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
// ── T1 Read Methods ──────────────────────────────────────────────────
|
|
2931
|
+
/** T1-3: Get the current Dutch auction price for a specific debt asset */
|
|
2932
|
+
async getAuctionPrice(inscriptionId, debtIndex) {
|
|
2933
|
+
const result = await this.contract.call("get_auction_price", [
|
|
2934
|
+
...toU256(inscriptionId),
|
|
2935
|
+
String(debtIndex)
|
|
2936
|
+
]);
|
|
2937
|
+
return extractU256(result);
|
|
2938
|
+
}
|
|
2939
|
+
/** T1-3: Get the auction end timestamp */
|
|
2940
|
+
async getAuctionEndTime(inscriptionId) {
|
|
2941
|
+
const result = await this.contract.call("get_auction_end_time", toU256(inscriptionId));
|
|
2942
|
+
return BigInt(String(result[0] ?? "0"));
|
|
2943
|
+
}
|
|
2627
2944
|
// ── Execute Methods ────────────────────────────────────────────────
|
|
2628
2945
|
/**
|
|
2629
2946
|
* Execute one or more calls via the connected account.
|
|
@@ -2665,6 +2982,35 @@ var InscriptionClient = class {
|
|
|
2665
2982
|
async cancelOrdersByNonce(minNonce) {
|
|
2666
2983
|
return this.execute([this.buildCancelOrdersByNonce(minNonce)]);
|
|
2667
2984
|
}
|
|
2985
|
+
// ── T1 Execute Methods ───────────────────────────────────────────────
|
|
2986
|
+
async settleCollection(params) {
|
|
2987
|
+
return this.execute([this.buildSettleCollection(params)]);
|
|
2988
|
+
}
|
|
2989
|
+
async commitRenegotiation(inscriptionId, proposalHash) {
|
|
2990
|
+
return this.execute([this.buildCommitRenegotiation(inscriptionId, proposalHash)]);
|
|
2991
|
+
}
|
|
2992
|
+
async executeRenegotiation(params, approvals) {
|
|
2993
|
+
const calls = [...approvals ?? [], this.buildExecuteRenegotiation(params)];
|
|
2994
|
+
return this.execute(calls);
|
|
2995
|
+
}
|
|
2996
|
+
async buyCollateral(params, approvals) {
|
|
2997
|
+
const calls = [...approvals ?? [], this.buildBuyCollateral(params)];
|
|
2998
|
+
return this.execute(calls);
|
|
2999
|
+
}
|
|
3000
|
+
async refinance(params, approvals) {
|
|
3001
|
+
const calls = [...approvals ?? [], this.buildRefinance(params)];
|
|
3002
|
+
return this.execute(calls);
|
|
3003
|
+
}
|
|
3004
|
+
async startAuction(inscriptionId) {
|
|
3005
|
+
return this.execute([this.buildStartAuction(inscriptionId)]);
|
|
3006
|
+
}
|
|
3007
|
+
async bid(inscriptionId, approvals) {
|
|
3008
|
+
const calls = [...approvals ?? [], this.buildBid(inscriptionId)];
|
|
3009
|
+
return this.execute(calls);
|
|
3010
|
+
}
|
|
3011
|
+
async claimCollateral(inscriptionId) {
|
|
3012
|
+
return this.execute([this.buildClaimCollateral(inscriptionId)]);
|
|
3013
|
+
}
|
|
2668
3014
|
};
|
|
2669
3015
|
function serializeAssets(assets) {
|
|
2670
3016
|
const calldata = [String(assets.length)];
|
|
@@ -2704,7 +3050,9 @@ function parseStoredInscription(result) {
|
|
|
2704
3050
|
multi_lender: Boolean(get("multi_lender", 8)),
|
|
2705
3051
|
debt_asset_count: Number(get("debt_asset_count", 9)),
|
|
2706
3052
|
interest_asset_count: Number(get("interest_asset_count", 10)),
|
|
2707
|
-
collateral_asset_count: Number(get("collateral_asset_count", 11))
|
|
3053
|
+
collateral_asset_count: Number(get("collateral_asset_count", 11)),
|
|
3054
|
+
auction_started: Boolean(get("auction_started", 12)),
|
|
3055
|
+
auction_start_time: BigInt(String(get("auction_start_time", 13) ?? "0"))
|
|
2708
3056
|
};
|
|
2709
3057
|
}
|
|
2710
3058
|
function extractFieldU256(val) {
|
|
@@ -3034,6 +3382,6 @@ var StelaSdk = class {
|
|
|
3034
3382
|
}
|
|
3035
3383
|
};
|
|
3036
3384
|
|
|
3037
|
-
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, ApiError, CHAIN_ID, EXPLORER_TX_URL, InscriptionClient, LockerClient, MAX_BPS, SELECTORS, STATUS_LABELS, STELA_ADDRESS, ShareClient, StelaSdk, TOKENS, VALID_STATUSES, VIRTUAL_SHARE_OFFSET, addressesEqual, calculateFeeShares, computeStatus, convertToShares, deserializeSignature, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, getBatchLendOfferTypedData, getInscriptionOrderTypedData, getLendOfferTypedData, getTokensForNetwork, hashAssets, hashBatchEntries, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, serializeSignature, sharesToPercentage, toHex, toU256 };
|
|
3385
|
+
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, AUCTION_DURATION, AUCTION_PENALTY_BPS, AUCTION_RESERVE_BPS, ApiClient, ApiError, CHAIN_ID, EXPLORER_TX_URL, GRACE_PERIOD, InscriptionClient, LockerClient, MAX_BPS, SELECTORS, STATUS_LABELS, STELA_ADDRESS, ShareClient, StelaSdk, TOKENS, VALID_STATUSES, VIRTUAL_SHARE_OFFSET, addressesEqual, calculateFeeShares, computeStatus, convertToShares, deserializeSignature, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, getBatchLendOfferTypedData, getCollateralSaleOfferTypedData, getCollectionBorrowAcceptanceTypedData, getCollectionLendOfferTypedData, getInscriptionOrderTypedData, getLendOfferTypedData, getRefinanceApprovalTypedData, getRefinanceOfferTypedData, getRenegotiationProposalTypedData, getTokensForNetwork, hashAssets, hashBatchEntries, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, serializeSignature, sharesToPercentage, toHex, toU256 };
|
|
3038
3386
|
//# sourceMappingURL=index.js.map
|
|
3039
3387
|
//# sourceMappingURL=index.js.map
|