aftermath-ts-sdk 2.0.0 → 2.0.1
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/dist/index.d.ts +1174 -62
- package/dist/index.js +879 -319
- package/dist/index.js.map +1 -1
- package/package.json +12 -13
package/dist/index.js
CHANGED
|
@@ -126,7 +126,6 @@ var init_dynamicFieldsApiHelpers = __esm({
|
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
// src/general/apiHelpers/eventsApiHelpers.ts
|
|
129
|
-
import dayjs from "dayjs";
|
|
130
129
|
var _EventsApiHelpers, EventsApiHelpers;
|
|
131
130
|
var init_eventsApiHelpers = __esm({
|
|
132
131
|
"src/general/apiHelpers/eventsApiHelpers.ts"() {
|
|
@@ -158,71 +157,56 @@ var init_eventsApiHelpers = __esm({
|
|
|
158
157
|
const { query, eventFromEventOnChain, cursor, limit } = inputs;
|
|
159
158
|
const fetchedEvents = await this.Provider.provider.queryEvents({
|
|
160
159
|
query,
|
|
161
|
-
cursor: cursor ? {
|
|
162
|
-
...cursor,
|
|
163
|
-
eventSeq: cursor?.eventSeq.toString()
|
|
164
|
-
} : void 0,
|
|
160
|
+
cursor: cursor ? { ...cursor, eventSeq: cursor.eventSeq.toString() } : void 0,
|
|
165
161
|
limit
|
|
166
|
-
// defaultlimit ?
|
|
167
162
|
});
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
(event) => eventFromEventOnChain(event)
|
|
171
|
-
);
|
|
172
|
-
const nextCursor = fetchedEvents.nextCursor ?? null;
|
|
173
|
-
return { events, nextCursor };
|
|
163
|
+
const events = fetchedEvents.data.map(eventFromEventOnChain);
|
|
164
|
+
return { events, nextCursor: fetchedEvents.nextCursor ?? null };
|
|
174
165
|
};
|
|
175
166
|
// TODO: make this function use timestamp passing as one of event filter args
|
|
176
167
|
this.fetchEventsWithinTime = async (inputs) => {
|
|
177
|
-
const { fetchEventsFunc,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
let cursor
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
limit: limitStepSize ?? _EventsApiHelpers.constants.defaultLimitStepSize
|
|
186
|
-
}
|
|
187
|
-
);
|
|
188
|
-
const events = eventsWithCursor.events;
|
|
189
|
-
const now = Date.now();
|
|
190
|
-
const endIndex = events.findIndex((event) => {
|
|
191
|
-
if (event.timestamp === void 0) return false;
|
|
192
|
-
const eventDate = dayjs.unix(event.timestamp / 1e3);
|
|
193
|
-
return dayjs(now).diff(eventDate, timeUnit, true) > time;
|
|
168
|
+
const { fetchEventsFunc, timeMs, limitStepSize } = inputs;
|
|
169
|
+
const limit = limitStepSize ?? _EventsApiHelpers.constants.defaultLimitStepSize;
|
|
170
|
+
const eventsWithinTime = [];
|
|
171
|
+
let cursor;
|
|
172
|
+
for (let loopCount = 0; loopCount < _EventsApiHelpers.constants.maxLoops; loopCount++) {
|
|
173
|
+
const { events, nextCursor } = await fetchEventsFunc({
|
|
174
|
+
cursor,
|
|
175
|
+
limit
|
|
194
176
|
});
|
|
195
|
-
|
|
196
|
-
|
|
177
|
+
const now = Date.now();
|
|
178
|
+
const endIndex = events.findIndex(
|
|
179
|
+
(event) => event.timestamp !== void 0 && now - event.timestamp > timeMs
|
|
180
|
+
);
|
|
181
|
+
eventsWithinTime.push(
|
|
197
182
|
...endIndex < 0 ? events : events.slice(0, endIndex)
|
|
198
|
-
|
|
199
|
-
if (events.length === 0 ||
|
|
200
|
-
eventsWithCursor.nextCursor === null || endIndex >= 0)
|
|
201
|
-
return eventsWithinTime;
|
|
202
|
-
cursor = eventsWithCursor.nextCursor;
|
|
203
|
-
loopCount += 1;
|
|
204
|
-
if (loopCount >= _EventsApiHelpers.constants.maxLoops) {
|
|
183
|
+
);
|
|
184
|
+
if (events.length === 0 || nextCursor === null || endIndex >= 0) {
|
|
205
185
|
return eventsWithinTime;
|
|
206
186
|
}
|
|
207
|
-
|
|
187
|
+
cursor = nextCursor;
|
|
188
|
+
}
|
|
189
|
+
return eventsWithinTime;
|
|
208
190
|
};
|
|
209
191
|
this.fetchAllEvents = async (inputs) => {
|
|
210
192
|
const { fetchEventsFunc, limitStepSize } = inputs;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
193
|
+
const limit = limitStepSize ?? _EventsApiHelpers.constants.defaultLimitStepSize;
|
|
194
|
+
const allEvents = [];
|
|
195
|
+
let cursor;
|
|
196
|
+
let done = false;
|
|
197
|
+
while (!done) {
|
|
198
|
+
const { events, nextCursor } = await fetchEventsFunc({
|
|
199
|
+
cursor,
|
|
200
|
+
limit
|
|
201
|
+
});
|
|
202
|
+
allEvents.push(...events);
|
|
203
|
+
if (events.length === 0 || nextCursor === null) {
|
|
204
|
+
done = true;
|
|
205
|
+
} else {
|
|
206
|
+
cursor = nextCursor;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return allEvents;
|
|
226
210
|
};
|
|
227
211
|
}
|
|
228
212
|
};
|
|
@@ -239,34 +223,21 @@ var init_eventsApiHelpers = __esm({
|
|
|
239
223
|
// =========================================================================
|
|
240
224
|
// Helpers
|
|
241
225
|
// =========================================================================
|
|
242
|
-
_EventsApiHelpers.
|
|
243
|
-
|
|
244
|
-
event.type.includes(
|
|
245
|
-
typeof eventType === "string" ? eventType : eventType()
|
|
246
|
-
) ? event : void 0
|
|
247
|
-
);
|
|
226
|
+
_EventsApiHelpers.resolveEventType = (eventType) => typeof eventType === "string" ? eventType : eventType();
|
|
227
|
+
_EventsApiHelpers.suiEventOfTypeOrUndefined = (event, eventType) => event.type.includes(_EventsApiHelpers.resolveEventType(eventType)) ? event : void 0;
|
|
248
228
|
_EventsApiHelpers.castEventOfTypeOrUndefined = (event, eventType, castFunction, exactMatch) => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
const castedEvent = castFunction(event);
|
|
254
|
-
return castedEvent;
|
|
229
|
+
const resolved = _EventsApiHelpers.resolveEventType(eventType);
|
|
230
|
+
const matches = exactMatch ? event.type === resolved : event.type.includes(resolved);
|
|
231
|
+
if (!matches) return void 0;
|
|
232
|
+
return castFunction(event);
|
|
255
233
|
};
|
|
256
234
|
_EventsApiHelpers.findCastEventsOrUndefined = (inputs) => {
|
|
257
235
|
const { events, eventType, castFunction } = inputs;
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
);
|
|
261
|
-
const castedEvents = foundEvents.map(
|
|
262
|
-
(event) => castFunction(event)
|
|
263
|
-
);
|
|
264
|
-
return castedEvents;
|
|
236
|
+
const resolved = _EventsApiHelpers.resolveEventType(eventType);
|
|
237
|
+
return events.filter((event) => event.type.includes(resolved)).map((event) => castFunction(event));
|
|
265
238
|
};
|
|
266
239
|
_EventsApiHelpers.findCastEventOrUndefined = (inputs) => {
|
|
267
|
-
|
|
268
|
-
if (events.length <= 0) return;
|
|
269
|
-
return events[0];
|
|
240
|
+
return _EventsApiHelpers.findCastEventsOrUndefined(inputs)[0];
|
|
270
241
|
};
|
|
271
242
|
_EventsApiHelpers.findCastEventInTransactionOrUndefined = (transaction, eventType, castFunction) => {
|
|
272
243
|
return _EventsApiHelpers.findCastEventOrUndefined({
|
|
@@ -276,15 +247,15 @@ var init_eventsApiHelpers = __esm({
|
|
|
276
247
|
});
|
|
277
248
|
};
|
|
278
249
|
_EventsApiHelpers.findCastEventInTransactionsOrUndefined = (transactions, eventType, castFunction) => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
(transaction) => _EventsApiHelpers.findCastEventInTransactionOrUndefined(
|
|
250
|
+
for (const transaction of transactions) {
|
|
251
|
+
const event = _EventsApiHelpers.findCastEventInTransactionOrUndefined(
|
|
282
252
|
transaction,
|
|
283
253
|
eventType,
|
|
284
254
|
castFunction
|
|
285
|
-
)
|
|
286
|
-
|
|
287
|
-
|
|
255
|
+
);
|
|
256
|
+
if (event !== void 0) return event;
|
|
257
|
+
}
|
|
258
|
+
return void 0;
|
|
288
259
|
};
|
|
289
260
|
_EventsApiHelpers.createEventType = (packageAddress, packageName, eventType, wrapperType) => {
|
|
290
261
|
const innerType = `${packageAddress}::${packageName}::${eventType}`;
|
|
@@ -2721,8 +2692,8 @@ var init_nftsApiCasting = __esm({
|
|
|
2721
2692
|
offChain: "creator"
|
|
2722
2693
|
}
|
|
2723
2694
|
];
|
|
2724
|
-
|
|
2725
|
-
|
|
2695
|
+
const suggested = {};
|
|
2696
|
+
const other = Helpers.deepCopy(fields);
|
|
2726
2697
|
for (const field of suggestedFields) {
|
|
2727
2698
|
if (!(field.onChain in other)) continue;
|
|
2728
2699
|
suggested[field.offChain] = other[field.onChain];
|
|
@@ -3574,12 +3545,12 @@ var init_transactionsApiHelpers = __esm({
|
|
|
3574
3545
|
});
|
|
3575
3546
|
|
|
3576
3547
|
// src/general/utils/helpers.ts
|
|
3577
|
-
import { isValidSuiAddress } from "@mysten/sui/utils";
|
|
3578
3548
|
import { decodeSuiPrivateKey } from "@mysten/sui/cryptography";
|
|
3579
3549
|
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
3580
3550
|
import { Secp256k1Keypair } from "@mysten/sui/keypairs/secp256k1";
|
|
3581
3551
|
import { Secp256r1Keypair } from "@mysten/sui/keypairs/secp256r1";
|
|
3582
|
-
|
|
3552
|
+
import { isValidSuiAddress } from "@mysten/sui/utils";
|
|
3553
|
+
var NUMERIC_STRING_REGEX, BIGINT_STRING_REGEX, HEX_STRING_REGEX, _Helpers, Helpers;
|
|
3583
3554
|
var init_helpers = __esm({
|
|
3584
3555
|
"src/general/utils/helpers.ts"() {
|
|
3585
3556
|
"use strict";
|
|
@@ -3588,6 +3559,9 @@ var init_helpers = __esm({
|
|
|
3588
3559
|
init_inspectionsApiHelpers();
|
|
3589
3560
|
init_objectsApiHelpers();
|
|
3590
3561
|
init_transactionsApiHelpers();
|
|
3562
|
+
NUMERIC_STRING_REGEX = /^\d*\.?\d*$/;
|
|
3563
|
+
BIGINT_STRING_REGEX = /^-?\d+n$/;
|
|
3564
|
+
HEX_STRING_REGEX = /^(0x)?[0-9A-F]+$/i;
|
|
3591
3565
|
_Helpers = class _Helpers {
|
|
3592
3566
|
static uniqueObjectArray(arr) {
|
|
3593
3567
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3632,17 +3606,13 @@ var init_helpers = __esm({
|
|
|
3632
3606
|
seen.add(obj);
|
|
3633
3607
|
if (Array.isArray(obj)) {
|
|
3634
3608
|
return obj.map(
|
|
3635
|
-
(item) =>
|
|
3636
|
-
);
|
|
3637
|
-
} else {
|
|
3638
|
-
const entries = Object.entries(obj).map(
|
|
3639
|
-
([key, value]) => [
|
|
3640
|
-
key,
|
|
3641
|
-
this.removeCircularReferences(value, seen)
|
|
3642
|
-
]
|
|
3609
|
+
(item) => _Helpers.removeCircularReferences(item, seen)
|
|
3643
3610
|
);
|
|
3644
|
-
return Object.fromEntries(entries);
|
|
3645
3611
|
}
|
|
3612
|
+
const entries = Object.entries(obj).map(
|
|
3613
|
+
([key, value]) => [key, _Helpers.removeCircularReferences(value, seen)]
|
|
3614
|
+
);
|
|
3615
|
+
return Object.fromEntries(entries);
|
|
3646
3616
|
}
|
|
3647
3617
|
return obj;
|
|
3648
3618
|
}
|
|
@@ -3671,8 +3641,10 @@ var init_helpers = __esm({
|
|
|
3671
3641
|
*/
|
|
3672
3642
|
static getObjectType(data) {
|
|
3673
3643
|
const objectType = data.data?.type;
|
|
3674
|
-
if (objectType)
|
|
3675
|
-
|
|
3644
|
+
if (objectType) {
|
|
3645
|
+
return _Helpers.addLeadingZeroesToType(objectType);
|
|
3646
|
+
}
|
|
3647
|
+
throw new Error(`no object type found on ${data.data?.objectId}`);
|
|
3676
3648
|
}
|
|
3677
3649
|
/**
|
|
3678
3650
|
* Extracts the object ID from a `SuiObjectResponse`, normalizing it with leading zeroes.
|
|
@@ -3683,8 +3655,10 @@ var init_helpers = __esm({
|
|
|
3683
3655
|
*/
|
|
3684
3656
|
static getObjectId(data) {
|
|
3685
3657
|
const objectId = data.data?.objectId;
|
|
3686
|
-
if (objectId)
|
|
3687
|
-
|
|
3658
|
+
if (objectId) {
|
|
3659
|
+
return _Helpers.addLeadingZeroesToType(objectId);
|
|
3660
|
+
}
|
|
3661
|
+
throw new Error(`no object id found on ${data.data?.type}`);
|
|
3688
3662
|
}
|
|
3689
3663
|
/**
|
|
3690
3664
|
* Retrieves the fields of a Move object from a `SuiObjectResponse`.
|
|
@@ -3693,12 +3667,13 @@ var init_helpers = __esm({
|
|
|
3693
3667
|
* @returns A record of fields for that object.
|
|
3694
3668
|
* @throws If no fields are found.
|
|
3695
3669
|
*/
|
|
3670
|
+
// biome-ignore lint/suspicious/noExplicitAny: Move fields are dynamic — callers access nested properties directly; typing as `unknown` would cascade casts through dozens of call sites
|
|
3696
3671
|
static getObjectFields(data) {
|
|
3697
3672
|
try {
|
|
3698
3673
|
const content = data.data?.content;
|
|
3699
3674
|
return content.fields;
|
|
3700
|
-
} catch (
|
|
3701
|
-
throw new Error(
|
|
3675
|
+
} catch (_e) {
|
|
3676
|
+
throw new Error(`no object fields found on ${data.data?.objectId}`);
|
|
3702
3677
|
}
|
|
3703
3678
|
}
|
|
3704
3679
|
/**
|
|
@@ -3710,8 +3685,10 @@ var init_helpers = __esm({
|
|
|
3710
3685
|
*/
|
|
3711
3686
|
static getObjectDisplay(data) {
|
|
3712
3687
|
const display = data.data?.display;
|
|
3713
|
-
if (display)
|
|
3714
|
-
|
|
3688
|
+
if (display) {
|
|
3689
|
+
return display;
|
|
3690
|
+
}
|
|
3691
|
+
throw new Error(`no object display found on ${data.data?.objectId}`);
|
|
3715
3692
|
}
|
|
3716
3693
|
// =========================================================================
|
|
3717
3694
|
// Error Parsing
|
|
@@ -3725,54 +3702,63 @@ var init_helpers = __esm({
|
|
|
3725
3702
|
*/
|
|
3726
3703
|
static parseMoveErrorMessage(inputs) {
|
|
3727
3704
|
const { errorMessage } = inputs;
|
|
3728
|
-
if (!errorMessage.toLowerCase().includes("moveabort"))
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
const
|
|
3733
|
-
|
|
3705
|
+
if (!errorMessage.toLowerCase().includes("moveabort")) {
|
|
3706
|
+
return void 0;
|
|
3707
|
+
}
|
|
3708
|
+
const moveErrorCode = (errorMsg) => {
|
|
3709
|
+
const startIndex = errorMsg.lastIndexOf(",");
|
|
3710
|
+
const endIndex = errorMsg.lastIndexOf(")");
|
|
3711
|
+
if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex) {
|
|
3734
3712
|
return void 0;
|
|
3713
|
+
}
|
|
3735
3714
|
try {
|
|
3736
|
-
const errorCode2 = parseInt(
|
|
3737
|
-
|
|
3715
|
+
const errorCode2 = Number.parseInt(
|
|
3716
|
+
errorMsg.slice(startIndex + 1, endIndex),
|
|
3717
|
+
10
|
|
3738
3718
|
);
|
|
3739
|
-
if (Number.isNaN(errorCode2))
|
|
3719
|
+
if (Number.isNaN(errorCode2)) {
|
|
3720
|
+
return void 0;
|
|
3721
|
+
}
|
|
3740
3722
|
return errorCode2;
|
|
3741
3723
|
} catch {
|
|
3742
3724
|
return void 0;
|
|
3743
3725
|
}
|
|
3744
3726
|
};
|
|
3745
|
-
const moveErrorPackageId = (
|
|
3746
|
-
const
|
|
3747
|
-
const
|
|
3748
|
-
|
|
3749
|
-
if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)
|
|
3727
|
+
const moveErrorPackageId = (errorMsg) => {
|
|
3728
|
+
const startIndex = errorMsg.toLowerCase().indexOf("address:");
|
|
3729
|
+
const endIndex = errorMsg.indexOf(", name:");
|
|
3730
|
+
if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex) {
|
|
3750
3731
|
return void 0;
|
|
3732
|
+
}
|
|
3751
3733
|
try {
|
|
3752
|
-
const pkgStr =
|
|
3753
|
-
const packageId2 = _Helpers.addLeadingZeroesToType(
|
|
3754
|
-
if (!
|
|
3734
|
+
const pkgStr = errorMsg.slice(startIndex + 8, endIndex).trim().replaceAll("0x", "");
|
|
3735
|
+
const packageId2 = _Helpers.addLeadingZeroesToType(`0x${pkgStr}`);
|
|
3736
|
+
if (!_Helpers.isValidHex(packageId2)) {
|
|
3737
|
+
return void 0;
|
|
3738
|
+
}
|
|
3755
3739
|
return packageId2;
|
|
3756
3740
|
} catch {
|
|
3757
3741
|
return void 0;
|
|
3758
3742
|
}
|
|
3759
3743
|
};
|
|
3760
|
-
const moveErrorModule = (
|
|
3761
|
-
const
|
|
3762
|
-
const
|
|
3763
|
-
|
|
3764
|
-
if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)
|
|
3744
|
+
const moveErrorModule = (errorMsg) => {
|
|
3745
|
+
const startIndex = errorMsg.toLowerCase().indexOf('identifier("');
|
|
3746
|
+
const endIndex = errorMsg.indexOf('")');
|
|
3747
|
+
if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex) {
|
|
3765
3748
|
return void 0;
|
|
3749
|
+
}
|
|
3766
3750
|
try {
|
|
3767
|
-
return
|
|
3751
|
+
return errorMsg.slice(startIndex + 12, endIndex).trim();
|
|
3768
3752
|
} catch {
|
|
3769
3753
|
return void 0;
|
|
3770
3754
|
}
|
|
3771
3755
|
};
|
|
3772
|
-
const errorCode = moveErrorCode(
|
|
3773
|
-
const packageId = moveErrorPackageId(
|
|
3774
|
-
const module = moveErrorModule(
|
|
3775
|
-
if (errorCode === void 0 || !packageId || !module)
|
|
3756
|
+
const errorCode = moveErrorCode(errorMessage);
|
|
3757
|
+
const packageId = moveErrorPackageId(errorMessage);
|
|
3758
|
+
const module = moveErrorModule(errorMessage);
|
|
3759
|
+
if (errorCode === void 0 || !packageId || !module) {
|
|
3760
|
+
return void 0;
|
|
3761
|
+
}
|
|
3776
3762
|
return { errorCode, packageId, module };
|
|
3777
3763
|
}
|
|
3778
3764
|
/**
|
|
@@ -3785,14 +3771,18 @@ var init_helpers = __esm({
|
|
|
3785
3771
|
*/
|
|
3786
3772
|
static translateMoveErrorMessage(inputs) {
|
|
3787
3773
|
const { errorMessage, moveErrors } = inputs;
|
|
3788
|
-
const parsed =
|
|
3789
|
-
if (!parsed
|
|
3774
|
+
const parsed = _Helpers.parseMoveErrorMessage({ errorMessage });
|
|
3775
|
+
if (!(parsed && parsed.packageId in moveErrors)) {
|
|
3776
|
+
return void 0;
|
|
3777
|
+
}
|
|
3790
3778
|
let error;
|
|
3791
3779
|
if (parsed.module in moveErrors[parsed.packageId] && parsed.errorCode in moveErrors[parsed.packageId][parsed.module]) {
|
|
3792
3780
|
error = moveErrors[parsed.packageId][parsed.module][parsed.errorCode];
|
|
3793
|
-
} else if ("ANY" in moveErrors[parsed.packageId] && parsed.errorCode in moveErrors[parsed.packageId]
|
|
3794
|
-
error = moveErrors[parsed.packageId]
|
|
3795
|
-
} else
|
|
3781
|
+
} else if ("ANY" in moveErrors[parsed.packageId] && parsed.errorCode in moveErrors[parsed.packageId].ANY) {
|
|
3782
|
+
error = moveErrors[parsed.packageId].ANY[parsed.errorCode];
|
|
3783
|
+
} else {
|
|
3784
|
+
return void 0;
|
|
3785
|
+
}
|
|
3796
3786
|
return {
|
|
3797
3787
|
...parsed,
|
|
3798
3788
|
error
|
|
@@ -3852,15 +3842,16 @@ var init_helpers = __esm({
|
|
|
3852
3842
|
let typeSuffix = "";
|
|
3853
3843
|
if (strippedType.includes("::")) {
|
|
3854
3844
|
const splitType = strippedType.replace("0x", "").split("::");
|
|
3855
|
-
typeSuffix = splitType.slice(1).reduce((acc, str) => acc
|
|
3845
|
+
typeSuffix = splitType.slice(1).reduce((acc, str) => `${acc}::${str}`, "");
|
|
3856
3846
|
strippedType = splitType[0];
|
|
3857
3847
|
}
|
|
3858
3848
|
const typeLength = strippedType.length;
|
|
3859
|
-
if (typeLength > EXPECTED_TYPE_LENGTH)
|
|
3849
|
+
if (typeLength > EXPECTED_TYPE_LENGTH) {
|
|
3860
3850
|
throw new Error("invalid type length");
|
|
3851
|
+
}
|
|
3861
3852
|
const zerosNeeded = EXPECTED_TYPE_LENGTH - typeLength;
|
|
3862
|
-
const zeroString =
|
|
3863
|
-
const newType =
|
|
3853
|
+
const zeroString = "0".repeat(zerosNeeded);
|
|
3854
|
+
const newType = `0x${zeroString}${strippedType}`;
|
|
3864
3855
|
return newType + typeSuffix;
|
|
3865
3856
|
};
|
|
3866
3857
|
/**
|
|
@@ -3872,7 +3863,9 @@ var init_helpers = __esm({
|
|
|
3872
3863
|
*/
|
|
3873
3864
|
_Helpers.splitNonSuiCoinType = (coin) => {
|
|
3874
3865
|
const [uncastChain, coinType] = coin.split(":");
|
|
3875
|
-
if (!uncastChain
|
|
3866
|
+
if (!(uncastChain && coinType)) {
|
|
3867
|
+
return { coinType: coin, chain: "sui" };
|
|
3868
|
+
}
|
|
3876
3869
|
const chain = uncastChain;
|
|
3877
3870
|
return { chain, coinType };
|
|
3878
3871
|
};
|
|
@@ -3885,7 +3878,7 @@ var init_helpers = __esm({
|
|
|
3885
3878
|
* @param str - The string to test.
|
|
3886
3879
|
* @returns `true` if it's a valid numeric string, otherwise `false`.
|
|
3887
3880
|
*/
|
|
3888
|
-
_Helpers.isNumber = (str) =>
|
|
3881
|
+
_Helpers.isNumber = (str) => NUMERIC_STRING_REGEX.test(str);
|
|
3889
3882
|
/**
|
|
3890
3883
|
* Sums an array of floating-point numbers, returning the numeric total.
|
|
3891
3884
|
*
|
|
@@ -4005,9 +3998,11 @@ var init_helpers = __esm({
|
|
|
4005
3998
|
* @param unsafeStringNumberConversion - If `true`, all numeric strings (e.g., "123") will also become BigInts.
|
|
4006
3999
|
* @returns The parsed JSON object with BigInt conversions where applicable.
|
|
4007
4000
|
*/
|
|
4008
|
-
_Helpers.parseJsonWithBigint = (json, unsafeStringNumberConversion = false) => JSON.parse(json, (
|
|
4009
|
-
if (value === null)
|
|
4010
|
-
|
|
4001
|
+
_Helpers.parseJsonWithBigint = (json, unsafeStringNumberConversion = false) => JSON.parse(json, (_key, value) => {
|
|
4002
|
+
if (value === null) {
|
|
4003
|
+
return void 0;
|
|
4004
|
+
}
|
|
4005
|
+
if (typeof value === "string" && BIGINT_STRING_REGEX.test(value)) {
|
|
4011
4006
|
return BigInt(value.slice(0, -1));
|
|
4012
4007
|
}
|
|
4013
4008
|
if (unsafeStringNumberConversion && typeof value === "string" && _Helpers.isNumber(value)) {
|
|
@@ -4033,17 +4028,13 @@ var init_helpers = __esm({
|
|
|
4033
4028
|
return new Date(target.getTime());
|
|
4034
4029
|
}
|
|
4035
4030
|
if (Array.isArray(target)) {
|
|
4036
|
-
|
|
4037
|
-
target.forEach((v) => {
|
|
4038
|
-
cp.push(v);
|
|
4039
|
-
});
|
|
4040
|
-
return cp.map((n) => _Helpers.deepCopy(n));
|
|
4031
|
+
return target.map((v) => _Helpers.deepCopy(v));
|
|
4041
4032
|
}
|
|
4042
4033
|
if (typeof target === "object") {
|
|
4043
|
-
const cp = {
|
|
4044
|
-
Object.keys(
|
|
4045
|
-
cp[k] = _Helpers.deepCopy(
|
|
4046
|
-
}
|
|
4034
|
+
const cp = {};
|
|
4035
|
+
for (const k of Object.keys(target)) {
|
|
4036
|
+
cp[k] = _Helpers.deepCopy(target[k]);
|
|
4037
|
+
}
|
|
4047
4038
|
return cp;
|
|
4048
4039
|
}
|
|
4049
4040
|
return target;
|
|
@@ -4055,13 +4046,13 @@ var init_helpers = __esm({
|
|
|
4055
4046
|
* @returns The index of the maximum value, or -1 if the array is empty.
|
|
4056
4047
|
*/
|
|
4057
4048
|
_Helpers.indexOfMax = (arr) => {
|
|
4058
|
-
if (arr.length === 0)
|
|
4059
|
-
|
|
4049
|
+
if (arr.length === 0) {
|
|
4050
|
+
return -1;
|
|
4051
|
+
}
|
|
4060
4052
|
let maxIndex = 0;
|
|
4061
4053
|
for (let i = 1; i < arr.length; i++) {
|
|
4062
|
-
if (arr[i] >
|
|
4054
|
+
if (arr[i] > arr[maxIndex]) {
|
|
4063
4055
|
maxIndex = i;
|
|
4064
|
-
max = arr[i];
|
|
4065
4056
|
}
|
|
4066
4057
|
}
|
|
4067
4058
|
return maxIndex;
|
|
@@ -4073,7 +4064,15 @@ var init_helpers = __esm({
|
|
|
4073
4064
|
* @param arr - The original array.
|
|
4074
4065
|
* @returns An array of unique items.
|
|
4075
4066
|
*/
|
|
4076
|
-
_Helpers.uniqueArray = (arr) =>
|
|
4067
|
+
_Helpers.uniqueArray = (arr) => {
|
|
4068
|
+
if (arr.length === 0) {
|
|
4069
|
+
return [];
|
|
4070
|
+
}
|
|
4071
|
+
if (typeof arr[0] === "object") {
|
|
4072
|
+
return _Helpers.uniqueObjectArray(arr);
|
|
4073
|
+
}
|
|
4074
|
+
return [...new Set(arr)];
|
|
4075
|
+
};
|
|
4077
4076
|
/**
|
|
4078
4077
|
* Returns a Promise that resolves after a specified number of milliseconds.
|
|
4079
4078
|
*
|
|
@@ -4100,8 +4099,11 @@ var init_helpers = __esm({
|
|
|
4100
4099
|
const falses = [];
|
|
4101
4100
|
for (let index = 0; index < array.length; index++) {
|
|
4102
4101
|
const item = array[index];
|
|
4103
|
-
if (func(item, index, array))
|
|
4104
|
-
|
|
4102
|
+
if (func(item, index, array)) {
|
|
4103
|
+
trues[trues.length] = item;
|
|
4104
|
+
} else {
|
|
4105
|
+
falses[falses.length] = item;
|
|
4106
|
+
}
|
|
4105
4107
|
}
|
|
4106
4108
|
return [trues, falses];
|
|
4107
4109
|
};
|
|
@@ -4126,14 +4128,9 @@ var init_helpers = __esm({
|
|
|
4126
4128
|
* @param predicate - A function taking `(key, value)` and returning a boolean.
|
|
4127
4129
|
* @returns A new object with only the entries that pass the predicate.
|
|
4128
4130
|
*/
|
|
4129
|
-
_Helpers.filterObject = (obj, predicate) => Object.
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
return {
|
|
4133
|
-
...acc,
|
|
4134
|
-
[key]: val
|
|
4135
|
-
};
|
|
4136
|
-
}, {});
|
|
4131
|
+
_Helpers.filterObject = (obj, predicate) => Object.fromEntries(
|
|
4132
|
+
Object.entries(obj).filter(([key, value]) => predicate(key, value))
|
|
4133
|
+
);
|
|
4137
4134
|
/**
|
|
4138
4135
|
* Applies downward slippage to a bigint amount by subtracting `slippage * amount`.
|
|
4139
4136
|
* For instance, for 1% slippage, we reduce the amount by 1%.
|
|
@@ -4173,10 +4170,7 @@ var init_helpers = __esm({
|
|
|
4173
4170
|
* @param hexString - The string to check.
|
|
4174
4171
|
* @returns `true` if `hexString` is a valid hex, otherwise `false`.
|
|
4175
4172
|
*/
|
|
4176
|
-
_Helpers.isValidHex = (hexString) =>
|
|
4177
|
-
const hexPattern = /^(0x)?[0-9A-F]+$/i;
|
|
4178
|
-
return hexPattern.test(hexString);
|
|
4179
|
-
};
|
|
4173
|
+
_Helpers.isValidHex = (hexString) => HEX_STRING_REGEX.test(hexString);
|
|
4180
4174
|
// =========================================================================
|
|
4181
4175
|
// Tx Command Input Construction
|
|
4182
4176
|
// =========================================================================
|
|
@@ -4205,10 +4199,12 @@ var init_helpers = __esm({
|
|
|
4205
4199
|
*/
|
|
4206
4200
|
_Helpers.isValidSuiAddress = (address) => isValidSuiAddress(
|
|
4207
4201
|
(() => {
|
|
4208
|
-
if (!address.startsWith("0x") || address.length < 3)
|
|
4202
|
+
if (!address.startsWith("0x") || address.length < 3) {
|
|
4203
|
+
return "";
|
|
4204
|
+
}
|
|
4209
4205
|
try {
|
|
4210
4206
|
return _Helpers.addLeadingZeroesToType(address);
|
|
4211
|
-
} catch
|
|
4207
|
+
} catch {
|
|
4212
4208
|
return "";
|
|
4213
4209
|
}
|
|
4214
4210
|
})()
|
|
@@ -4235,9 +4231,7 @@ var init_helpers = __esm({
|
|
|
4235
4231
|
case "Secp256r1":
|
|
4236
4232
|
return Secp256r1Keypair.fromSecretKey(parsedKeypair.secretKey);
|
|
4237
4233
|
default:
|
|
4238
|
-
throw new Error(
|
|
4239
|
-
`unsupported scheme \`${parsedKeypair.scheme}\``
|
|
4240
|
-
);
|
|
4234
|
+
throw new Error(`unsupported scheme \`${parsedKeypair.scheme}\``);
|
|
4241
4235
|
}
|
|
4242
4236
|
};
|
|
4243
4237
|
Helpers = _Helpers;
|
|
@@ -4287,7 +4281,10 @@ var init_caller = __esm({
|
|
|
4287
4281
|
throw new Error(`HTTP ${status} ${response.statusText}: ${body}`);
|
|
4288
4282
|
}
|
|
4289
4283
|
const text = await response.text();
|
|
4290
|
-
const output = disableBigIntJsonParsing ? JSON.parse(
|
|
4284
|
+
const output = disableBigIntJsonParsing ? JSON.parse(
|
|
4285
|
+
text,
|
|
4286
|
+
(_key, value) => value === null ? void 0 : value
|
|
4287
|
+
) : Helpers.parseJsonWithBigint(text);
|
|
4291
4288
|
return output ?? void 0;
|
|
4292
4289
|
}
|
|
4293
4290
|
// =========================================================================
|
|
@@ -4354,10 +4351,7 @@ var init_caller = __esm({
|
|
|
4354
4351
|
signal,
|
|
4355
4352
|
options
|
|
4356
4353
|
);
|
|
4357
|
-
const tx = Transaction2.fromKind(response.txKind);
|
|
4358
|
-
if (body?.walletAddress) {
|
|
4359
|
-
tx.setSender(body.walletAddress);
|
|
4360
|
-
}
|
|
4354
|
+
const tx = response.sponsorSignature ? Transaction2.from(response.txKind) : Transaction2.fromKind(response.txKind);
|
|
4361
4355
|
const { txKind, ...rest } = response;
|
|
4362
4356
|
return { ...rest, tx };
|
|
4363
4357
|
}
|
|
@@ -4703,8 +4697,6 @@ var init_auth2 = __esm({
|
|
|
4703
4697
|
});
|
|
4704
4698
|
|
|
4705
4699
|
// src/packages/farms/farmsStakingPool.ts
|
|
4706
|
-
import dayjs2 from "dayjs";
|
|
4707
|
-
import duration from "dayjs/plugin/duration";
|
|
4708
4700
|
var FarmsStakingPool;
|
|
4709
4701
|
var init_farmsStakingPool = __esm({
|
|
4710
4702
|
"src/packages/farms/farmsStakingPool.ts"() {
|
|
@@ -4791,7 +4783,7 @@ var init_farmsStakingPool = __esm({
|
|
|
4791
4783
|
return Math.max(
|
|
4792
4784
|
Math.min(
|
|
4793
4785
|
this.stakingPool.maxLockDurationMs,
|
|
4794
|
-
this.stakingPool.emissionEndTimestamp -
|
|
4786
|
+
this.stakingPool.emissionEndTimestamp - Date.now()
|
|
4795
4787
|
),
|
|
4796
4788
|
0
|
|
4797
4789
|
);
|
|
@@ -4811,7 +4803,7 @@ var init_farmsStakingPool = __esm({
|
|
|
4811
4803
|
* ```
|
|
4812
4804
|
*/
|
|
4813
4805
|
this.emitRewards = () => {
|
|
4814
|
-
const currentTimestamp =
|
|
4806
|
+
const currentTimestamp = Date.now();
|
|
4815
4807
|
if (this.stakingPool.stakedAmount === BigInt(0)) return;
|
|
4816
4808
|
const rewardCoins = Helpers.deepCopy(this.stakingPool.rewardCoins);
|
|
4817
4809
|
for (const [rewardCoinIndex, rewardCoin] of rewardCoins.entries()) {
|
|
@@ -4839,15 +4831,14 @@ var init_farmsStakingPool = __esm({
|
|
|
4839
4831
|
const { coinType, price, decimals, tvlUsd } = inputs;
|
|
4840
4832
|
if (price <= 0 || tvlUsd <= 0) return 0;
|
|
4841
4833
|
const rewardCoin = this.rewardCoin({ coinType });
|
|
4842
|
-
const currentTimestamp =
|
|
4834
|
+
const currentTimestamp = Date.now();
|
|
4843
4835
|
if (rewardCoin.emissionRate > rewardCoin.actualRewards) return 0;
|
|
4844
4836
|
if (rewardCoin.emissionStartTimestamp > currentTimestamp || currentTimestamp > this.stakingPool.emissionEndTimestamp) {
|
|
4845
4837
|
return 0;
|
|
4846
4838
|
}
|
|
4847
4839
|
const emissionRateTokens = rewardCoin.emissionRate;
|
|
4848
4840
|
const emissionRateUsd = Coin.balanceWithDecimals(emissionRateTokens, decimals) * price;
|
|
4849
|
-
|
|
4850
|
-
const oneYearMs = dayjs2.duration(1, "year").asMilliseconds();
|
|
4841
|
+
const oneYearMs = 365 * 24 * 60 * 60 * 1e3;
|
|
4851
4842
|
const rewardsUsdOneYear = emissionRateUsd * (oneYearMs / rewardCoin.emissionSchedulesMs);
|
|
4852
4843
|
const apr = rewardsUsdOneYear / tvlUsd / Casting.bigIntToFixedNumber(this.stakingPool.maxLockMultiplier);
|
|
4853
4844
|
return apr < 0 ? 0 : isNaN(apr) ? 0 : apr;
|
|
@@ -5119,7 +5110,7 @@ var init_farmsStakingPool = __esm({
|
|
|
5119
5110
|
*/
|
|
5120
5111
|
calcRewardsToEmit(inputs) {
|
|
5121
5112
|
const { rewardCoin } = inputs;
|
|
5122
|
-
const currentTimestamp =
|
|
5113
|
+
const currentTimestamp = Date.now();
|
|
5123
5114
|
const rewardsToEmit = this.calcRewardsEmittedFromTimeTmToTn({
|
|
5124
5115
|
timestampTm: rewardCoin.lastRewardTimestamp,
|
|
5125
5116
|
timestampTn: currentTimestamp,
|
|
@@ -5145,7 +5136,6 @@ var init_farmsStakingPool = __esm({
|
|
|
5145
5136
|
});
|
|
5146
5137
|
|
|
5147
5138
|
// src/packages/farms/farmsStakedPosition.ts
|
|
5148
|
-
import dayjs3 from "dayjs";
|
|
5149
5139
|
var FarmsStakedPosition;
|
|
5150
5140
|
var init_farmsStakedPosition = __esm({
|
|
5151
5141
|
"src/packages/farms/farmsStakedPosition.ts"() {
|
|
@@ -5347,7 +5337,7 @@ var init_farmsStakedPosition = __esm({
|
|
|
5347
5337
|
];
|
|
5348
5338
|
stakingPool.stakingPool.stakedAmountWithMultiplier += this.stakedPosition.stakedAmountWithMultiplier;
|
|
5349
5339
|
}
|
|
5350
|
-
const currentTimestamp =
|
|
5340
|
+
const currentTimestamp = Date.now();
|
|
5351
5341
|
stakingPool.emitRewards();
|
|
5352
5342
|
for (const [
|
|
5353
5343
|
rewardCoinIndex,
|
|
@@ -5396,7 +5386,7 @@ var init_farmsStakedPosition = __esm({
|
|
|
5396
5386
|
*/
|
|
5397
5387
|
this.isUnlocked = (inputs) => {
|
|
5398
5388
|
const { stakingPool } = inputs;
|
|
5399
|
-
const currentTime =
|
|
5389
|
+
const currentTime = Date.now();
|
|
5400
5390
|
return this.unlockTimestamp() <= currentTime || stakingPool.stakingPool.emissionEndTimestamp <= currentTime || stakingPool.stakingPool.isUnlocked;
|
|
5401
5391
|
};
|
|
5402
5392
|
/**
|
|
@@ -8060,7 +8050,7 @@ var init_pools = __esm({
|
|
|
8060
8050
|
* This indicates the user's liquidity positions across multiple pools.
|
|
8061
8051
|
*
|
|
8062
8052
|
* @param inputs - An object containing the `walletAddress`.
|
|
8063
|
-
* @returns
|
|
8053
|
+
* @returns An array of `PoolLpInfo` objects summarizing the user's LP balances.
|
|
8064
8054
|
*
|
|
8065
8055
|
* @example
|
|
8066
8056
|
* ```typescript
|
|
@@ -8711,6 +8701,13 @@ var init_nftAmmTypes = __esm({
|
|
|
8711
8701
|
}
|
|
8712
8702
|
});
|
|
8713
8703
|
|
|
8704
|
+
// src/packages/gasPools/gasPoolsTypes.ts
|
|
8705
|
+
var init_gasPoolsTypes = __esm({
|
|
8706
|
+
"src/packages/gasPools/gasPoolsTypes.ts"() {
|
|
8707
|
+
"use strict";
|
|
8708
|
+
}
|
|
8709
|
+
});
|
|
8710
|
+
|
|
8714
8711
|
// src/packages/pools/poolsTypes.ts
|
|
8715
8712
|
var init_poolsTypes = __esm({
|
|
8716
8713
|
"src/packages/pools/poolsTypes.ts"() {
|
|
@@ -8786,6 +8783,7 @@ var init_types2 = __esm({
|
|
|
8786
8783
|
init_faucetTypes();
|
|
8787
8784
|
init_nftAmmTypes();
|
|
8788
8785
|
init_perpetualsTypes();
|
|
8786
|
+
init_gasPoolsTypes();
|
|
8789
8787
|
init_poolsTypes();
|
|
8790
8788
|
init_referralsTypes();
|
|
8791
8789
|
init_rewardsTypes();
|
|
@@ -9125,6 +9123,28 @@ var init_perpetualsMarket = __esm({
|
|
|
9125
9123
|
abortSignal
|
|
9126
9124
|
);
|
|
9127
9125
|
}
|
|
9126
|
+
/**
|
|
9127
|
+
* Market-level preview of placing a scale order.
|
|
9128
|
+
*
|
|
9129
|
+
* Similar to {@link getPlaceLimitOrderPreview}, this uses:
|
|
9130
|
+
* - `account/previews/place-scale-order`
|
|
9131
|
+
* - `accountId: undefined`
|
|
9132
|
+
*
|
|
9133
|
+
* @param inputs - {@link SdkPerpetualsPlaceScaleOrderPreviewInputs}.
|
|
9134
|
+
* @param abortSignal - Optional abort signal to cancel the request.
|
|
9135
|
+
*
|
|
9136
|
+
* @returns Either `{ error }` or a preview describing the simulated post-order state.
|
|
9137
|
+
*/
|
|
9138
|
+
async getPlaceScaleOrderPreview(inputs, abortSignal) {
|
|
9139
|
+
return this.fetchApi(
|
|
9140
|
+
"account/previews/place-scale-order",
|
|
9141
|
+
{
|
|
9142
|
+
...inputs,
|
|
9143
|
+
accountId: void 0
|
|
9144
|
+
},
|
|
9145
|
+
abortSignal
|
|
9146
|
+
);
|
|
9147
|
+
}
|
|
9128
9148
|
// =========================================================================
|
|
9129
9149
|
// Order History
|
|
9130
9150
|
// =========================================================================
|
|
@@ -9344,7 +9364,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9344
9364
|
* ```
|
|
9345
9365
|
*/
|
|
9346
9366
|
async getWithdrawCollateralTx(inputs) {
|
|
9347
|
-
const {
|
|
9367
|
+
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9348
9368
|
if (this.vaultId)
|
|
9349
9369
|
throw new Error(
|
|
9350
9370
|
"this method is not supported for vaults, please use method `getAdminWithdrawTx` on class `PerpetualsVault` instead"
|
|
@@ -9352,8 +9372,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9352
9372
|
return this.fetchApiTxObject(
|
|
9353
9373
|
"account/transactions/withdraw-collateral",
|
|
9354
9374
|
{
|
|
9355
|
-
|
|
9356
|
-
recipientAddress,
|
|
9375
|
+
...otherInputs,
|
|
9357
9376
|
walletAddress: this.ownerAddress(),
|
|
9358
9377
|
accountId: this.accountCap.accountId,
|
|
9359
9378
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
@@ -9381,12 +9400,11 @@ var init_perpetualsAccount = __esm({
|
|
|
9381
9400
|
* @returns Transaction response containing a `tx`.
|
|
9382
9401
|
*/
|
|
9383
9402
|
async getAllocateCollateralTx(inputs) {
|
|
9384
|
-
const { tx,
|
|
9403
|
+
const { tx, ...otherInputs } = inputs;
|
|
9385
9404
|
return this.fetchApiTxObject(
|
|
9386
9405
|
`${this.vaultId ? "vault" : "account"}/transactions/allocate-collateral`,
|
|
9387
9406
|
{
|
|
9388
|
-
|
|
9389
|
-
allocateAmount,
|
|
9407
|
+
...otherInputs,
|
|
9390
9408
|
..."vaultId" in this.accountCap ? {
|
|
9391
9409
|
vaultId: this.accountCap.vaultId,
|
|
9392
9410
|
accountId: void 0
|
|
@@ -9419,12 +9437,11 @@ var init_perpetualsAccount = __esm({
|
|
|
9419
9437
|
* @returns Transaction response containing a `tx`.
|
|
9420
9438
|
*/
|
|
9421
9439
|
async getDeallocateCollateralTx(inputs) {
|
|
9422
|
-
const { tx,
|
|
9440
|
+
const { tx, ...otherInputs } = inputs;
|
|
9423
9441
|
return this.fetchApiTxObject(
|
|
9424
9442
|
`${this.vaultId ? "vault" : "account"}/transactions/deallocate-collateral`,
|
|
9425
9443
|
{
|
|
9426
|
-
|
|
9427
|
-
deallocateAmount,
|
|
9444
|
+
...otherInputs,
|
|
9428
9445
|
..."vaultId" in this.accountCap ? {
|
|
9429
9446
|
vaultId: this.accountCap.vaultId,
|
|
9430
9447
|
accountId: void 0
|
|
@@ -9456,7 +9473,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9456
9473
|
* @returns Transaction response containing a `tx`.
|
|
9457
9474
|
*/
|
|
9458
9475
|
async getTransferCollateralTx(inputs) {
|
|
9459
|
-
const {
|
|
9476
|
+
const { tx, ...otherInputs } = inputs;
|
|
9460
9477
|
if ("vaultId" in this.accountCap)
|
|
9461
9478
|
throw new Error(
|
|
9462
9479
|
"`getTransferCollateralTx` not supported by vault accounts"
|
|
@@ -9464,9 +9481,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9464
9481
|
return this.fetchApiTxObject(
|
|
9465
9482
|
`${this.vaultId ? "vault" : "account"}/transactions/transfer-collateral`,
|
|
9466
9483
|
{
|
|
9467
|
-
|
|
9468
|
-
toAccountId,
|
|
9469
|
-
toAccountCapId,
|
|
9484
|
+
...otherInputs,
|
|
9470
9485
|
walletAddress: this.ownerAddress(),
|
|
9471
9486
|
fromAccountId: this.accountCap.accountId,
|
|
9472
9487
|
fromAccountCapId: this.accountCap.objectId,
|
|
@@ -9590,6 +9605,80 @@ var init_perpetualsAccount = __esm({
|
|
|
9590
9605
|
}
|
|
9591
9606
|
);
|
|
9592
9607
|
}
|
|
9608
|
+
/**
|
|
9609
|
+
* Build a `place-scale-order` transaction for this account.
|
|
9610
|
+
*
|
|
9611
|
+
* A scale order distributes a total size across multiple limit orders
|
|
9612
|
+
* evenly spaced between a start and end price. An optional `sizeSkew`
|
|
9613
|
+
* parameter controls whether the distribution is uniform or weighted.
|
|
9614
|
+
*
|
|
9615
|
+
* @param inputs - See {@link SdkPerpetualsPlaceScaleOrderInputs}.
|
|
9616
|
+
*
|
|
9617
|
+
* @returns Transaction response containing `tx`.
|
|
9618
|
+
*/
|
|
9619
|
+
async getPlaceScaleOrderTx(inputs) {
|
|
9620
|
+
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9621
|
+
const tx = txFromInputs ?? new Transaction3();
|
|
9622
|
+
return this.fetchApiTxObject(
|
|
9623
|
+
`${this.vaultId ? "vault" : "account"}/transactions/place-scale-order`,
|
|
9624
|
+
{
|
|
9625
|
+
...otherInputs,
|
|
9626
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
9627
|
+
{ tx }
|
|
9628
|
+
),
|
|
9629
|
+
walletAddress: this.ownerAddress(),
|
|
9630
|
+
..."vaultId" in this.accountCap ? {
|
|
9631
|
+
vaultId: this.accountCap.vaultId,
|
|
9632
|
+
accountId: void 0
|
|
9633
|
+
} : {
|
|
9634
|
+
accountId: this.accountCap.accountId,
|
|
9635
|
+
accountCapId: this.accountCap.objectId,
|
|
9636
|
+
vaultId: void 0
|
|
9637
|
+
}
|
|
9638
|
+
},
|
|
9639
|
+
void 0,
|
|
9640
|
+
{
|
|
9641
|
+
txKind: true
|
|
9642
|
+
}
|
|
9643
|
+
);
|
|
9644
|
+
}
|
|
9645
|
+
/**
|
|
9646
|
+
* Build a `cancel-and-place-orders` transaction for this account.
|
|
9647
|
+
*
|
|
9648
|
+
* Atomically cancels existing orders and places new ones in a single
|
|
9649
|
+
* transaction. Useful for rebalancing order grids or replacing stale
|
|
9650
|
+
* orders without intermediate exposure.
|
|
9651
|
+
*
|
|
9652
|
+
* @param inputs - See {@link SdkPerpetualsCancelAndPlaceOrdersInputs}.
|
|
9653
|
+
*
|
|
9654
|
+
* @returns Transaction response containing `tx`.
|
|
9655
|
+
*/
|
|
9656
|
+
async getCancelAndPlaceOrdersTx(inputs) {
|
|
9657
|
+
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9658
|
+
const tx = txFromInputs ?? new Transaction3();
|
|
9659
|
+
return this.fetchApiTxObject(
|
|
9660
|
+
`${this.vaultId ? "vault" : "account"}/transactions/cancel-and-place-orders`,
|
|
9661
|
+
{
|
|
9662
|
+
...otherInputs,
|
|
9663
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
9664
|
+
{ tx }
|
|
9665
|
+
),
|
|
9666
|
+
walletAddress: this.ownerAddress(),
|
|
9667
|
+
..."vaultId" in this.accountCap ? {
|
|
9668
|
+
vaultId: this.accountCap.vaultId,
|
|
9669
|
+
accountId: void 0
|
|
9670
|
+
} : {
|
|
9671
|
+
accountId: this.accountCap.accountId,
|
|
9672
|
+
accountCapId: this.accountCap.objectId,
|
|
9673
|
+
vaultId: void 0
|
|
9674
|
+
}
|
|
9675
|
+
},
|
|
9676
|
+
void 0,
|
|
9677
|
+
{
|
|
9678
|
+
txKind: true
|
|
9679
|
+
}
|
|
9680
|
+
);
|
|
9681
|
+
}
|
|
9593
9682
|
/**
|
|
9594
9683
|
* Build a `cancel-orders` transaction for this account.
|
|
9595
9684
|
*
|
|
@@ -9686,19 +9775,12 @@ var init_perpetualsAccount = __esm({
|
|
|
9686
9775
|
* @returns Transaction response containing `tx`.
|
|
9687
9776
|
*/
|
|
9688
9777
|
async getPlaceStopOrdersTx(inputs) {
|
|
9689
|
-
const {
|
|
9690
|
-
tx: txFromInputs,
|
|
9691
|
-
isSponsoredTx,
|
|
9692
|
-
stopOrders,
|
|
9693
|
-
gasCoinArg
|
|
9694
|
-
} = inputs;
|
|
9778
|
+
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9695
9779
|
const tx = txFromInputs ?? new Transaction3();
|
|
9696
9780
|
return this.fetchApiTxObject(
|
|
9697
9781
|
`${this.vaultId ? "vault" : "account"}/transactions/place-stop-orders`,
|
|
9698
9782
|
{
|
|
9699
|
-
|
|
9700
|
-
gasCoinArg,
|
|
9701
|
-
isSponsoredTx,
|
|
9783
|
+
...otherInputs,
|
|
9702
9784
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
9703
9785
|
{ tx }
|
|
9704
9786
|
),
|
|
@@ -9735,19 +9817,14 @@ var init_perpetualsAccount = __esm({
|
|
|
9735
9817
|
* @returns Transaction response containing `tx`.
|
|
9736
9818
|
*/
|
|
9737
9819
|
async getPlaceSlTpOrdersTx(inputs) {
|
|
9738
|
-
const {
|
|
9739
|
-
tx: txFromInputs,
|
|
9740
|
-
isSponsoredTx,
|
|
9741
|
-
marketId,
|
|
9742
|
-
...slTpInputs
|
|
9743
|
-
} = inputs;
|
|
9820
|
+
const { tx: txFromInputs, marketId, ...otherInputs } = inputs;
|
|
9744
9821
|
const position = this.positionForMarketId({ marketId });
|
|
9745
9822
|
if (!position) throw new Error("you have no position for this market");
|
|
9746
9823
|
const tx = txFromInputs ?? new Transaction3();
|
|
9747
9824
|
return this.fetchApiTxObject(
|
|
9748
9825
|
`${this.vaultId ? "vault" : "account"}/transactions/place-sl-tp-orders`,
|
|
9749
9826
|
{
|
|
9750
|
-
...
|
|
9827
|
+
...otherInputs,
|
|
9751
9828
|
marketId,
|
|
9752
9829
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
9753
9830
|
{ tx }
|
|
@@ -9787,12 +9864,12 @@ var init_perpetualsAccount = __esm({
|
|
|
9787
9864
|
* @returns Transaction response containing `tx`.
|
|
9788
9865
|
*/
|
|
9789
9866
|
async getEditStopOrdersTx(inputs) {
|
|
9790
|
-
const { tx: txFromInputs,
|
|
9867
|
+
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9791
9868
|
const tx = txFromInputs ?? new Transaction3();
|
|
9792
9869
|
return this.fetchApiTxObject(
|
|
9793
9870
|
`${this.vaultId ? "vault" : "account"}/transactions/edit-stop-orders`,
|
|
9794
9871
|
{
|
|
9795
|
-
|
|
9872
|
+
...otherInputs,
|
|
9796
9873
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
9797
9874
|
{ tx }
|
|
9798
9875
|
),
|
|
@@ -9869,13 +9946,11 @@ var init_perpetualsAccount = __esm({
|
|
|
9869
9946
|
* @returns Transaction response containing `tx`.
|
|
9870
9947
|
*/
|
|
9871
9948
|
async getSetLeverageTx(inputs) {
|
|
9872
|
-
const {
|
|
9949
|
+
const { tx, ...otherInputs } = inputs;
|
|
9873
9950
|
return this.fetchApiTxObject(
|
|
9874
9951
|
`${this.vaultId ? "vault" : "account"}/transactions/set-leverage`,
|
|
9875
9952
|
{
|
|
9876
|
-
|
|
9877
|
-
marketId,
|
|
9878
|
-
collateralChange,
|
|
9953
|
+
...otherInputs,
|
|
9879
9954
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
9880
9955
|
{ tx }
|
|
9881
9956
|
),
|
|
@@ -10043,6 +10118,38 @@ var init_perpetualsAccount = __esm({
|
|
|
10043
10118
|
abortSignal
|
|
10044
10119
|
);
|
|
10045
10120
|
}
|
|
10121
|
+
/**
|
|
10122
|
+
* Preview the effects of placing a scale order (without building a tx).
|
|
10123
|
+
*
|
|
10124
|
+
* A scale order distributes total size across multiple limit orders
|
|
10125
|
+
* spaced between a start and end price. The preview simulates:
|
|
10126
|
+
* - How much size would execute immediately vs post to the book
|
|
10127
|
+
* - Expected slippage and execution price
|
|
10128
|
+
* - Resulting position and margin impact
|
|
10129
|
+
*
|
|
10130
|
+
* @param inputs - See {@link SdkPerpetualsPlaceScaleOrderPreviewInputs}.
|
|
10131
|
+
* @param abortSignal - Optional `AbortSignal` to cancel the request.
|
|
10132
|
+
*
|
|
10133
|
+
* @returns Either an error message or a preview object similar to
|
|
10134
|
+
* {@link getPlaceMarketOrderPreview}.
|
|
10135
|
+
*/
|
|
10136
|
+
async getPlaceScaleOrderPreview(inputs, abortSignal) {
|
|
10137
|
+
return this.fetchApi(
|
|
10138
|
+
`${this.vaultId ? "vault" : "account"}/previews/place-scale-order`,
|
|
10139
|
+
{
|
|
10140
|
+
...inputs,
|
|
10141
|
+
..."vaultId" in this.accountCap ? {
|
|
10142
|
+
vaultId: this.accountCap.vaultId,
|
|
10143
|
+
accountId: void 0
|
|
10144
|
+
} : {
|
|
10145
|
+
accountId: this.accountCap.accountId,
|
|
10146
|
+
accountCapId: this.accountCap.objectId,
|
|
10147
|
+
vaultId: void 0
|
|
10148
|
+
}
|
|
10149
|
+
},
|
|
10150
|
+
abortSignal
|
|
10151
|
+
);
|
|
10152
|
+
}
|
|
10046
10153
|
/**
|
|
10047
10154
|
* Preview the effects of canceling orders across one or more markets.
|
|
10048
10155
|
*
|
|
@@ -10849,10 +10956,11 @@ var init_perpetualsVault = __esm({
|
|
|
10849
10956
|
}
|
|
10850
10957
|
// TODO: docs
|
|
10851
10958
|
async getPauseVaultForForceWithdrawRequestTx(inputs) {
|
|
10852
|
-
const { tx } = inputs;
|
|
10959
|
+
const { tx, ...otherInputs } = inputs;
|
|
10853
10960
|
return this.fetchApiTxObject(
|
|
10854
10961
|
"vault/transactions/pause-vault-for-force-withdraw-request",
|
|
10855
10962
|
{
|
|
10963
|
+
...otherInputs,
|
|
10856
10964
|
vaultId: this.vaultObject.objectId,
|
|
10857
10965
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
10858
10966
|
{
|
|
@@ -11057,6 +11165,39 @@ var init_perpetualsVault = __esm({
|
|
|
11057
11165
|
{ txKind: true }
|
|
11058
11166
|
);
|
|
11059
11167
|
}
|
|
11168
|
+
/**
|
|
11169
|
+
* Build an owner transaction to withdraw locked liquidity from the vault.
|
|
11170
|
+
*
|
|
11171
|
+
* Owner-locked liquidity is LP that was locked at vault creation time.
|
|
11172
|
+
* This flow allows the owner to withdraw a portion without going through
|
|
11173
|
+
* the standard withdraw-request lifecycle. Owner-locked withdrawals are
|
|
11174
|
+
* exempt from performance fees.
|
|
11175
|
+
*
|
|
11176
|
+
* @param inputs.amount - Amount of locked LP to withdraw (native units).
|
|
11177
|
+
* @param inputs.minCollateralAmountOut - Minimum collateral out to protect from slippage.
|
|
11178
|
+
* @param inputs.recipientAddress - Optional recipient address for withdrawn collateral.
|
|
11179
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
11180
|
+
*
|
|
11181
|
+
* @returns Response containing `tx` and any extra outputs described by
|
|
11182
|
+
* {@link ApiPerpetualsVaultOwnerWithdrawLockedLiquidityTxResponse}.
|
|
11183
|
+
*/
|
|
11184
|
+
async getOwnerWithdrawLockedLiquidityTx(inputs) {
|
|
11185
|
+
const { tx, ...otherInputs } = inputs;
|
|
11186
|
+
return this.fetchApiTxObject(
|
|
11187
|
+
"vault/transactions/owner/withdraw-locked-liquidity",
|
|
11188
|
+
{
|
|
11189
|
+
...otherInputs,
|
|
11190
|
+
vaultId: this.vaultObject.objectId,
|
|
11191
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
11192
|
+
{
|
|
11193
|
+
tx: tx ?? new Transaction4()
|
|
11194
|
+
}
|
|
11195
|
+
)
|
|
11196
|
+
},
|
|
11197
|
+
void 0,
|
|
11198
|
+
{ txKind: true }
|
|
11199
|
+
);
|
|
11200
|
+
}
|
|
11060
11201
|
// =========================================================================
|
|
11061
11202
|
// User Interactions Txs
|
|
11062
11203
|
// =========================================================================
|
|
@@ -11219,6 +11360,22 @@ var init_perpetualsVault = __esm({
|
|
|
11219
11360
|
vaultId: this.vaultObject.objectId
|
|
11220
11361
|
});
|
|
11221
11362
|
}
|
|
11363
|
+
/**
|
|
11364
|
+
* Preview an owner locked liquidity withdrawal.
|
|
11365
|
+
*
|
|
11366
|
+
* Returns the estimated collateral output for withdrawing a given amount
|
|
11367
|
+
* of the owner's locked LP tokens. Owner-locked withdrawals are exempt
|
|
11368
|
+
* from performance fees.
|
|
11369
|
+
*
|
|
11370
|
+
* @param inputs.amount - Amount of locked LP to withdraw (native units).
|
|
11371
|
+
* @returns Preview response including estimated collateral out and price.
|
|
11372
|
+
*/
|
|
11373
|
+
async getPreviewOwnerWithdrawLockedLiquidity(inputs) {
|
|
11374
|
+
return this.fetchApi("vault/previews/owner/withdraw-locked-liquidity", {
|
|
11375
|
+
...inputs,
|
|
11376
|
+
vaultId: this.vaultObject.objectId
|
|
11377
|
+
});
|
|
11378
|
+
}
|
|
11222
11379
|
// =========================================================================
|
|
11223
11380
|
// User Previews
|
|
11224
11381
|
// =========================================================================
|
|
@@ -11731,6 +11888,22 @@ var init_perpetuals = __esm({
|
|
|
11731
11888
|
async getOwnedVaultCaps(inputs) {
|
|
11732
11889
|
return this.fetchApi("vaults/owned-vault-caps", inputs);
|
|
11733
11890
|
}
|
|
11891
|
+
/**
|
|
11892
|
+
* Fetch all vault **assistant** caps owned by a wallet.
|
|
11893
|
+
*
|
|
11894
|
+
* Assistant caps grant a non-owner wallet the ability to operate a vault
|
|
11895
|
+
* on behalf of the owner. The returned caps are structurally identical to
|
|
11896
|
+
* regular vault caps ({@link PerpetualsVaultCap}) and can be used to
|
|
11897
|
+
* construct a {@link PerpetualsAccount} that signs vault transactions with
|
|
11898
|
+
* the assistant's wallet.
|
|
11899
|
+
*
|
|
11900
|
+
* @param inputs.walletAddress - Assistant wallet address.
|
|
11901
|
+
* @returns {@link ApiPerpetualsOwnedVaultAssistantCapsResponse} containing
|
|
11902
|
+
* assistant caps.
|
|
11903
|
+
*/
|
|
11904
|
+
async getOwnedVaultAssistantCaps(inputs) {
|
|
11905
|
+
return this.fetchApi("vaults/owned-vault-assistant-caps", inputs);
|
|
11906
|
+
}
|
|
11734
11907
|
/**
|
|
11735
11908
|
* Fetch all pending vault withdrawal requests created by a given wallet.
|
|
11736
11909
|
*
|
|
@@ -11795,10 +11968,24 @@ var init_perpetuals = __esm({
|
|
|
11795
11968
|
});
|
|
11796
11969
|
}
|
|
11797
11970
|
/**
|
|
11798
|
-
* Fetch
|
|
11971
|
+
* Fetch historical funding rate data for a single market.
|
|
11799
11972
|
*
|
|
11800
|
-
*
|
|
11801
|
-
*
|
|
11973
|
+
* @param inputs.marketId - Market ID to query.
|
|
11974
|
+
* @param inputs.fromTimestamp - Start timestamp (inclusive).
|
|
11975
|
+
* @param inputs.toTimestamp - End timestamp (exclusive).
|
|
11976
|
+
* @param inputs.limit - Optional cap on the number of points returned.
|
|
11977
|
+
*
|
|
11978
|
+
* @returns {@link ApiPerpetualsMarketFundingHistoryResponse} containing
|
|
11979
|
+
* funding history points.
|
|
11980
|
+
*/
|
|
11981
|
+
getMarketFundingHistory(inputs) {
|
|
11982
|
+
return this.fetchApi("market/funding-history", inputs);
|
|
11983
|
+
}
|
|
11984
|
+
/**
|
|
11985
|
+
* Fetch 24-hour volume and price change stats for multiple markets.
|
|
11986
|
+
*
|
|
11987
|
+
* Returns volume, price change, and the latest base, collateral,
|
|
11988
|
+
* mid, and mark prices for each requested market.
|
|
11802
11989
|
*
|
|
11803
11990
|
* @param inputs.marketIds - Market IDs to query.
|
|
11804
11991
|
* @returns {@link ApiPerpetualsMarkets24hrStatsResponse}.
|
|
@@ -11848,27 +12035,26 @@ var init_perpetuals = __esm({
|
|
|
11848
12035
|
// Transactions
|
|
11849
12036
|
// =========================================================================
|
|
11850
12037
|
/**
|
|
11851
|
-
* Build a
|
|
11852
|
-
* to another wallet.
|
|
12038
|
+
* Build a transaction to transfer a Perpetuals capability object (cap) to another wallet.
|
|
11853
12039
|
*
|
|
11854
|
-
*
|
|
11855
|
-
*
|
|
11856
|
-
*
|
|
11857
|
-
*
|
|
12040
|
+
* Supports two methods:
|
|
12041
|
+
* - **Method 1**: Provide `capObjectId` to transfer an existing on-chain object.
|
|
12042
|
+
* - **Method 2**: Provide `composed` with the PTB argument and capability type
|
|
12043
|
+
* from a deferred PTB composition (e.g., from `getCreateAccountTx` with `deferShare=true`).
|
|
11858
12044
|
*
|
|
11859
12045
|
* @param inputs.recipientAddress - Recipient wallet address that should receive the cap.
|
|
11860
|
-
* @param inputs.capObjectId - Object ID of the capability to transfer.
|
|
12046
|
+
* @param inputs.capObjectId - Object ID of the capability to transfer (Method 1).
|
|
12047
|
+
* @param inputs.composed - Composed PTB argument + capability type (Method 2).
|
|
11861
12048
|
* @param inputs.tx - Optional transaction to extend.
|
|
11862
12049
|
*
|
|
11863
12050
|
* @returns Transaction response containing a `tx`.
|
|
11864
12051
|
*/
|
|
11865
12052
|
async getTransferCapTx(inputs) {
|
|
11866
|
-
const { tx,
|
|
12053
|
+
const { tx, ...otherInputs } = inputs;
|
|
11867
12054
|
return this.fetchApiTxObject(
|
|
11868
12055
|
"transactions/transfer-cap",
|
|
11869
12056
|
{
|
|
11870
|
-
|
|
11871
|
-
capObjectId,
|
|
12057
|
+
...otherInputs,
|
|
11872
12058
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
11873
12059
|
{
|
|
11874
12060
|
tx: tx ?? new Transaction5()
|
|
@@ -11884,20 +12070,23 @@ var init_perpetuals = __esm({
|
|
|
11884
12070
|
/**
|
|
11885
12071
|
* Build a `create-account` transaction for Aftermath Perpetuals.
|
|
11886
12072
|
*
|
|
12073
|
+
* When `deferShare` is `true`, the response includes a `deferred` object with
|
|
12074
|
+
* `accountArg`, `sharePolicyArg`, `adminCapArg`, and `collateralCoinType` so you
|
|
12075
|
+
* can compose additional commands (grant-agent-wallet, transfer-cap) before calling
|
|
12076
|
+
* {@link getShareAccountTx} to finalize.
|
|
12077
|
+
*
|
|
11887
12078
|
* @param inputs.walletAddress - Wallet address that will own the new account.
|
|
11888
12079
|
* @param inputs.collateralCoinType - Collateral coin type used by the account.
|
|
11889
|
-
* @param inputs.
|
|
11890
|
-
*
|
|
11891
|
-
*
|
|
11892
|
-
* @returns {@link SdkTransactionResponse} with `tx`.
|
|
12080
|
+
* @param inputs.deferShare - When true, returns `deferred` args without sharing yet.
|
|
12081
|
+
* @param inputs.tx - Optional {@link Transaction} to extend.
|
|
12082
|
+
* @returns `tx` plus optional `deferred` containing argument references when deferred.
|
|
11893
12083
|
*/
|
|
11894
12084
|
async getCreateAccountTx(inputs) {
|
|
11895
|
-
const {
|
|
12085
|
+
const { tx, ...otherInputs } = inputs;
|
|
11896
12086
|
return this.fetchApiTxObject(
|
|
11897
12087
|
"transactions/create-account",
|
|
11898
12088
|
{
|
|
11899
|
-
|
|
11900
|
-
collateralCoinType,
|
|
12089
|
+
...otherInputs,
|
|
11901
12090
|
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
11902
12091
|
{ tx }
|
|
11903
12092
|
)
|
|
@@ -11908,6 +12097,76 @@ var init_perpetuals = __esm({
|
|
|
11908
12097
|
}
|
|
11909
12098
|
);
|
|
11910
12099
|
}
|
|
12100
|
+
/**
|
|
12101
|
+
* Build a transaction that grants an Agent Wallet permission on a Perpetuals account.
|
|
12102
|
+
*
|
|
12103
|
+
* Supports two methods:
|
|
12104
|
+
* - **Method 1 (existing account)**: Provide `accountId` to look up an existing shared account.
|
|
12105
|
+
* - **Method 2 (composed flow)**: Provide `deferred` with the argument references
|
|
12106
|
+
* from a deferred `getCreateAccountTx` call.
|
|
12107
|
+
*
|
|
12108
|
+
* @param inputs.recipientAddress - Wallet address to receive agent permissions.
|
|
12109
|
+
* @param inputs.accountId - Perpetuals account ID (Method 1).
|
|
12110
|
+
* @param inputs.deferred - Deferred account args from `getCreateAccountTx` (Method 2).
|
|
12111
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
12112
|
+
*
|
|
12113
|
+
* @returns Transaction response containing a `tx`.
|
|
12114
|
+
*/
|
|
12115
|
+
async getGrantAgentWalletTx(inputs) {
|
|
12116
|
+
const { tx, ...otherInputs } = inputs;
|
|
12117
|
+
return this.fetchApiTxObject(
|
|
12118
|
+
"account/transactions/grant-agent-wallet",
|
|
12119
|
+
{
|
|
12120
|
+
...otherInputs,
|
|
12121
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
12122
|
+
{
|
|
12123
|
+
tx: tx ?? new Transaction5()
|
|
12124
|
+
}
|
|
12125
|
+
)
|
|
12126
|
+
},
|
|
12127
|
+
void 0,
|
|
12128
|
+
{
|
|
12129
|
+
txKind: true
|
|
12130
|
+
}
|
|
12131
|
+
);
|
|
12132
|
+
}
|
|
12133
|
+
/**
|
|
12134
|
+
* Build a transaction to share a Perpetuals account that was created with deferred sharing.
|
|
12135
|
+
*
|
|
12136
|
+
* This finalizes the account creation flow by consuming the `AccountSharePolicy`
|
|
12137
|
+
* and sharing the `Account` object. Call this after composing additional commands
|
|
12138
|
+
* (grant-agent-wallet, transfer-cap) with the args returned by {@link getCreateAccountTx}.
|
|
12139
|
+
*
|
|
12140
|
+
* Pass the deferred fields (`accountArg`, `sharePolicyArg`, `adminCapArg`,
|
|
12141
|
+
* `collateralCoinType`) from the `deferred` object returned by `getCreateAccountTx`.
|
|
12142
|
+
*
|
|
12143
|
+
* @param inputs.accountArg - Account argument from deferred create.
|
|
12144
|
+
* @param inputs.sharePolicyArg - Share policy argument from deferred create.
|
|
12145
|
+
* @param inputs.adminCapArg - Admin cap argument from deferred create.
|
|
12146
|
+
* @param inputs.collateralCoinType - Collateral type for the account.
|
|
12147
|
+
* @param inputs.sponsor - Optional sponsorship config.
|
|
12148
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
12149
|
+
*
|
|
12150
|
+
* @returns Transaction response containing a `tx`.
|
|
12151
|
+
*/
|
|
12152
|
+
async getShareAccountTx(inputs) {
|
|
12153
|
+
const { tx, ...otherInputs } = inputs;
|
|
12154
|
+
return this.fetchApiTxObject(
|
|
12155
|
+
"account/transactions/share",
|
|
12156
|
+
{
|
|
12157
|
+
...otherInputs,
|
|
12158
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
12159
|
+
{
|
|
12160
|
+
tx: tx ?? new Transaction5()
|
|
12161
|
+
}
|
|
12162
|
+
)
|
|
12163
|
+
},
|
|
12164
|
+
void 0,
|
|
12165
|
+
{
|
|
12166
|
+
txKind: true
|
|
12167
|
+
}
|
|
12168
|
+
);
|
|
12169
|
+
}
|
|
11911
12170
|
/**
|
|
11912
12171
|
* Build a `create-vault-cap` transaction.
|
|
11913
12172
|
*
|
|
@@ -11969,6 +12228,61 @@ var init_perpetuals = __esm({
|
|
|
11969
12228
|
);
|
|
11970
12229
|
}
|
|
11971
12230
|
// =========================================================================
|
|
12231
|
+
// Rebates
|
|
12232
|
+
// =========================================================================
|
|
12233
|
+
/**
|
|
12234
|
+
* Calculate rewards and rebates for one or more perpetuals accounts.
|
|
12235
|
+
*
|
|
12236
|
+
* Computes per-account maker and taker reward allocations, fee-tier rebates,
|
|
12237
|
+
* and volume-based metrics. When `accountIds` is omitted or empty, all eligible
|
|
12238
|
+
* accounts are included.
|
|
12239
|
+
*
|
|
12240
|
+
* **Note:** All data returned is for the current epoch only.
|
|
12241
|
+
*
|
|
12242
|
+
* @param inputs.totalMakerRewards - Total maker reward pool to distribute.
|
|
12243
|
+
* @param inputs.totalTakerRewards - Total taker reward pool to distribute.
|
|
12244
|
+
* @param inputs.accountIds - Optional list of account IDs.
|
|
12245
|
+
* @returns {@link ApiPerpetualsCurrentRebateRewardsResponse} with per-account reward and rebate data.
|
|
12246
|
+
*
|
|
12247
|
+
* @example
|
|
12248
|
+
* ```ts
|
|
12249
|
+
* const { totalQScoreFinal, rewards } = await perps.getCurrentRebateRewards({
|
|
12250
|
+
* totalMakerRewards: 10000,
|
|
12251
|
+
* totalTakerRewards: 5000,
|
|
12252
|
+
* });
|
|
12253
|
+
* ```
|
|
12254
|
+
*/
|
|
12255
|
+
async getCurrentRebateRewards(inputs) {
|
|
12256
|
+
return this.fetchApi("rebates/rewards", inputs);
|
|
12257
|
+
}
|
|
12258
|
+
/**
|
|
12259
|
+
* Generate a CSV-formatted rebate report for perpetuals market makers.
|
|
12260
|
+
*
|
|
12261
|
+
* Computes per-account reward allocations and fee-tier rebate adjustments,
|
|
12262
|
+
* returning the result as a CSV string. When `aggregated` is true, the CSV
|
|
12263
|
+
* groups rewards by owner address instead of per-account.
|
|
12264
|
+
*
|
|
12265
|
+
* **Note:** All data returned is for the current epoch only.
|
|
12266
|
+
*
|
|
12267
|
+
* @param inputs - {@link ApiPerpetualsCreateCsvRebatesBody}.
|
|
12268
|
+
* @returns {@link ApiPerpetualsCreateCsvRebatesResponse} containing the CSV string.
|
|
12269
|
+
*/
|
|
12270
|
+
async getCsvRebates(inputs) {
|
|
12271
|
+
return this.fetchApi("rebates/create-csv-rebates", inputs);
|
|
12272
|
+
}
|
|
12273
|
+
/**
|
|
12274
|
+
* Generate a CSV-formatted referral rebate report.
|
|
12275
|
+
*
|
|
12276
|
+
* Calculates referrer commissions and referee discounts based on trading
|
|
12277
|
+
* fees within the specified epoch, returning the result as a CSV string.
|
|
12278
|
+
*
|
|
12279
|
+
* @param inputs - {@link ApiPerpetualsCreateReferralCsvRebatesBody}.
|
|
12280
|
+
* @returns {@link ApiPerpetualsCreateReferralCsvRebatesResponse} containing the CSV string.
|
|
12281
|
+
*/
|
|
12282
|
+
async getReferralCsvRebates(inputs) {
|
|
12283
|
+
return this.fetchApi("rebates/create-referral-csv-rebates", inputs);
|
|
12284
|
+
}
|
|
12285
|
+
// =========================================================================
|
|
11972
12286
|
// Builder Codes Transactions
|
|
11973
12287
|
// =========================================================================
|
|
11974
12288
|
/**
|
|
@@ -11994,9 +12308,15 @@ var init_perpetuals = __esm({
|
|
|
11994
12308
|
* ```
|
|
11995
12309
|
*/
|
|
11996
12310
|
async getCreateBuilderCodeIntegratorConfigTx(inputs) {
|
|
12311
|
+
const { tx, ...otherInputs } = inputs;
|
|
11997
12312
|
return this.fetchApiTxObject(
|
|
11998
12313
|
"builder-codes/transactions/create-integrator-config",
|
|
11999
|
-
|
|
12314
|
+
{
|
|
12315
|
+
...otherInputs,
|
|
12316
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
12317
|
+
{ tx }
|
|
12318
|
+
)
|
|
12319
|
+
},
|
|
12000
12320
|
void 0,
|
|
12001
12321
|
{
|
|
12002
12322
|
txKind: true
|
|
@@ -12026,9 +12346,15 @@ var init_perpetuals = __esm({
|
|
|
12026
12346
|
* ```
|
|
12027
12347
|
*/
|
|
12028
12348
|
async getRemoveBuilderCodeIntegratorConfigTx(inputs) {
|
|
12349
|
+
const { tx, ...otherInputs } = inputs;
|
|
12029
12350
|
return this.fetchApiTxObject(
|
|
12030
12351
|
"builder-codes/transactions/remove-integrator-config",
|
|
12031
|
-
|
|
12352
|
+
{
|
|
12353
|
+
...otherInputs,
|
|
12354
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
12355
|
+
{ tx }
|
|
12356
|
+
)
|
|
12357
|
+
},
|
|
12032
12358
|
void 0,
|
|
12033
12359
|
{
|
|
12034
12360
|
txKind: true
|
|
@@ -12058,9 +12384,15 @@ var init_perpetuals = __esm({
|
|
|
12058
12384
|
* ```
|
|
12059
12385
|
*/
|
|
12060
12386
|
async getCreateBuilderCodeIntegratorVaultTx(inputs) {
|
|
12387
|
+
const { tx, ...otherInputs } = inputs;
|
|
12061
12388
|
return this.fetchApiTxObject(
|
|
12062
12389
|
"builder-codes/transactions/create-integrator-vault",
|
|
12063
|
-
|
|
12390
|
+
{
|
|
12391
|
+
...otherInputs,
|
|
12392
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
12393
|
+
{ tx }
|
|
12394
|
+
)
|
|
12395
|
+
},
|
|
12064
12396
|
void 0,
|
|
12065
12397
|
{
|
|
12066
12398
|
txKind: true
|
|
@@ -12104,9 +12436,15 @@ var init_perpetuals = __esm({
|
|
|
12104
12436
|
* ```
|
|
12105
12437
|
*/
|
|
12106
12438
|
async getClaimBuilderCodeIntegratorVaultFeesTx(inputs) {
|
|
12439
|
+
const { tx, ...otherInputs } = inputs;
|
|
12107
12440
|
return this.fetchApiTxObject(
|
|
12108
12441
|
"builder-codes/transactions/claim-integrator-vault-fees",
|
|
12109
|
-
|
|
12442
|
+
{
|
|
12443
|
+
...otherInputs,
|
|
12444
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
12445
|
+
{ tx }
|
|
12446
|
+
)
|
|
12447
|
+
},
|
|
12110
12448
|
void 0,
|
|
12111
12449
|
{
|
|
12112
12450
|
txKind: true
|
|
@@ -13291,6 +13629,228 @@ var init_staking2 = __esm({
|
|
|
13291
13629
|
}
|
|
13292
13630
|
});
|
|
13293
13631
|
|
|
13632
|
+
// src/packages/gasPools/gasPools.ts
|
|
13633
|
+
var GasPools;
|
|
13634
|
+
var init_gasPools = __esm({
|
|
13635
|
+
"src/packages/gasPools/gasPools.ts"() {
|
|
13636
|
+
"use strict";
|
|
13637
|
+
init_caller();
|
|
13638
|
+
GasPools = class extends Caller {
|
|
13639
|
+
// =========================================================================
|
|
13640
|
+
// Constructor
|
|
13641
|
+
// =========================================================================
|
|
13642
|
+
constructor(config, Provider) {
|
|
13643
|
+
super(config, "gas-pool");
|
|
13644
|
+
this.Provider = Provider;
|
|
13645
|
+
}
|
|
13646
|
+
// =========================================================================
|
|
13647
|
+
// Pool
|
|
13648
|
+
// =========================================================================
|
|
13649
|
+
/**
|
|
13650
|
+
* Fetches the gas pool details for a given wallet address.
|
|
13651
|
+
*
|
|
13652
|
+
* @param inputs - {@link ApiGasPoolBody}
|
|
13653
|
+
* @returns {@link ApiGasPoolResponse} containing pool ID, balance, and whitelisted addresses.
|
|
13654
|
+
*/
|
|
13655
|
+
async getPool(inputs) {
|
|
13656
|
+
return this.fetchApi(
|
|
13657
|
+
"pool",
|
|
13658
|
+
inputs
|
|
13659
|
+
);
|
|
13660
|
+
}
|
|
13661
|
+
// =========================================================================
|
|
13662
|
+
// Transactions
|
|
13663
|
+
// =========================================================================
|
|
13664
|
+
/**
|
|
13665
|
+
* Builds a transaction to create a new gas pool for the given wallet.
|
|
13666
|
+
*
|
|
13667
|
+
* When `deferShare` is `true`, the response includes `gasPoolArg` and
|
|
13668
|
+
* `sharePolicyArg` so you can compose additional commands (e.g. deposit,
|
|
13669
|
+
* grant) before calling {@link getShareTx} to finalize.
|
|
13670
|
+
*
|
|
13671
|
+
* @param inputs.walletAddress - Wallet address to create the gas pool for.
|
|
13672
|
+
* @param inputs.initialDepositAmount - Optional initial deposit amount in MIST.
|
|
13673
|
+
* @param inputs.deferShare - When true, returns args without sharing yet.
|
|
13674
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
13675
|
+
* @returns `tx` plus optional `gasPoolArg` and `sharePolicyArg` when deferred.
|
|
13676
|
+
*/
|
|
13677
|
+
async getCreateTx(inputs) {
|
|
13678
|
+
const { tx, ...otherInputs } = inputs;
|
|
13679
|
+
return this.fetchApiTxObject(
|
|
13680
|
+
"transactions/create",
|
|
13681
|
+
{
|
|
13682
|
+
...otherInputs,
|
|
13683
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
13684
|
+
{ tx }
|
|
13685
|
+
)
|
|
13686
|
+
},
|
|
13687
|
+
void 0,
|
|
13688
|
+
{ txKind: true }
|
|
13689
|
+
);
|
|
13690
|
+
}
|
|
13691
|
+
/**
|
|
13692
|
+
* Builds a transaction to deposit into the gas pool.
|
|
13693
|
+
*
|
|
13694
|
+
* Supports SUI and non-SUI deposits. For non-SUI deposits, the input coin
|
|
13695
|
+
* is swapped into SUI via the Aftermath router before depositing.
|
|
13696
|
+
*
|
|
13697
|
+
* @param inputs.walletAddress - Wallet address submitting the deposit.
|
|
13698
|
+
* @param inputs.isSponsoredTx - Whether to build the transaction for sponsored gas. Defaults to false.
|
|
13699
|
+
* @param inputs.coinType - Coin type to deposit. Defaults to SUI.
|
|
13700
|
+
* @param inputs.amount - Amount to deposit (required when sourcing from wallet or for non-SUI).
|
|
13701
|
+
* @param inputs.coinArg - PTB coin argument to use as input (if omitted, sourced from wallet).
|
|
13702
|
+
* @param inputs.slippage - Slippage tolerance for non-SUI swaps (defaults to 0.01).
|
|
13703
|
+
* @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
|
|
13704
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
13705
|
+
* @returns {@link SdkTransactionResponse} with `tx`.
|
|
13706
|
+
*/
|
|
13707
|
+
async getDepositTx(inputs) {
|
|
13708
|
+
const { tx, ...otherInputs } = inputs;
|
|
13709
|
+
return this.fetchApiTxObject(
|
|
13710
|
+
"transactions/deposit",
|
|
13711
|
+
{
|
|
13712
|
+
...otherInputs,
|
|
13713
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
13714
|
+
{ tx }
|
|
13715
|
+
)
|
|
13716
|
+
},
|
|
13717
|
+
void 0,
|
|
13718
|
+
{ txKind: true }
|
|
13719
|
+
);
|
|
13720
|
+
}
|
|
13721
|
+
/**
|
|
13722
|
+
* Builds a transaction to withdraw SUI from the gas pool.
|
|
13723
|
+
*
|
|
13724
|
+
* When `deferTransfer` is `true`, the withdrawn coin is not transferred.
|
|
13725
|
+
* Instead, `withdrawnCoinArg` is returned for further PTB composition.
|
|
13726
|
+
*
|
|
13727
|
+
* @param inputs.walletAddress - Wallet address submitting the withdrawal.
|
|
13728
|
+
* @param inputs.amount - Amount of SUI to withdraw in MIST.
|
|
13729
|
+
* @param inputs.recipientAddress - Optional recipient (defaults to `walletAddress`).
|
|
13730
|
+
* @param inputs.deferTransfer - When true, returns the withdrawn coin arg instead of transferring.
|
|
13731
|
+
* @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
|
|
13732
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
13733
|
+
* @returns `tx` plus optional `withdrawnCoinArg` when deferred.
|
|
13734
|
+
*/
|
|
13735
|
+
async getWithdrawTx(inputs) {
|
|
13736
|
+
const { tx, ...otherInputs } = inputs;
|
|
13737
|
+
return this.fetchApiTxObject(
|
|
13738
|
+
"transactions/withdraw",
|
|
13739
|
+
{
|
|
13740
|
+
...otherInputs,
|
|
13741
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
13742
|
+
{ tx }
|
|
13743
|
+
)
|
|
13744
|
+
},
|
|
13745
|
+
void 0,
|
|
13746
|
+
{ txKind: true }
|
|
13747
|
+
);
|
|
13748
|
+
}
|
|
13749
|
+
/**
|
|
13750
|
+
* Builds a transaction to sponsor (rebate) the transaction sender
|
|
13751
|
+
* using SUI from the gas pool.
|
|
13752
|
+
*
|
|
13753
|
+
* @param inputs.walletAddress - Wallet address submitting the sponsor transaction.
|
|
13754
|
+
* @param inputs.amount - Amount of SUI to rebate in MIST.
|
|
13755
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
13756
|
+
* @returns {@link SdkTransactionResponse} with `tx`.
|
|
13757
|
+
*/
|
|
13758
|
+
async getSponsorTx(inputs) {
|
|
13759
|
+
const { tx, ...otherInputs } = inputs;
|
|
13760
|
+
return this.fetchApiTxObject(
|
|
13761
|
+
"transactions/sponsor",
|
|
13762
|
+
{
|
|
13763
|
+
...otherInputs,
|
|
13764
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
13765
|
+
{ tx }
|
|
13766
|
+
)
|
|
13767
|
+
},
|
|
13768
|
+
void 0,
|
|
13769
|
+
{ txKind: true }
|
|
13770
|
+
);
|
|
13771
|
+
}
|
|
13772
|
+
/**
|
|
13773
|
+
* Builds a transaction to grant another wallet access to the gas pool.
|
|
13774
|
+
*
|
|
13775
|
+
* @param inputs.walletAddress - Owner wallet address.
|
|
13776
|
+
* @param inputs.targetWalletAddress - Wallet address to grant access to.
|
|
13777
|
+
* @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
|
|
13778
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
13779
|
+
* @returns {@link SdkTransactionResponse} with `tx`.
|
|
13780
|
+
*/
|
|
13781
|
+
async getGrantTx(inputs) {
|
|
13782
|
+
const { tx, ...otherInputs } = inputs;
|
|
13783
|
+
return this.fetchApiTxObject(
|
|
13784
|
+
"transactions/grant",
|
|
13785
|
+
{
|
|
13786
|
+
...otherInputs,
|
|
13787
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
13788
|
+
{ tx }
|
|
13789
|
+
)
|
|
13790
|
+
},
|
|
13791
|
+
void 0,
|
|
13792
|
+
{ txKind: true }
|
|
13793
|
+
);
|
|
13794
|
+
}
|
|
13795
|
+
/**
|
|
13796
|
+
* Builds a transaction to revoke another wallet's access to the gas pool.
|
|
13797
|
+
*
|
|
13798
|
+
* @param inputs.walletAddress - Owner wallet address.
|
|
13799
|
+
* @param inputs.targetWalletAddress - Wallet address to revoke access from.
|
|
13800
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
13801
|
+
* @returns {@link SdkTransactionResponse} with `tx`.
|
|
13802
|
+
*/
|
|
13803
|
+
async getRevokeTx(inputs) {
|
|
13804
|
+
const { tx, ...otherInputs } = inputs;
|
|
13805
|
+
return this.fetchApiTxObject(
|
|
13806
|
+
"transactions/revoke",
|
|
13807
|
+
{
|
|
13808
|
+
...otherInputs,
|
|
13809
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
13810
|
+
{ tx }
|
|
13811
|
+
)
|
|
13812
|
+
},
|
|
13813
|
+
void 0,
|
|
13814
|
+
{ txKind: true }
|
|
13815
|
+
);
|
|
13816
|
+
}
|
|
13817
|
+
/**
|
|
13818
|
+
* Builds a transaction to share a gas pool that was created with `deferShare: true`.
|
|
13819
|
+
*
|
|
13820
|
+
* Use this after composing additional commands (deposit, grant, etc.) with
|
|
13821
|
+
* the `gasPoolArg` returned by {@link getCreateTx}.
|
|
13822
|
+
*
|
|
13823
|
+
* @param inputs.gasPoolArg - Gas pool argument from a deferred create.
|
|
13824
|
+
* @param inputs.sharePolicyArg - Share policy argument from a deferred create.
|
|
13825
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
13826
|
+
* @returns {@link SdkTransactionResponse} with `tx`.
|
|
13827
|
+
*/
|
|
13828
|
+
async getShareTx(inputs) {
|
|
13829
|
+
const { tx, ...otherInputs } = inputs;
|
|
13830
|
+
return this.fetchApiTxObject(
|
|
13831
|
+
"transactions/share",
|
|
13832
|
+
{
|
|
13833
|
+
...otherInputs,
|
|
13834
|
+
txKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(
|
|
13835
|
+
{ tx }
|
|
13836
|
+
)
|
|
13837
|
+
},
|
|
13838
|
+
void 0,
|
|
13839
|
+
{ txKind: true }
|
|
13840
|
+
);
|
|
13841
|
+
}
|
|
13842
|
+
};
|
|
13843
|
+
}
|
|
13844
|
+
});
|
|
13845
|
+
|
|
13846
|
+
// src/packages/gasPools/index.ts
|
|
13847
|
+
var init_gasPools2 = __esm({
|
|
13848
|
+
"src/packages/gasPools/index.ts"() {
|
|
13849
|
+
"use strict";
|
|
13850
|
+
init_gasPools();
|
|
13851
|
+
}
|
|
13852
|
+
});
|
|
13853
|
+
|
|
13294
13854
|
// src/packages/sui/sui.ts
|
|
13295
13855
|
var Sui;
|
|
13296
13856
|
var init_sui = __esm({
|
|
@@ -13365,7 +13925,7 @@ var init_sui2 = __esm({
|
|
|
13365
13925
|
});
|
|
13366
13926
|
|
|
13367
13927
|
// src/packages/suiFrens/suiFren.ts
|
|
13368
|
-
import
|
|
13928
|
+
import { format } from "date-fns";
|
|
13369
13929
|
var SuiFren;
|
|
13370
13930
|
var init_suiFren = __esm({
|
|
13371
13931
|
"src/packages/suiFrens/suiFren.ts"() {
|
|
@@ -13405,7 +13965,7 @@ var init_suiFren = __esm({
|
|
|
13405
13965
|
"Main Color": this.suiFren.attributes.main,
|
|
13406
13966
|
"Secondary Color": this.suiFren.attributes.secondary,
|
|
13407
13967
|
"Birth Location": this.suiFren.birthLocation,
|
|
13408
|
-
Birthday:
|
|
13968
|
+
Birthday: format(this.suiFren.birthdate, "MMMM d, yyyy"),
|
|
13409
13969
|
Cohort: this.suiFren.cohort.toString(),
|
|
13410
13970
|
Generation: this.suiFren.generation.toString()
|
|
13411
13971
|
// Genes: this.suiFren.genes.toString(),
|
|
@@ -13832,6 +14392,8 @@ var init_packages = __esm({
|
|
|
13832
14392
|
init_referralVault2();
|
|
13833
14393
|
init_router2();
|
|
13834
14394
|
init_staking2();
|
|
14395
|
+
init_gasPools2();
|
|
14396
|
+
init_auth2();
|
|
13835
14397
|
init_sui2();
|
|
13836
14398
|
init_suiFrens2();
|
|
13837
14399
|
}
|
|
@@ -17339,10 +17901,9 @@ var init_multisigApi = __esm({
|
|
|
17339
17901
|
constructor(Provider) {
|
|
17340
17902
|
this.Provider = Provider;
|
|
17341
17903
|
const sharedCustodyAddresses = this.Provider.addresses.sharedCustody;
|
|
17342
|
-
if (!sharedCustodyAddresses)
|
|
17343
|
-
throw new Error(
|
|
17344
|
-
|
|
17345
|
-
);
|
|
17904
|
+
if (!sharedCustodyAddresses) {
|
|
17905
|
+
throw new Error("not all required addresses have been set in provider");
|
|
17906
|
+
}
|
|
17346
17907
|
this.sharedCustodyAddresses = sharedCustodyAddresses;
|
|
17347
17908
|
}
|
|
17348
17909
|
// =========================================================================
|
|
@@ -17355,7 +17916,10 @@ var init_multisigApi = __esm({
|
|
|
17355
17916
|
);
|
|
17356
17917
|
const afPublicKeyArray = new Uint8Array(afPublicKeyBuffer).subarray(1);
|
|
17357
17918
|
const afPK = new Ed25519PublicKey(afPublicKeyArray);
|
|
17358
|
-
const
|
|
17919
|
+
const userPublicKeyArray = new Uint8Array(inputs.userPublicKey);
|
|
17920
|
+
const userPK = new Ed25519PublicKey(
|
|
17921
|
+
userPublicKeyArray.length === 33 ? userPublicKeyArray.subarray(1) : userPublicKeyArray
|
|
17922
|
+
);
|
|
17359
17923
|
const newMultiSigPublicKey = MultiSigPublicKey.fromPublicKeys({
|
|
17360
17924
|
threshold: 1,
|
|
17361
17925
|
publicKeys: [
|
|
@@ -19113,20 +19677,20 @@ var init_perpetualsApi = __esm({
|
|
|
19113
19677
|
});
|
|
19114
19678
|
|
|
19115
19679
|
// src/packages/pools/api/poolsApi.ts
|
|
19680
|
+
import { bcs as bcs2 } from "@mysten/sui/bcs";
|
|
19116
19681
|
import {
|
|
19117
19682
|
Transaction as Transaction11
|
|
19118
19683
|
} from "@mysten/sui/transactions";
|
|
19119
19684
|
import { fromBase64, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
19120
|
-
import { bcs as bcs2 } from "@mysten/sui/bcs";
|
|
19121
19685
|
var _PoolsApi, PoolsApi;
|
|
19122
19686
|
var init_poolsApi = __esm({
|
|
19123
19687
|
"src/packages/pools/api/poolsApi.ts"() {
|
|
19124
19688
|
"use strict";
|
|
19125
|
-
|
|
19126
|
-
init_pools();
|
|
19689
|
+
init_eventsApiHelpers();
|
|
19127
19690
|
init_utils();
|
|
19691
|
+
init_casting();
|
|
19128
19692
|
init_coin2();
|
|
19129
|
-
|
|
19693
|
+
init_pools();
|
|
19130
19694
|
_PoolsApi = class _PoolsApi {
|
|
19131
19695
|
// =========================================================================
|
|
19132
19696
|
// Constructor
|
|
@@ -19137,19 +19701,17 @@ var init_poolsApi = __esm({
|
|
|
19137
19701
|
* @throws {Error} Throws an error if not all required addresses have been set in AfSdk
|
|
19138
19702
|
*/
|
|
19139
19703
|
constructor(Provider) {
|
|
19140
|
-
this.Provider = Provider;
|
|
19141
19704
|
// =========================================================================
|
|
19142
19705
|
// Public Methods
|
|
19143
19706
|
// =========================================================================
|
|
19144
19707
|
// =========================================================================
|
|
19145
19708
|
// Objects
|
|
19146
19709
|
// =========================================================================
|
|
19147
|
-
this.fetchOwnedDaoFeePoolOwnerCaps =
|
|
19710
|
+
this.fetchOwnedDaoFeePoolOwnerCaps = (inputs) => {
|
|
19148
19711
|
const { walletAddress } = inputs;
|
|
19149
|
-
if (!this.objectTypes.daoFeePoolOwnerCap)
|
|
19150
|
-
throw new Error(
|
|
19151
|
-
|
|
19152
|
-
);
|
|
19712
|
+
if (!this.objectTypes.daoFeePoolOwnerCap) {
|
|
19713
|
+
throw new Error("dao fee pool addresses have not been set in provider");
|
|
19714
|
+
}
|
|
19153
19715
|
return this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
|
|
19154
19716
|
walletAddress,
|
|
19155
19717
|
objectType: this.objectTypes.daoFeePoolOwnerCap,
|
|
@@ -19269,11 +19831,7 @@ var init_poolsApi = __esm({
|
|
|
19269
19831
|
tx.object(this.addresses.referralVault.objects.referralVault),
|
|
19270
19832
|
typeof lpCoinId === "string" ? tx.object(lpCoinId) : lpCoinId,
|
|
19271
19833
|
tx.pure(
|
|
19272
|
-
bcs2.vector(bcs2.u64()).serialize(
|
|
19273
|
-
expectedAmountsOut.map(
|
|
19274
|
-
(amount) => amount.toString()
|
|
19275
|
-
)
|
|
19276
|
-
)
|
|
19834
|
+
bcs2.vector(bcs2.u64()).serialize(expectedAmountsOut.map((amount) => amount.toString()))
|
|
19277
19835
|
),
|
|
19278
19836
|
tx.pure.u64(Pools.normalizeInvertSlippage(slippage))
|
|
19279
19837
|
]
|
|
@@ -19318,10 +19876,11 @@ var init_poolsApi = __esm({
|
|
|
19318
19876
|
*/
|
|
19319
19877
|
this.publishLpCoinTx = (inputs) => {
|
|
19320
19878
|
const compilations = this.addresses.pools.other?.createLpCoinPackageCompilations;
|
|
19321
|
-
if (!compilations)
|
|
19879
|
+
if (!compilations) {
|
|
19322
19880
|
throw new Error(
|
|
19323
19881
|
"not all required addresses have been set in provider for lp coin publishing (requires package compilations)"
|
|
19324
19882
|
);
|
|
19883
|
+
}
|
|
19325
19884
|
const { tx, lpCoinDecimals } = inputs;
|
|
19326
19885
|
const compiledModulesAndDeps = JSON.parse(compilations[lpCoinDecimals]);
|
|
19327
19886
|
return tx.publish({
|
|
@@ -19368,9 +19927,7 @@ var init_poolsApi = __esm({
|
|
|
19368
19927
|
),
|
|
19369
19928
|
tx.pure(
|
|
19370
19929
|
bcs2.vector(bcs2.u8()).serialize(
|
|
19371
|
-
Casting.u8VectorFromString(
|
|
19372
|
-
lpCoinMetadata.name.toString()
|
|
19373
|
-
)
|
|
19930
|
+
Casting.u8VectorFromString(lpCoinMetadata.name.toString())
|
|
19374
19931
|
)
|
|
19375
19932
|
),
|
|
19376
19933
|
tx.pure(
|
|
@@ -19381,9 +19938,7 @@ var init_poolsApi = __esm({
|
|
|
19381
19938
|
)
|
|
19382
19939
|
),
|
|
19383
19940
|
tx.pure(
|
|
19384
|
-
bcs2.vector(bcs2.u8()).serialize(
|
|
19385
|
-
Casting.u8VectorFromString(lpCoinDescription)
|
|
19386
|
-
)
|
|
19941
|
+
bcs2.vector(bcs2.u8()).serialize(Casting.u8VectorFromString(lpCoinDescription))
|
|
19387
19942
|
),
|
|
19388
19943
|
tx.pure(
|
|
19389
19944
|
bcs2.vector(bcs2.u8()).serialize(Casting.u8VectorFromString(lpCoinIconUrl))
|
|
@@ -19440,10 +19995,9 @@ var init_poolsApi = __esm({
|
|
|
19440
19995
|
};
|
|
19441
19996
|
this.daoFeePoolNewTx = (inputs) => {
|
|
19442
19997
|
const { tx, poolId } = inputs;
|
|
19443
|
-
if (!this.addresses.daoFeePools)
|
|
19444
|
-
throw new Error(
|
|
19445
|
-
|
|
19446
|
-
);
|
|
19998
|
+
if (!this.addresses.daoFeePools) {
|
|
19999
|
+
throw new Error("dao fee pool addresses have not been set in provider");
|
|
20000
|
+
}
|
|
19447
20001
|
return tx.moveCall({
|
|
19448
20002
|
target: Helpers.transactions.createTxTarget(
|
|
19449
20003
|
this.addresses.daoFeePools.packages.amm,
|
|
@@ -19462,10 +20016,9 @@ var init_poolsApi = __esm({
|
|
|
19462
20016
|
};
|
|
19463
20017
|
this.daoFeePoolUpdateFeeBpsTx = (inputs) => {
|
|
19464
20018
|
const { tx } = inputs;
|
|
19465
|
-
if (!this.addresses.daoFeePools)
|
|
19466
|
-
throw new Error(
|
|
19467
|
-
|
|
19468
|
-
);
|
|
20019
|
+
if (!this.addresses.daoFeePools) {
|
|
20020
|
+
throw new Error("dao fee pool addresses have not been set in provider");
|
|
20021
|
+
}
|
|
19469
20022
|
return tx.moveCall({
|
|
19470
20023
|
target: Helpers.transactions.createTxTarget(
|
|
19471
20024
|
this.addresses.daoFeePools.packages.amm,
|
|
@@ -19485,10 +20038,9 @@ var init_poolsApi = __esm({
|
|
|
19485
20038
|
};
|
|
19486
20039
|
this.daoFeePoolUpdateFeeRecipientTx = (inputs) => {
|
|
19487
20040
|
const { tx } = inputs;
|
|
19488
|
-
if (!this.addresses.daoFeePools)
|
|
19489
|
-
throw new Error(
|
|
19490
|
-
|
|
19491
|
-
);
|
|
20041
|
+
if (!this.addresses.daoFeePools) {
|
|
20042
|
+
throw new Error("dao fee pool addresses have not been set in provider");
|
|
20043
|
+
}
|
|
19492
20044
|
return tx.moveCall({
|
|
19493
20045
|
target: Helpers.transactions.createTxTarget(
|
|
19494
20046
|
this.addresses.daoFeePools.packages.amm,
|
|
@@ -19522,10 +20074,9 @@ var init_poolsApi = __esm({
|
|
|
19522
20074
|
lpCoinType,
|
|
19523
20075
|
slippage
|
|
19524
20076
|
} = inputs;
|
|
19525
|
-
if (!this.addresses.daoFeePools)
|
|
19526
|
-
throw new Error(
|
|
19527
|
-
|
|
19528
|
-
);
|
|
20077
|
+
if (!this.addresses.daoFeePools) {
|
|
20078
|
+
throw new Error("dao fee pool addresses have not been set in provider");
|
|
20079
|
+
}
|
|
19529
20080
|
return tx.moveCall({
|
|
19530
20081
|
target: Helpers.transactions.createTxTarget(
|
|
19531
20082
|
this.addresses.daoFeePools.packages.amm,
|
|
@@ -19563,10 +20114,9 @@ var init_poolsApi = __esm({
|
|
|
19563
20114
|
lpCoinType,
|
|
19564
20115
|
slippage
|
|
19565
20116
|
} = inputs;
|
|
19566
|
-
if (!this.addresses.daoFeePools)
|
|
19567
|
-
throw new Error(
|
|
19568
|
-
|
|
19569
|
-
);
|
|
20117
|
+
if (!this.addresses.daoFeePools) {
|
|
20118
|
+
throw new Error("dao fee pool addresses have not been set in provider");
|
|
20119
|
+
}
|
|
19570
20120
|
const poolSize = coinTypes.length;
|
|
19571
20121
|
return tx.moveCall({
|
|
19572
20122
|
target: Helpers.transactions.createTxTarget(
|
|
@@ -19603,10 +20153,9 @@ var init_poolsApi = __esm({
|
|
|
19603
20153
|
*/
|
|
19604
20154
|
this.daoFeePoolAllCoinWithdrawTx = (inputs) => {
|
|
19605
20155
|
const { tx, daoFeePoolId, lpCoinId, coinTypes, lpCoinType } = inputs;
|
|
19606
|
-
if (!this.addresses.daoFeePools)
|
|
19607
|
-
throw new Error(
|
|
19608
|
-
|
|
19609
|
-
);
|
|
20156
|
+
if (!this.addresses.daoFeePools) {
|
|
20157
|
+
throw new Error("dao fee pool addresses have not been set in provider");
|
|
20158
|
+
}
|
|
19610
20159
|
const poolSize = coinTypes.length;
|
|
19611
20160
|
return tx.moveCall({
|
|
19612
20161
|
target: Helpers.transactions.createTxTarget(
|
|
@@ -19656,11 +20205,12 @@ var init_poolsApi = __esm({
|
|
|
19656
20205
|
} = inputs;
|
|
19657
20206
|
const tx = new Transaction11();
|
|
19658
20207
|
tx.setSender(walletAddress);
|
|
19659
|
-
if (referrer)
|
|
20208
|
+
if (referrer) {
|
|
19660
20209
|
this.Provider.ReferralVault().updateReferrerTx({
|
|
19661
20210
|
tx,
|
|
19662
20211
|
referrer
|
|
19663
20212
|
});
|
|
20213
|
+
}
|
|
19664
20214
|
const amountOut = pool.getTradeAmountOut({
|
|
19665
20215
|
coinInAmount,
|
|
19666
20216
|
coinInType,
|
|
@@ -19701,7 +20251,7 @@ var init_poolsApi = __esm({
|
|
|
19701
20251
|
}
|
|
19702
20252
|
return tx;
|
|
19703
20253
|
};
|
|
19704
|
-
this.fetchAddTradeTx =
|
|
20254
|
+
this.fetchAddTradeTx = (inputs) => {
|
|
19705
20255
|
const {
|
|
19706
20256
|
tx,
|
|
19707
20257
|
coinInId,
|
|
@@ -19751,11 +20301,12 @@ var init_poolsApi = __esm({
|
|
|
19751
20301
|
} = inputs;
|
|
19752
20302
|
const tx = new Transaction11();
|
|
19753
20303
|
tx.setSender(walletAddress);
|
|
19754
|
-
if (referrer)
|
|
20304
|
+
if (referrer) {
|
|
19755
20305
|
this.Provider.ReferralVault().updateReferrerTx({
|
|
19756
20306
|
tx,
|
|
19757
20307
|
referrer
|
|
19758
20308
|
});
|
|
20309
|
+
}
|
|
19759
20310
|
const { coins: coinTypes, balances: coinAmounts } = Coin.coinsAndBalancesOverZero(amountsIn);
|
|
19760
20311
|
const { lpRatio } = pool.getDepositLpAmountOut({
|
|
19761
20312
|
amountsIn,
|
|
@@ -19816,11 +20367,12 @@ var init_poolsApi = __esm({
|
|
|
19816
20367
|
} = inputs;
|
|
19817
20368
|
const tx = new Transaction11();
|
|
19818
20369
|
tx.setSender(walletAddress);
|
|
19819
|
-
if (referrer)
|
|
20370
|
+
if (referrer) {
|
|
19820
20371
|
this.Provider.ReferralVault().updateReferrerTx({
|
|
19821
20372
|
tx,
|
|
19822
20373
|
referrer
|
|
19823
20374
|
});
|
|
20375
|
+
}
|
|
19824
20376
|
const lpRatio = pool.getMultiCoinWithdrawLpRatio({
|
|
19825
20377
|
lpCoinAmountIn: lpCoinAmount
|
|
19826
20378
|
});
|
|
@@ -19860,11 +20412,12 @@ var init_poolsApi = __esm({
|
|
|
19860
20412
|
const { walletAddress, pool, lpCoinAmount, referrer } = inputs;
|
|
19861
20413
|
const tx = new Transaction11();
|
|
19862
20414
|
tx.setSender(walletAddress);
|
|
19863
|
-
if (referrer)
|
|
20415
|
+
if (referrer) {
|
|
19864
20416
|
this.Provider.ReferralVault().updateReferrerTx({
|
|
19865
20417
|
tx,
|
|
19866
20418
|
referrer
|
|
19867
20419
|
});
|
|
20420
|
+
}
|
|
19868
20421
|
const lpCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({
|
|
19869
20422
|
tx,
|
|
19870
20423
|
walletAddress,
|
|
@@ -19909,7 +20462,9 @@ var init_poolsApi = __esm({
|
|
|
19909
20462
|
tx.transferObjects([upgradeCap], inputs.walletAddress);
|
|
19910
20463
|
return tx;
|
|
19911
20464
|
};
|
|
19912
|
-
this.buildDaoFeePoolUpdateFeeBpsTx = Helpers.transactions.createBuildTxFunc(
|
|
20465
|
+
this.buildDaoFeePoolUpdateFeeBpsTx = Helpers.transactions.createBuildTxFunc(
|
|
20466
|
+
this.daoFeePoolUpdateFeeBpsTx
|
|
20467
|
+
);
|
|
19913
20468
|
this.buildDaoFeePoolUpdateFeeRecipientTx = Helpers.transactions.createBuildTxFunc(
|
|
19914
20469
|
this.daoFeePoolUpdateFeeRecipientTx
|
|
19915
20470
|
);
|
|
@@ -19946,13 +20501,13 @@ var init_poolsApi = __esm({
|
|
|
19946
20501
|
_PoolsApi.constants.moduleNames.events,
|
|
19947
20502
|
_PoolsApi.constants.eventNames.withdrawV2
|
|
19948
20503
|
);
|
|
20504
|
+
this.Provider = Provider;
|
|
19949
20505
|
const pools = Provider.addresses.pools;
|
|
19950
20506
|
const referralVault = Provider.addresses.referralVault;
|
|
19951
20507
|
const daoFeePools = Provider.addresses.daoFeePools;
|
|
19952
|
-
if (!pools
|
|
19953
|
-
throw new Error(
|
|
19954
|
-
|
|
19955
|
-
);
|
|
20508
|
+
if (!(pools && referralVault)) {
|
|
20509
|
+
throw new Error("not all required addresses have been set in provider");
|
|
20510
|
+
}
|
|
19956
20511
|
this.addresses = {
|
|
19957
20512
|
pools,
|
|
19958
20513
|
referralVault,
|
|
@@ -21779,8 +22334,7 @@ var init_suiFrensApi = __esm({
|
|
|
21779
22334
|
this.fetchSuiFrenVaultStateV1Object(),
|
|
21780
22335
|
this.Provider.Events().fetchEventsWithinTime({
|
|
21781
22336
|
fetchEventsFunc: this.fetchMixSuiFrensEvents,
|
|
21782
|
-
|
|
21783
|
-
time: 24
|
|
22337
|
+
timeMs: 24 * 60 * 60 * 1e3
|
|
21784
22338
|
})
|
|
21785
22339
|
]);
|
|
21786
22340
|
const mixingFees24hr = Helpers.sumBigInt(
|
|
@@ -22414,6 +22968,7 @@ var init_aftermath = __esm({
|
|
|
22414
22968
|
init_faucet();
|
|
22415
22969
|
init_limitOrders();
|
|
22416
22970
|
init_multisig();
|
|
22971
|
+
init_gasPools2();
|
|
22417
22972
|
init_perpetuals2();
|
|
22418
22973
|
init_pools();
|
|
22419
22974
|
init_referrals();
|
|
@@ -22487,6 +23042,10 @@ var init_aftermath = __esm({
|
|
|
22487
23042
|
* Returns an instance of `Referrals` for referral-based interactions in the protocol.
|
|
22488
23043
|
*/
|
|
22489
23044
|
this.Referrals = () => new Referrals(this.config);
|
|
23045
|
+
/**
|
|
23046
|
+
* Returns an instance of `GasPools` for shared gas pool interactions.
|
|
23047
|
+
*/
|
|
23048
|
+
this.GasPools = () => new GasPools(this.config, this.Provider);
|
|
22490
23049
|
/**
|
|
22491
23050
|
* Returns an instance of `Perpetuals` for futures or perpetual contract interactions.
|
|
22492
23051
|
*/
|
|
@@ -22647,6 +23206,7 @@ export {
|
|
|
22647
23206
|
FarmsStakedPosition,
|
|
22648
23207
|
FarmsStakingPool,
|
|
22649
23208
|
Faucet,
|
|
23209
|
+
GasPools,
|
|
22650
23210
|
Helpers,
|
|
22651
23211
|
NftAmm,
|
|
22652
23212
|
Perpetuals,
|