@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.d.cts
CHANGED
|
@@ -60,6 +60,23 @@ interface Inscription extends StoredInscription {
|
|
|
60
60
|
id: string;
|
|
61
61
|
status: InscriptionStatus;
|
|
62
62
|
}
|
|
63
|
+
/** Signed order for the matching engine (matches Cairo SignedOrder struct) */
|
|
64
|
+
interface SignedOrder {
|
|
65
|
+
/** Order creator (could be borrower or lender) */
|
|
66
|
+
maker: string;
|
|
67
|
+
/** Zero address = open to anyone; nonzero = private OTC (only this address can fill) */
|
|
68
|
+
allowed_taker: string;
|
|
69
|
+
/** The inscription being offered for filling */
|
|
70
|
+
inscription_id: bigint;
|
|
71
|
+
/** Fill percentage being offered (in BPS, max 10,000) */
|
|
72
|
+
bps: bigint;
|
|
73
|
+
/** Unix timestamp deadline for order expiration */
|
|
74
|
+
deadline: bigint;
|
|
75
|
+
/** Maker nonce; bump via cancel_orders_by_nonce to invalidate batch */
|
|
76
|
+
nonce: string;
|
|
77
|
+
/** Minimum acceptable partial fill (0 = any amount accepted) */
|
|
78
|
+
min_fill_bps: bigint;
|
|
79
|
+
}
|
|
63
80
|
|
|
64
81
|
/** Row shape returned by the /api/inscriptions list endpoint */
|
|
65
82
|
interface InscriptionRow {
|
|
@@ -192,8 +209,65 @@ interface TransferSingleEvent {
|
|
|
192
209
|
transaction_hash: string;
|
|
193
210
|
block_number: number;
|
|
194
211
|
}
|
|
212
|
+
/** OrderSettled event (emitted by settle()) */
|
|
213
|
+
interface OrderSettledEvent {
|
|
214
|
+
type: 'OrderSettled';
|
|
215
|
+
inscription_id: bigint;
|
|
216
|
+
borrower: string;
|
|
217
|
+
lender: string;
|
|
218
|
+
relayer: string;
|
|
219
|
+
relayer_fee_amount: bigint;
|
|
220
|
+
transaction_hash: string;
|
|
221
|
+
block_number: number;
|
|
222
|
+
}
|
|
223
|
+
/** OrderFilled event (emitted by fill_signed_order()) */
|
|
224
|
+
interface OrderFilledEvent {
|
|
225
|
+
type: 'OrderFilled';
|
|
226
|
+
inscription_id: bigint;
|
|
227
|
+
order_hash: string;
|
|
228
|
+
taker: string;
|
|
229
|
+
fill_bps: bigint;
|
|
230
|
+
total_filled_bps: bigint;
|
|
231
|
+
transaction_hash: string;
|
|
232
|
+
block_number: number;
|
|
233
|
+
}
|
|
234
|
+
/** OrderCancelled event (emitted by cancel_order()) */
|
|
235
|
+
interface OrderCancelledEvent {
|
|
236
|
+
type: 'OrderCancelled';
|
|
237
|
+
order_hash: string;
|
|
238
|
+
maker: string;
|
|
239
|
+
transaction_hash: string;
|
|
240
|
+
block_number: number;
|
|
241
|
+
}
|
|
242
|
+
/** OrdersBulkCancelled event (emitted by cancel_orders_by_nonce()) */
|
|
243
|
+
interface OrdersBulkCancelledEvent {
|
|
244
|
+
type: 'OrdersBulkCancelled';
|
|
245
|
+
maker: string;
|
|
246
|
+
new_min_nonce: string;
|
|
247
|
+
transaction_hash: string;
|
|
248
|
+
block_number: number;
|
|
249
|
+
}
|
|
250
|
+
/** PrivateSettled event (emitted by settle() when lender_commitment != 0) */
|
|
251
|
+
interface PrivateSettledEvent {
|
|
252
|
+
type: 'PrivateSettled';
|
|
253
|
+
inscription_id: bigint;
|
|
254
|
+
lender_commitment: string;
|
|
255
|
+
shares_committed: bigint;
|
|
256
|
+
transaction_hash: string;
|
|
257
|
+
block_number: number;
|
|
258
|
+
}
|
|
259
|
+
/** PrivateSharesRedeemed event (emitted by private_redeem()) */
|
|
260
|
+
interface PrivateSharesRedeemedEvent {
|
|
261
|
+
type: 'PrivateSharesRedeemed';
|
|
262
|
+
inscription_id: bigint;
|
|
263
|
+
nullifier: string;
|
|
264
|
+
shares: bigint;
|
|
265
|
+
recipient: string;
|
|
266
|
+
transaction_hash: string;
|
|
267
|
+
block_number: number;
|
|
268
|
+
}
|
|
195
269
|
/** Discriminated union of all Stela protocol events */
|
|
196
|
-
type StelaEvent = InscriptionCreatedEvent | InscriptionSignedEvent | InscriptionCancelledEvent | InscriptionRepaidEvent | InscriptionLiquidatedEvent | SharesRedeemedEvent | TransferSingleEvent;
|
|
270
|
+
type StelaEvent = InscriptionCreatedEvent | InscriptionSignedEvent | InscriptionCancelledEvent | InscriptionRepaidEvent | InscriptionLiquidatedEvent | SharesRedeemedEvent | TransferSingleEvent | OrderSettledEvent | OrderFilledEvent | OrderCancelledEvent | OrdersBulkCancelledEvent | PrivateSettledEvent | PrivateSharesRedeemedEvent;
|
|
197
271
|
|
|
198
272
|
/** State of a locker account */
|
|
199
273
|
interface LockerState {
|
|
@@ -301,6 +375,10 @@ declare const SELECTORS: {
|
|
|
301
375
|
readonly InscriptionLiquidated: string;
|
|
302
376
|
readonly SharesRedeemed: string;
|
|
303
377
|
readonly TransferSingle: string;
|
|
378
|
+
readonly OrderSettled: string;
|
|
379
|
+
readonly OrderFilled: string;
|
|
380
|
+
readonly OrderCancelled: string;
|
|
381
|
+
readonly OrdersBulkCancelled: string;
|
|
304
382
|
};
|
|
305
383
|
|
|
306
384
|
/** Parse a single raw event into a typed StelaEvent. Returns null if unrecognized. */
|
|
@@ -340,9 +418,27 @@ declare function getInscriptionOrderTypedData(params: {
|
|
|
340
418
|
nonce: bigint;
|
|
341
419
|
chainId: string;
|
|
342
420
|
}): TypedData;
|
|
421
|
+
/**
|
|
422
|
+
* Build SNIP-12 TypedData for a private lend offer.
|
|
423
|
+
*
|
|
424
|
+
* Convenience wrapper around getLendOfferTypedData that sets lender to zero address
|
|
425
|
+
* and includes the deposit commitment. For private settlements, the lender is anonymous
|
|
426
|
+
* — the privacy pool's deposit commitment proves ownership instead.
|
|
427
|
+
*/
|
|
428
|
+
declare function getPrivateLendOfferTypedData(params: {
|
|
429
|
+
orderHash: string;
|
|
430
|
+
issuedDebtPercentage: bigint;
|
|
431
|
+
nonce: bigint;
|
|
432
|
+
chainId: string;
|
|
433
|
+
/** The deposit commitment from the privacy pool shield() call. */
|
|
434
|
+
depositCommitment: string;
|
|
435
|
+
}): TypedData;
|
|
343
436
|
/**
|
|
344
437
|
* Build SNIP-12 TypedData for a lender's LendOffer.
|
|
345
438
|
* The lender signs this off-chain to accept an order without gas.
|
|
439
|
+
*
|
|
440
|
+
* @param lenderCommitment - Privacy commitment. When non-zero, shares are committed to the
|
|
441
|
+
* privacy pool's Merkle tree instead of minting ERC1155 to the lender. Defaults to '0'.
|
|
346
442
|
*/
|
|
347
443
|
declare function getLendOfferTypedData(params: {
|
|
348
444
|
orderHash: string;
|
|
@@ -350,6 +446,8 @@ declare function getLendOfferTypedData(params: {
|
|
|
350
446
|
issuedDebtPercentage: bigint;
|
|
351
447
|
nonce: bigint;
|
|
352
448
|
chainId: string;
|
|
449
|
+
/** Privacy commitment (default '0' = non-private). */
|
|
450
|
+
lenderCommitment?: string;
|
|
353
451
|
}): TypedData;
|
|
354
452
|
|
|
355
453
|
/**
|
|
@@ -362,6 +460,72 @@ interface StoredSignature {
|
|
|
362
460
|
declare function serializeSignature(sig: string[]): StoredSignature;
|
|
363
461
|
declare function deserializeSignature(stored: StoredSignature): string[];
|
|
364
462
|
|
|
463
|
+
/** A private share note — represents committed shares in the privacy pool. */
|
|
464
|
+
interface PrivateNote {
|
|
465
|
+
/** The lender who owns these shares */
|
|
466
|
+
owner: string;
|
|
467
|
+
/** The inscription ID */
|
|
468
|
+
inscriptionId: bigint;
|
|
469
|
+
/** Number of shares */
|
|
470
|
+
shares: bigint;
|
|
471
|
+
/** Random salt for commitment uniqueness */
|
|
472
|
+
salt: string;
|
|
473
|
+
/** The commitment (Poseidon hash of above fields) */
|
|
474
|
+
commitment: string;
|
|
475
|
+
}
|
|
476
|
+
/** Request to privately redeem shares (matches Cairo PrivateRedeemRequest). */
|
|
477
|
+
interface PrivateRedeemRequest {
|
|
478
|
+
/** Merkle root the proof was generated against */
|
|
479
|
+
root: string;
|
|
480
|
+
/** The inscription ID */
|
|
481
|
+
inscriptionId: bigint;
|
|
482
|
+
/** Number of shares being redeemed */
|
|
483
|
+
shares: bigint;
|
|
484
|
+
/** Nullifier (prevents double-spend) */
|
|
485
|
+
nullifier: string;
|
|
486
|
+
/** Change commitment (for partial redemption). '0' if full redemption. */
|
|
487
|
+
changeCommitment: string;
|
|
488
|
+
/** Recipient address for redeemed assets */
|
|
489
|
+
recipient: string;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Compute a note commitment matching the Cairo compute_commitment function.
|
|
494
|
+
*
|
|
495
|
+
* commitment = Poseidon(domain, owner, inscription_id.low, inscription_id.high,
|
|
496
|
+
* shares.low, shares.high, salt)
|
|
497
|
+
*/
|
|
498
|
+
declare function computeCommitment(owner: string, inscriptionId: bigint, shares: bigint, salt: string): string;
|
|
499
|
+
/**
|
|
500
|
+
* Derive a nullifier from a commitment and the owner's secret.
|
|
501
|
+
* Matches Cairo: nullifier = Poseidon(domain, commitment, owner_secret)
|
|
502
|
+
*/
|
|
503
|
+
declare function computeNullifier(commitment: string, ownerSecret: string): string;
|
|
504
|
+
/**
|
|
505
|
+
* Compute a Poseidon hash of two children (for Merkle tree internal nodes).
|
|
506
|
+
* Matches Cairo: hash_pair(left, right) = Poseidon(left, right)
|
|
507
|
+
*/
|
|
508
|
+
declare function hashPair(left: string, right: string): string;
|
|
509
|
+
/**
|
|
510
|
+
* Generate a random salt for commitment uniqueness.
|
|
511
|
+
* Returns a hex-encoded felt252 (< 2^251).
|
|
512
|
+
*/
|
|
513
|
+
declare function generateSalt(): string;
|
|
514
|
+
/**
|
|
515
|
+
* Compute a deposit commitment for the privacy pool's shield() call.
|
|
516
|
+
*
|
|
517
|
+
* This is the commitment that a depositor provides when shielding tokens into the privacy pool.
|
|
518
|
+
* It links the depositor, token, amount, and a secret salt so the deposit can later be consumed
|
|
519
|
+
* during private settlement.
|
|
520
|
+
*
|
|
521
|
+
* commitment = Poseidon(domain, depositor, token, amount.low, amount.high, salt)
|
|
522
|
+
*/
|
|
523
|
+
declare function computeDepositCommitment(depositor: string, token: string, amount: bigint, salt: bigint): string;
|
|
524
|
+
/**
|
|
525
|
+
* Create a full private note: generates salt, computes commitment.
|
|
526
|
+
*/
|
|
527
|
+
declare function createPrivateNote(owner: string, inscriptionId: bigint, shares: bigint, salt?: string): PrivateNote;
|
|
528
|
+
|
|
365
529
|
interface InscriptionClientOptions {
|
|
366
530
|
stelaAddress: string;
|
|
367
531
|
provider: RpcProvider;
|
|
@@ -378,12 +542,64 @@ declare class InscriptionClient {
|
|
|
378
542
|
convertToShares(inscriptionId: bigint, percentage: bigint): Promise<bigint>;
|
|
379
543
|
getNonce(address: string): Promise<bigint>;
|
|
380
544
|
getRelayerFee(): Promise<bigint>;
|
|
545
|
+
getTreasury(): Promise<string>;
|
|
546
|
+
isPaused(): Promise<boolean>;
|
|
547
|
+
isOrderRegistered(orderHash: string): Promise<boolean>;
|
|
548
|
+
isOrderCancelled(orderHash: string): Promise<boolean>;
|
|
549
|
+
getFilledBps(orderHash: string): Promise<bigint>;
|
|
550
|
+
getMakerMinNonce(maker: string): Promise<string>;
|
|
381
551
|
buildCreateInscription(params: InscriptionParams): Call;
|
|
382
552
|
buildSignInscription(inscriptionId: bigint, bps: bigint): Call;
|
|
383
553
|
buildCancelInscription(inscriptionId: bigint): Call;
|
|
384
554
|
buildRepay(inscriptionId: bigint): Call;
|
|
385
555
|
buildLiquidate(inscriptionId: bigint): Call;
|
|
386
556
|
buildRedeem(inscriptionId: bigint, shares: bigint): Call;
|
|
557
|
+
buildPrivateRedeem(request: PrivateRedeemRequest, proof: string[]): Call;
|
|
558
|
+
/**
|
|
559
|
+
* Build a shield() call on the privacy pool contract.
|
|
560
|
+
* The depositor shields tokens into the pool, creating a commitment that can
|
|
561
|
+
* later be consumed during private settlement.
|
|
562
|
+
*/
|
|
563
|
+
buildShieldDeposit(params: {
|
|
564
|
+
privacyPoolAddress: string;
|
|
565
|
+
token: string;
|
|
566
|
+
amount: bigint;
|
|
567
|
+
commitment: string;
|
|
568
|
+
}): Call;
|
|
569
|
+
/**
|
|
570
|
+
* Build a settle() call for private settlement.
|
|
571
|
+
*
|
|
572
|
+
* In a private settlement, the lender is zero address and the lender_commitment
|
|
573
|
+
* is the deposit commitment from the privacy pool. The contract skips lender
|
|
574
|
+
* signature verification and instead consumes the deposit from the privacy pool.
|
|
575
|
+
*/
|
|
576
|
+
buildSettlePrivate(params: {
|
|
577
|
+
order: {
|
|
578
|
+
borrower: string;
|
|
579
|
+
debtHash: string;
|
|
580
|
+
interestHash: string;
|
|
581
|
+
collateralHash: string;
|
|
582
|
+
debtCount: number;
|
|
583
|
+
interestCount: number;
|
|
584
|
+
collateralCount: number;
|
|
585
|
+
duration: bigint;
|
|
586
|
+
deadline: bigint;
|
|
587
|
+
multiLender: boolean;
|
|
588
|
+
nonce: bigint;
|
|
589
|
+
};
|
|
590
|
+
debtAssets: Asset[];
|
|
591
|
+
interestAssets: Asset[];
|
|
592
|
+
collateralAssets: Asset[];
|
|
593
|
+
borrowerSig: string[];
|
|
594
|
+
offer: {
|
|
595
|
+
orderHash: string;
|
|
596
|
+
issuedDebtPercentage: bigint;
|
|
597
|
+
nonce: bigint;
|
|
598
|
+
/** The deposit commitment from the privacy pool. */
|
|
599
|
+
lenderCommitment: string;
|
|
600
|
+
};
|
|
601
|
+
lenderSig: string[];
|
|
602
|
+
}): Call;
|
|
387
603
|
buildSettle(params: {
|
|
388
604
|
order: {
|
|
389
605
|
borrower: string;
|
|
@@ -407,9 +623,14 @@ declare class InscriptionClient {
|
|
|
407
623
|
lender: string;
|
|
408
624
|
issuedDebtPercentage: bigint;
|
|
409
625
|
nonce: bigint;
|
|
626
|
+
/** Privacy commitment. When non-zero, shares go to privacy pool. Default '0'. */
|
|
627
|
+
lenderCommitment?: string;
|
|
410
628
|
};
|
|
411
629
|
lenderSig: string[];
|
|
412
630
|
}): Call;
|
|
631
|
+
buildFillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint): Call;
|
|
632
|
+
buildCancelOrder(order: SignedOrder): Call;
|
|
633
|
+
buildCancelOrdersByNonce(minNonce: string): Call;
|
|
413
634
|
/**
|
|
414
635
|
* Execute one or more calls via the connected account.
|
|
415
636
|
* Pass approval calls to bundle ERC20 approve + protocol call atomically.
|
|
@@ -435,6 +656,18 @@ declare class InscriptionClient {
|
|
|
435
656
|
redeem(inscriptionId: bigint, shares: bigint): Promise<{
|
|
436
657
|
transaction_hash: string;
|
|
437
658
|
}>;
|
|
659
|
+
privateRedeem(request: PrivateRedeemRequest, proof: string[]): Promise<{
|
|
660
|
+
transaction_hash: string;
|
|
661
|
+
}>;
|
|
662
|
+
fillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint, approvals?: Call[]): Promise<{
|
|
663
|
+
transaction_hash: string;
|
|
664
|
+
}>;
|
|
665
|
+
cancelOrder(order: SignedOrder): Promise<{
|
|
666
|
+
transaction_hash: string;
|
|
667
|
+
}>;
|
|
668
|
+
cancelOrdersByNonce(minNonce: string): Promise<{
|
|
669
|
+
transaction_hash: string;
|
|
670
|
+
}>;
|
|
438
671
|
}
|
|
439
672
|
|
|
440
673
|
interface ShareClientOptions {
|
|
@@ -575,4 +808,4 @@ declare class StelaSdk {
|
|
|
575
808
|
constructor(opts: StelaSdkOptions);
|
|
576
809
|
}
|
|
577
810
|
|
|
578
|
-
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, type ApiClientOptions, type ApiDetailResponse, ApiError, type ApiListResponse, type Asset, type AssetRow, type AssetType, type Call, type Inscription, type InscriptionCancelledEvent, InscriptionClient, type InscriptionClientOptions, type InscriptionCreatedEvent, type InscriptionEventRow, type InscriptionLiquidatedEvent, type InscriptionParams, type InscriptionRepaidEvent, type InscriptionRow, type InscriptionSignedEvent, type InscriptionStatus, type ListInscriptionsParams, type LockerCall, LockerClient, type LockerInfo, type LockerState, MAX_BPS, type Network, type RawEvent, SELECTORS, STATUS_LABELS, STELA_ADDRESS, type ShareBalance, ShareClient, type ShareClientOptions, type SharesRedeemedEvent, type StatusInput, type StelaEvent, StelaSdk, type StelaSdkOptions, type StoredInscription, type StoredSignature, TOKENS, type TokenInfo, type TransferSingleEvent, type TreasuryAsset, 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 };
|
|
811
|
+
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, type ApiClientOptions, type ApiDetailResponse, ApiError, type ApiListResponse, type Asset, type AssetRow, type AssetType, type Call, type Inscription, type InscriptionCancelledEvent, InscriptionClient, type InscriptionClientOptions, type InscriptionCreatedEvent, type InscriptionEventRow, type InscriptionLiquidatedEvent, type InscriptionParams, type InscriptionRepaidEvent, type InscriptionRow, type InscriptionSignedEvent, type InscriptionStatus, type ListInscriptionsParams, type LockerCall, LockerClient, type LockerInfo, type LockerState, MAX_BPS, type Network, type OrderCancelledEvent, type OrderFilledEvent, type OrderSettledEvent, type OrdersBulkCancelledEvent, type PrivateNote, type PrivateRedeemRequest, type PrivateSettledEvent, type PrivateSharesRedeemedEvent, type RawEvent, SELECTORS, STATUS_LABELS, STELA_ADDRESS, type ShareBalance, ShareClient, type ShareClientOptions, type SharesRedeemedEvent, type SignedOrder, type StatusInput, type StelaEvent, StelaSdk, type StelaSdkOptions, type StoredInscription, type StoredSignature, TOKENS, type TokenInfo, type TransferSingleEvent, type TreasuryAsset, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,23 @@ interface Inscription extends StoredInscription {
|
|
|
60
60
|
id: string;
|
|
61
61
|
status: InscriptionStatus;
|
|
62
62
|
}
|
|
63
|
+
/** Signed order for the matching engine (matches Cairo SignedOrder struct) */
|
|
64
|
+
interface SignedOrder {
|
|
65
|
+
/** Order creator (could be borrower or lender) */
|
|
66
|
+
maker: string;
|
|
67
|
+
/** Zero address = open to anyone; nonzero = private OTC (only this address can fill) */
|
|
68
|
+
allowed_taker: string;
|
|
69
|
+
/** The inscription being offered for filling */
|
|
70
|
+
inscription_id: bigint;
|
|
71
|
+
/** Fill percentage being offered (in BPS, max 10,000) */
|
|
72
|
+
bps: bigint;
|
|
73
|
+
/** Unix timestamp deadline for order expiration */
|
|
74
|
+
deadline: bigint;
|
|
75
|
+
/** Maker nonce; bump via cancel_orders_by_nonce to invalidate batch */
|
|
76
|
+
nonce: string;
|
|
77
|
+
/** Minimum acceptable partial fill (0 = any amount accepted) */
|
|
78
|
+
min_fill_bps: bigint;
|
|
79
|
+
}
|
|
63
80
|
|
|
64
81
|
/** Row shape returned by the /api/inscriptions list endpoint */
|
|
65
82
|
interface InscriptionRow {
|
|
@@ -192,8 +209,65 @@ interface TransferSingleEvent {
|
|
|
192
209
|
transaction_hash: string;
|
|
193
210
|
block_number: number;
|
|
194
211
|
}
|
|
212
|
+
/** OrderSettled event (emitted by settle()) */
|
|
213
|
+
interface OrderSettledEvent {
|
|
214
|
+
type: 'OrderSettled';
|
|
215
|
+
inscription_id: bigint;
|
|
216
|
+
borrower: string;
|
|
217
|
+
lender: string;
|
|
218
|
+
relayer: string;
|
|
219
|
+
relayer_fee_amount: bigint;
|
|
220
|
+
transaction_hash: string;
|
|
221
|
+
block_number: number;
|
|
222
|
+
}
|
|
223
|
+
/** OrderFilled event (emitted by fill_signed_order()) */
|
|
224
|
+
interface OrderFilledEvent {
|
|
225
|
+
type: 'OrderFilled';
|
|
226
|
+
inscription_id: bigint;
|
|
227
|
+
order_hash: string;
|
|
228
|
+
taker: string;
|
|
229
|
+
fill_bps: bigint;
|
|
230
|
+
total_filled_bps: bigint;
|
|
231
|
+
transaction_hash: string;
|
|
232
|
+
block_number: number;
|
|
233
|
+
}
|
|
234
|
+
/** OrderCancelled event (emitted by cancel_order()) */
|
|
235
|
+
interface OrderCancelledEvent {
|
|
236
|
+
type: 'OrderCancelled';
|
|
237
|
+
order_hash: string;
|
|
238
|
+
maker: string;
|
|
239
|
+
transaction_hash: string;
|
|
240
|
+
block_number: number;
|
|
241
|
+
}
|
|
242
|
+
/** OrdersBulkCancelled event (emitted by cancel_orders_by_nonce()) */
|
|
243
|
+
interface OrdersBulkCancelledEvent {
|
|
244
|
+
type: 'OrdersBulkCancelled';
|
|
245
|
+
maker: string;
|
|
246
|
+
new_min_nonce: string;
|
|
247
|
+
transaction_hash: string;
|
|
248
|
+
block_number: number;
|
|
249
|
+
}
|
|
250
|
+
/** PrivateSettled event (emitted by settle() when lender_commitment != 0) */
|
|
251
|
+
interface PrivateSettledEvent {
|
|
252
|
+
type: 'PrivateSettled';
|
|
253
|
+
inscription_id: bigint;
|
|
254
|
+
lender_commitment: string;
|
|
255
|
+
shares_committed: bigint;
|
|
256
|
+
transaction_hash: string;
|
|
257
|
+
block_number: number;
|
|
258
|
+
}
|
|
259
|
+
/** PrivateSharesRedeemed event (emitted by private_redeem()) */
|
|
260
|
+
interface PrivateSharesRedeemedEvent {
|
|
261
|
+
type: 'PrivateSharesRedeemed';
|
|
262
|
+
inscription_id: bigint;
|
|
263
|
+
nullifier: string;
|
|
264
|
+
shares: bigint;
|
|
265
|
+
recipient: string;
|
|
266
|
+
transaction_hash: string;
|
|
267
|
+
block_number: number;
|
|
268
|
+
}
|
|
195
269
|
/** Discriminated union of all Stela protocol events */
|
|
196
|
-
type StelaEvent = InscriptionCreatedEvent | InscriptionSignedEvent | InscriptionCancelledEvent | InscriptionRepaidEvent | InscriptionLiquidatedEvent | SharesRedeemedEvent | TransferSingleEvent;
|
|
270
|
+
type StelaEvent = InscriptionCreatedEvent | InscriptionSignedEvent | InscriptionCancelledEvent | InscriptionRepaidEvent | InscriptionLiquidatedEvent | SharesRedeemedEvent | TransferSingleEvent | OrderSettledEvent | OrderFilledEvent | OrderCancelledEvent | OrdersBulkCancelledEvent | PrivateSettledEvent | PrivateSharesRedeemedEvent;
|
|
197
271
|
|
|
198
272
|
/** State of a locker account */
|
|
199
273
|
interface LockerState {
|
|
@@ -301,6 +375,10 @@ declare const SELECTORS: {
|
|
|
301
375
|
readonly InscriptionLiquidated: string;
|
|
302
376
|
readonly SharesRedeemed: string;
|
|
303
377
|
readonly TransferSingle: string;
|
|
378
|
+
readonly OrderSettled: string;
|
|
379
|
+
readonly OrderFilled: string;
|
|
380
|
+
readonly OrderCancelled: string;
|
|
381
|
+
readonly OrdersBulkCancelled: string;
|
|
304
382
|
};
|
|
305
383
|
|
|
306
384
|
/** Parse a single raw event into a typed StelaEvent. Returns null if unrecognized. */
|
|
@@ -340,9 +418,27 @@ declare function getInscriptionOrderTypedData(params: {
|
|
|
340
418
|
nonce: bigint;
|
|
341
419
|
chainId: string;
|
|
342
420
|
}): TypedData;
|
|
421
|
+
/**
|
|
422
|
+
* Build SNIP-12 TypedData for a private lend offer.
|
|
423
|
+
*
|
|
424
|
+
* Convenience wrapper around getLendOfferTypedData that sets lender to zero address
|
|
425
|
+
* and includes the deposit commitment. For private settlements, the lender is anonymous
|
|
426
|
+
* — the privacy pool's deposit commitment proves ownership instead.
|
|
427
|
+
*/
|
|
428
|
+
declare function getPrivateLendOfferTypedData(params: {
|
|
429
|
+
orderHash: string;
|
|
430
|
+
issuedDebtPercentage: bigint;
|
|
431
|
+
nonce: bigint;
|
|
432
|
+
chainId: string;
|
|
433
|
+
/** The deposit commitment from the privacy pool shield() call. */
|
|
434
|
+
depositCommitment: string;
|
|
435
|
+
}): TypedData;
|
|
343
436
|
/**
|
|
344
437
|
* Build SNIP-12 TypedData for a lender's LendOffer.
|
|
345
438
|
* The lender signs this off-chain to accept an order without gas.
|
|
439
|
+
*
|
|
440
|
+
* @param lenderCommitment - Privacy commitment. When non-zero, shares are committed to the
|
|
441
|
+
* privacy pool's Merkle tree instead of minting ERC1155 to the lender. Defaults to '0'.
|
|
346
442
|
*/
|
|
347
443
|
declare function getLendOfferTypedData(params: {
|
|
348
444
|
orderHash: string;
|
|
@@ -350,6 +446,8 @@ declare function getLendOfferTypedData(params: {
|
|
|
350
446
|
issuedDebtPercentage: bigint;
|
|
351
447
|
nonce: bigint;
|
|
352
448
|
chainId: string;
|
|
449
|
+
/** Privacy commitment (default '0' = non-private). */
|
|
450
|
+
lenderCommitment?: string;
|
|
353
451
|
}): TypedData;
|
|
354
452
|
|
|
355
453
|
/**
|
|
@@ -362,6 +460,72 @@ interface StoredSignature {
|
|
|
362
460
|
declare function serializeSignature(sig: string[]): StoredSignature;
|
|
363
461
|
declare function deserializeSignature(stored: StoredSignature): string[];
|
|
364
462
|
|
|
463
|
+
/** A private share note — represents committed shares in the privacy pool. */
|
|
464
|
+
interface PrivateNote {
|
|
465
|
+
/** The lender who owns these shares */
|
|
466
|
+
owner: string;
|
|
467
|
+
/** The inscription ID */
|
|
468
|
+
inscriptionId: bigint;
|
|
469
|
+
/** Number of shares */
|
|
470
|
+
shares: bigint;
|
|
471
|
+
/** Random salt for commitment uniqueness */
|
|
472
|
+
salt: string;
|
|
473
|
+
/** The commitment (Poseidon hash of above fields) */
|
|
474
|
+
commitment: string;
|
|
475
|
+
}
|
|
476
|
+
/** Request to privately redeem shares (matches Cairo PrivateRedeemRequest). */
|
|
477
|
+
interface PrivateRedeemRequest {
|
|
478
|
+
/** Merkle root the proof was generated against */
|
|
479
|
+
root: string;
|
|
480
|
+
/** The inscription ID */
|
|
481
|
+
inscriptionId: bigint;
|
|
482
|
+
/** Number of shares being redeemed */
|
|
483
|
+
shares: bigint;
|
|
484
|
+
/** Nullifier (prevents double-spend) */
|
|
485
|
+
nullifier: string;
|
|
486
|
+
/** Change commitment (for partial redemption). '0' if full redemption. */
|
|
487
|
+
changeCommitment: string;
|
|
488
|
+
/** Recipient address for redeemed assets */
|
|
489
|
+
recipient: string;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Compute a note commitment matching the Cairo compute_commitment function.
|
|
494
|
+
*
|
|
495
|
+
* commitment = Poseidon(domain, owner, inscription_id.low, inscription_id.high,
|
|
496
|
+
* shares.low, shares.high, salt)
|
|
497
|
+
*/
|
|
498
|
+
declare function computeCommitment(owner: string, inscriptionId: bigint, shares: bigint, salt: string): string;
|
|
499
|
+
/**
|
|
500
|
+
* Derive a nullifier from a commitment and the owner's secret.
|
|
501
|
+
* Matches Cairo: nullifier = Poseidon(domain, commitment, owner_secret)
|
|
502
|
+
*/
|
|
503
|
+
declare function computeNullifier(commitment: string, ownerSecret: string): string;
|
|
504
|
+
/**
|
|
505
|
+
* Compute a Poseidon hash of two children (for Merkle tree internal nodes).
|
|
506
|
+
* Matches Cairo: hash_pair(left, right) = Poseidon(left, right)
|
|
507
|
+
*/
|
|
508
|
+
declare function hashPair(left: string, right: string): string;
|
|
509
|
+
/**
|
|
510
|
+
* Generate a random salt for commitment uniqueness.
|
|
511
|
+
* Returns a hex-encoded felt252 (< 2^251).
|
|
512
|
+
*/
|
|
513
|
+
declare function generateSalt(): string;
|
|
514
|
+
/**
|
|
515
|
+
* Compute a deposit commitment for the privacy pool's shield() call.
|
|
516
|
+
*
|
|
517
|
+
* This is the commitment that a depositor provides when shielding tokens into the privacy pool.
|
|
518
|
+
* It links the depositor, token, amount, and a secret salt so the deposit can later be consumed
|
|
519
|
+
* during private settlement.
|
|
520
|
+
*
|
|
521
|
+
* commitment = Poseidon(domain, depositor, token, amount.low, amount.high, salt)
|
|
522
|
+
*/
|
|
523
|
+
declare function computeDepositCommitment(depositor: string, token: string, amount: bigint, salt: bigint): string;
|
|
524
|
+
/**
|
|
525
|
+
* Create a full private note: generates salt, computes commitment.
|
|
526
|
+
*/
|
|
527
|
+
declare function createPrivateNote(owner: string, inscriptionId: bigint, shares: bigint, salt?: string): PrivateNote;
|
|
528
|
+
|
|
365
529
|
interface InscriptionClientOptions {
|
|
366
530
|
stelaAddress: string;
|
|
367
531
|
provider: RpcProvider;
|
|
@@ -378,12 +542,64 @@ declare class InscriptionClient {
|
|
|
378
542
|
convertToShares(inscriptionId: bigint, percentage: bigint): Promise<bigint>;
|
|
379
543
|
getNonce(address: string): Promise<bigint>;
|
|
380
544
|
getRelayerFee(): Promise<bigint>;
|
|
545
|
+
getTreasury(): Promise<string>;
|
|
546
|
+
isPaused(): Promise<boolean>;
|
|
547
|
+
isOrderRegistered(orderHash: string): Promise<boolean>;
|
|
548
|
+
isOrderCancelled(orderHash: string): Promise<boolean>;
|
|
549
|
+
getFilledBps(orderHash: string): Promise<bigint>;
|
|
550
|
+
getMakerMinNonce(maker: string): Promise<string>;
|
|
381
551
|
buildCreateInscription(params: InscriptionParams): Call;
|
|
382
552
|
buildSignInscription(inscriptionId: bigint, bps: bigint): Call;
|
|
383
553
|
buildCancelInscription(inscriptionId: bigint): Call;
|
|
384
554
|
buildRepay(inscriptionId: bigint): Call;
|
|
385
555
|
buildLiquidate(inscriptionId: bigint): Call;
|
|
386
556
|
buildRedeem(inscriptionId: bigint, shares: bigint): Call;
|
|
557
|
+
buildPrivateRedeem(request: PrivateRedeemRequest, proof: string[]): Call;
|
|
558
|
+
/**
|
|
559
|
+
* Build a shield() call on the privacy pool contract.
|
|
560
|
+
* The depositor shields tokens into the pool, creating a commitment that can
|
|
561
|
+
* later be consumed during private settlement.
|
|
562
|
+
*/
|
|
563
|
+
buildShieldDeposit(params: {
|
|
564
|
+
privacyPoolAddress: string;
|
|
565
|
+
token: string;
|
|
566
|
+
amount: bigint;
|
|
567
|
+
commitment: string;
|
|
568
|
+
}): Call;
|
|
569
|
+
/**
|
|
570
|
+
* Build a settle() call for private settlement.
|
|
571
|
+
*
|
|
572
|
+
* In a private settlement, the lender is zero address and the lender_commitment
|
|
573
|
+
* is the deposit commitment from the privacy pool. The contract skips lender
|
|
574
|
+
* signature verification and instead consumes the deposit from the privacy pool.
|
|
575
|
+
*/
|
|
576
|
+
buildSettlePrivate(params: {
|
|
577
|
+
order: {
|
|
578
|
+
borrower: string;
|
|
579
|
+
debtHash: string;
|
|
580
|
+
interestHash: string;
|
|
581
|
+
collateralHash: string;
|
|
582
|
+
debtCount: number;
|
|
583
|
+
interestCount: number;
|
|
584
|
+
collateralCount: number;
|
|
585
|
+
duration: bigint;
|
|
586
|
+
deadline: bigint;
|
|
587
|
+
multiLender: boolean;
|
|
588
|
+
nonce: bigint;
|
|
589
|
+
};
|
|
590
|
+
debtAssets: Asset[];
|
|
591
|
+
interestAssets: Asset[];
|
|
592
|
+
collateralAssets: Asset[];
|
|
593
|
+
borrowerSig: string[];
|
|
594
|
+
offer: {
|
|
595
|
+
orderHash: string;
|
|
596
|
+
issuedDebtPercentage: bigint;
|
|
597
|
+
nonce: bigint;
|
|
598
|
+
/** The deposit commitment from the privacy pool. */
|
|
599
|
+
lenderCommitment: string;
|
|
600
|
+
};
|
|
601
|
+
lenderSig: string[];
|
|
602
|
+
}): Call;
|
|
387
603
|
buildSettle(params: {
|
|
388
604
|
order: {
|
|
389
605
|
borrower: string;
|
|
@@ -407,9 +623,14 @@ declare class InscriptionClient {
|
|
|
407
623
|
lender: string;
|
|
408
624
|
issuedDebtPercentage: bigint;
|
|
409
625
|
nonce: bigint;
|
|
626
|
+
/** Privacy commitment. When non-zero, shares go to privacy pool. Default '0'. */
|
|
627
|
+
lenderCommitment?: string;
|
|
410
628
|
};
|
|
411
629
|
lenderSig: string[];
|
|
412
630
|
}): Call;
|
|
631
|
+
buildFillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint): Call;
|
|
632
|
+
buildCancelOrder(order: SignedOrder): Call;
|
|
633
|
+
buildCancelOrdersByNonce(minNonce: string): Call;
|
|
413
634
|
/**
|
|
414
635
|
* Execute one or more calls via the connected account.
|
|
415
636
|
* Pass approval calls to bundle ERC20 approve + protocol call atomically.
|
|
@@ -435,6 +656,18 @@ declare class InscriptionClient {
|
|
|
435
656
|
redeem(inscriptionId: bigint, shares: bigint): Promise<{
|
|
436
657
|
transaction_hash: string;
|
|
437
658
|
}>;
|
|
659
|
+
privateRedeem(request: PrivateRedeemRequest, proof: string[]): Promise<{
|
|
660
|
+
transaction_hash: string;
|
|
661
|
+
}>;
|
|
662
|
+
fillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint, approvals?: Call[]): Promise<{
|
|
663
|
+
transaction_hash: string;
|
|
664
|
+
}>;
|
|
665
|
+
cancelOrder(order: SignedOrder): Promise<{
|
|
666
|
+
transaction_hash: string;
|
|
667
|
+
}>;
|
|
668
|
+
cancelOrdersByNonce(minNonce: string): Promise<{
|
|
669
|
+
transaction_hash: string;
|
|
670
|
+
}>;
|
|
438
671
|
}
|
|
439
672
|
|
|
440
673
|
interface ShareClientOptions {
|
|
@@ -575,4 +808,4 @@ declare class StelaSdk {
|
|
|
575
808
|
constructor(opts: StelaSdkOptions);
|
|
576
809
|
}
|
|
577
810
|
|
|
578
|
-
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, type ApiClientOptions, type ApiDetailResponse, ApiError, type ApiListResponse, type Asset, type AssetRow, type AssetType, type Call, type Inscription, type InscriptionCancelledEvent, InscriptionClient, type InscriptionClientOptions, type InscriptionCreatedEvent, type InscriptionEventRow, type InscriptionLiquidatedEvent, type InscriptionParams, type InscriptionRepaidEvent, type InscriptionRow, type InscriptionSignedEvent, type InscriptionStatus, type ListInscriptionsParams, type LockerCall, LockerClient, type LockerInfo, type LockerState, MAX_BPS, type Network, type RawEvent, SELECTORS, STATUS_LABELS, STELA_ADDRESS, type ShareBalance, ShareClient, type ShareClientOptions, type SharesRedeemedEvent, type StatusInput, type StelaEvent, StelaSdk, type StelaSdkOptions, type StoredInscription, type StoredSignature, TOKENS, type TokenInfo, type TransferSingleEvent, type TreasuryAsset, 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 };
|
|
811
|
+
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, type ApiClientOptions, type ApiDetailResponse, ApiError, type ApiListResponse, type Asset, type AssetRow, type AssetType, type Call, type Inscription, type InscriptionCancelledEvent, InscriptionClient, type InscriptionClientOptions, type InscriptionCreatedEvent, type InscriptionEventRow, type InscriptionLiquidatedEvent, type InscriptionParams, type InscriptionRepaidEvent, type InscriptionRow, type InscriptionSignedEvent, type InscriptionStatus, type ListInscriptionsParams, type LockerCall, LockerClient, type LockerInfo, type LockerState, MAX_BPS, type Network, type OrderCancelledEvent, type OrderFilledEvent, type OrderSettledEvent, type OrdersBulkCancelledEvent, type PrivateNote, type PrivateRedeemRequest, type PrivateSettledEvent, type PrivateSharesRedeemedEvent, type RawEvent, SELECTORS, STATUS_LABELS, STELA_ADDRESS, type ShareBalance, ShareClient, type ShareClientOptions, type SharesRedeemedEvent, type SignedOrder, type StatusInput, type StelaEvent, StelaSdk, type StelaSdkOptions, type StoredInscription, type StoredSignature, TOKENS, type TokenInfo, type TransferSingleEvent, type TreasuryAsset, 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 };
|