@fepvenancio/stela-sdk 0.9.0 → 0.11.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 +184 -31
- package/dist/index.cjs +432 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +404 -1
- package/dist/index.d.ts +404 -1
- package/dist/index.js +404 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,6 +20,16 @@ var STATUS_LABELS = {
|
|
|
20
20
|
cancelled: "Cancelled"
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
// src/types/orderbook.ts
|
|
24
|
+
var DURATION_RANGES = {
|
|
25
|
+
all: null,
|
|
26
|
+
"7d": [0, 7 * 86400 + 1],
|
|
27
|
+
"30d": [7 * 86400, 30 * 86400 + 1],
|
|
28
|
+
"90d": [30 * 86400, 90 * 86400 + 1],
|
|
29
|
+
"180d": [90 * 86400, 180 * 86400 + 1],
|
|
30
|
+
"365d": [180 * 86400, 366 * 86400]
|
|
31
|
+
};
|
|
32
|
+
|
|
23
33
|
// src/constants/addresses.ts
|
|
24
34
|
var STELA_ADDRESS = {
|
|
25
35
|
sepolia: "0x0109c6caae0c5b4da6e063ed6c02ae784be05aa90806501a48dcfbb213bd7c03",
|
|
@@ -60,6 +70,40 @@ var GRACE_PERIOD = 86400n;
|
|
|
60
70
|
var AUCTION_DURATION = 86400n;
|
|
61
71
|
var AUCTION_PENALTY_BPS = 500n;
|
|
62
72
|
var AUCTION_RESERVE_BPS = 1000n;
|
|
73
|
+
|
|
74
|
+
// src/constants/presets.ts
|
|
75
|
+
var SWAP_DEADLINE_PRESETS = [
|
|
76
|
+
{ label: "5m", seconds: 300 },
|
|
77
|
+
{ label: "15m", seconds: 900 },
|
|
78
|
+
{ label: "30m", seconds: 1800 },
|
|
79
|
+
{ label: "1h", seconds: 3600 },
|
|
80
|
+
{ label: "12h", seconds: 43200 },
|
|
81
|
+
{ label: "1d", seconds: 86400 },
|
|
82
|
+
{ label: "7d", seconds: 604800 },
|
|
83
|
+
{ label: "30d", seconds: 2592e3 }
|
|
84
|
+
];
|
|
85
|
+
var LEND_DEADLINE_PRESETS = [
|
|
86
|
+
{ label: "7d", seconds: 604800 },
|
|
87
|
+
{ label: "14d", seconds: 1209600 },
|
|
88
|
+
{ label: "30d", seconds: 2592e3 },
|
|
89
|
+
{ label: "60d", seconds: 5184e3 },
|
|
90
|
+
{ label: "90d", seconds: 7776e3 }
|
|
91
|
+
];
|
|
92
|
+
var DURATION_PRESETS = [
|
|
93
|
+
{ label: "1d", seconds: 86400 },
|
|
94
|
+
{ label: "7d", seconds: 604800 },
|
|
95
|
+
{ label: "14d", seconds: 1209600 },
|
|
96
|
+
{ label: "30d", seconds: 2592e3 },
|
|
97
|
+
{ label: "90d", seconds: 7776e3 },
|
|
98
|
+
{ label: "180d", seconds: 15552e3 },
|
|
99
|
+
{ label: "1y", seconds: 31536e3 }
|
|
100
|
+
];
|
|
101
|
+
function formatDurationHuman(seconds) {
|
|
102
|
+
if (seconds < 3600) return `${Math.round(seconds / 60)} min`;
|
|
103
|
+
if (seconds < 86400) return `${Math.round(seconds / 3600)} hours`;
|
|
104
|
+
const days = Math.round(seconds / 86400);
|
|
105
|
+
return `${days} day${days !== 1 ? "s" : ""}`;
|
|
106
|
+
}
|
|
63
107
|
var U128_MAX = (1n << 128n) - 1n;
|
|
64
108
|
var U256_MAX = (1n << 256n) - 1n;
|
|
65
109
|
var toU256 = (n) => {
|
|
@@ -152,6 +196,292 @@ function computeStatus(a, nowSeconds) {
|
|
|
152
196
|
if (now > signedAt + duration) return "expired";
|
|
153
197
|
return "filled";
|
|
154
198
|
}
|
|
199
|
+
var EXTENDED_LABELS = {
|
|
200
|
+
overdue: "Overdue",
|
|
201
|
+
auctioned: "Auctioned",
|
|
202
|
+
grace_period: "Grace Period"
|
|
203
|
+
};
|
|
204
|
+
function getStatusBadgeVariant(status) {
|
|
205
|
+
if (status === "overdue") return "overdue";
|
|
206
|
+
if (status === "auctioned") return "auctioned";
|
|
207
|
+
if (status === "grace_period") return "grace_period";
|
|
208
|
+
return status in STATUS_LABELS ? status : "open";
|
|
209
|
+
}
|
|
210
|
+
function getStatusLabel(status) {
|
|
211
|
+
return EXTENDED_LABELS[status] ?? STATUS_LABELS[status] ?? status;
|
|
212
|
+
}
|
|
213
|
+
var ORDER_STATUS_LABELS = {
|
|
214
|
+
pending: "Pending",
|
|
215
|
+
matched: "Matched",
|
|
216
|
+
settled: "Settled",
|
|
217
|
+
expired: "Expired",
|
|
218
|
+
cancelled: "Cancelled"
|
|
219
|
+
};
|
|
220
|
+
function getOrderStatusBadgeVariant(status) {
|
|
221
|
+
const map = {
|
|
222
|
+
pending: "pending",
|
|
223
|
+
matched: "matched",
|
|
224
|
+
settled: "settled",
|
|
225
|
+
expired: "expired",
|
|
226
|
+
cancelled: "cancelled"
|
|
227
|
+
};
|
|
228
|
+
return map[status] ?? "pending";
|
|
229
|
+
}
|
|
230
|
+
function getOrderStatusLabel(status) {
|
|
231
|
+
return ORDER_STATUS_LABELS[status] ?? status;
|
|
232
|
+
}
|
|
233
|
+
var INSCRIPTION_STATUS_GROUPS = {
|
|
234
|
+
open: /* @__PURE__ */ new Set(["open", "partial"]),
|
|
235
|
+
active: /* @__PURE__ */ new Set(["filled", "auctioned", "grace_period"]),
|
|
236
|
+
closed: /* @__PURE__ */ new Set(["repaid", "liquidated", "expired", "overdue", "cancelled"])
|
|
237
|
+
};
|
|
238
|
+
var ORDER_STATUS_GROUPS = {
|
|
239
|
+
open: /* @__PURE__ */ new Set(["pending"]),
|
|
240
|
+
active: /* @__PURE__ */ new Set(["matched"]),
|
|
241
|
+
closed: /* @__PURE__ */ new Set(["settled", "expired", "cancelled"])
|
|
242
|
+
};
|
|
243
|
+
function inscriptionMatchesGroup(enrichedStatus, group) {
|
|
244
|
+
if (group === "all") return true;
|
|
245
|
+
return INSCRIPTION_STATUS_GROUPS[group]?.has(enrichedStatus) ?? false;
|
|
246
|
+
}
|
|
247
|
+
function orderMatchesGroup(orderStatus, group) {
|
|
248
|
+
if (group === "all") return true;
|
|
249
|
+
return ORDER_STATUS_GROUPS[group]?.has(orderStatus) ?? false;
|
|
250
|
+
}
|
|
251
|
+
var STATUS_DESCRIPTIONS = {
|
|
252
|
+
open: "Waiting for a lender to sign. The borrower has set the loan terms.",
|
|
253
|
+
partial: "Partially funded by lenders. More lenders can still contribute.",
|
|
254
|
+
filled: "Fully funded and active. The borrower received the debt tokens.",
|
|
255
|
+
repaid: "The borrower repaid the loan. Lenders can redeem their shares.",
|
|
256
|
+
liquidated: "Loan expired without repayment. Collateral distributed to lenders.",
|
|
257
|
+
overdue: "Loan duration elapsed without repayment. Anyone can liquidate.",
|
|
258
|
+
auctioned: "Auction started. The collateral is being sold to the highest bidder.",
|
|
259
|
+
grace_period: "Loan expired but within the 24-hour grace period. The borrower can still repay.",
|
|
260
|
+
expired: "Expired before being funded. No lender action was taken.",
|
|
261
|
+
cancelled: "Cancelled by the borrower before any lender signed.",
|
|
262
|
+
pending: "Gasless order waiting for a lender offer. No gas was spent.",
|
|
263
|
+
matched: "A lender offered. The settlement bot will execute it shortly.",
|
|
264
|
+
settled: "Settled on-chain. The loan is now active as an inscription."
|
|
265
|
+
};
|
|
266
|
+
var CONCEPT_DESCRIPTIONS = {
|
|
267
|
+
debt: "Tokens the borrower wants to borrow. Lenders provide these.",
|
|
268
|
+
interest: "Extra tokens the borrower pays as reward for the lender.",
|
|
269
|
+
collateral: "Tokens locked by the borrower as security for the loan.",
|
|
270
|
+
duration: "How long the borrower has to repay after funding.",
|
|
271
|
+
apy: "Annual Percentage Yield \u2014 annualized return for lenders.",
|
|
272
|
+
offChain: "Gasless orders signed off-chain. No gas until settlement.",
|
|
273
|
+
shares: "ERC1155 tokens representing a lender's portion of a loan."
|
|
274
|
+
};
|
|
275
|
+
function enrichStatus(row) {
|
|
276
|
+
const base = computeStatus({
|
|
277
|
+
signed_at: BigInt(row.signed_at ?? "0"),
|
|
278
|
+
duration: BigInt(row.duration),
|
|
279
|
+
issued_debt_percentage: BigInt(row.issued_debt_percentage),
|
|
280
|
+
is_repaid: row.status === "repaid",
|
|
281
|
+
liquidated: row.status === "liquidated",
|
|
282
|
+
deadline: BigInt(row.deadline ?? "0"),
|
|
283
|
+
status: row.status
|
|
284
|
+
});
|
|
285
|
+
if (row.auction_started) {
|
|
286
|
+
return "auctioned";
|
|
287
|
+
}
|
|
288
|
+
if (base === "expired" && row.signed_at && BigInt(row.signed_at) > 0n) {
|
|
289
|
+
const signedAt = BigInt(row.signed_at);
|
|
290
|
+
const duration = BigInt(row.duration);
|
|
291
|
+
const nowSeconds = BigInt(Math.floor(Date.now() / 1e3));
|
|
292
|
+
const expiryTime = signedAt + duration;
|
|
293
|
+
if (nowSeconds <= expiryTime + GRACE_PERIOD) {
|
|
294
|
+
return "grace_period";
|
|
295
|
+
}
|
|
296
|
+
return "overdue";
|
|
297
|
+
}
|
|
298
|
+
return base;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/utils/order.ts
|
|
302
|
+
function normalizeOrderData(raw) {
|
|
303
|
+
return {
|
|
304
|
+
borrower: raw.borrower ?? "",
|
|
305
|
+
debtAssets: raw.debt_assets ?? raw.debtAssets ?? [],
|
|
306
|
+
interestAssets: raw.interest_assets ?? raw.interestAssets ?? [],
|
|
307
|
+
collateralAssets: raw.collateral_assets ?? raw.collateralAssets ?? [],
|
|
308
|
+
duration: raw.duration ?? "0",
|
|
309
|
+
deadline: raw.deadline ?? "0",
|
|
310
|
+
multiLender: raw.multi_lender ?? raw.multiLender ?? false
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function sanitizeAssets(arr) {
|
|
314
|
+
if (!Array.isArray(arr)) return [];
|
|
315
|
+
return arr.filter(
|
|
316
|
+
(a) => a != null && typeof a === "object" && typeof a.asset_address === "string" && typeof a.asset_type === "string"
|
|
317
|
+
).map((a) => ({
|
|
318
|
+
asset_address: String(a.asset_address),
|
|
319
|
+
asset_type: String(a.asset_type),
|
|
320
|
+
value: String(a.value ?? "0"),
|
|
321
|
+
token_id: String(a.token_id ?? "0")
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
function parseOrderRow(row) {
|
|
325
|
+
let parsed = {};
|
|
326
|
+
const raw = row.order_data;
|
|
327
|
+
if (typeof raw === "string") {
|
|
328
|
+
try {
|
|
329
|
+
parsed = JSON.parse(raw);
|
|
330
|
+
} catch {
|
|
331
|
+
parsed = {};
|
|
332
|
+
}
|
|
333
|
+
} else if (raw && typeof raw === "object") {
|
|
334
|
+
parsed = raw;
|
|
335
|
+
}
|
|
336
|
+
const debtAssets = sanitizeAssets(parsed.debtAssets ?? parsed.debt_assets);
|
|
337
|
+
const interestAssets = sanitizeAssets(parsed.interestAssets ?? parsed.interest_assets);
|
|
338
|
+
const collateralAssets = sanitizeAssets(parsed.collateralAssets ?? parsed.collateral_assets);
|
|
339
|
+
const { borrower_signature: rawSig, ...safeRow } = row;
|
|
340
|
+
const includeSig = row.status === "pending" && rawSig != null;
|
|
341
|
+
return {
|
|
342
|
+
...safeRow,
|
|
343
|
+
...includeSig ? { borrower_signature: rawSig } : {},
|
|
344
|
+
order_data: {
|
|
345
|
+
borrower: parsed.borrower ?? "",
|
|
346
|
+
debtAssets,
|
|
347
|
+
interestAssets,
|
|
348
|
+
collateralAssets,
|
|
349
|
+
debtCount: debtAssets.length,
|
|
350
|
+
interestCount: interestAssets.length,
|
|
351
|
+
collateralCount: collateralAssets.length,
|
|
352
|
+
duration: String(parsed.duration ?? "0"),
|
|
353
|
+
deadline: String(parsed.deadline ?? "0"),
|
|
354
|
+
multiLender: parsed.multiLender ?? parsed.multi_lender ?? false,
|
|
355
|
+
nonce: String(parsed.nonce ?? row.nonce ?? "0"),
|
|
356
|
+
orderHash: parsed.orderHash ?? void 0
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/utils/signature.ts
|
|
362
|
+
function formatSig(signature) {
|
|
363
|
+
if (Array.isArray(signature)) {
|
|
364
|
+
return signature.map((s) => typeof s === "bigint" ? "0x" + s.toString(16) : String(s));
|
|
365
|
+
}
|
|
366
|
+
const sig = signature;
|
|
367
|
+
return [sig.r, sig.s].map((s) => typeof s === "bigint" ? "0x" + s.toString(16) : String(s));
|
|
368
|
+
}
|
|
369
|
+
function parseSigToArray(raw) {
|
|
370
|
+
if (Array.isArray(raw)) return raw.map(String);
|
|
371
|
+
if (typeof raw === "string") {
|
|
372
|
+
if (raw.startsWith("[")) {
|
|
373
|
+
const parsed = JSON.parse(raw);
|
|
374
|
+
if (!Array.isArray(parsed) || parsed.length < 1 || !parsed.every((s) => typeof s === "string" || typeof s === "number"))
|
|
375
|
+
throw new Error("Invalid signature array format");
|
|
376
|
+
return parsed.map(String);
|
|
377
|
+
}
|
|
378
|
+
if (raw.startsWith("{")) {
|
|
379
|
+
const obj = JSON.parse(raw);
|
|
380
|
+
if (typeof obj.r !== "string" || typeof obj.s !== "string")
|
|
381
|
+
throw new Error("Invalid signature object format: missing r or s");
|
|
382
|
+
return [obj.r, obj.s];
|
|
383
|
+
}
|
|
384
|
+
const parts = raw.split(",");
|
|
385
|
+
if (parts.length < 2) throw new Error("Invalid signature CSV: expected at least 2 elements");
|
|
386
|
+
return parts;
|
|
387
|
+
}
|
|
388
|
+
throw new Error("Invalid signature format");
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// src/utils/calldata.ts
|
|
392
|
+
function serializeAssetCalldata(assets) {
|
|
393
|
+
const calldata = [String(assets.length)];
|
|
394
|
+
for (const asset of assets) {
|
|
395
|
+
const enumVal = ASSET_TYPE_ENUM[asset.asset_type] ?? 0;
|
|
396
|
+
const [valueLow, valueHigh] = toU256(BigInt(asset.value));
|
|
397
|
+
const [tokenIdLow, tokenIdHigh] = toU256(BigInt(asset.token_id));
|
|
398
|
+
calldata.push(
|
|
399
|
+
normalizeAddress(asset.asset_address),
|
|
400
|
+
String(enumVal),
|
|
401
|
+
valueLow,
|
|
402
|
+
valueHigh,
|
|
403
|
+
tokenIdLow,
|
|
404
|
+
tokenIdHigh
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
return calldata;
|
|
408
|
+
}
|
|
409
|
+
function parseAssetArray(calldata, offset) {
|
|
410
|
+
const count = Number(BigInt(calldata[offset]));
|
|
411
|
+
let pos = offset + 1;
|
|
412
|
+
const assets = [];
|
|
413
|
+
for (let i = 0; i < count; i++) {
|
|
414
|
+
const address = normalizeAddress(calldata[pos]);
|
|
415
|
+
const typeEnum = Number(BigInt(calldata[pos + 1]));
|
|
416
|
+
const valueLow = BigInt(calldata[pos + 2]);
|
|
417
|
+
const valueHigh = BigInt(calldata[pos + 3]);
|
|
418
|
+
const tokenIdLow = BigInt(calldata[pos + 4]);
|
|
419
|
+
const tokenIdHigh = BigInt(calldata[pos + 5]);
|
|
420
|
+
assets.push({
|
|
421
|
+
asset_address: address,
|
|
422
|
+
asset_type: ASSET_TYPE_NAMES[typeEnum] ?? "unknown",
|
|
423
|
+
value: fromU256({ low: valueLow, high: valueHigh }).toString(),
|
|
424
|
+
token_id: fromU256({ low: tokenIdLow, high: tokenIdHigh }).toString()
|
|
425
|
+
});
|
|
426
|
+
pos += 6;
|
|
427
|
+
}
|
|
428
|
+
return { assets, nextOffset: pos };
|
|
429
|
+
}
|
|
430
|
+
function serializeSignatureCalldata(sig) {
|
|
431
|
+
let parts;
|
|
432
|
+
if (sig.startsWith("[")) {
|
|
433
|
+
parts = JSON.parse(sig);
|
|
434
|
+
} else if (sig.startsWith("{")) {
|
|
435
|
+
const obj = JSON.parse(sig);
|
|
436
|
+
parts = [obj.r, obj.s];
|
|
437
|
+
} else {
|
|
438
|
+
parts = sig.split(",");
|
|
439
|
+
}
|
|
440
|
+
return [String(parts.length), ...parts];
|
|
441
|
+
}
|
|
442
|
+
function standardizeHex(hex) {
|
|
443
|
+
const clean = hex.toLowerCase().replace(/^0x/, "");
|
|
444
|
+
return "0x" + clean;
|
|
445
|
+
}
|
|
446
|
+
var CREATE_INSCRIPTION_SELECTOR = "0x1883531093e6399258a46b3e397a8ec94952f12d37afeeea49fb35b4361d262";
|
|
447
|
+
var SETTLE_SELECTOR = "0x1482408710165f49db4f7b422428870c37d86b0624cd661b387e24aa64f0249";
|
|
448
|
+
var BATCH_SETTLE_SELECTOR = "0x116475a69261425e56d6d49661fec19f7629381447afd9c70300115e6f44d0f";
|
|
449
|
+
function findCall(calldata, selectors) {
|
|
450
|
+
const numCalls = Number(BigInt(calldata[0]));
|
|
451
|
+
if (numCalls > 0 && numCalls < 100) {
|
|
452
|
+
let pos = 1;
|
|
453
|
+
for (let i = 0; i < numCalls; i++) {
|
|
454
|
+
const selector = standardizeHex(calldata[pos + 1]);
|
|
455
|
+
const cdLen = Number(BigInt(calldata[pos + 2]));
|
|
456
|
+
const cdStart = pos + 3;
|
|
457
|
+
if (selectors.includes(selector)) {
|
|
458
|
+
return { selector, cd: calldata.slice(cdStart, cdStart + cdLen) };
|
|
459
|
+
}
|
|
460
|
+
pos = cdStart + cdLen;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
function parseInscriptionCalldata(calldata) {
|
|
466
|
+
try {
|
|
467
|
+
const match = findCall(calldata, [CREATE_INSCRIPTION_SELECTOR, SETTLE_SELECTOR, BATCH_SETTLE_SELECTOR]);
|
|
468
|
+
if (!match) return null;
|
|
469
|
+
let offset;
|
|
470
|
+
if (match.selector === CREATE_INSCRIPTION_SELECTOR) {
|
|
471
|
+
offset = 1;
|
|
472
|
+
} else if (match.selector === SETTLE_SELECTOR) {
|
|
473
|
+
offset = 11;
|
|
474
|
+
} else {
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
const { assets: debt, nextOffset: afterDebt } = parseAssetArray(match.cd, offset);
|
|
478
|
+
const { assets: interest, nextOffset: afterInterest } = parseAssetArray(match.cd, afterDebt);
|
|
479
|
+
const { assets: collateral } = parseAssetArray(match.cd, afterInterest);
|
|
480
|
+
return { debt, interest, collateral };
|
|
481
|
+
} catch {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
155
485
|
|
|
156
486
|
// src/tokens/registry.ts
|
|
157
487
|
var TOKENS = [
|
|
@@ -378,6 +708,22 @@ function computeSafePositionFloor(params) {
|
|
|
378
708
|
});
|
|
379
709
|
return { debtFloor, interestFloor };
|
|
380
710
|
}
|
|
711
|
+
|
|
712
|
+
// src/math/rate.ts
|
|
713
|
+
function computeInterestRate(debtAssets, interestAssets) {
|
|
714
|
+
let debtTotal = 0n;
|
|
715
|
+
let interestTotal = 0n;
|
|
716
|
+
for (const a of debtAssets) {
|
|
717
|
+
if (a.asset_type === "ERC721") continue;
|
|
718
|
+
debtTotal += BigInt(a.value || "0");
|
|
719
|
+
}
|
|
720
|
+
for (const a of interestAssets) {
|
|
721
|
+
if (a.asset_type === "ERC721") continue;
|
|
722
|
+
interestTotal += BigInt(a.value || "0");
|
|
723
|
+
}
|
|
724
|
+
if (debtTotal === 0n) return null;
|
|
725
|
+
return Number(interestTotal * 1000000n / debtTotal) / 1e6;
|
|
726
|
+
}
|
|
381
727
|
var SELECTORS = {
|
|
382
728
|
InscriptionCreated: hash.getSelectorFromName("InscriptionCreated"),
|
|
383
729
|
InscriptionSigned: hash.getSelectorFromName("InscriptionSigned"),
|
|
@@ -554,6 +900,29 @@ var STELA_DOMAIN = {
|
|
|
554
900
|
// filled at call time
|
|
555
901
|
revision: "1"
|
|
556
902
|
};
|
|
903
|
+
function getCancelOrderTypedData(orderId, chainId) {
|
|
904
|
+
return {
|
|
905
|
+
types: {
|
|
906
|
+
StarknetDomain: [
|
|
907
|
+
{ name: "name", type: "shortstring" },
|
|
908
|
+
{ name: "version", type: "shortstring" },
|
|
909
|
+
{ name: "chainId", type: "shortstring" },
|
|
910
|
+
{ name: "revision", type: "shortstring" }
|
|
911
|
+
],
|
|
912
|
+
CancelOrder: [
|
|
913
|
+
{ name: "order_id", type: "string" }
|
|
914
|
+
]
|
|
915
|
+
},
|
|
916
|
+
primaryType: "CancelOrder",
|
|
917
|
+
domain: {
|
|
918
|
+
...STELA_DOMAIN,
|
|
919
|
+
chainId
|
|
920
|
+
},
|
|
921
|
+
message: {
|
|
922
|
+
order_id: orderId
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
}
|
|
557
926
|
function getInscriptionOrderTypedData(params) {
|
|
558
927
|
return {
|
|
559
928
|
types: {
|
|
@@ -841,6 +1210,27 @@ function getRefinanceApprovalTypedData(params) {
|
|
|
841
1210
|
}
|
|
842
1211
|
};
|
|
843
1212
|
}
|
|
1213
|
+
function getTermsAcknowledgmentTypedData(params) {
|
|
1214
|
+
return {
|
|
1215
|
+
types: {
|
|
1216
|
+
StarknetDomain: STARKNET_DOMAIN_TYPE,
|
|
1217
|
+
TermsAcknowledgment: [
|
|
1218
|
+
{ name: "user", type: "ContractAddress" },
|
|
1219
|
+
{ name: "terms_version", type: "shortstring" },
|
|
1220
|
+
{ name: "terms_hash", type: "felt" },
|
|
1221
|
+
{ name: "agreed_at", type: "u128" }
|
|
1222
|
+
]
|
|
1223
|
+
},
|
|
1224
|
+
primaryType: "TermsAcknowledgment",
|
|
1225
|
+
domain: { ...STELA_DOMAIN, chainId: params.chainId },
|
|
1226
|
+
message: {
|
|
1227
|
+
user: params.user,
|
|
1228
|
+
terms_version: params.termsVersion,
|
|
1229
|
+
terms_hash: params.termsHash,
|
|
1230
|
+
agreed_at: params.agreedAt.toString()
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
844
1234
|
|
|
845
1235
|
// src/offchain/signature.ts
|
|
846
1236
|
function serializeSignature(sig) {
|
|
@@ -3931,6 +4321,19 @@ var StelaSdk = class {
|
|
|
3931
4321
|
}
|
|
3932
4322
|
};
|
|
3933
4323
|
|
|
3934
|
-
|
|
4324
|
+
// src/client/nonce.ts
|
|
4325
|
+
async function getNonce(provider, stelaAddress, accountAddress) {
|
|
4326
|
+
const result = await provider.callContract(
|
|
4327
|
+
{
|
|
4328
|
+
contractAddress: stelaAddress,
|
|
4329
|
+
entrypoint: "nonces",
|
|
4330
|
+
calldata: [accountAddress]
|
|
4331
|
+
},
|
|
4332
|
+
"latest"
|
|
4333
|
+
);
|
|
4334
|
+
return BigInt(result[0]);
|
|
4335
|
+
}
|
|
4336
|
+
|
|
4337
|
+
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, AUCTION_DURATION, AUCTION_PENALTY_BPS, AUCTION_RESERVE_BPS, ApiClient, ApiError, CHAIN_ID, CONCEPT_DESCRIPTIONS, DEFAULT_DUST_BUFFER_SECONDS, DURATION_PRESETS, DURATION_RANGES, EXPLORER_TX_URL, GRACE_PERIOD, INSCRIPTION_STATUS_GROUPS, InscriptionClient, LEND_DEADLINE_PRESETS, LockerClient, MAX_BPS, ORDER_STATUS_GROUPS, ORDER_STATUS_LABELS, SELECTORS, STATUS_DESCRIPTIONS, STATUS_LABELS, STELA_ADDRESS, SWAP_DEADLINE_PRESETS, ShareClient, StelaSdk, TOKENS, VALID_STATUSES, VIRTUAL_SHARE_OFFSET, accruedInterestWithBuffer, addressesEqual, calculateFeeShares, computeInterestRate, computePositionValue, computeSafePositionFloor, computeStatus, convertToShares, deserializeSignature, divCeil, enrichStatus, findTokenByAddress, formatAddress, formatDuration, formatDurationHuman, formatSig, formatTimestamp, formatTokenValue, fromU256, getBatchLendOfferTypedData, getCancelOrderTypedData, getCollateralSaleOfferTypedData, getCollectionBorrowAcceptanceTypedData, getCollectionLendOfferTypedData, getInscriptionOrderTypedData, getLendOfferTypedData, getNFTCollections, getNonce, getOrderStatusBadgeVariant, getOrderStatusLabel, getRefinanceApprovalTypedData, getRefinanceOfferTypedData, getRenegotiationProposalTypedData, getStatusBadgeVariant, getStatusLabel, getTermsAcknowledgmentTypedData, getTokensForNetwork, hashAssets, hashBatchEntries, inscriptionIdToHex, inscriptionMatchesGroup, normalizeAddress, normalizeOrderData, orderMatchesGroup, parseAmount, parseAssetArray, parseEvent, parseEvents, parseInscriptionCalldata, parseOrderRow, parseSigToArray, proRataInterest, proportionalAssetValue, resolveNetwork, scaleByPercentage, serializeAssetCalldata, serializeSignature, serializeSignatureCalldata, shareProportionBps, sharesToPercentage, toHex, toU256 };
|
|
3935
4338
|
//# sourceMappingURL=index.js.map
|
|
3936
4339
|
//# sourceMappingURL=index.js.map
|