@fepvenancio/stela-sdk 0.2.3 → 0.4.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/README.md +347 -79
- package/dist/index.cjs +605 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +235 -2
- package/dist/index.d.ts +235 -2
- package/dist/index.js +600 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/stela.json +365 -10
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hash, uint256, addAddressPadding, validateAndParseAddress, Contract } from 'starknet';
|
|
1
|
+
import { hash, shortString, uint256, addAddressPadding, validateAndParseAddress, Contract } from 'starknet';
|
|
2
2
|
|
|
3
3
|
// src/types/common.ts
|
|
4
4
|
var VALID_STATUSES = [
|
|
@@ -22,7 +22,7 @@ var STATUS_LABELS = {
|
|
|
22
22
|
|
|
23
23
|
// src/constants/addresses.ts
|
|
24
24
|
var STELA_ADDRESS = {
|
|
25
|
-
sepolia: "
|
|
25
|
+
sepolia: "0x00b7deedb4ab03d94f54da2e7c911c2336b19c2a4610eb98f55cd7be5a53ece0",
|
|
26
26
|
mainnet: "0x0"
|
|
27
27
|
};
|
|
28
28
|
var VALID_NETWORKS = ["sepolia", "mainnet"];
|
|
@@ -281,7 +281,11 @@ var SELECTORS = {
|
|
|
281
281
|
InscriptionRepaid: hash.getSelectorFromName("InscriptionRepaid"),
|
|
282
282
|
InscriptionLiquidated: hash.getSelectorFromName("InscriptionLiquidated"),
|
|
283
283
|
SharesRedeemed: hash.getSelectorFromName("SharesRedeemed"),
|
|
284
|
-
TransferSingle: hash.getSelectorFromName("TransferSingle")
|
|
284
|
+
TransferSingle: hash.getSelectorFromName("TransferSingle"),
|
|
285
|
+
OrderSettled: hash.getSelectorFromName("OrderSettled"),
|
|
286
|
+
OrderFilled: hash.getSelectorFromName("OrderFilled"),
|
|
287
|
+
OrderCancelled: hash.getSelectorFromName("OrderCancelled"),
|
|
288
|
+
OrdersBulkCancelled: hash.getSelectorFromName("OrdersBulkCancelled")
|
|
285
289
|
};
|
|
286
290
|
function feltsToU256(low, high) {
|
|
287
291
|
return uint256.uint256ToBN({ low: BigInt(low), high: BigInt(high) });
|
|
@@ -360,6 +364,48 @@ function parseEvent(raw) {
|
|
|
360
364
|
block_number: raw.block_number
|
|
361
365
|
};
|
|
362
366
|
}
|
|
367
|
+
case SELECTORS.OrderSettled: {
|
|
368
|
+
return {
|
|
369
|
+
type: "OrderSettled",
|
|
370
|
+
inscription_id: feltsToU256(raw.keys[1], raw.keys[2]),
|
|
371
|
+
borrower: raw.keys[3],
|
|
372
|
+
lender: raw.keys[4],
|
|
373
|
+
relayer: raw.data[0],
|
|
374
|
+
relayer_fee_amount: feltsToU256(raw.data[1], raw.data[2]),
|
|
375
|
+
transaction_hash: raw.transaction_hash,
|
|
376
|
+
block_number: raw.block_number
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
case SELECTORS.OrderFilled: {
|
|
380
|
+
return {
|
|
381
|
+
type: "OrderFilled",
|
|
382
|
+
inscription_id: feltsToU256(raw.keys[1], raw.keys[2]),
|
|
383
|
+
order_hash: raw.keys[3],
|
|
384
|
+
taker: raw.keys[4],
|
|
385
|
+
fill_bps: feltsToU256(raw.data[0], raw.data[1]),
|
|
386
|
+
total_filled_bps: feltsToU256(raw.data[2], raw.data[3]),
|
|
387
|
+
transaction_hash: raw.transaction_hash,
|
|
388
|
+
block_number: raw.block_number
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
case SELECTORS.OrderCancelled: {
|
|
392
|
+
return {
|
|
393
|
+
type: "OrderCancelled",
|
|
394
|
+
order_hash: raw.keys[1],
|
|
395
|
+
maker: raw.data[0],
|
|
396
|
+
transaction_hash: raw.transaction_hash,
|
|
397
|
+
block_number: raw.block_number
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
case SELECTORS.OrdersBulkCancelled: {
|
|
401
|
+
return {
|
|
402
|
+
type: "OrdersBulkCancelled",
|
|
403
|
+
maker: raw.keys[1],
|
|
404
|
+
new_min_nonce: raw.data[0],
|
|
405
|
+
transaction_hash: raw.transaction_hash,
|
|
406
|
+
block_number: raw.block_number
|
|
407
|
+
};
|
|
408
|
+
}
|
|
363
409
|
default:
|
|
364
410
|
return null;
|
|
365
411
|
}
|
|
@@ -436,6 +482,16 @@ function getInscriptionOrderTypedData(params) {
|
|
|
436
482
|
}
|
|
437
483
|
};
|
|
438
484
|
}
|
|
485
|
+
function getPrivateLendOfferTypedData(params) {
|
|
486
|
+
return getLendOfferTypedData({
|
|
487
|
+
orderHash: params.orderHash,
|
|
488
|
+
lender: "0x0",
|
|
489
|
+
issuedDebtPercentage: params.issuedDebtPercentage,
|
|
490
|
+
nonce: params.nonce,
|
|
491
|
+
chainId: params.chainId,
|
|
492
|
+
lenderCommitment: params.depositCommitment
|
|
493
|
+
});
|
|
494
|
+
}
|
|
439
495
|
function getLendOfferTypedData(params) {
|
|
440
496
|
return {
|
|
441
497
|
types: {
|
|
@@ -449,7 +505,8 @@ function getLendOfferTypedData(params) {
|
|
|
449
505
|
{ name: "order_hash", type: "felt" },
|
|
450
506
|
{ name: "lender", type: "ContractAddress" },
|
|
451
507
|
{ name: "issued_debt_percentage", type: "u256" },
|
|
452
|
-
{ name: "nonce", type: "felt" }
|
|
508
|
+
{ name: "nonce", type: "felt" },
|
|
509
|
+
{ name: "lender_commitment", type: "felt" }
|
|
453
510
|
],
|
|
454
511
|
u256: [
|
|
455
512
|
{ name: "low", type: "u128" },
|
|
@@ -468,7 +525,8 @@ function getLendOfferTypedData(params) {
|
|
|
468
525
|
low: (params.issuedDebtPercentage & (1n << 128n) - 1n).toString(),
|
|
469
526
|
high: (params.issuedDebtPercentage >> 128n).toString()
|
|
470
527
|
},
|
|
471
|
-
nonce: params.nonce.toString()
|
|
528
|
+
nonce: params.nonce.toString(),
|
|
529
|
+
lender_commitment: params.lenderCommitment ?? "0"
|
|
472
530
|
}
|
|
473
531
|
};
|
|
474
532
|
}
|
|
@@ -480,6 +538,54 @@ function serializeSignature(sig) {
|
|
|
480
538
|
function deserializeSignature(stored) {
|
|
481
539
|
return [stored.r, stored.s];
|
|
482
540
|
}
|
|
541
|
+
var COMMITMENT_DOMAIN = shortString.encodeShortString("STELA_COMMITMENT_V1");
|
|
542
|
+
var NULLIFIER_DOMAIN = shortString.encodeShortString("STELA_NULLIFIER_V1");
|
|
543
|
+
function computeCommitment(owner, inscriptionId, shares, salt) {
|
|
544
|
+
const [idLow, idHigh] = toU256(inscriptionId);
|
|
545
|
+
const [sharesLow, sharesHigh] = toU256(shares);
|
|
546
|
+
return hash.computePoseidonHashOnElements([
|
|
547
|
+
COMMITMENT_DOMAIN,
|
|
548
|
+
owner,
|
|
549
|
+
idLow,
|
|
550
|
+
idHigh,
|
|
551
|
+
sharesLow,
|
|
552
|
+
sharesHigh,
|
|
553
|
+
salt
|
|
554
|
+
]);
|
|
555
|
+
}
|
|
556
|
+
function computeNullifier(commitment, ownerSecret) {
|
|
557
|
+
return hash.computePoseidonHashOnElements([NULLIFIER_DOMAIN, commitment, ownerSecret]);
|
|
558
|
+
}
|
|
559
|
+
function hashPair(left, right) {
|
|
560
|
+
return hash.computePoseidonHashOnElements([left, right]);
|
|
561
|
+
}
|
|
562
|
+
function generateSalt() {
|
|
563
|
+
const bytes = new Uint8Array(31);
|
|
564
|
+
crypto.getRandomValues(bytes);
|
|
565
|
+
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
566
|
+
}
|
|
567
|
+
function computeDepositCommitment(depositor, token, amount, salt) {
|
|
568
|
+
const [amountLow, amountHigh] = toU256(amount);
|
|
569
|
+
return hash.computePoseidonHashOnElements([
|
|
570
|
+
COMMITMENT_DOMAIN,
|
|
571
|
+
depositor,
|
|
572
|
+
token,
|
|
573
|
+
amountLow,
|
|
574
|
+
amountHigh,
|
|
575
|
+
"0x" + salt.toString(16)
|
|
576
|
+
]);
|
|
577
|
+
}
|
|
578
|
+
function createPrivateNote(owner, inscriptionId, shares, salt) {
|
|
579
|
+
const noteSalt = salt ?? generateSalt();
|
|
580
|
+
const commitment = computeCommitment(owner, inscriptionId, shares, noteSalt);
|
|
581
|
+
return {
|
|
582
|
+
owner,
|
|
583
|
+
inscriptionId,
|
|
584
|
+
shares,
|
|
585
|
+
salt: noteSalt,
|
|
586
|
+
commitment
|
|
587
|
+
};
|
|
588
|
+
}
|
|
483
589
|
|
|
484
590
|
// src/abi/stela.json
|
|
485
591
|
var stela_default = [
|
|
@@ -594,6 +700,46 @@ var stela_default = [
|
|
|
594
700
|
}
|
|
595
701
|
]
|
|
596
702
|
},
|
|
703
|
+
{
|
|
704
|
+
type: "struct",
|
|
705
|
+
name: "stela::types::private_redeem::PrivateRedeemRequest",
|
|
706
|
+
members: [
|
|
707
|
+
{
|
|
708
|
+
name: "root",
|
|
709
|
+
type: "core::felt252"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
name: "inscription_id",
|
|
713
|
+
type: "core::integer::u256"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
name: "shares",
|
|
717
|
+
type: "core::integer::u256"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
name: "nullifier",
|
|
721
|
+
type: "core::felt252"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
name: "change_commitment",
|
|
725
|
+
type: "core::felt252"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
name: "recipient",
|
|
729
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
730
|
+
}
|
|
731
|
+
]
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
type: "struct",
|
|
735
|
+
name: "core::array::Span::<core::felt252>",
|
|
736
|
+
members: [
|
|
737
|
+
{
|
|
738
|
+
name: "snapshot",
|
|
739
|
+
type: "@core::array::Array::<core::felt252>"
|
|
740
|
+
}
|
|
741
|
+
]
|
|
742
|
+
},
|
|
597
743
|
{
|
|
598
744
|
type: "struct",
|
|
599
745
|
name: "stela::snip12::InscriptionOrder",
|
|
@@ -663,6 +809,44 @@ var stela_default = [
|
|
|
663
809
|
{
|
|
664
810
|
name: "nonce",
|
|
665
811
|
type: "core::felt252"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
name: "lender_commitment",
|
|
815
|
+
type: "core::felt252"
|
|
816
|
+
}
|
|
817
|
+
]
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
type: "struct",
|
|
821
|
+
name: "stela::types::signed_order::SignedOrder",
|
|
822
|
+
members: [
|
|
823
|
+
{
|
|
824
|
+
name: "maker",
|
|
825
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
name: "allowed_taker",
|
|
829
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
name: "inscription_id",
|
|
833
|
+
type: "core::integer::u256"
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
name: "bps",
|
|
837
|
+
type: "core::integer::u256"
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
name: "deadline",
|
|
841
|
+
type: "core::integer::u64"
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
name: "nonce",
|
|
845
|
+
type: "core::felt252"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
name: "min_fill_bps",
|
|
849
|
+
type: "core::integer::u256"
|
|
666
850
|
}
|
|
667
851
|
]
|
|
668
852
|
},
|
|
@@ -808,6 +992,22 @@ var stela_default = [
|
|
|
808
992
|
outputs: [],
|
|
809
993
|
state_mutability: "external"
|
|
810
994
|
},
|
|
995
|
+
{
|
|
996
|
+
type: "function",
|
|
997
|
+
name: "private_redeem",
|
|
998
|
+
inputs: [
|
|
999
|
+
{
|
|
1000
|
+
name: "request",
|
|
1001
|
+
type: "stela::types::private_redeem::PrivateRedeemRequest"
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
name: "proof",
|
|
1005
|
+
type: "core::array::Span::<core::felt252>"
|
|
1006
|
+
}
|
|
1007
|
+
],
|
|
1008
|
+
outputs: [],
|
|
1009
|
+
state_mutability: "external"
|
|
1010
|
+
},
|
|
811
1011
|
{
|
|
812
1012
|
type: "function",
|
|
813
1013
|
name: "settle",
|
|
@@ -844,6 +1044,50 @@ var stela_default = [
|
|
|
844
1044
|
outputs: [],
|
|
845
1045
|
state_mutability: "external"
|
|
846
1046
|
},
|
|
1047
|
+
{
|
|
1048
|
+
type: "function",
|
|
1049
|
+
name: "fill_signed_order",
|
|
1050
|
+
inputs: [
|
|
1051
|
+
{
|
|
1052
|
+
name: "order",
|
|
1053
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
name: "signature",
|
|
1057
|
+
type: "core::array::Array::<core::felt252>"
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
name: "fill_bps",
|
|
1061
|
+
type: "core::integer::u256"
|
|
1062
|
+
}
|
|
1063
|
+
],
|
|
1064
|
+
outputs: [],
|
|
1065
|
+
state_mutability: "external"
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
type: "function",
|
|
1069
|
+
name: "cancel_order",
|
|
1070
|
+
inputs: [
|
|
1071
|
+
{
|
|
1072
|
+
name: "order",
|
|
1073
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1074
|
+
}
|
|
1075
|
+
],
|
|
1076
|
+
outputs: [],
|
|
1077
|
+
state_mutability: "external"
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
type: "function",
|
|
1081
|
+
name: "cancel_orders_by_nonce",
|
|
1082
|
+
inputs: [
|
|
1083
|
+
{
|
|
1084
|
+
name: "min_nonce",
|
|
1085
|
+
type: "core::felt252"
|
|
1086
|
+
}
|
|
1087
|
+
],
|
|
1088
|
+
outputs: [],
|
|
1089
|
+
state_mutability: "external"
|
|
1090
|
+
},
|
|
847
1091
|
{
|
|
848
1092
|
type: "function",
|
|
849
1093
|
name: "get_inscription",
|
|
@@ -956,6 +1200,81 @@ var stela_default = [
|
|
|
956
1200
|
],
|
|
957
1201
|
state_mutability: "view"
|
|
958
1202
|
},
|
|
1203
|
+
{
|
|
1204
|
+
type: "function",
|
|
1205
|
+
name: "is_order_registered",
|
|
1206
|
+
inputs: [
|
|
1207
|
+
{
|
|
1208
|
+
name: "order_hash",
|
|
1209
|
+
type: "core::felt252"
|
|
1210
|
+
}
|
|
1211
|
+
],
|
|
1212
|
+
outputs: [
|
|
1213
|
+
{
|
|
1214
|
+
type: "core::bool"
|
|
1215
|
+
}
|
|
1216
|
+
],
|
|
1217
|
+
state_mutability: "view"
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
type: "function",
|
|
1221
|
+
name: "is_order_cancelled",
|
|
1222
|
+
inputs: [
|
|
1223
|
+
{
|
|
1224
|
+
name: "order_hash",
|
|
1225
|
+
type: "core::felt252"
|
|
1226
|
+
}
|
|
1227
|
+
],
|
|
1228
|
+
outputs: [
|
|
1229
|
+
{
|
|
1230
|
+
type: "core::bool"
|
|
1231
|
+
}
|
|
1232
|
+
],
|
|
1233
|
+
state_mutability: "view"
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
type: "function",
|
|
1237
|
+
name: "get_filled_bps",
|
|
1238
|
+
inputs: [
|
|
1239
|
+
{
|
|
1240
|
+
name: "order_hash",
|
|
1241
|
+
type: "core::felt252"
|
|
1242
|
+
}
|
|
1243
|
+
],
|
|
1244
|
+
outputs: [
|
|
1245
|
+
{
|
|
1246
|
+
type: "core::integer::u256"
|
|
1247
|
+
}
|
|
1248
|
+
],
|
|
1249
|
+
state_mutability: "view"
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
type: "function",
|
|
1253
|
+
name: "get_maker_min_nonce",
|
|
1254
|
+
inputs: [
|
|
1255
|
+
{
|
|
1256
|
+
name: "maker",
|
|
1257
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1258
|
+
}
|
|
1259
|
+
],
|
|
1260
|
+
outputs: [
|
|
1261
|
+
{
|
|
1262
|
+
type: "core::felt252"
|
|
1263
|
+
}
|
|
1264
|
+
],
|
|
1265
|
+
state_mutability: "view"
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
type: "function",
|
|
1269
|
+
name: "get_privacy_pool",
|
|
1270
|
+
inputs: [],
|
|
1271
|
+
outputs: [
|
|
1272
|
+
{
|
|
1273
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1274
|
+
}
|
|
1275
|
+
],
|
|
1276
|
+
state_mutability: "view"
|
|
1277
|
+
},
|
|
959
1278
|
{
|
|
960
1279
|
type: "function",
|
|
961
1280
|
name: "set_inscription_fee",
|
|
@@ -1028,6 +1347,18 @@ var stela_default = [
|
|
|
1028
1347
|
outputs: [],
|
|
1029
1348
|
state_mutability: "external"
|
|
1030
1349
|
},
|
|
1350
|
+
{
|
|
1351
|
+
type: "function",
|
|
1352
|
+
name: "set_privacy_pool",
|
|
1353
|
+
inputs: [
|
|
1354
|
+
{
|
|
1355
|
+
name: "privacy_pool",
|
|
1356
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1357
|
+
}
|
|
1358
|
+
],
|
|
1359
|
+
outputs: [],
|
|
1360
|
+
state_mutability: "external"
|
|
1361
|
+
},
|
|
1031
1362
|
{
|
|
1032
1363
|
type: "function",
|
|
1033
1364
|
name: "pause",
|
|
@@ -1089,16 +1420,6 @@ var stela_default = [
|
|
|
1089
1420
|
}
|
|
1090
1421
|
]
|
|
1091
1422
|
},
|
|
1092
|
-
{
|
|
1093
|
-
type: "struct",
|
|
1094
|
-
name: "core::array::Span::<core::felt252>",
|
|
1095
|
-
members: [
|
|
1096
|
-
{
|
|
1097
|
-
name: "snapshot",
|
|
1098
|
-
type: "@core::array::Array::<core::felt252>"
|
|
1099
|
-
}
|
|
1100
|
-
]
|
|
1101
|
-
},
|
|
1102
1423
|
{
|
|
1103
1424
|
type: "struct",
|
|
1104
1425
|
name: "core::byte_array::ByteArray",
|
|
@@ -1900,6 +2221,121 @@ var stela_default = [
|
|
|
1900
2221
|
}
|
|
1901
2222
|
]
|
|
1902
2223
|
},
|
|
2224
|
+
{
|
|
2225
|
+
type: "event",
|
|
2226
|
+
name: "stela::stela::StelaProtocol::OrderFilled",
|
|
2227
|
+
kind: "struct",
|
|
2228
|
+
members: [
|
|
2229
|
+
{
|
|
2230
|
+
name: "inscription_id",
|
|
2231
|
+
type: "core::integer::u256",
|
|
2232
|
+
kind: "key"
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
name: "order_hash",
|
|
2236
|
+
type: "core::felt252",
|
|
2237
|
+
kind: "key"
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
name: "taker",
|
|
2241
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2242
|
+
kind: "key"
|
|
2243
|
+
},
|
|
2244
|
+
{
|
|
2245
|
+
name: "fill_bps",
|
|
2246
|
+
type: "core::integer::u256",
|
|
2247
|
+
kind: "data"
|
|
2248
|
+
},
|
|
2249
|
+
{
|
|
2250
|
+
name: "total_filled_bps",
|
|
2251
|
+
type: "core::integer::u256",
|
|
2252
|
+
kind: "data"
|
|
2253
|
+
}
|
|
2254
|
+
]
|
|
2255
|
+
},
|
|
2256
|
+
{
|
|
2257
|
+
type: "event",
|
|
2258
|
+
name: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2259
|
+
kind: "struct",
|
|
2260
|
+
members: [
|
|
2261
|
+
{
|
|
2262
|
+
name: "order_hash",
|
|
2263
|
+
type: "core::felt252",
|
|
2264
|
+
kind: "key"
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
name: "maker",
|
|
2268
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2269
|
+
kind: "data"
|
|
2270
|
+
}
|
|
2271
|
+
]
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
type: "event",
|
|
2275
|
+
name: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2276
|
+
kind: "struct",
|
|
2277
|
+
members: [
|
|
2278
|
+
{
|
|
2279
|
+
name: "maker",
|
|
2280
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2281
|
+
kind: "key"
|
|
2282
|
+
},
|
|
2283
|
+
{
|
|
2284
|
+
name: "new_min_nonce",
|
|
2285
|
+
type: "core::felt252",
|
|
2286
|
+
kind: "data"
|
|
2287
|
+
}
|
|
2288
|
+
]
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
type: "event",
|
|
2292
|
+
name: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2293
|
+
kind: "struct",
|
|
2294
|
+
members: [
|
|
2295
|
+
{
|
|
2296
|
+
name: "inscription_id",
|
|
2297
|
+
type: "core::integer::u256",
|
|
2298
|
+
kind: "key"
|
|
2299
|
+
},
|
|
2300
|
+
{
|
|
2301
|
+
name: "lender_commitment",
|
|
2302
|
+
type: "core::felt252",
|
|
2303
|
+
kind: "key"
|
|
2304
|
+
},
|
|
2305
|
+
{
|
|
2306
|
+
name: "shares_committed",
|
|
2307
|
+
type: "core::integer::u256",
|
|
2308
|
+
kind: "data"
|
|
2309
|
+
}
|
|
2310
|
+
]
|
|
2311
|
+
},
|
|
2312
|
+
{
|
|
2313
|
+
type: "event",
|
|
2314
|
+
name: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2315
|
+
kind: "struct",
|
|
2316
|
+
members: [
|
|
2317
|
+
{
|
|
2318
|
+
name: "inscription_id",
|
|
2319
|
+
type: "core::integer::u256",
|
|
2320
|
+
kind: "key"
|
|
2321
|
+
},
|
|
2322
|
+
{
|
|
2323
|
+
name: "nullifier",
|
|
2324
|
+
type: "core::felt252",
|
|
2325
|
+
kind: "key"
|
|
2326
|
+
},
|
|
2327
|
+
{
|
|
2328
|
+
name: "shares",
|
|
2329
|
+
type: "core::integer::u256",
|
|
2330
|
+
kind: "data"
|
|
2331
|
+
},
|
|
2332
|
+
{
|
|
2333
|
+
name: "recipient",
|
|
2334
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2335
|
+
kind: "data"
|
|
2336
|
+
}
|
|
2337
|
+
]
|
|
2338
|
+
},
|
|
1903
2339
|
{
|
|
1904
2340
|
type: "event",
|
|
1905
2341
|
name: "stela::stela::StelaProtocol::Event",
|
|
@@ -1969,6 +2405,31 @@ var stela_default = [
|
|
|
1969
2405
|
name: "OrderSettled",
|
|
1970
2406
|
type: "stela::stela::StelaProtocol::OrderSettled",
|
|
1971
2407
|
kind: "nested"
|
|
2408
|
+
},
|
|
2409
|
+
{
|
|
2410
|
+
name: "OrderFilled",
|
|
2411
|
+
type: "stela::stela::StelaProtocol::OrderFilled",
|
|
2412
|
+
kind: "nested"
|
|
2413
|
+
},
|
|
2414
|
+
{
|
|
2415
|
+
name: "OrderCancelled",
|
|
2416
|
+
type: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2417
|
+
kind: "nested"
|
|
2418
|
+
},
|
|
2419
|
+
{
|
|
2420
|
+
name: "OrdersBulkCancelled",
|
|
2421
|
+
type: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2422
|
+
kind: "nested"
|
|
2423
|
+
},
|
|
2424
|
+
{
|
|
2425
|
+
name: "PrivateSettled",
|
|
2426
|
+
type: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2427
|
+
kind: "nested"
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
name: "PrivateSharesRedeemed",
|
|
2431
|
+
type: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2432
|
+
kind: "nested"
|
|
1972
2433
|
}
|
|
1973
2434
|
]
|
|
1974
2435
|
}
|
|
@@ -2005,13 +2466,37 @@ var InscriptionClient = class {
|
|
|
2005
2466
|
return extractU256(result);
|
|
2006
2467
|
}
|
|
2007
2468
|
async getNonce(address) {
|
|
2008
|
-
const result = await this.contract.call("nonces", [address]);
|
|
2469
|
+
const result = await this.contract.call("nonces", [address], { blockIdentifier: "latest" });
|
|
2009
2470
|
return BigInt(String(result[0] ?? "0"));
|
|
2010
2471
|
}
|
|
2011
2472
|
async getRelayerFee() {
|
|
2012
2473
|
const result = await this.contract.call("get_relayer_fee");
|
|
2013
2474
|
return extractU256(result);
|
|
2014
2475
|
}
|
|
2476
|
+
async getTreasury() {
|
|
2477
|
+
const result = await this.contract.call("get_treasury");
|
|
2478
|
+
return String(result[0]);
|
|
2479
|
+
}
|
|
2480
|
+
async isPaused() {
|
|
2481
|
+
const result = await this.contract.call("is_paused");
|
|
2482
|
+
return Boolean(result[0]);
|
|
2483
|
+
}
|
|
2484
|
+
async isOrderRegistered(orderHash) {
|
|
2485
|
+
const result = await this.contract.call("is_order_registered", [orderHash]);
|
|
2486
|
+
return Boolean(result[0]);
|
|
2487
|
+
}
|
|
2488
|
+
async isOrderCancelled(orderHash) {
|
|
2489
|
+
const result = await this.contract.call("is_order_cancelled", [orderHash]);
|
|
2490
|
+
return Boolean(result[0]);
|
|
2491
|
+
}
|
|
2492
|
+
async getFilledBps(orderHash) {
|
|
2493
|
+
const result = await this.contract.call("get_filled_bps", [orderHash]);
|
|
2494
|
+
return extractU256(result);
|
|
2495
|
+
}
|
|
2496
|
+
async getMakerMinNonce(maker) {
|
|
2497
|
+
const result = await this.contract.call("get_maker_min_nonce", [maker], { blockIdentifier: "latest" });
|
|
2498
|
+
return String(result[0] ?? "0");
|
|
2499
|
+
}
|
|
2015
2500
|
// ── Call Builders ──────────────────────────────────────────────────
|
|
2016
2501
|
buildCreateInscription(params) {
|
|
2017
2502
|
const calldata = [
|
|
@@ -2060,6 +2545,53 @@ var InscriptionClient = class {
|
|
|
2060
2545
|
calldata: [...toU256(inscriptionId), ...toU256(shares)]
|
|
2061
2546
|
};
|
|
2062
2547
|
}
|
|
2548
|
+
buildPrivateRedeem(request, proof) {
|
|
2549
|
+
const calldata = [
|
|
2550
|
+
// PrivateRedeemRequest struct fields (must match Cairo Serde order)
|
|
2551
|
+
request.root,
|
|
2552
|
+
...toU256(request.inscriptionId),
|
|
2553
|
+
...toU256(request.shares),
|
|
2554
|
+
request.nullifier,
|
|
2555
|
+
request.changeCommitment,
|
|
2556
|
+
request.recipient,
|
|
2557
|
+
// proof array
|
|
2558
|
+
String(proof.length),
|
|
2559
|
+
...proof
|
|
2560
|
+
];
|
|
2561
|
+
return { contractAddress: this.address, entrypoint: "private_redeem", calldata };
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
* Build a shield() call on the privacy pool contract.
|
|
2565
|
+
* The depositor shields tokens into the pool, creating a commitment that can
|
|
2566
|
+
* later be consumed during private settlement.
|
|
2567
|
+
*/
|
|
2568
|
+
buildShieldDeposit(params) {
|
|
2569
|
+
return {
|
|
2570
|
+
contractAddress: params.privacyPoolAddress,
|
|
2571
|
+
entrypoint: "shield",
|
|
2572
|
+
calldata: [
|
|
2573
|
+
params.token,
|
|
2574
|
+
...toU256(params.amount),
|
|
2575
|
+
params.commitment
|
|
2576
|
+
]
|
|
2577
|
+
};
|
|
2578
|
+
}
|
|
2579
|
+
/**
|
|
2580
|
+
* Build a settle() call for private settlement.
|
|
2581
|
+
*
|
|
2582
|
+
* In a private settlement, the lender is zero address and the lender_commitment
|
|
2583
|
+
* is the deposit commitment from the privacy pool. The contract skips lender
|
|
2584
|
+
* signature verification and instead consumes the deposit from the privacy pool.
|
|
2585
|
+
*/
|
|
2586
|
+
buildSettlePrivate(params) {
|
|
2587
|
+
return this.buildSettle({
|
|
2588
|
+
...params,
|
|
2589
|
+
offer: {
|
|
2590
|
+
...params.offer,
|
|
2591
|
+
lender: "0x0"
|
|
2592
|
+
}
|
|
2593
|
+
});
|
|
2594
|
+
}
|
|
2063
2595
|
buildSettle(params) {
|
|
2064
2596
|
const calldata = [
|
|
2065
2597
|
// Order struct fields
|
|
@@ -2088,12 +2620,50 @@ var InscriptionClient = class {
|
|
|
2088
2620
|
params.offer.lender,
|
|
2089
2621
|
...toU256(params.offer.issuedDebtPercentage),
|
|
2090
2622
|
params.offer.nonce.toString(),
|
|
2623
|
+
params.offer.lenderCommitment ?? "0",
|
|
2091
2624
|
// lender_sig array
|
|
2092
2625
|
String(params.lenderSig.length),
|
|
2093
2626
|
...params.lenderSig
|
|
2094
2627
|
];
|
|
2095
2628
|
return { contractAddress: this.address, entrypoint: "settle", calldata };
|
|
2096
2629
|
}
|
|
2630
|
+
buildFillSignedOrder(order, signature, fillBps) {
|
|
2631
|
+
const calldata = [
|
|
2632
|
+
// SignedOrder struct fields
|
|
2633
|
+
order.maker,
|
|
2634
|
+
order.allowed_taker,
|
|
2635
|
+
...toU256(order.inscription_id),
|
|
2636
|
+
...toU256(order.bps),
|
|
2637
|
+
order.deadline.toString(),
|
|
2638
|
+
order.nonce,
|
|
2639
|
+
...toU256(order.min_fill_bps),
|
|
2640
|
+
// signature array
|
|
2641
|
+
String(signature.length),
|
|
2642
|
+
...signature,
|
|
2643
|
+
// fill_bps
|
|
2644
|
+
...toU256(fillBps)
|
|
2645
|
+
];
|
|
2646
|
+
return { contractAddress: this.address, entrypoint: "fill_signed_order", calldata };
|
|
2647
|
+
}
|
|
2648
|
+
buildCancelOrder(order) {
|
|
2649
|
+
const calldata = [
|
|
2650
|
+
order.maker,
|
|
2651
|
+
order.allowed_taker,
|
|
2652
|
+
...toU256(order.inscription_id),
|
|
2653
|
+
...toU256(order.bps),
|
|
2654
|
+
order.deadline.toString(),
|
|
2655
|
+
order.nonce,
|
|
2656
|
+
...toU256(order.min_fill_bps)
|
|
2657
|
+
];
|
|
2658
|
+
return { contractAddress: this.address, entrypoint: "cancel_order", calldata };
|
|
2659
|
+
}
|
|
2660
|
+
buildCancelOrdersByNonce(minNonce) {
|
|
2661
|
+
return {
|
|
2662
|
+
contractAddress: this.address,
|
|
2663
|
+
entrypoint: "cancel_orders_by_nonce",
|
|
2664
|
+
calldata: [minNonce]
|
|
2665
|
+
};
|
|
2666
|
+
}
|
|
2097
2667
|
// ── Execute Methods ────────────────────────────────────────────────
|
|
2098
2668
|
/**
|
|
2099
2669
|
* Execute one or more calls via the connected account.
|
|
@@ -2125,6 +2695,19 @@ var InscriptionClient = class {
|
|
|
2125
2695
|
async redeem(inscriptionId, shares) {
|
|
2126
2696
|
return this.execute([this.buildRedeem(inscriptionId, shares)]);
|
|
2127
2697
|
}
|
|
2698
|
+
async privateRedeem(request, proof) {
|
|
2699
|
+
return this.execute([this.buildPrivateRedeem(request, proof)]);
|
|
2700
|
+
}
|
|
2701
|
+
async fillSignedOrder(order, signature, fillBps, approvals) {
|
|
2702
|
+
const calls = [...approvals ?? [], this.buildFillSignedOrder(order, signature, fillBps)];
|
|
2703
|
+
return this.execute(calls);
|
|
2704
|
+
}
|
|
2705
|
+
async cancelOrder(order) {
|
|
2706
|
+
return this.execute([this.buildCancelOrder(order)]);
|
|
2707
|
+
}
|
|
2708
|
+
async cancelOrdersByNonce(minNonce) {
|
|
2709
|
+
return this.execute([this.buildCancelOrdersByNonce(minNonce)]);
|
|
2710
|
+
}
|
|
2128
2711
|
};
|
|
2129
2712
|
function serializeAssets(assets) {
|
|
2130
2713
|
const calldata = [String(assets.length)];
|
|
@@ -2493,6 +3076,6 @@ var StelaSdk = class {
|
|
|
2493
3076
|
}
|
|
2494
3077
|
};
|
|
2495
3078
|
|
|
2496
|
-
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, ApiError, 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, getInscriptionOrderTypedData, getLendOfferTypedData, getTokensForNetwork, hashAssets, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, serializeSignature, sharesToPercentage, toHex, toU256 };
|
|
3079
|
+
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, ApiError, InscriptionClient, LockerClient, MAX_BPS, SELECTORS, STATUS_LABELS, STELA_ADDRESS, ShareClient, StelaSdk, TOKENS, VALID_STATUSES, VIRTUAL_SHARE_OFFSET, addressesEqual, calculateFeeShares, computeCommitment, computeDepositCommitment, computeNullifier, computeStatus, convertToShares, createPrivateNote, deserializeSignature, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, generateSalt, getInscriptionOrderTypedData, getLendOfferTypedData, getPrivateLendOfferTypedData, getTokensForNetwork, hashAssets, hashPair, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, serializeSignature, sharesToPercentage, toHex, toU256 };
|
|
2497
3080
|
//# sourceMappingURL=index.js.map
|
|
2498
3081
|
//# sourceMappingURL=index.js.map
|