@trinaryex/sdk 3.5.0 → 3.7.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/DESIGN.md +11 -0
- package/README.md +2 -1
- package/dist/ReadOnlyClient.d.ts +20 -1
- package/dist/TriexClient.d.ts +20 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +337 -164
- package/dist/queries.d.ts +10 -1
- package/dist/schemas.d.ts +251 -2
- package/dist/types.d.ts +29 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -317,21 +317,21 @@ async function O(e, n, r, i) {
|
|
|
317
317
|
//#endregion
|
|
318
318
|
//#region src/transactions.ts
|
|
319
319
|
var se = /* @__PURE__ */ i({
|
|
320
|
-
cancelAllOrdersItem: () =>
|
|
321
|
-
cancelOrderItem: () =>
|
|
320
|
+
cancelAllOrdersItem: () => I,
|
|
321
|
+
cancelOrderItem: () => F,
|
|
322
322
|
depositCoin: () => j,
|
|
323
323
|
depositMulticoinObject: () => ce,
|
|
324
324
|
generateProofAsOwner: () => A,
|
|
325
|
-
modifyOrderItem: () =>
|
|
325
|
+
modifyOrderItem: () => L,
|
|
326
326
|
newBalanceManager: () => k,
|
|
327
|
-
placeLimitOrderItem: () =>
|
|
328
|
-
placeMarketOrderItem: () =>
|
|
329
|
-
redeemReceipt: () =>
|
|
330
|
-
sourceItemsFromHangar: () =>
|
|
327
|
+
placeLimitOrderItem: () => N,
|
|
328
|
+
placeMarketOrderItem: () => P,
|
|
329
|
+
redeemReceipt: () => fe,
|
|
330
|
+
sourceItemsFromHangar: () => M,
|
|
331
331
|
withdrawAllCoin: () => ue,
|
|
332
|
-
withdrawAllMulticoin: () =>
|
|
332
|
+
withdrawAllMulticoin: () => de,
|
|
333
333
|
withdrawCoin: () => le,
|
|
334
|
-
withdrawSettledAmounts: () =>
|
|
334
|
+
withdrawSettledAmounts: () => R
|
|
335
335
|
});
|
|
336
336
|
function k(e, t) {
|
|
337
337
|
return e.moveCall({
|
|
@@ -372,7 +372,7 @@ function ue(e, t, n, r = t.credCoinType) {
|
|
|
372
372
|
arguments: [n]
|
|
373
373
|
});
|
|
374
374
|
}
|
|
375
|
-
function
|
|
375
|
+
function de(e, t, n, r, i) {
|
|
376
376
|
return e.moveCall({
|
|
377
377
|
target: `${t.triex}::balance_manager::withdraw_all_multicoin`,
|
|
378
378
|
arguments: [
|
|
@@ -382,7 +382,7 @@ function M(e, t, n, r, i) {
|
|
|
382
382
|
]
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function fe(e, t, n, r) {
|
|
386
386
|
e.moveCall({
|
|
387
387
|
target: `${t.warehouseReceipts}::receipt::redeem_receipt`,
|
|
388
388
|
arguments: [
|
|
@@ -395,7 +395,7 @@ function N(e, t, n, r) {
|
|
|
395
395
|
]
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function M(e, t, n, r) {
|
|
399
399
|
let i = e.object(r.characterId), a = e.moveCall({
|
|
400
400
|
target: `${t.world}::character::borrow_owner_cap`,
|
|
401
401
|
typeArguments: [r.capTypeArg],
|
|
@@ -426,7 +426,7 @@ function P(e, t, n, r) {
|
|
|
426
426
|
arguments: [n, c]
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function N(e, t, n) {
|
|
430
430
|
e.moveCall({
|
|
431
431
|
target: `${t.triex}::multicoin_pool::place_limit_order`,
|
|
432
432
|
typeArguments: [t.credCoinType],
|
|
@@ -444,7 +444,7 @@ function F(e, t, n) {
|
|
|
444
444
|
]
|
|
445
445
|
});
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function P(e, t, n) {
|
|
448
448
|
e.moveCall({
|
|
449
449
|
target: `${t.triex}::multicoin_pool::place_market_order`,
|
|
450
450
|
typeArguments: [t.credCoinType],
|
|
@@ -459,7 +459,7 @@ function I(e, t, n) {
|
|
|
459
459
|
]
|
|
460
460
|
});
|
|
461
461
|
}
|
|
462
|
-
function
|
|
462
|
+
function F(e, t, n) {
|
|
463
463
|
e.moveCall({
|
|
464
464
|
target: `${t.triex}::multicoin_pool::cancel_order`,
|
|
465
465
|
typeArguments: [t.credCoinType],
|
|
@@ -472,7 +472,7 @@ function L(e, t, n) {
|
|
|
472
472
|
]
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
|
-
function
|
|
475
|
+
function I(e, t, n) {
|
|
476
476
|
e.moveCall({
|
|
477
477
|
target: `${t.triex}::multicoin_pool::cancel_all_orders`,
|
|
478
478
|
typeArguments: [t.credCoinType],
|
|
@@ -484,7 +484,7 @@ function R(e, t, n) {
|
|
|
484
484
|
]
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function L(e, t, n) {
|
|
488
488
|
e.moveCall({
|
|
489
489
|
target: `${t.triex}::multicoin_pool::modify_order`,
|
|
490
490
|
typeArguments: [t.credCoinType],
|
|
@@ -498,7 +498,7 @@ function z(e, t, n) {
|
|
|
498
498
|
]
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function R(e, t, n) {
|
|
502
502
|
e.moveCall({
|
|
503
503
|
target: `${t.triex}::multicoin_pool::withdraw_settled_amounts`,
|
|
504
504
|
typeArguments: [n.quoteCoinType ?? t.credCoinType],
|
|
@@ -511,7 +511,7 @@ function B(e, t, n) {
|
|
|
511
511
|
}
|
|
512
512
|
//#endregion
|
|
513
513
|
//#region src/funding.ts
|
|
514
|
-
async function
|
|
514
|
+
async function z(e, t, n, r, i, a = "Insufficient wallet balance to fund this transaction.") {
|
|
515
515
|
let o = e.core, s = [], c = 0n, l;
|
|
516
516
|
for (let e = 0; e < 40 && c < i; e++) {
|
|
517
517
|
let e = await o.listCoins({
|
|
@@ -533,7 +533,7 @@ async function V(e, t, n, r, i, a = "Insufficient wallet balance to fund this tr
|
|
|
533
533
|
let [p] = t.splitCoins(f, [t.pure.u64(i)]);
|
|
534
534
|
return p;
|
|
535
535
|
}
|
|
536
|
-
async function
|
|
536
|
+
async function B(e, t, n, r, i) {
|
|
537
537
|
let { assetId: a, amount: o } = i;
|
|
538
538
|
if (o <= 0n) throw new d(u.ValidationFailed, "Item amount must be positive.");
|
|
539
539
|
let s = i.deficitMode && i.balanceManagerId ? await w(e, n, i.balanceManagerId, i.vaultCollectionId, a) : {
|
|
@@ -549,7 +549,7 @@ async function H(e, t, n, r, i) {
|
|
|
549
549
|
if (c -= m, c <= 0n) return;
|
|
550
550
|
let [h, g] = await Promise.all([D(e, i.ssuObjectId, i.owner), E(e, n, i.owner)]), _ = async (o, s, c, l) => {
|
|
551
551
|
let u = await ie(e, o);
|
|
552
|
-
|
|
552
|
+
M(t, n, r, {
|
|
553
553
|
ssuObjectId: i.ssuObjectId,
|
|
554
554
|
characterId: c,
|
|
555
555
|
capRef: u,
|
|
@@ -581,34 +581,34 @@ async function H(e, t, n, r, i) {
|
|
|
581
581
|
}
|
|
582
582
|
//#endregion
|
|
583
583
|
//#region src/money.ts
|
|
584
|
-
var
|
|
585
|
-
function
|
|
584
|
+
var pe = 1000000000n, V = 1n, H = 1000000000n, me = 18446744073709551615n;
|
|
585
|
+
function he(e, t) {
|
|
586
586
|
let n = typeof e == "number" ? e.toString() : e.trim();
|
|
587
587
|
if (!/^\d+(\.\d+)?$/.test(n)) throw Error(`toBase: invalid amount "${e}"`);
|
|
588
588
|
let [r, i = ""] = n.split("."), a = (i + "0".repeat(t)).slice(0, t);
|
|
589
589
|
return BigInt(r) * 10n ** BigInt(t) + BigInt(a || "0");
|
|
590
590
|
}
|
|
591
|
-
function
|
|
591
|
+
function ge(e, t) {
|
|
592
592
|
let n = e < 0n, r = n ? -e : e, i = 10n ** BigInt(t), a = r / i, o = (r % i).toString().padStart(t, "0").replace(/0+$/, ""), s = n ? "-" : "";
|
|
593
593
|
return o ? `${s}${a}.${o}` : `${s}${a}`;
|
|
594
594
|
}
|
|
595
|
-
function
|
|
596
|
-
return e * t *
|
|
595
|
+
function U(e, t) {
|
|
596
|
+
return e * t * V / 1n;
|
|
597
597
|
}
|
|
598
|
-
function
|
|
599
|
-
return
|
|
598
|
+
function _e(e, t, n) {
|
|
599
|
+
return U(e, t) * (H + n) / H;
|
|
600
600
|
}
|
|
601
|
-
function
|
|
602
|
-
return e * t /
|
|
601
|
+
function ve(e, t) {
|
|
602
|
+
return e * t / H + 2n;
|
|
603
603
|
}
|
|
604
|
-
function
|
|
604
|
+
function ye(e, t, n) {
|
|
605
605
|
let r = t, i = 0n;
|
|
606
606
|
for (let t of e) {
|
|
607
607
|
if (r <= 0n) break;
|
|
608
608
|
let e = t.remainingQuantity < r ? t.remainingQuantity : r;
|
|
609
609
|
i += e * t.price, r -= e;
|
|
610
610
|
}
|
|
611
|
-
let a = i * n /
|
|
611
|
+
let a = i * n / H;
|
|
612
612
|
return {
|
|
613
613
|
quote: i,
|
|
614
614
|
fee: a,
|
|
@@ -618,7 +618,7 @@ function _e(e, t, n) {
|
|
|
618
618
|
}
|
|
619
619
|
//#endregion
|
|
620
620
|
//#region src/schemas.ts
|
|
621
|
-
var
|
|
621
|
+
var W = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
622
622
|
try {
|
|
623
623
|
return BigInt(e);
|
|
624
624
|
} catch {
|
|
@@ -627,14 +627,14 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
627
627
|
message: `not an integer: ${e}`
|
|
628
628
|
}), n.NEVER;
|
|
629
629
|
}
|
|
630
|
-
}),
|
|
630
|
+
}), be = n.object({
|
|
631
631
|
pool_id: n.string(),
|
|
632
632
|
order_id: n.string(),
|
|
633
|
-
price:
|
|
633
|
+
price: W,
|
|
634
634
|
is_bid: n.boolean(),
|
|
635
635
|
balance_manager_id: n.string(),
|
|
636
|
-
remaining_quantity:
|
|
637
|
-
filled_quantity:
|
|
636
|
+
remaining_quantity: W,
|
|
637
|
+
filled_quantity: W,
|
|
638
638
|
expires_at: n.number().nullable(),
|
|
639
639
|
last_activity_at: n.number(),
|
|
640
640
|
asset_id: n.string(),
|
|
@@ -667,22 +667,22 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
667
667
|
quoteAssetDecimals: e.quote_asset_decimals,
|
|
668
668
|
traderAddress: e.trader_address,
|
|
669
669
|
traderName: e.trader_name
|
|
670
|
-
})),
|
|
671
|
-
data: n.array(
|
|
670
|
+
})), xe = n.object({
|
|
671
|
+
data: n.array(be),
|
|
672
672
|
next_cursor: n.string().nullable(),
|
|
673
673
|
prev_cursor: n.string().nullable()
|
|
674
674
|
}).transform((e) => ({
|
|
675
675
|
orders: e.data,
|
|
676
676
|
nextCursor: e.next_cursor,
|
|
677
677
|
prevCursor: e.prev_cursor
|
|
678
|
-
})),
|
|
678
|
+
})), Se = n.object({ pool_id: n.string().nullable() }).transform((e) => ({ poolId: e.pool_id })), G = n.object({
|
|
679
679
|
encodedOrderId: n.string(),
|
|
680
|
-
quantity:
|
|
681
|
-
filledQuantity:
|
|
682
|
-
expireTimestamp:
|
|
683
|
-
lastUpdatedTimestamp:
|
|
680
|
+
quantity: W,
|
|
681
|
+
filledQuantity: W,
|
|
682
|
+
expireTimestamp: W,
|
|
683
|
+
lastUpdatedTimestamp: W,
|
|
684
684
|
status: n.number(),
|
|
685
|
-
price:
|
|
685
|
+
price: W
|
|
686
686
|
}).transform((e) => ({
|
|
687
687
|
orderId: e.encodedOrderId,
|
|
688
688
|
quantity: e.quantity,
|
|
@@ -692,10 +692,10 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
692
692
|
lastUpdatedTimestamp: e.lastUpdatedTimestamp,
|
|
693
693
|
status: e.status,
|
|
694
694
|
price: e.price
|
|
695
|
-
})),
|
|
696
|
-
bids: n.array(
|
|
697
|
-
asks: n.array(
|
|
698
|
-
}),
|
|
695
|
+
})), Ce = n.object({
|
|
696
|
+
bids: n.array(G),
|
|
697
|
+
asks: n.array(G)
|
|
698
|
+
}), we = n.object({
|
|
699
699
|
pool_id: n.string(),
|
|
700
700
|
pool_name: n.string(),
|
|
701
701
|
base_asset_symbol: n.string(),
|
|
@@ -723,14 +723,14 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
723
723
|
collectionId: e.collection_id,
|
|
724
724
|
feeRateScaled: e.fee === null ? 0n : BigInt(e.fee),
|
|
725
725
|
feeRate: e.fee_rate
|
|
726
|
-
})),
|
|
726
|
+
})), Te = n.object({
|
|
727
727
|
hub_id: n.string(),
|
|
728
728
|
collection_id: n.string(),
|
|
729
729
|
vault_config_id: n.string().nullable(),
|
|
730
730
|
pool_id: n.string().nullable(),
|
|
731
|
-
metadata:
|
|
732
|
-
bids: n.array(
|
|
733
|
-
asks: n.array(
|
|
731
|
+
metadata: we.nullable(),
|
|
732
|
+
bids: n.array(G),
|
|
733
|
+
asks: n.array(G)
|
|
734
734
|
}).transform((e) => ({
|
|
735
735
|
hubId: e.hub_id,
|
|
736
736
|
collectionId: e.collection_id,
|
|
@@ -739,7 +739,7 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
739
739
|
metadata: e.metadata,
|
|
740
740
|
bids: e.bids,
|
|
741
741
|
asks: e.asks
|
|
742
|
-
})),
|
|
742
|
+
})), Ee = n.object({
|
|
743
743
|
hub_id: n.string(),
|
|
744
744
|
collection_id: n.string(),
|
|
745
745
|
vault_config_id: n.string()
|
|
@@ -747,7 +747,7 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
747
747
|
hubId: e.hub_id,
|
|
748
748
|
collectionId: e.collection_id,
|
|
749
749
|
vaultConfigId: e.vault_config_id
|
|
750
|
-
})),
|
|
750
|
+
})), K = {
|
|
751
751
|
hub_id: n.string(),
|
|
752
752
|
assembly_item_id: n.string(),
|
|
753
753
|
assembly_tenant: n.string(),
|
|
@@ -761,25 +761,55 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
761
761
|
updated_at: n.number(),
|
|
762
762
|
tx_digest: n.string(),
|
|
763
763
|
is_public: n.boolean(),
|
|
764
|
-
region_id: n.number().nullable()
|
|
764
|
+
region_id: n.number().nullable()
|
|
765
|
+
};
|
|
766
|
+
function q(e) {
|
|
767
|
+
return {
|
|
768
|
+
hubId: e.hub_id,
|
|
769
|
+
assemblyItemId: e.assembly_item_id,
|
|
770
|
+
assemblyTenant: e.assembly_tenant,
|
|
771
|
+
typeId: e.type_id,
|
|
772
|
+
ownerCapId: e.owner_cap_id,
|
|
773
|
+
owner: e.owner,
|
|
774
|
+
solarSystemId: e.solar_system,
|
|
775
|
+
x: e.x,
|
|
776
|
+
y: e.y,
|
|
777
|
+
z: e.z,
|
|
778
|
+
updatedAt: e.updated_at,
|
|
779
|
+
txDigest: e.tx_digest,
|
|
780
|
+
isPublic: e.is_public,
|
|
781
|
+
regionId: e.region_id
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
var De = n.object({
|
|
785
|
+
...K,
|
|
765
786
|
solar_system_name: n.string().nullable()
|
|
766
787
|
}).transform((e) => ({
|
|
767
|
-
|
|
768
|
-
assemblyItemId: e.assembly_item_id,
|
|
769
|
-
assemblyTenant: e.assembly_tenant,
|
|
770
|
-
typeId: e.type_id,
|
|
771
|
-
ownerCapId: e.owner_cap_id,
|
|
772
|
-
owner: e.owner,
|
|
773
|
-
solarSystemId: e.solar_system,
|
|
774
|
-
x: e.x,
|
|
775
|
-
y: e.y,
|
|
776
|
-
z: e.z,
|
|
777
|
-
updatedAt: e.updated_at,
|
|
778
|
-
txDigest: e.tx_digest,
|
|
779
|
-
isPublic: e.is_public,
|
|
780
|
-
regionId: e.region_id,
|
|
788
|
+
...q(e),
|
|
781
789
|
solarSystemName: e.solar_system_name
|
|
782
|
-
})),
|
|
790
|
+
})), Oe = n.object({
|
|
791
|
+
data: n.array(De),
|
|
792
|
+
next_cursor: n.string().nullable()
|
|
793
|
+
}).transform((e) => ({
|
|
794
|
+
locations: e.data,
|
|
795
|
+
nextCursor: e.next_cursor
|
|
796
|
+
})), ke = n.object({
|
|
797
|
+
...K,
|
|
798
|
+
solar_system_name: n.string().nullable(),
|
|
799
|
+
distance_ly: n.string()
|
|
800
|
+
}).transform((e) => ({
|
|
801
|
+
...q(e),
|
|
802
|
+
solarSystemName: e.solar_system_name,
|
|
803
|
+
distanceLy: e.distance_ly
|
|
804
|
+
})), Ae = n.object({
|
|
805
|
+
...K,
|
|
806
|
+
pool_count: n.number(),
|
|
807
|
+
last_activity_at: n.number().nullable()
|
|
808
|
+
}).transform((e) => ({
|
|
809
|
+
...q(e),
|
|
810
|
+
poolCount: e.pool_count,
|
|
811
|
+
lastActivityAt: e.last_activity_at
|
|
812
|
+
})), je = n.object({
|
|
783
813
|
asset_id: n.string(),
|
|
784
814
|
has_bids: n.boolean(),
|
|
785
815
|
has_asks: n.boolean()
|
|
@@ -787,49 +817,83 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
787
817
|
assetId: e.asset_id,
|
|
788
818
|
hasBids: e.has_bids,
|
|
789
819
|
hasAsks: e.has_asks
|
|
790
|
-
})),
|
|
791
|
-
data: n.array(
|
|
820
|
+
})), Me = n.object({
|
|
821
|
+
data: n.array(je),
|
|
792
822
|
next_cursor: n.string().nullable()
|
|
793
823
|
}).transform((e) => ({
|
|
794
824
|
items: e.data,
|
|
795
825
|
nextCursor: e.next_cursor
|
|
796
|
-
})),
|
|
826
|
+
})), Ne = n.object({
|
|
797
827
|
hub_id: n.string(),
|
|
798
828
|
collection_id: n.string()
|
|
799
829
|
}).transform((e) => ({
|
|
800
830
|
hubId: e.hub_id,
|
|
801
831
|
collectionId: e.collection_id
|
|
802
|
-
})),
|
|
832
|
+
})), Pe = n.object({
|
|
833
|
+
assembly_id: n.string(),
|
|
834
|
+
owner: n.string().nullable()
|
|
835
|
+
}).transform((e) => ({
|
|
836
|
+
assemblyId: e.assembly_id,
|
|
837
|
+
owner: e.owner
|
|
838
|
+
})), Fe = n.object({
|
|
839
|
+
assembly_id: n.string(),
|
|
840
|
+
owner: n.string().nullable(),
|
|
841
|
+
owner_character_name: n.string().nullable(),
|
|
842
|
+
owner_character_id: n.string().nullable(),
|
|
843
|
+
assembly_name: n.string().nullable()
|
|
844
|
+
}).transform((e) => ({
|
|
845
|
+
assemblyId: e.assembly_id,
|
|
846
|
+
owner: e.owner,
|
|
847
|
+
ownerCharacterName: e.owner_character_name,
|
|
848
|
+
ownerCharacterId: e.owner_character_id,
|
|
849
|
+
assemblyName: e.assembly_name
|
|
850
|
+
})), Ie = n.object({
|
|
851
|
+
balance_manager_id: n.string(),
|
|
852
|
+
owner: n.string().nullable(),
|
|
853
|
+
owner_name: n.string().nullable(),
|
|
854
|
+
root_ou_id: n.string().nullable()
|
|
855
|
+
}).transform((e) => ({
|
|
856
|
+
balanceManagerId: e.balance_manager_id,
|
|
857
|
+
owner: e.owner,
|
|
858
|
+
ownerName: e.owner_name,
|
|
859
|
+
rootOuId: e.root_ou_id
|
|
860
|
+
})), Le = n.object({
|
|
861
|
+
solar_system_id: n.number(),
|
|
862
|
+
solar_system_name: n.string().nullable()
|
|
863
|
+
}).transform((e) => ({
|
|
864
|
+
solarSystemId: e.solar_system_id,
|
|
865
|
+
solarSystemName: e.solar_system_name
|
|
866
|
+
})), Re = n.object({
|
|
803
867
|
asset_id: n.string(),
|
|
804
868
|
quantity: n.number()
|
|
805
869
|
}).transform((e) => ({
|
|
806
870
|
assetId: e.asset_id,
|
|
807
871
|
quantity: e.quantity
|
|
808
|
-
})),
|
|
872
|
+
})), ze = n.object({
|
|
809
873
|
output_quantity: n.number(),
|
|
810
|
-
components: n.array(
|
|
874
|
+
components: n.array(Re)
|
|
811
875
|
}).transform((e) => ({
|
|
812
876
|
outputQuantity: e.output_quantity,
|
|
813
877
|
components: e.components
|
|
814
|
-
})),
|
|
878
|
+
})), Be = n.object({
|
|
815
879
|
asset_id: n.string(),
|
|
816
880
|
name: n.string().nullable(),
|
|
817
881
|
symbol: n.string().nullable(),
|
|
818
882
|
mass: n.number(),
|
|
819
|
-
recipes: n.array(
|
|
883
|
+
recipes: n.array(ze)
|
|
820
884
|
}).transform((e) => ({
|
|
821
885
|
assetId: e.asset_id,
|
|
822
886
|
name: e.name,
|
|
823
887
|
symbol: e.symbol,
|
|
824
888
|
mass: e.mass,
|
|
825
889
|
recipes: e.recipes
|
|
826
|
-
})),
|
|
890
|
+
})), Ve = n.object({ data: n.array(Be) }).transform((e) => ({ items: e.data })), J = n.object({
|
|
827
891
|
asset_id: n.string(),
|
|
828
|
-
amount:
|
|
892
|
+
amount: W
|
|
829
893
|
}).transform((e) => ({
|
|
830
894
|
assetId: e.asset_id,
|
|
831
895
|
amount: e.amount
|
|
832
|
-
})),
|
|
896
|
+
})), He = n.object({
|
|
833
897
|
storage_unit_id: n.string(),
|
|
834
898
|
collection_id: n.string(),
|
|
835
899
|
warehouse: n.array(J),
|
|
@@ -843,14 +907,14 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
843
907
|
marketplace: e.marketplace,
|
|
844
908
|
hangar: e.hangar,
|
|
845
909
|
orgVaults: e.org_vaults
|
|
846
|
-
})),
|
|
910
|
+
})), Ue = n.object({
|
|
847
911
|
pool_id: n.string(),
|
|
848
912
|
order_id: n.string(),
|
|
849
913
|
encoded_order_id: n.string().optional(),
|
|
850
914
|
side: n.enum(["buy", "sell"]),
|
|
851
|
-
price:
|
|
852
|
-
remaining_quantity:
|
|
853
|
-
filled_quantity:
|
|
915
|
+
price: W,
|
|
916
|
+
remaining_quantity: W,
|
|
917
|
+
filled_quantity: W,
|
|
854
918
|
expires_at: n.number(),
|
|
855
919
|
updated_at: n.number(),
|
|
856
920
|
asset_id: n.string(),
|
|
@@ -871,21 +935,21 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
871
935
|
storageUnitId: e.storage_unit_id,
|
|
872
936
|
quoteAssetSymbol: e.quote_asset_symbol,
|
|
873
937
|
quoteAssetDecimals: e.quote_asset_decimals
|
|
874
|
-
})),
|
|
875
|
-
data: n.array(
|
|
938
|
+
})), We = n.object({
|
|
939
|
+
data: n.array(Ue),
|
|
876
940
|
next_cursor: n.string().nullable()
|
|
877
941
|
}).transform((e) => ({
|
|
878
942
|
orders: e.data,
|
|
879
943
|
nextCursor: e.next_cursor
|
|
880
|
-
})),
|
|
944
|
+
})), Ge = n.object({
|
|
881
945
|
event_digest: n.string(),
|
|
882
946
|
pool_id: n.string(),
|
|
883
947
|
order_id: n.string(),
|
|
884
948
|
counterparty_balance_manager_id: n.string(),
|
|
885
|
-
price:
|
|
886
|
-
base_quantity:
|
|
887
|
-
quote_quantity:
|
|
888
|
-
fee:
|
|
949
|
+
price: W,
|
|
950
|
+
base_quantity: W,
|
|
951
|
+
quote_quantity: W,
|
|
952
|
+
fee: W,
|
|
889
953
|
role: n.enum(["maker", "taker"]),
|
|
890
954
|
taker_is_bid: n.boolean(),
|
|
891
955
|
filled_at: n.number()
|
|
@@ -901,21 +965,21 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
901
965
|
role: e.role,
|
|
902
966
|
takerIsBid: e.taker_is_bid,
|
|
903
967
|
filledAt: e.filled_at
|
|
904
|
-
})),
|
|
905
|
-
data: n.array(
|
|
968
|
+
})), Ke = n.object({
|
|
969
|
+
data: n.array(Ge),
|
|
906
970
|
next_cursor: n.string().nullable()
|
|
907
971
|
}).transform((e) => ({
|
|
908
972
|
fills: e.data,
|
|
909
973
|
nextCursor: e.next_cursor
|
|
910
|
-
})),
|
|
974
|
+
})), qe = n.object({
|
|
911
975
|
event_digest: n.string(),
|
|
912
976
|
pool_id: n.string(),
|
|
913
977
|
order_id: n.string(),
|
|
914
978
|
counterparty_balance_manager_id: n.string(),
|
|
915
|
-
price:
|
|
916
|
-
base_quantity:
|
|
917
|
-
quote_quantity:
|
|
918
|
-
fee:
|
|
979
|
+
price: W,
|
|
980
|
+
base_quantity: W,
|
|
981
|
+
quote_quantity: W,
|
|
982
|
+
fee: W,
|
|
919
983
|
role: n.enum(["maker", "taker"]),
|
|
920
984
|
side: n.enum(["buy", "sell"]),
|
|
921
985
|
traded_at: n.number(),
|
|
@@ -935,29 +999,29 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
935
999
|
tradedAt: e.traded_at,
|
|
936
1000
|
assetId: e.asset_id,
|
|
937
1001
|
storageUnitId: e.storage_unit_id
|
|
938
|
-
})),
|
|
939
|
-
data: n.array(
|
|
1002
|
+
})), Je = n.object({
|
|
1003
|
+
data: n.array(qe),
|
|
940
1004
|
next_cursor: n.string().nullable()
|
|
941
1005
|
}).transform((e) => ({
|
|
942
1006
|
trades: e.data,
|
|
943
1007
|
nextCursor: e.next_cursor
|
|
944
|
-
})),
|
|
945
|
-
base:
|
|
946
|
-
quote:
|
|
947
|
-
cred:
|
|
1008
|
+
})), Ye = n.object({
|
|
1009
|
+
base: W,
|
|
1010
|
+
quote: W,
|
|
1011
|
+
cred: W
|
|
948
1012
|
}).transform((e) => ({
|
|
949
1013
|
base: e.base,
|
|
950
1014
|
quote: e.quote,
|
|
951
1015
|
cred: e.cred
|
|
952
|
-
})),
|
|
1016
|
+
})), Xe = n.object({
|
|
953
1017
|
pool_id: n.string(),
|
|
954
1018
|
collection_id: n.string(),
|
|
955
1019
|
asset_id: n.string(),
|
|
956
1020
|
quote_asset_id: n.string().nullable(),
|
|
957
1021
|
storage_unit_id: n.string(),
|
|
958
1022
|
vault_config_id: n.string(),
|
|
959
|
-
settled:
|
|
960
|
-
owed:
|
|
1023
|
+
settled: Ye,
|
|
1024
|
+
owed: Ye,
|
|
961
1025
|
open_order_count: n.number()
|
|
962
1026
|
}).transform((e) => ({
|
|
963
1027
|
poolId: e.pool_id,
|
|
@@ -969,10 +1033,10 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
969
1033
|
settled: e.settled,
|
|
970
1034
|
owed: e.owed,
|
|
971
1035
|
openOrderCount: e.open_order_count
|
|
972
|
-
})),
|
|
1036
|
+
})), Ze = n.object({
|
|
973
1037
|
collection_id: n.string(),
|
|
974
1038
|
asset_id: n.string(),
|
|
975
|
-
amount:
|
|
1039
|
+
amount: W,
|
|
976
1040
|
storage_unit_id: n.string(),
|
|
977
1041
|
vault_config_id: n.string()
|
|
978
1042
|
}).transform((e) => ({
|
|
@@ -981,11 +1045,11 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
|
|
|
981
1045
|
amount: e.amount,
|
|
982
1046
|
storageUnitId: e.storage_unit_id,
|
|
983
1047
|
vaultConfigId: e.vault_config_id
|
|
984
|
-
})),
|
|
1048
|
+
})), Qe = n.object({
|
|
985
1049
|
balance_manager_id: n.string(),
|
|
986
1050
|
as_of_checkpoint: n.string().nullable(),
|
|
987
|
-
pools: n.array(
|
|
988
|
-
items: n.array(
|
|
1051
|
+
pools: n.array(Xe),
|
|
1052
|
+
items: n.array(Ze)
|
|
989
1053
|
}).transform((e) => ({
|
|
990
1054
|
balanceManagerId: e.balance_manager_id,
|
|
991
1055
|
asOfCheckpoint: e.as_of_checkpoint,
|
|
@@ -1034,7 +1098,7 @@ var X = class {
|
|
|
1034
1098
|
return await i.json();
|
|
1035
1099
|
}
|
|
1036
1100
|
async discovery(e) {
|
|
1037
|
-
return Y(
|
|
1101
|
+
return Y(xe, await this.get("/v1/discovery", {
|
|
1038
1102
|
storage_unit_ids: e?.storageUnitIds?.join(","),
|
|
1039
1103
|
asset_id: e?.assetId,
|
|
1040
1104
|
balance_manager_id: e?.balanceManagerId,
|
|
@@ -1045,49 +1109,104 @@ var X = class {
|
|
|
1045
1109
|
}), "discovery");
|
|
1046
1110
|
}
|
|
1047
1111
|
async resolvePool(e) {
|
|
1048
|
-
return Y(
|
|
1112
|
+
return Y(Se, await this.get("/v1/pools/resolve", {
|
|
1049
1113
|
collection_id: e.collectionId,
|
|
1050
1114
|
asset_id: e.assetId,
|
|
1051
1115
|
quote_type: e.quoteType
|
|
1052
1116
|
}), "resolvePool").poolId;
|
|
1053
1117
|
}
|
|
1054
1118
|
async hubItemOrderbook(e) {
|
|
1055
|
-
return Y(
|
|
1119
|
+
return Y(Te, await this.get(`/v1/hubs/${encodeURIComponent(e.hubId)}/items/${encodeURIComponent(e.assetId)}/orderbook`, { quote_type: e.quoteType }, u.HubNotFound), "hubItemOrderbook");
|
|
1056
1120
|
}
|
|
1057
1121
|
async orderbook(e) {
|
|
1058
1122
|
return {
|
|
1059
1123
|
poolId: e,
|
|
1060
|
-
...Y(
|
|
1124
|
+
...Y(Ce, await this.get(`/v1/pools/${encodeURIComponent(e)}/orderbook`, void 0, u.PoolNotFound), "orderbook")
|
|
1061
1125
|
};
|
|
1062
1126
|
}
|
|
1063
1127
|
async poolMetadata(e) {
|
|
1064
|
-
return Y(
|
|
1128
|
+
return Y(we, await this.get(`/v1/pools/${encodeURIComponent(e)}/metadata`, void 0, u.PoolNotFound), "poolMetadata");
|
|
1065
1129
|
}
|
|
1066
1130
|
async hubVault(e) {
|
|
1067
|
-
return Y(
|
|
1131
|
+
return Y(Ee, await this.get(`/v1/hubs/${encodeURIComponent(e)}/vault`, void 0, u.HubNotFound), "hubVault");
|
|
1068
1132
|
}
|
|
1069
1133
|
async hubLocation(e) {
|
|
1070
1134
|
try {
|
|
1071
|
-
return Y(
|
|
1135
|
+
return Y(De, await this.get(`/v1/hubs/${encodeURIComponent(e)}/location`, void 0, u.HubNotFound), "hubLocation");
|
|
1072
1136
|
} catch (e) {
|
|
1073
1137
|
if (e instanceof d && e.status === 404) return null;
|
|
1074
1138
|
throw e;
|
|
1075
1139
|
}
|
|
1076
1140
|
}
|
|
1141
|
+
async hubLocations(e) {
|
|
1142
|
+
return Y(Oe, await this.get("/v1/hubs/locations", {
|
|
1143
|
+
limit: e?.limit,
|
|
1144
|
+
cursor: e?.cursor,
|
|
1145
|
+
solar_system: e?.solarSystemId,
|
|
1146
|
+
tenant: e?.tenant,
|
|
1147
|
+
has_vault: e?.hasVault
|
|
1148
|
+
}), "hubLocations");
|
|
1149
|
+
}
|
|
1150
|
+
async itemLocations(e, t) {
|
|
1151
|
+
return Y(Oe, await this.get(`/v1/items/${encodeURIComponent(e)}/locations`, {
|
|
1152
|
+
limit: t?.limit,
|
|
1153
|
+
cursor: t?.cursor
|
|
1154
|
+
}), "itemLocations");
|
|
1155
|
+
}
|
|
1156
|
+
async nearbyHubs(e) {
|
|
1157
|
+
let t = await this.get(`/v1/hubs/${encodeURIComponent(e.hubId)}/nearby`, {
|
|
1158
|
+
range: e.rangeLy,
|
|
1159
|
+
type_id: e.assetId
|
|
1160
|
+
}, u.HubNotFound);
|
|
1161
|
+
return Y(n.array(ke), t, "nearbyHubs");
|
|
1162
|
+
}
|
|
1163
|
+
async nearbyHubsBySystem(e) {
|
|
1164
|
+
let t = await this.get("/v1/hubs/nearby-by-system", {
|
|
1165
|
+
system_id: e.solarSystem,
|
|
1166
|
+
range: e.rangeLy,
|
|
1167
|
+
type_id: e.assetId
|
|
1168
|
+
});
|
|
1169
|
+
return Y(n.array(ke), t, "nearbyHubsBySystem");
|
|
1170
|
+
}
|
|
1171
|
+
async hubsEnriched(e) {
|
|
1172
|
+
if (e.length === 0) return [];
|
|
1173
|
+
let t = await this.get("/v1/hubs/enriched", { ids: e.join(",") });
|
|
1174
|
+
return Y(n.array(Ae), t, "hubsEnriched");
|
|
1175
|
+
}
|
|
1077
1176
|
async hubItems(e) {
|
|
1078
|
-
return Y(
|
|
1177
|
+
return Y(Me, await this.get(`/v1/hubs/${encodeURIComponent(e)}/items`, void 0, u.HubNotFound), "hubItems");
|
|
1079
1178
|
}
|
|
1080
1179
|
async searchItems(e, t) {
|
|
1081
|
-
return Y(
|
|
1180
|
+
return Y(Ve, await this.get("/v1/world/items/search", {
|
|
1082
1181
|
q: e,
|
|
1083
1182
|
limit: t
|
|
1084
1183
|
}), "searchItems");
|
|
1085
1184
|
}
|
|
1086
1185
|
async collectionHub(e) {
|
|
1087
|
-
return Y(
|
|
1186
|
+
return Y(Ne, await this.get(`/v1/collections/${encodeURIComponent(e)}/hub`, void 0, u.HubNotFound), "collectionHub");
|
|
1187
|
+
}
|
|
1188
|
+
async assemblyOwners(e) {
|
|
1189
|
+
if (e.length === 0) return [];
|
|
1190
|
+
let t = await this.get("/v1/assemblies/owners", { ids: e.join(",") });
|
|
1191
|
+
return Y(n.array(Pe), t, "assemblyOwners");
|
|
1192
|
+
}
|
|
1193
|
+
async assembliesEnriched(e) {
|
|
1194
|
+
if (e.length === 0) return [];
|
|
1195
|
+
let t = await this.get("/v1/assemblies/enriched", { ids: e.join(",") });
|
|
1196
|
+
return Y(n.array(Fe), t, "assembliesEnriched");
|
|
1197
|
+
}
|
|
1198
|
+
async balanceManagerOwners(e) {
|
|
1199
|
+
if (e.length === 0) return [];
|
|
1200
|
+
let t = await this.get("/v1/balance-managers/owners", { ids: e.join(",") });
|
|
1201
|
+
return Y(n.array(Ie), t, "balanceManagerOwners");
|
|
1202
|
+
}
|
|
1203
|
+
async solarSystemNames(e) {
|
|
1204
|
+
if (e.length === 0) return [];
|
|
1205
|
+
let t = await this.get("/v1/solar-systems/names", { ids: e.join(",") });
|
|
1206
|
+
return Y(n.array(Le), t, "solarSystemNames");
|
|
1088
1207
|
}
|
|
1089
1208
|
async inventoryBalances(e) {
|
|
1090
|
-
return Y(
|
|
1209
|
+
return Y(He, await this.get("/v1/inventory/balances", {
|
|
1091
1210
|
storage_unit_id: e.storageUnitId,
|
|
1092
1211
|
owner_address: e.address,
|
|
1093
1212
|
balance_manager_id: e.balanceManagerId,
|
|
@@ -1096,14 +1215,14 @@ var X = class {
|
|
|
1096
1215
|
}, u.HubNotFound), "inventoryBalances");
|
|
1097
1216
|
}
|
|
1098
1217
|
async openOrders(e, t) {
|
|
1099
|
-
return Y(
|
|
1218
|
+
return Y(We, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/open-orders`, {
|
|
1100
1219
|
before: t?.before,
|
|
1101
1220
|
after: t?.after,
|
|
1102
1221
|
limit: t?.limit
|
|
1103
1222
|
}, u.BalanceManagerNotFound), "openOrders");
|
|
1104
1223
|
}
|
|
1105
1224
|
async fills(e, t) {
|
|
1106
|
-
return Y(
|
|
1225
|
+
return Y(Ke, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/fills`, {
|
|
1107
1226
|
before: t?.before,
|
|
1108
1227
|
after: t?.after,
|
|
1109
1228
|
limit: t?.limit,
|
|
@@ -1112,10 +1231,10 @@ var X = class {
|
|
|
1112
1231
|
}, u.BalanceManagerNotFound), "fills");
|
|
1113
1232
|
}
|
|
1114
1233
|
async sweepable(e) {
|
|
1115
|
-
return Y(
|
|
1234
|
+
return Y(Qe, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/sweepable`, void 0, u.BalanceManagerNotFound), "sweepable");
|
|
1116
1235
|
}
|
|
1117
1236
|
async trades(e, t) {
|
|
1118
|
-
return Y(
|
|
1237
|
+
return Y(Je, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/trades`, {
|
|
1119
1238
|
before: t?.before,
|
|
1120
1239
|
after: t?.after,
|
|
1121
1240
|
limit: t?.limit,
|
|
@@ -1123,7 +1242,7 @@ var X = class {
|
|
|
1123
1242
|
asset_id: t?.assetId
|
|
1124
1243
|
}, u.BalanceManagerNotFound), "trades");
|
|
1125
1244
|
}
|
|
1126
|
-
},
|
|
1245
|
+
}, $e = class {
|
|
1127
1246
|
suiClient;
|
|
1128
1247
|
ids;
|
|
1129
1248
|
indexer;
|
|
@@ -1135,7 +1254,7 @@ var X = class {
|
|
|
1135
1254
|
market;
|
|
1136
1255
|
orders;
|
|
1137
1256
|
constructor(e) {
|
|
1138
|
-
this.suiClient = e.suiClient, this.executor = e.executor, this.address = e.address, this.ids = l(e.network ?? "testnet", e.packageIds), this.indexer = new X(e.indexerUrl ?? "https://api.trinary.exchange", e.apiKey), this.account = new
|
|
1257
|
+
this.suiClient = e.suiClient, this.executor = e.executor, this.address = e.address, this.ids = l(e.network ?? "testnet", e.packageIds), this.indexer = new X(e.indexerUrl ?? "https://api.trinary.exchange", e.apiKey), this.account = new tt(this), this.balances = new nt(this), this.market = new rt(this), this.orders = new it(this);
|
|
1139
1258
|
}
|
|
1140
1259
|
requireExecutor() {
|
|
1141
1260
|
if (!this.executor) throw new d(u.ExecutorRequired, "This operation writes on-chain and requires an `executor`.");
|
|
@@ -1170,7 +1289,7 @@ var X = class {
|
|
|
1170
1289
|
n || e.transferObjects([t], r);
|
|
1171
1290
|
let i = await m(this.requireExecutor(), e);
|
|
1172
1291
|
if (!n) {
|
|
1173
|
-
let e =
|
|
1292
|
+
let e = et(i);
|
|
1174
1293
|
e && this.rememberBalanceManagerId(e);
|
|
1175
1294
|
}
|
|
1176
1295
|
return Z(i);
|
|
@@ -1181,7 +1300,7 @@ var X = class {
|
|
|
1181
1300
|
return t;
|
|
1182
1301
|
}
|
|
1183
1302
|
};
|
|
1184
|
-
function
|
|
1303
|
+
function et(e) {
|
|
1185
1304
|
return g(e, "::balance_manager::BalanceManager")?.objectId ?? null;
|
|
1186
1305
|
}
|
|
1187
1306
|
function Z(e) {
|
|
@@ -1191,7 +1310,7 @@ function Z(e) {
|
|
|
1191
1310
|
raw: e.raw
|
|
1192
1311
|
};
|
|
1193
1312
|
}
|
|
1194
|
-
var
|
|
1313
|
+
var tt = class {
|
|
1195
1314
|
c;
|
|
1196
1315
|
constructor(e) {
|
|
1197
1316
|
this.c = e;
|
|
@@ -1211,7 +1330,7 @@ var Ke = class {
|
|
|
1211
1330
|
};
|
|
1212
1331
|
let i = this.c.requireExecutor(), a = new e(), o = k(a, this.c.ids);
|
|
1213
1332
|
a.transferObjects([o], n);
|
|
1214
|
-
let s =
|
|
1333
|
+
let s = et(await m(i, a));
|
|
1215
1334
|
if (!s) throw new d(u.UnexpectedResponse, "Balance manager created but no created-object info found — have the executor include effects+objectTypes (v2) or objectChanges (legacy).");
|
|
1216
1335
|
return this.c.rememberBalanceManagerId(s), {
|
|
1217
1336
|
balanceManagerId: s,
|
|
@@ -1222,14 +1341,14 @@ var Ke = class {
|
|
|
1222
1341
|
if (e.amount <= 0n) throw new d(u.ValidationFailed, "Deposit amount must be positive.");
|
|
1223
1342
|
let t = this.c.requireAddress();
|
|
1224
1343
|
this.c.requireExecutor();
|
|
1225
|
-
let { tx: n, bm: r, existingBmId: i } = await this.c.beginBmTx(t), a = await
|
|
1344
|
+
let { tx: n, bm: r, existingBmId: i } = await this.c.beginBmTx(t), a = await z(this.c.suiClient, n, t, this.c.ids.credCoinType, e.amount, "Insufficient CRED in the wallet for this deposit.");
|
|
1226
1345
|
return j(n, this.c.ids, r, a), this.c.finishBmTx(n, r, i, t);
|
|
1227
1346
|
}
|
|
1228
1347
|
async depositItems(e) {
|
|
1229
1348
|
let t = this.c.requireAddress();
|
|
1230
1349
|
this.c.requireExecutor();
|
|
1231
1350
|
let n = await this.c.indexer.hubVault(e.storageUnitId), r = S(e.storageUnitId), { tx: i, bm: a, existingBmId: o } = await this.c.beginBmTx(t);
|
|
1232
|
-
for (let s of e.items) await
|
|
1351
|
+
for (let s of e.items) await B(this.c.suiClient, i, this.c.ids, a, {
|
|
1233
1352
|
owner: t,
|
|
1234
1353
|
ssuObjectId: r,
|
|
1235
1354
|
vaultConfigId: n.vaultConfigId,
|
|
@@ -1254,8 +1373,8 @@ var Ke = class {
|
|
|
1254
1373
|
}
|
|
1255
1374
|
let c = await D(this.c.suiClient, o, n), l = new e(), f = l.object(r);
|
|
1256
1375
|
for (let e of t.items) {
|
|
1257
|
-
let t =
|
|
1258
|
-
|
|
1376
|
+
let t = de(l, this.c.ids, f, a.collectionId, BigInt(e.assetId));
|
|
1377
|
+
fe(l, this.c.ids, t, {
|
|
1259
1378
|
ssuObjectId: o,
|
|
1260
1379
|
characterId: s,
|
|
1261
1380
|
vaultConfigId: a.vaultConfigId,
|
|
@@ -1269,6 +1388,9 @@ var Ke = class {
|
|
|
1269
1388
|
let e = this.c.requireAddress(), t = await this.c.requireBalanceManagerId(e);
|
|
1270
1389
|
return this.c.indexer.sweepable(t);
|
|
1271
1390
|
}
|
|
1391
|
+
owners(e) {
|
|
1392
|
+
return this.c.indexer.balanceManagerOwners(e.balanceManagerIds);
|
|
1393
|
+
}
|
|
1272
1394
|
async claimSettled(t) {
|
|
1273
1395
|
let n = this.c.requireAddress(), r = await this.c.requireBalanceManagerId(n), i = this.c.requireExecutor(), a;
|
|
1274
1396
|
if (a = t?.poolIds?.length ? t.poolIds.map((e) => ({ poolId: e })) : (await this.c.indexer.sweepable(r)).pools.filter((e) => e.settled.base > 0n || e.settled.quote > 0n || e.settled.cred > 0n).map((e) => ({
|
|
@@ -1276,7 +1398,7 @@ var Ke = class {
|
|
|
1276
1398
|
quoteCoinType: e.quoteAssetId ?? void 0
|
|
1277
1399
|
})), a.length === 0) throw new d(u.ValidationFailed, "Nothing settled to claim — no pools with claimable balances.");
|
|
1278
1400
|
let o = new e(), s = o.object(r), c = A(o, this.c.ids, s)[0];
|
|
1279
|
-
for (let e of a)
|
|
1401
|
+
for (let e of a) R(o, this.c.ids, {
|
|
1280
1402
|
poolId: e.poolId,
|
|
1281
1403
|
bm: s,
|
|
1282
1404
|
proof: c,
|
|
@@ -1284,7 +1406,7 @@ var Ke = class {
|
|
|
1284
1406
|
});
|
|
1285
1407
|
return Z(await m(i, o));
|
|
1286
1408
|
}
|
|
1287
|
-
},
|
|
1409
|
+
}, nt = class {
|
|
1288
1410
|
c;
|
|
1289
1411
|
constructor(e) {
|
|
1290
1412
|
this.c = e;
|
|
@@ -1306,7 +1428,7 @@ var Ke = class {
|
|
|
1306
1428
|
balanceManagerId: r
|
|
1307
1429
|
};
|
|
1308
1430
|
}
|
|
1309
|
-
},
|
|
1431
|
+
}, rt = class {
|
|
1310
1432
|
c;
|
|
1311
1433
|
constructor(e) {
|
|
1312
1434
|
this.c = e;
|
|
@@ -1351,7 +1473,31 @@ var Ke = class {
|
|
|
1351
1473
|
poolMetadata(e) {
|
|
1352
1474
|
return this.c.indexer.poolMetadata(e);
|
|
1353
1475
|
}
|
|
1354
|
-
|
|
1476
|
+
hubLocations(e) {
|
|
1477
|
+
return this.c.indexer.hubLocations(e);
|
|
1478
|
+
}
|
|
1479
|
+
itemLocations(e, t) {
|
|
1480
|
+
return this.c.indexer.itemLocations(e, t);
|
|
1481
|
+
}
|
|
1482
|
+
nearbyHubs(e) {
|
|
1483
|
+
return this.c.indexer.nearbyHubs(e);
|
|
1484
|
+
}
|
|
1485
|
+
nearbyHubsBySystem(e) {
|
|
1486
|
+
return this.c.indexer.nearbyHubsBySystem(e);
|
|
1487
|
+
}
|
|
1488
|
+
hubsEnriched(e) {
|
|
1489
|
+
return this.c.indexer.hubsEnriched(e.hubIds);
|
|
1490
|
+
}
|
|
1491
|
+
assemblyOwners(e) {
|
|
1492
|
+
return this.c.indexer.assemblyOwners(e.assemblyIds);
|
|
1493
|
+
}
|
|
1494
|
+
assembliesEnriched(e) {
|
|
1495
|
+
return this.c.indexer.assembliesEnriched(e.assemblyIds);
|
|
1496
|
+
}
|
|
1497
|
+
solarSystemNames(e) {
|
|
1498
|
+
return this.c.indexer.solarSystemNames(e.solarSystemIds);
|
|
1499
|
+
}
|
|
1500
|
+
}, it = class {
|
|
1355
1501
|
c;
|
|
1356
1502
|
constructor(e) {
|
|
1357
1503
|
this.c = e;
|
|
@@ -1361,7 +1507,7 @@ var Ke = class {
|
|
|
1361
1507
|
let t = this.c.requireAddress();
|
|
1362
1508
|
this.c.requireExecutor();
|
|
1363
1509
|
let n = e.side === "buy", r = await this.c.indexer.hubVault(e.storageUnitId), i = await this.requirePool(r.collectionId, e), { tx: a, bm: o, existingBmId: s } = await this.c.beginBmTx(t);
|
|
1364
|
-
if (!n) await
|
|
1510
|
+
if (!n) await B(this.c.suiClient, a, this.c.ids, o, {
|
|
1365
1511
|
owner: t,
|
|
1366
1512
|
ssuObjectId: S(e.storageUnitId),
|
|
1367
1513
|
vaultConfigId: r.vaultConfigId,
|
|
@@ -1375,13 +1521,13 @@ var Ke = class {
|
|
|
1375
1521
|
let n = e.quoteDeposit;
|
|
1376
1522
|
if (n === void 0) {
|
|
1377
1523
|
let t = await this.c.indexer.poolMetadata(i);
|
|
1378
|
-
n =
|
|
1524
|
+
n = _e(e.price, e.quantity, t.feeRateScaled);
|
|
1379
1525
|
}
|
|
1380
1526
|
if (n <= 0n) throw new d(u.ValidationFailed, "Invalid quote deposit amount.");
|
|
1381
1527
|
await this.depositQuoteDeficit(a, o, s, t, n);
|
|
1382
1528
|
}
|
|
1383
1529
|
let c = A(a, this.c.ids, o)[0];
|
|
1384
|
-
return
|
|
1530
|
+
return N(a, this.c.ids, {
|
|
1385
1531
|
poolId: i,
|
|
1386
1532
|
bm: o,
|
|
1387
1533
|
proof: c,
|
|
@@ -1398,7 +1544,7 @@ var Ke = class {
|
|
|
1398
1544
|
let t = this.c.requireAddress();
|
|
1399
1545
|
this.c.requireExecutor();
|
|
1400
1546
|
let n = e.side === "buy", r = await this.c.indexer.hubVault(e.storageUnitId), i = await this.requirePool(r.collectionId, e), { tx: a, bm: o, existingBmId: s } = await this.c.beginBmTx(t);
|
|
1401
|
-
if (!n) await
|
|
1547
|
+
if (!n) await B(this.c.suiClient, a, this.c.ids, o, {
|
|
1402
1548
|
owner: t,
|
|
1403
1549
|
ssuObjectId: S(e.storageUnitId),
|
|
1404
1550
|
vaultConfigId: r.vaultConfigId,
|
|
@@ -1410,11 +1556,11 @@ var Ke = class {
|
|
|
1410
1556
|
});
|
|
1411
1557
|
else {
|
|
1412
1558
|
if (!e.quoteBudget || e.quoteBudget <= 0n) throw new d(u.ValidationFailed, "Market buys require `quoteBudget` (see estimateMarketBuyCost).");
|
|
1413
|
-
let n = await this.c.indexer.poolMetadata(i), r = e.quoteBudget +
|
|
1559
|
+
let n = await this.c.indexer.poolMetadata(i), r = e.quoteBudget + ve(e.quantity, n.feeRateScaled);
|
|
1414
1560
|
await this.depositQuoteDeficit(a, o, s, t, r);
|
|
1415
1561
|
}
|
|
1416
1562
|
let c = A(a, this.c.ids, o)[0];
|
|
1417
|
-
return
|
|
1563
|
+
return P(a, this.c.ids, {
|
|
1418
1564
|
poolId: i,
|
|
1419
1565
|
bm: o,
|
|
1420
1566
|
proof: c,
|
|
@@ -1425,7 +1571,7 @@ var Ke = class {
|
|
|
1425
1571
|
}
|
|
1426
1572
|
async cancel(e) {
|
|
1427
1573
|
let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
|
|
1428
|
-
return
|
|
1574
|
+
return F(t, this.c.ids, {
|
|
1429
1575
|
poolId: r,
|
|
1430
1576
|
bm: n,
|
|
1431
1577
|
proof: a,
|
|
@@ -1434,7 +1580,7 @@ var Ke = class {
|
|
|
1434
1580
|
}
|
|
1435
1581
|
async cancelAll(e) {
|
|
1436
1582
|
let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
|
|
1437
|
-
return
|
|
1583
|
+
return I(t, this.c.ids, {
|
|
1438
1584
|
poolId: r,
|
|
1439
1585
|
bm: n,
|
|
1440
1586
|
proof: a
|
|
@@ -1443,7 +1589,7 @@ var Ke = class {
|
|
|
1443
1589
|
async modify(e) {
|
|
1444
1590
|
if (e.newQuantity <= 0n) throw new d(u.ValidationFailed, "Modified quantity must be positive.");
|
|
1445
1591
|
let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
|
|
1446
|
-
return
|
|
1592
|
+
return L(t, this.c.ids, {
|
|
1447
1593
|
poolId: r,
|
|
1448
1594
|
bm: n,
|
|
1449
1595
|
proof: a,
|
|
@@ -1486,7 +1632,7 @@ var Ke = class {
|
|
|
1486
1632
|
async depositQuoteDeficit(e, t, n, r, i) {
|
|
1487
1633
|
let a = n ? await C(this.c.suiClient, this.c.ids, n) : 0n, o = i > a ? i - a : 0n;
|
|
1488
1634
|
if (o === 0n) return;
|
|
1489
|
-
let s = await
|
|
1635
|
+
let s = await z(this.c.suiClient, e, r, this.c.ids.credCoinType, o, "Insufficient CRED to fund the balance manager for this order.");
|
|
1490
1636
|
j(e, this.c.ids, t, s);
|
|
1491
1637
|
}
|
|
1492
1638
|
async beginCancelTx(t) {
|
|
@@ -1498,7 +1644,7 @@ var Ke = class {
|
|
|
1498
1644
|
execute: async () => Z(await m(i, s))
|
|
1499
1645
|
};
|
|
1500
1646
|
}
|
|
1501
|
-
},
|
|
1647
|
+
}, at = class {
|
|
1502
1648
|
ids;
|
|
1503
1649
|
indexer;
|
|
1504
1650
|
constructor(e) {
|
|
@@ -1544,6 +1690,33 @@ var Ke = class {
|
|
|
1544
1690
|
poolMetadata(e) {
|
|
1545
1691
|
return this.indexer.poolMetadata(e);
|
|
1546
1692
|
}
|
|
1693
|
+
hubLocations(e) {
|
|
1694
|
+
return this.indexer.hubLocations(e);
|
|
1695
|
+
}
|
|
1696
|
+
itemLocations(e, t) {
|
|
1697
|
+
return this.indexer.itemLocations(e, t);
|
|
1698
|
+
}
|
|
1699
|
+
nearbyHubs(e) {
|
|
1700
|
+
return this.indexer.nearbyHubs(e);
|
|
1701
|
+
}
|
|
1702
|
+
nearbyHubsBySystem(e) {
|
|
1703
|
+
return this.indexer.nearbyHubsBySystem(e);
|
|
1704
|
+
}
|
|
1705
|
+
hubsEnriched(e) {
|
|
1706
|
+
return this.indexer.hubsEnriched(e.hubIds);
|
|
1707
|
+
}
|
|
1708
|
+
assemblyOwners(e) {
|
|
1709
|
+
return this.indexer.assemblyOwners(e.assemblyIds);
|
|
1710
|
+
}
|
|
1711
|
+
assembliesEnriched(e) {
|
|
1712
|
+
return this.indexer.assembliesEnriched(e.assemblyIds);
|
|
1713
|
+
}
|
|
1714
|
+
solarSystemNames(e) {
|
|
1715
|
+
return this.indexer.solarSystemNames(e.solarSystemIds);
|
|
1716
|
+
}
|
|
1717
|
+
accountOwners(e) {
|
|
1718
|
+
return this.indexer.balanceManagerOwners(e.balanceManagerIds);
|
|
1719
|
+
}
|
|
1547
1720
|
balancesAtHub(e) {
|
|
1548
1721
|
return this.indexer.inventoryBalances(e);
|
|
1549
1722
|
}
|
|
@@ -1562,7 +1735,7 @@ var Ke = class {
|
|
|
1562
1735
|
};
|
|
1563
1736
|
//#endregion
|
|
1564
1737
|
//#region src/book.ts
|
|
1565
|
-
function
|
|
1738
|
+
function ot(e) {
|
|
1566
1739
|
let t = [];
|
|
1567
1740
|
for (let n of e) {
|
|
1568
1741
|
let e = t[t.length - 1];
|
|
@@ -1580,11 +1753,11 @@ function Q(e) {
|
|
|
1580
1753
|
function $(e) {
|
|
1581
1754
|
return e.asks[0] ?? null;
|
|
1582
1755
|
}
|
|
1583
|
-
function
|
|
1756
|
+
function st(e) {
|
|
1584
1757
|
let t = Q(e), n = $(e);
|
|
1585
1758
|
return !t || !n ? null : (t.price + n.price) / 2n;
|
|
1586
1759
|
}
|
|
1587
|
-
function
|
|
1760
|
+
function ct(e) {
|
|
1588
1761
|
let t = Q(e), n = $(e);
|
|
1589
1762
|
if (!t || !n) return null;
|
|
1590
1763
|
let r = n.price - t.price, i = (t.price + n.price) / 2n;
|
|
@@ -1596,19 +1769,19 @@ function $e(e) {
|
|
|
1596
1769
|
bps: Number(r * 10000n / i)
|
|
1597
1770
|
};
|
|
1598
1771
|
}
|
|
1599
|
-
function
|
|
1772
|
+
function lt(e) {
|
|
1600
1773
|
let t = 0n;
|
|
1601
1774
|
for (let n of e) t += n.remainingQuantity;
|
|
1602
1775
|
return t;
|
|
1603
1776
|
}
|
|
1604
|
-
function
|
|
1777
|
+
function ut(e) {
|
|
1605
1778
|
let t = 0n, n = 0n;
|
|
1606
1779
|
for (let r of e) t += r.baseQuantity, n += r.quoteQuantity;
|
|
1607
1780
|
return t === 0n ? null : n / t;
|
|
1608
1781
|
}
|
|
1609
1782
|
//#endregion
|
|
1610
1783
|
//#region src/paging.ts
|
|
1611
|
-
async function*
|
|
1784
|
+
async function* dt(e, t, n) {
|
|
1612
1785
|
let r = n?.maxItems ?? 1e4, i = t?.cursor, a = 0;
|
|
1613
1786
|
for (;;) {
|
|
1614
1787
|
let n = await e.discovery({
|
|
@@ -1620,7 +1793,7 @@ async function* nt(e, t, n) {
|
|
|
1620
1793
|
i = n.nextCursor;
|
|
1621
1794
|
}
|
|
1622
1795
|
}
|
|
1623
|
-
async function*
|
|
1796
|
+
async function* ft(e, t, n, r) {
|
|
1624
1797
|
let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
|
|
1625
1798
|
for (;;) {
|
|
1626
1799
|
let r = await e.fills(t, {
|
|
@@ -1632,7 +1805,7 @@ async function* rt(e, t, n, r) {
|
|
|
1632
1805
|
a = r.fills[r.fills.length - 1].filledAt;
|
|
1633
1806
|
}
|
|
1634
1807
|
}
|
|
1635
|
-
async function*
|
|
1808
|
+
async function* pt(e, t, n, r) {
|
|
1636
1809
|
let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
|
|
1637
1810
|
for (;;) {
|
|
1638
1811
|
let r = await e.trades(t, {
|
|
@@ -1646,7 +1819,7 @@ async function* it(e, t, n, r) {
|
|
|
1646
1819
|
}
|
|
1647
1820
|
//#endregion
|
|
1648
1821
|
//#region src/wait.ts
|
|
1649
|
-
async function
|
|
1822
|
+
async function mt(e, t) {
|
|
1650
1823
|
let n = t?.timeoutMs ?? 3e4, r = t?.intervalMs ?? 2e3, i = Date.now() + n;
|
|
1651
1824
|
for (;;) {
|
|
1652
1825
|
let a = await e();
|
|
@@ -1656,4 +1829,4 @@ async function at(e, t) {
|
|
|
1656
1829
|
}
|
|
1657
1830
|
}
|
|
1658
1831
|
//#endregion
|
|
1659
|
-
export { o as CLOCK_ID, a as DEFAULT_INDEXER_URL,
|
|
1832
|
+
export { o as CLOCK_ID, a as DEFAULT_INDEXER_URL, H as FEE_RATE_SCALING, me as GTC_EXPIRE, X as IndexerClient, V as MULTICOIN_PRICE_SCALING, c as NETWORK_PRESETS, at as ReadOnlyClient, s as STILLNESS_PACKAGE_IDS, pe as TRIEX_PRICE_SCALING, $e as TriexClient, d as TriexClientError, u as TriexError, ot as aggregateLevels, $ as bestAsk, Q as bestBid, _e as computeBidQuoteDeposit, U as computeItemQuote, lt as depth, ye as estimateMarketBuyCost, m as executeAndNormalize, p as explainMoveAbort, E as fetchCharacterInfo, O as fetchInventorySlotQuantity, D as fetchSsuOwnerInfo, g as findCreatedObject, oe as findOwnedItemReceipts, ge as fromBase, C as getBalanceManagerCurrencyBalance, w as getBalanceManagerItemBalance, ie as getObjectRef, T as getRegistryMulticoinCollectionId, ae as getWalletCurrencyBalance, dt as iterateDiscovery, ft as iterateFills, pt as iterateTrades, ve as marketBuyRoundingBuffer, st as midPrice, h as normalizeExecuteResult, z as prepareWalletCoinInput, l as resolvePackageIds, B as sourceItemsIntoBalanceManager, ct as spread, he as toBase, S as toSsuObjectId, se as transactions, mt as untilIndexed, ut as vwap };
|