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