@fepvenancio/stela-sdk 0.7.1 → 0.8.1

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.js CHANGED
@@ -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) {
@@ -867,6 +1050,210 @@ var stela_default = [
867
1050
  {
868
1051
  name: "collateral_asset_count",
869
1052
  type: "core::integer::u32"
1053
+ },
1054
+ {
1055
+ name: "auction_started",
1056
+ type: "core::bool"
1057
+ },
1058
+ {
1059
+ name: "auction_start_time",
1060
+ type: "core::integer::u64"
1061
+ }
1062
+ ]
1063
+ },
1064
+ {
1065
+ type: "struct",
1066
+ name: "stela::snip12::CollectionLendOffer",
1067
+ members: [
1068
+ {
1069
+ name: "lender",
1070
+ type: "core::starknet::contract_address::ContractAddress"
1071
+ },
1072
+ {
1073
+ name: "debt_hash",
1074
+ type: "core::felt252"
1075
+ },
1076
+ {
1077
+ name: "interest_hash",
1078
+ type: "core::felt252"
1079
+ },
1080
+ {
1081
+ name: "debt_count",
1082
+ type: "core::integer::u32"
1083
+ },
1084
+ {
1085
+ name: "interest_count",
1086
+ type: "core::integer::u32"
1087
+ },
1088
+ {
1089
+ name: "collection_address",
1090
+ type: "core::starknet::contract_address::ContractAddress"
1091
+ },
1092
+ {
1093
+ name: "duration",
1094
+ type: "core::integer::u64"
1095
+ },
1096
+ {
1097
+ name: "deadline",
1098
+ type: "core::integer::u64"
1099
+ },
1100
+ {
1101
+ name: "nonce",
1102
+ type: "core::felt252"
1103
+ }
1104
+ ]
1105
+ },
1106
+ {
1107
+ type: "struct",
1108
+ name: "stela::snip12::CollectionBorrowAcceptance",
1109
+ members: [
1110
+ {
1111
+ name: "offer_hash",
1112
+ type: "core::felt252"
1113
+ },
1114
+ {
1115
+ name: "borrower",
1116
+ type: "core::starknet::contract_address::ContractAddress"
1117
+ },
1118
+ {
1119
+ name: "token_id",
1120
+ type: "core::integer::u256"
1121
+ },
1122
+ {
1123
+ name: "nonce",
1124
+ type: "core::felt252"
1125
+ }
1126
+ ]
1127
+ },
1128
+ {
1129
+ type: "struct",
1130
+ name: "stela::snip12::RenegotiationProposal",
1131
+ members: [
1132
+ {
1133
+ name: "inscription_id",
1134
+ type: "core::integer::u256"
1135
+ },
1136
+ {
1137
+ name: "proposer",
1138
+ type: "core::starknet::contract_address::ContractAddress"
1139
+ },
1140
+ {
1141
+ name: "new_duration",
1142
+ type: "core::integer::u64"
1143
+ },
1144
+ {
1145
+ name: "new_interest_hash",
1146
+ type: "core::felt252"
1147
+ },
1148
+ {
1149
+ name: "new_interest_count",
1150
+ type: "core::integer::u32"
1151
+ },
1152
+ {
1153
+ name: "proposal_deadline",
1154
+ type: "core::integer::u64"
1155
+ },
1156
+ {
1157
+ name: "nonce",
1158
+ type: "core::felt252"
1159
+ }
1160
+ ]
1161
+ },
1162
+ {
1163
+ type: "struct",
1164
+ name: "stela::snip12::CollateralSaleOffer",
1165
+ members: [
1166
+ {
1167
+ name: "inscription_id",
1168
+ type: "core::integer::u256"
1169
+ },
1170
+ {
1171
+ name: "borrower",
1172
+ type: "core::starknet::contract_address::ContractAddress"
1173
+ },
1174
+ {
1175
+ name: "min_price",
1176
+ type: "core::integer::u256"
1177
+ },
1178
+ {
1179
+ name: "payment_token",
1180
+ type: "core::starknet::contract_address::ContractAddress"
1181
+ },
1182
+ {
1183
+ name: "allowed_buyer",
1184
+ type: "core::starknet::contract_address::ContractAddress"
1185
+ },
1186
+ {
1187
+ name: "deadline",
1188
+ type: "core::integer::u64"
1189
+ },
1190
+ {
1191
+ name: "nonce",
1192
+ type: "core::felt252"
1193
+ }
1194
+ ]
1195
+ },
1196
+ {
1197
+ type: "struct",
1198
+ name: "stela::snip12::RefinanceOffer",
1199
+ members: [
1200
+ {
1201
+ name: "inscription_id",
1202
+ type: "core::integer::u256"
1203
+ },
1204
+ {
1205
+ name: "new_lender",
1206
+ type: "core::starknet::contract_address::ContractAddress"
1207
+ },
1208
+ {
1209
+ name: "new_debt_hash",
1210
+ type: "core::felt252"
1211
+ },
1212
+ {
1213
+ name: "new_interest_hash",
1214
+ type: "core::felt252"
1215
+ },
1216
+ {
1217
+ name: "new_debt_count",
1218
+ type: "core::integer::u32"
1219
+ },
1220
+ {
1221
+ name: "new_interest_count",
1222
+ type: "core::integer::u32"
1223
+ },
1224
+ {
1225
+ name: "new_duration",
1226
+ type: "core::integer::u64"
1227
+ },
1228
+ {
1229
+ name: "deadline",
1230
+ type: "core::integer::u64"
1231
+ },
1232
+ {
1233
+ name: "nonce",
1234
+ type: "core::felt252"
1235
+ }
1236
+ ]
1237
+ },
1238
+ {
1239
+ type: "struct",
1240
+ name: "stela::snip12::RefinanceApproval",
1241
+ members: [
1242
+ {
1243
+ name: "inscription_id",
1244
+ type: "core::integer::u256"
1245
+ },
1246
+ {
1247
+ name: "offer_hash",
1248
+ type: "core::felt252"
1249
+ },
1250
+ {
1251
+ name: "borrower",
1252
+ type: "core::starknet::contract_address::ContractAddress"
1253
+ },
1254
+ {
1255
+ name: "nonce",
1256
+ type: "core::felt252"
870
1257
  }
871
1258
  ]
872
1259
  },
@@ -1419,6 +1806,206 @@ var stela_default = [
1419
1806
  ],
1420
1807
  outputs: [],
1421
1808
  state_mutability: "external"
1809
+ },
1810
+ {
1811
+ type: "function",
1812
+ name: "settle_collection",
1813
+ inputs: [
1814
+ {
1815
+ name: "offer",
1816
+ type: "stela::snip12::CollectionLendOffer"
1817
+ },
1818
+ {
1819
+ name: "acceptance",
1820
+ type: "stela::snip12::CollectionBorrowAcceptance"
1821
+ },
1822
+ {
1823
+ name: "debt_assets",
1824
+ type: "core::array::Array::<stela::types::asset::Asset>"
1825
+ },
1826
+ {
1827
+ name: "interest_assets",
1828
+ type: "core::array::Array::<stela::types::asset::Asset>"
1829
+ },
1830
+ {
1831
+ name: "lender_sig",
1832
+ type: "core::array::Array::<core::felt252>"
1833
+ },
1834
+ {
1835
+ name: "borrower_sig",
1836
+ type: "core::array::Array::<core::felt252>"
1837
+ }
1838
+ ],
1839
+ outputs: [],
1840
+ state_mutability: "external"
1841
+ },
1842
+ {
1843
+ type: "function",
1844
+ name: "commit_renegotiation",
1845
+ inputs: [
1846
+ {
1847
+ name: "inscription_id",
1848
+ type: "core::integer::u256"
1849
+ },
1850
+ {
1851
+ name: "proposal_hash",
1852
+ type: "core::felt252"
1853
+ }
1854
+ ],
1855
+ outputs: [],
1856
+ state_mutability: "external"
1857
+ },
1858
+ {
1859
+ type: "function",
1860
+ name: "execute_renegotiation",
1861
+ inputs: [
1862
+ {
1863
+ name: "inscription_id",
1864
+ type: "core::integer::u256"
1865
+ },
1866
+ {
1867
+ name: "proposal",
1868
+ type: "stela::snip12::RenegotiationProposal"
1869
+ },
1870
+ {
1871
+ name: "proposer_sig",
1872
+ type: "core::array::Array::<core::felt252>"
1873
+ },
1874
+ {
1875
+ name: "new_interest_assets",
1876
+ type: "core::array::Array::<stela::types::asset::Asset>"
1877
+ }
1878
+ ],
1879
+ outputs: [],
1880
+ state_mutability: "external"
1881
+ },
1882
+ {
1883
+ type: "function",
1884
+ name: "buy_collateral",
1885
+ inputs: [
1886
+ {
1887
+ name: "inscription_id",
1888
+ type: "core::integer::u256"
1889
+ },
1890
+ {
1891
+ name: "offer",
1892
+ type: "stela::snip12::CollateralSaleOffer"
1893
+ },
1894
+ {
1895
+ name: "borrower_sig",
1896
+ type: "core::array::Array::<core::felt252>"
1897
+ },
1898
+ {
1899
+ name: "sale_price",
1900
+ type: "core::integer::u256"
1901
+ }
1902
+ ],
1903
+ outputs: [],
1904
+ state_mutability: "external"
1905
+ },
1906
+ {
1907
+ type: "function",
1908
+ name: "refinance",
1909
+ inputs: [
1910
+ {
1911
+ name: "offer",
1912
+ type: "stela::snip12::RefinanceOffer"
1913
+ },
1914
+ {
1915
+ name: "new_debt_assets",
1916
+ type: "core::array::Array::<stela::types::asset::Asset>"
1917
+ },
1918
+ {
1919
+ name: "new_interest_assets",
1920
+ type: "core::array::Array::<stela::types::asset::Asset>"
1921
+ },
1922
+ {
1923
+ name: "new_lender_sig",
1924
+ type: "core::array::Array::<core::felt252>"
1925
+ },
1926
+ {
1927
+ name: "approval",
1928
+ type: "stela::snip12::RefinanceApproval"
1929
+ },
1930
+ {
1931
+ name: "borrower_sig",
1932
+ type: "core::array::Array::<core::felt252>"
1933
+ }
1934
+ ],
1935
+ outputs: [],
1936
+ state_mutability: "external"
1937
+ },
1938
+ {
1939
+ type: "function",
1940
+ name: "start_auction",
1941
+ inputs: [
1942
+ {
1943
+ name: "inscription_id",
1944
+ type: "core::integer::u256"
1945
+ }
1946
+ ],
1947
+ outputs: [],
1948
+ state_mutability: "external"
1949
+ },
1950
+ {
1951
+ type: "function",
1952
+ name: "bid",
1953
+ inputs: [
1954
+ {
1955
+ name: "inscription_id",
1956
+ type: "core::integer::u256"
1957
+ }
1958
+ ],
1959
+ outputs: [],
1960
+ state_mutability: "external"
1961
+ },
1962
+ {
1963
+ type: "function",
1964
+ name: "claim_collateral",
1965
+ inputs: [
1966
+ {
1967
+ name: "inscription_id",
1968
+ type: "core::integer::u256"
1969
+ }
1970
+ ],
1971
+ outputs: [],
1972
+ state_mutability: "external"
1973
+ },
1974
+ {
1975
+ type: "function",
1976
+ name: "get_auction_price",
1977
+ inputs: [
1978
+ {
1979
+ name: "inscription_id",
1980
+ type: "core::integer::u256"
1981
+ },
1982
+ {
1983
+ name: "debt_index",
1984
+ type: "core::integer::u32"
1985
+ }
1986
+ ],
1987
+ outputs: [
1988
+ {
1989
+ type: "core::integer::u256"
1990
+ }
1991
+ ],
1992
+ state_mutability: "view"
1993
+ },
1994
+ {
1995
+ type: "function",
1996
+ name: "get_auction_end_time",
1997
+ inputs: [
1998
+ {
1999
+ name: "inscription_id",
2000
+ type: "core::integer::u256"
2001
+ }
2002
+ ],
2003
+ outputs: [
2004
+ {
2005
+ type: "core::integer::u64"
2006
+ }
2007
+ ],
2008
+ state_mutability: "view"
1422
2009
  }
1423
2010
  ]
1424
2011
  },
@@ -2609,6 +3196,155 @@ var InscriptionClient = class {
2609
3196
  calldata: [minNonce]
2610
3197
  };
2611
3198
  }
3199
+ // ── T1 Call Builders ─────────────────────────────────────────────────
3200
+ /** T1-2: Settle a collection-wide lend offer */
3201
+ buildSettleCollection(params) {
3202
+ const calldata = [
3203
+ // CollectionLendOffer struct (9 fields)
3204
+ params.offer.lender,
3205
+ params.offer.debtHash,
3206
+ params.offer.interestHash,
3207
+ String(params.offer.debtCount),
3208
+ String(params.offer.interestCount),
3209
+ params.offer.collectionAddress,
3210
+ params.offer.duration.toString(),
3211
+ params.offer.deadline.toString(),
3212
+ params.offer.nonce.toString(),
3213
+ // CollectionBorrowAcceptance struct (4 fields)
3214
+ params.acceptance.offerHash,
3215
+ params.acceptance.borrower,
3216
+ ...toU256(params.acceptance.tokenId),
3217
+ params.acceptance.nonce.toString(),
3218
+ // debt_assets array
3219
+ ...serializeAssets(params.debtAssets),
3220
+ // interest_assets array
3221
+ ...serializeAssets(params.interestAssets),
3222
+ // lender_sig array
3223
+ String(params.lenderSig.length),
3224
+ ...params.lenderSig,
3225
+ // borrower_sig array
3226
+ String(params.borrowerSig.length),
3227
+ ...params.borrowerSig
3228
+ ];
3229
+ return { contractAddress: this.address, entrypoint: "settle_collection", calldata };
3230
+ }
3231
+ /** T1-4: Commit a renegotiation proposal hash on-chain */
3232
+ buildCommitRenegotiation(inscriptionId, proposalHash) {
3233
+ return {
3234
+ contractAddress: this.address,
3235
+ entrypoint: "commit_renegotiation",
3236
+ calldata: [...toU256(inscriptionId), proposalHash]
3237
+ };
3238
+ }
3239
+ /** T1-4: Execute a committed renegotiation proposal */
3240
+ buildExecuteRenegotiation(params) {
3241
+ const calldata = [
3242
+ ...toU256(params.inscriptionId),
3243
+ // RenegotiationProposal struct (7 fields)
3244
+ ...toU256(params.proposal.inscriptionId),
3245
+ params.proposal.proposer,
3246
+ params.proposal.newDuration.toString(),
3247
+ params.proposal.newInterestHash,
3248
+ String(params.proposal.newInterestCount),
3249
+ params.proposal.proposalDeadline.toString(),
3250
+ params.proposal.nonce.toString(),
3251
+ // proposer_sig array
3252
+ String(params.proposerSig.length),
3253
+ ...params.proposerSig,
3254
+ // new_interest_assets array
3255
+ ...serializeAssets(params.newInterestAssets)
3256
+ ];
3257
+ return { contractAddress: this.address, entrypoint: "execute_renegotiation", calldata };
3258
+ }
3259
+ /** T1-5: Buy collateral from a borrower's sale offer */
3260
+ buildBuyCollateral(params) {
3261
+ const calldata = [
3262
+ ...toU256(params.inscriptionId),
3263
+ // CollateralSaleOffer struct (7 fields)
3264
+ ...toU256(params.offer.inscriptionId),
3265
+ params.offer.borrower,
3266
+ ...toU256(params.offer.minPrice),
3267
+ params.offer.paymentToken,
3268
+ params.offer.allowedBuyer,
3269
+ params.offer.deadline.toString(),
3270
+ params.offer.nonce.toString(),
3271
+ // borrower_sig array
3272
+ String(params.borrowerSig.length),
3273
+ ...params.borrowerSig,
3274
+ // sale_price
3275
+ ...toU256(params.salePrice)
3276
+ ];
3277
+ return { contractAddress: this.address, entrypoint: "buy_collateral", calldata };
3278
+ }
3279
+ /** T1-1: Refinance an existing loan with a new lender */
3280
+ buildRefinance(params) {
3281
+ const calldata = [
3282
+ // RefinanceOffer struct (9 fields)
3283
+ ...toU256(params.offer.inscriptionId),
3284
+ params.offer.newLender,
3285
+ params.offer.newDebtHash,
3286
+ params.offer.newInterestHash,
3287
+ String(params.offer.newDebtCount),
3288
+ String(params.offer.newInterestCount),
3289
+ params.offer.newDuration.toString(),
3290
+ params.offer.deadline.toString(),
3291
+ params.offer.nonce.toString(),
3292
+ // new_debt_assets array
3293
+ ...serializeAssets(params.newDebtAssets),
3294
+ // new_interest_assets array
3295
+ ...serializeAssets(params.newInterestAssets),
3296
+ // new_lender_sig array
3297
+ String(params.newLenderSig.length),
3298
+ ...params.newLenderSig,
3299
+ // RefinanceApproval struct (4 fields)
3300
+ ...toU256(params.approval.inscriptionId),
3301
+ params.approval.offerHash,
3302
+ params.approval.borrower,
3303
+ params.approval.nonce.toString(),
3304
+ // borrower_sig array
3305
+ String(params.borrowerSig.length),
3306
+ ...params.borrowerSig
3307
+ ];
3308
+ return { contractAddress: this.address, entrypoint: "refinance", calldata };
3309
+ }
3310
+ /** T1-3: Start a Dutch auction on an expired, unfilled inscription */
3311
+ buildStartAuction(inscriptionId) {
3312
+ return {
3313
+ contractAddress: this.address,
3314
+ entrypoint: "start_auction",
3315
+ calldata: [...toU256(inscriptionId)]
3316
+ };
3317
+ }
3318
+ /** T1-3: Bid on an active Dutch auction */
3319
+ buildBid(inscriptionId) {
3320
+ return {
3321
+ contractAddress: this.address,
3322
+ entrypoint: "bid",
3323
+ calldata: [...toU256(inscriptionId)]
3324
+ };
3325
+ }
3326
+ /** T1-3: Claim collateral after an auction expires with no bids */
3327
+ buildClaimCollateral(inscriptionId) {
3328
+ return {
3329
+ contractAddress: this.address,
3330
+ entrypoint: "claim_collateral",
3331
+ calldata: [...toU256(inscriptionId)]
3332
+ };
3333
+ }
3334
+ // ── T1 Read Methods ──────────────────────────────────────────────────
3335
+ /** T1-3: Get the current Dutch auction price for a specific debt asset */
3336
+ async getAuctionPrice(inscriptionId, debtIndex) {
3337
+ const result = await this.contract.call("get_auction_price", [
3338
+ ...toU256(inscriptionId),
3339
+ String(debtIndex)
3340
+ ]);
3341
+ return extractU256(result);
3342
+ }
3343
+ /** T1-3: Get the auction end timestamp */
3344
+ async getAuctionEndTime(inscriptionId) {
3345
+ const result = await this.contract.call("get_auction_end_time", toU256(inscriptionId));
3346
+ return BigInt(String(result[0] ?? "0"));
3347
+ }
2612
3348
  // ── Execute Methods ────────────────────────────────────────────────
2613
3349
  /**
2614
3350
  * Execute one or more calls via the connected account.
@@ -2650,6 +3386,35 @@ var InscriptionClient = class {
2650
3386
  async cancelOrdersByNonce(minNonce) {
2651
3387
  return this.execute([this.buildCancelOrdersByNonce(minNonce)]);
2652
3388
  }
3389
+ // ── T1 Execute Methods ───────────────────────────────────────────────
3390
+ async settleCollection(params) {
3391
+ return this.execute([this.buildSettleCollection(params)]);
3392
+ }
3393
+ async commitRenegotiation(inscriptionId, proposalHash) {
3394
+ return this.execute([this.buildCommitRenegotiation(inscriptionId, proposalHash)]);
3395
+ }
3396
+ async executeRenegotiation(params, approvals) {
3397
+ const calls = [...approvals ?? [], this.buildExecuteRenegotiation(params)];
3398
+ return this.execute(calls);
3399
+ }
3400
+ async buyCollateral(params, approvals) {
3401
+ const calls = [...approvals ?? [], this.buildBuyCollateral(params)];
3402
+ return this.execute(calls);
3403
+ }
3404
+ async refinance(params, approvals) {
3405
+ const calls = [...approvals ?? [], this.buildRefinance(params)];
3406
+ return this.execute(calls);
3407
+ }
3408
+ async startAuction(inscriptionId) {
3409
+ return this.execute([this.buildStartAuction(inscriptionId)]);
3410
+ }
3411
+ async bid(inscriptionId, approvals) {
3412
+ const calls = [...approvals ?? [], this.buildBid(inscriptionId)];
3413
+ return this.execute(calls);
3414
+ }
3415
+ async claimCollateral(inscriptionId) {
3416
+ return this.execute([this.buildClaimCollateral(inscriptionId)]);
3417
+ }
2653
3418
  };
2654
3419
  function serializeAssets(assets) {
2655
3420
  const calldata = [String(assets.length)];
@@ -2689,7 +3454,9 @@ function parseStoredInscription(result) {
2689
3454
  multi_lender: Boolean(get("multi_lender", 8)),
2690
3455
  debt_asset_count: Number(get("debt_asset_count", 9)),
2691
3456
  interest_asset_count: Number(get("interest_asset_count", 10)),
2692
- collateral_asset_count: Number(get("collateral_asset_count", 11))
3457
+ collateral_asset_count: Number(get("collateral_asset_count", 11)),
3458
+ auction_started: Boolean(get("auction_started", 12)),
3459
+ auction_start_time: BigInt(String(get("auction_start_time", 13) ?? "0"))
2693
3460
  };
2694
3461
  }
2695
3462
  function extractFieldU256(val) {
@@ -3019,6 +3786,6 @@ var StelaSdk = class {
3019
3786
  }
3020
3787
  };
3021
3788
 
3022
- 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 };
3789
+ 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 };
3023
3790
  //# sourceMappingURL=index.js.map
3024
3791
  //# sourceMappingURL=index.js.map