@fepvenancio/stela-sdk 0.2.3 → 0.3.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 +2 -2
- package/dist/index.cjs +549 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -2
- package/dist/index.d.ts +165 -2
- package/dist/index.js +546 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/erc20 2.json +54 -0
- package/src/abi/erc20 3.json +54 -0
- package/src/abi/locker 2.json +50 -0
- package/src/abi/locker 3.json +50 -0
- package/src/abi/stela 2.json +1381 -0
- package/src/abi/stela 3.json +1714 -0
- 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. */
|
|
@@ -343,6 +421,9 @@ declare function getInscriptionOrderTypedData(params: {
|
|
|
343
421
|
/**
|
|
344
422
|
* Build SNIP-12 TypedData for a lender's LendOffer.
|
|
345
423
|
* The lender signs this off-chain to accept an order without gas.
|
|
424
|
+
*
|
|
425
|
+
* @param lenderCommitment - Privacy commitment. When non-zero, shares are committed to the
|
|
426
|
+
* privacy pool's Merkle tree instead of minting ERC1155 to the lender. Defaults to '0'.
|
|
346
427
|
*/
|
|
347
428
|
declare function getLendOfferTypedData(params: {
|
|
348
429
|
orderHash: string;
|
|
@@ -350,6 +431,8 @@ declare function getLendOfferTypedData(params: {
|
|
|
350
431
|
issuedDebtPercentage: bigint;
|
|
351
432
|
nonce: bigint;
|
|
352
433
|
chainId: string;
|
|
434
|
+
/** Privacy commitment (default '0' = non-private). */
|
|
435
|
+
lenderCommitment?: string;
|
|
353
436
|
}): TypedData;
|
|
354
437
|
|
|
355
438
|
/**
|
|
@@ -362,6 +445,62 @@ interface StoredSignature {
|
|
|
362
445
|
declare function serializeSignature(sig: string[]): StoredSignature;
|
|
363
446
|
declare function deserializeSignature(stored: StoredSignature): string[];
|
|
364
447
|
|
|
448
|
+
/** A private share note — represents committed shares in the privacy pool. */
|
|
449
|
+
interface PrivateNote {
|
|
450
|
+
/** The lender who owns these shares */
|
|
451
|
+
owner: string;
|
|
452
|
+
/** The inscription ID */
|
|
453
|
+
inscriptionId: bigint;
|
|
454
|
+
/** Number of shares */
|
|
455
|
+
shares: bigint;
|
|
456
|
+
/** Random salt for commitment uniqueness */
|
|
457
|
+
salt: string;
|
|
458
|
+
/** The commitment (Poseidon hash of above fields) */
|
|
459
|
+
commitment: string;
|
|
460
|
+
}
|
|
461
|
+
/** Request to privately redeem shares (matches Cairo PrivateRedeemRequest). */
|
|
462
|
+
interface PrivateRedeemRequest {
|
|
463
|
+
/** Merkle root the proof was generated against */
|
|
464
|
+
root: string;
|
|
465
|
+
/** The inscription ID */
|
|
466
|
+
inscriptionId: bigint;
|
|
467
|
+
/** Number of shares being redeemed */
|
|
468
|
+
shares: bigint;
|
|
469
|
+
/** Nullifier (prevents double-spend) */
|
|
470
|
+
nullifier: string;
|
|
471
|
+
/** Change commitment (for partial redemption). '0' if full redemption. */
|
|
472
|
+
changeCommitment: string;
|
|
473
|
+
/** Recipient address for redeemed assets */
|
|
474
|
+
recipient: string;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Compute a note commitment matching the Cairo compute_commitment function.
|
|
479
|
+
*
|
|
480
|
+
* commitment = Poseidon(domain, owner, inscription_id.low, inscription_id.high,
|
|
481
|
+
* shares.low, shares.high, salt)
|
|
482
|
+
*/
|
|
483
|
+
declare function computeCommitment(owner: string, inscriptionId: bigint, shares: bigint, salt: string): string;
|
|
484
|
+
/**
|
|
485
|
+
* Derive a nullifier from a commitment and the owner's secret.
|
|
486
|
+
* Matches Cairo: nullifier = Poseidon(domain, commitment, owner_secret)
|
|
487
|
+
*/
|
|
488
|
+
declare function computeNullifier(commitment: string, ownerSecret: string): string;
|
|
489
|
+
/**
|
|
490
|
+
* Compute a Poseidon hash of two children (for Merkle tree internal nodes).
|
|
491
|
+
* Matches Cairo: hash_pair(left, right) = Poseidon(left, right)
|
|
492
|
+
*/
|
|
493
|
+
declare function hashPair(left: string, right: string): string;
|
|
494
|
+
/**
|
|
495
|
+
* Generate a random salt for commitment uniqueness.
|
|
496
|
+
* Returns a hex-encoded felt252 (< 2^251).
|
|
497
|
+
*/
|
|
498
|
+
declare function generateSalt(): string;
|
|
499
|
+
/**
|
|
500
|
+
* Create a full private note: generates salt, computes commitment.
|
|
501
|
+
*/
|
|
502
|
+
declare function createPrivateNote(owner: string, inscriptionId: bigint, shares: bigint, salt?: string): PrivateNote;
|
|
503
|
+
|
|
365
504
|
interface InscriptionClientOptions {
|
|
366
505
|
stelaAddress: string;
|
|
367
506
|
provider: RpcProvider;
|
|
@@ -378,12 +517,19 @@ declare class InscriptionClient {
|
|
|
378
517
|
convertToShares(inscriptionId: bigint, percentage: bigint): Promise<bigint>;
|
|
379
518
|
getNonce(address: string): Promise<bigint>;
|
|
380
519
|
getRelayerFee(): Promise<bigint>;
|
|
520
|
+
getTreasury(): Promise<string>;
|
|
521
|
+
isPaused(): Promise<boolean>;
|
|
522
|
+
isOrderRegistered(orderHash: string): Promise<boolean>;
|
|
523
|
+
isOrderCancelled(orderHash: string): Promise<boolean>;
|
|
524
|
+
getFilledBps(orderHash: string): Promise<bigint>;
|
|
525
|
+
getMakerMinNonce(maker: string): Promise<string>;
|
|
381
526
|
buildCreateInscription(params: InscriptionParams): Call;
|
|
382
527
|
buildSignInscription(inscriptionId: bigint, bps: bigint): Call;
|
|
383
528
|
buildCancelInscription(inscriptionId: bigint): Call;
|
|
384
529
|
buildRepay(inscriptionId: bigint): Call;
|
|
385
530
|
buildLiquidate(inscriptionId: bigint): Call;
|
|
386
531
|
buildRedeem(inscriptionId: bigint, shares: bigint): Call;
|
|
532
|
+
buildPrivateRedeem(request: PrivateRedeemRequest, proof: string[]): Call;
|
|
387
533
|
buildSettle(params: {
|
|
388
534
|
order: {
|
|
389
535
|
borrower: string;
|
|
@@ -407,9 +553,14 @@ declare class InscriptionClient {
|
|
|
407
553
|
lender: string;
|
|
408
554
|
issuedDebtPercentage: bigint;
|
|
409
555
|
nonce: bigint;
|
|
556
|
+
/** Privacy commitment. When non-zero, shares go to privacy pool. Default '0'. */
|
|
557
|
+
lenderCommitment?: string;
|
|
410
558
|
};
|
|
411
559
|
lenderSig: string[];
|
|
412
560
|
}): Call;
|
|
561
|
+
buildFillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint): Call;
|
|
562
|
+
buildCancelOrder(order: SignedOrder): Call;
|
|
563
|
+
buildCancelOrdersByNonce(minNonce: string): Call;
|
|
413
564
|
/**
|
|
414
565
|
* Execute one or more calls via the connected account.
|
|
415
566
|
* Pass approval calls to bundle ERC20 approve + protocol call atomically.
|
|
@@ -435,6 +586,18 @@ declare class InscriptionClient {
|
|
|
435
586
|
redeem(inscriptionId: bigint, shares: bigint): Promise<{
|
|
436
587
|
transaction_hash: string;
|
|
437
588
|
}>;
|
|
589
|
+
privateRedeem(request: PrivateRedeemRequest, proof: string[]): Promise<{
|
|
590
|
+
transaction_hash: string;
|
|
591
|
+
}>;
|
|
592
|
+
fillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint, approvals?: Call[]): Promise<{
|
|
593
|
+
transaction_hash: string;
|
|
594
|
+
}>;
|
|
595
|
+
cancelOrder(order: SignedOrder): Promise<{
|
|
596
|
+
transaction_hash: string;
|
|
597
|
+
}>;
|
|
598
|
+
cancelOrdersByNonce(minNonce: string): Promise<{
|
|
599
|
+
transaction_hash: string;
|
|
600
|
+
}>;
|
|
438
601
|
}
|
|
439
602
|
|
|
440
603
|
interface ShareClientOptions {
|
|
@@ -575,4 +738,4 @@ declare class StelaSdk {
|
|
|
575
738
|
constructor(opts: StelaSdkOptions);
|
|
576
739
|
}
|
|
577
740
|
|
|
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 };
|
|
741
|
+
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, computeNullifier, computeStatus, convertToShares, createPrivateNote, deserializeSignature, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, generateSalt, getInscriptionOrderTypedData, getLendOfferTypedData, 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. */
|
|
@@ -343,6 +421,9 @@ declare function getInscriptionOrderTypedData(params: {
|
|
|
343
421
|
/**
|
|
344
422
|
* Build SNIP-12 TypedData for a lender's LendOffer.
|
|
345
423
|
* The lender signs this off-chain to accept an order without gas.
|
|
424
|
+
*
|
|
425
|
+
* @param lenderCommitment - Privacy commitment. When non-zero, shares are committed to the
|
|
426
|
+
* privacy pool's Merkle tree instead of minting ERC1155 to the lender. Defaults to '0'.
|
|
346
427
|
*/
|
|
347
428
|
declare function getLendOfferTypedData(params: {
|
|
348
429
|
orderHash: string;
|
|
@@ -350,6 +431,8 @@ declare function getLendOfferTypedData(params: {
|
|
|
350
431
|
issuedDebtPercentage: bigint;
|
|
351
432
|
nonce: bigint;
|
|
352
433
|
chainId: string;
|
|
434
|
+
/** Privacy commitment (default '0' = non-private). */
|
|
435
|
+
lenderCommitment?: string;
|
|
353
436
|
}): TypedData;
|
|
354
437
|
|
|
355
438
|
/**
|
|
@@ -362,6 +445,62 @@ interface StoredSignature {
|
|
|
362
445
|
declare function serializeSignature(sig: string[]): StoredSignature;
|
|
363
446
|
declare function deserializeSignature(stored: StoredSignature): string[];
|
|
364
447
|
|
|
448
|
+
/** A private share note — represents committed shares in the privacy pool. */
|
|
449
|
+
interface PrivateNote {
|
|
450
|
+
/** The lender who owns these shares */
|
|
451
|
+
owner: string;
|
|
452
|
+
/** The inscription ID */
|
|
453
|
+
inscriptionId: bigint;
|
|
454
|
+
/** Number of shares */
|
|
455
|
+
shares: bigint;
|
|
456
|
+
/** Random salt for commitment uniqueness */
|
|
457
|
+
salt: string;
|
|
458
|
+
/** The commitment (Poseidon hash of above fields) */
|
|
459
|
+
commitment: string;
|
|
460
|
+
}
|
|
461
|
+
/** Request to privately redeem shares (matches Cairo PrivateRedeemRequest). */
|
|
462
|
+
interface PrivateRedeemRequest {
|
|
463
|
+
/** Merkle root the proof was generated against */
|
|
464
|
+
root: string;
|
|
465
|
+
/** The inscription ID */
|
|
466
|
+
inscriptionId: bigint;
|
|
467
|
+
/** Number of shares being redeemed */
|
|
468
|
+
shares: bigint;
|
|
469
|
+
/** Nullifier (prevents double-spend) */
|
|
470
|
+
nullifier: string;
|
|
471
|
+
/** Change commitment (for partial redemption). '0' if full redemption. */
|
|
472
|
+
changeCommitment: string;
|
|
473
|
+
/** Recipient address for redeemed assets */
|
|
474
|
+
recipient: string;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Compute a note commitment matching the Cairo compute_commitment function.
|
|
479
|
+
*
|
|
480
|
+
* commitment = Poseidon(domain, owner, inscription_id.low, inscription_id.high,
|
|
481
|
+
* shares.low, shares.high, salt)
|
|
482
|
+
*/
|
|
483
|
+
declare function computeCommitment(owner: string, inscriptionId: bigint, shares: bigint, salt: string): string;
|
|
484
|
+
/**
|
|
485
|
+
* Derive a nullifier from a commitment and the owner's secret.
|
|
486
|
+
* Matches Cairo: nullifier = Poseidon(domain, commitment, owner_secret)
|
|
487
|
+
*/
|
|
488
|
+
declare function computeNullifier(commitment: string, ownerSecret: string): string;
|
|
489
|
+
/**
|
|
490
|
+
* Compute a Poseidon hash of two children (for Merkle tree internal nodes).
|
|
491
|
+
* Matches Cairo: hash_pair(left, right) = Poseidon(left, right)
|
|
492
|
+
*/
|
|
493
|
+
declare function hashPair(left: string, right: string): string;
|
|
494
|
+
/**
|
|
495
|
+
* Generate a random salt for commitment uniqueness.
|
|
496
|
+
* Returns a hex-encoded felt252 (< 2^251).
|
|
497
|
+
*/
|
|
498
|
+
declare function generateSalt(): string;
|
|
499
|
+
/**
|
|
500
|
+
* Create a full private note: generates salt, computes commitment.
|
|
501
|
+
*/
|
|
502
|
+
declare function createPrivateNote(owner: string, inscriptionId: bigint, shares: bigint, salt?: string): PrivateNote;
|
|
503
|
+
|
|
365
504
|
interface InscriptionClientOptions {
|
|
366
505
|
stelaAddress: string;
|
|
367
506
|
provider: RpcProvider;
|
|
@@ -378,12 +517,19 @@ declare class InscriptionClient {
|
|
|
378
517
|
convertToShares(inscriptionId: bigint, percentage: bigint): Promise<bigint>;
|
|
379
518
|
getNonce(address: string): Promise<bigint>;
|
|
380
519
|
getRelayerFee(): Promise<bigint>;
|
|
520
|
+
getTreasury(): Promise<string>;
|
|
521
|
+
isPaused(): Promise<boolean>;
|
|
522
|
+
isOrderRegistered(orderHash: string): Promise<boolean>;
|
|
523
|
+
isOrderCancelled(orderHash: string): Promise<boolean>;
|
|
524
|
+
getFilledBps(orderHash: string): Promise<bigint>;
|
|
525
|
+
getMakerMinNonce(maker: string): Promise<string>;
|
|
381
526
|
buildCreateInscription(params: InscriptionParams): Call;
|
|
382
527
|
buildSignInscription(inscriptionId: bigint, bps: bigint): Call;
|
|
383
528
|
buildCancelInscription(inscriptionId: bigint): Call;
|
|
384
529
|
buildRepay(inscriptionId: bigint): Call;
|
|
385
530
|
buildLiquidate(inscriptionId: bigint): Call;
|
|
386
531
|
buildRedeem(inscriptionId: bigint, shares: bigint): Call;
|
|
532
|
+
buildPrivateRedeem(request: PrivateRedeemRequest, proof: string[]): Call;
|
|
387
533
|
buildSettle(params: {
|
|
388
534
|
order: {
|
|
389
535
|
borrower: string;
|
|
@@ -407,9 +553,14 @@ declare class InscriptionClient {
|
|
|
407
553
|
lender: string;
|
|
408
554
|
issuedDebtPercentage: bigint;
|
|
409
555
|
nonce: bigint;
|
|
556
|
+
/** Privacy commitment. When non-zero, shares go to privacy pool. Default '0'. */
|
|
557
|
+
lenderCommitment?: string;
|
|
410
558
|
};
|
|
411
559
|
lenderSig: string[];
|
|
412
560
|
}): Call;
|
|
561
|
+
buildFillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint): Call;
|
|
562
|
+
buildCancelOrder(order: SignedOrder): Call;
|
|
563
|
+
buildCancelOrdersByNonce(minNonce: string): Call;
|
|
413
564
|
/**
|
|
414
565
|
* Execute one or more calls via the connected account.
|
|
415
566
|
* Pass approval calls to bundle ERC20 approve + protocol call atomically.
|
|
@@ -435,6 +586,18 @@ declare class InscriptionClient {
|
|
|
435
586
|
redeem(inscriptionId: bigint, shares: bigint): Promise<{
|
|
436
587
|
transaction_hash: string;
|
|
437
588
|
}>;
|
|
589
|
+
privateRedeem(request: PrivateRedeemRequest, proof: string[]): Promise<{
|
|
590
|
+
transaction_hash: string;
|
|
591
|
+
}>;
|
|
592
|
+
fillSignedOrder(order: SignedOrder, signature: string[], fillBps: bigint, approvals?: Call[]): Promise<{
|
|
593
|
+
transaction_hash: string;
|
|
594
|
+
}>;
|
|
595
|
+
cancelOrder(order: SignedOrder): Promise<{
|
|
596
|
+
transaction_hash: string;
|
|
597
|
+
}>;
|
|
598
|
+
cancelOrdersByNonce(minNonce: string): Promise<{
|
|
599
|
+
transaction_hash: string;
|
|
600
|
+
}>;
|
|
438
601
|
}
|
|
439
602
|
|
|
440
603
|
interface ShareClientOptions {
|
|
@@ -575,4 +738,4 @@ declare class StelaSdk {
|
|
|
575
738
|
constructor(opts: StelaSdkOptions);
|
|
576
739
|
}
|
|
577
740
|
|
|
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 };
|
|
741
|
+
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, computeNullifier, computeStatus, convertToShares, createPrivateNote, deserializeSignature, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, generateSalt, getInscriptionOrderTypedData, getLendOfferTypedData, getTokensForNetwork, hashAssets, hashPair, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, serializeSignature, sharesToPercentage, toHex, toU256 };
|