@nightlylabs/dex-sdk 0.0.69 → 0.0.71
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.cjs +68 -19
- package/dist/index.d.cts +79 -6
- package/dist/index.d.ts +79 -6
- package/dist/index.js +73 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -490,6 +490,10 @@ var EndpointsV1 = /* @__PURE__ */ ((EndpointsV12) => {
|
|
|
490
490
|
EndpointsV12["GetUserFundingHistory"] = "/v1/get_user_funding_history";
|
|
491
491
|
EndpointsV12["GetUserPortfolioValue"] = "/v1/get_user_portfolio_value";
|
|
492
492
|
EndpointsV12["SyncStatus"] = "/v1/sync_status";
|
|
493
|
+
EndpointsV12["GetUserAggregatedReferral"] = "/v1/get_user_aggregated_referral";
|
|
494
|
+
EndpointsV12["GetUserAggregatedStats"] = "/v1/get_user_aggregated_stats";
|
|
495
|
+
EndpointsV12["GetUserReferralStats"] = "/v1/get_user_referral_stats";
|
|
496
|
+
EndpointsV12["GetUserTradeStats"] = "/v1/get_user_trade_stats";
|
|
493
497
|
return EndpointsV12;
|
|
494
498
|
})(EndpointsV1 || {});
|
|
495
499
|
var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
@@ -990,6 +994,28 @@ var Client = class _Client {
|
|
|
990
994
|
const response = await this.sendGetJson("/v1/get_user_portfolio_value" /* GetUserPortfolioValue */, request);
|
|
991
995
|
return response;
|
|
992
996
|
};
|
|
997
|
+
this.getUserTradeStatsHistory = async (request) => {
|
|
998
|
+
if (request.timestampEndMs && request.timestampStartMs && request.timestampEndMs > request.timestampStartMs) {
|
|
999
|
+
throw new Error("timestampEndMs must be lower than timestampStartMs");
|
|
1000
|
+
}
|
|
1001
|
+
const response = await this.sendGetJson("/v1/get_user_trade_stats" /* GetUserTradeStats */, request);
|
|
1002
|
+
return response;
|
|
1003
|
+
};
|
|
1004
|
+
this.getUserAggregatedStats = async (request) => {
|
|
1005
|
+
const response = await this.sendGetJson("/v1/get_user_aggregated_stats" /* GetUserAggregatedStats */, request);
|
|
1006
|
+
return response;
|
|
1007
|
+
};
|
|
1008
|
+
this.getUserReferralStatsHistory = async (request) => {
|
|
1009
|
+
if (request.timestampEndMs && request.timestampStartMs && request.timestampEndMs > request.timestampStartMs) {
|
|
1010
|
+
throw new Error("timestampEndMs must be lower than timestampStartMs");
|
|
1011
|
+
}
|
|
1012
|
+
const response = await this.sendGetJson("/v1/get_user_referral_stats" /* GetUserReferralStats */, request);
|
|
1013
|
+
return response;
|
|
1014
|
+
};
|
|
1015
|
+
this.getUserAggregatedReferralStats = async (request) => {
|
|
1016
|
+
const response = await this.sendGetJson("/v1/get_user_aggregated_referral" /* GetUserAggregatedReferral */, request);
|
|
1017
|
+
return response;
|
|
1018
|
+
};
|
|
993
1019
|
// Meta
|
|
994
1020
|
this.getTime = async () => {
|
|
995
1021
|
const response = await this.sendGetJson("/time" /* Time */);
|
|
@@ -1067,7 +1093,7 @@ var Client = class _Client {
|
|
|
1067
1093
|
this._ws?.send(JSON.stringify(message));
|
|
1068
1094
|
});
|
|
1069
1095
|
}
|
|
1070
|
-
static async create(connection, apiKey, url = "
|
|
1096
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1071
1097
|
return _Client.init(connection, apiKey, url, enableWs);
|
|
1072
1098
|
}
|
|
1073
1099
|
async setApiKey(apiKey) {
|
|
@@ -1088,16 +1114,25 @@ var Client = class _Client {
|
|
|
1088
1114
|
// needs to be signed by user and sent to blockchain
|
|
1089
1115
|
async createUser(params) {
|
|
1090
1116
|
const apiKey = generateApiKey();
|
|
1091
|
-
const payload = (0,
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1117
|
+
const payload = await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1118
|
+
aptosConfig: this._aptos.config,
|
|
1119
|
+
abi: parseEntryFunctionAbi({
|
|
1120
|
+
moduleAbi: createUser_default,
|
|
1121
|
+
functionName: createUser_default.name,
|
|
1122
|
+
moduleAddress: createUser_default.address,
|
|
1123
|
+
moduleName: createUser_default.name
|
|
1124
|
+
}),
|
|
1125
|
+
function: `${createUser_default.address}::${createUser_default.name}::create_user`,
|
|
1126
|
+
typeArguments: [],
|
|
1127
|
+
functionArguments: [params.name, params.referralId]
|
|
1100
1128
|
});
|
|
1129
|
+
const tx = new import_ts_sdk2.SimpleTransaction(
|
|
1130
|
+
await (0, import_ts_sdk2.generateRawTransaction)({
|
|
1131
|
+
sender: params.sender,
|
|
1132
|
+
aptosConfig: this._aptos.config,
|
|
1133
|
+
payload
|
|
1134
|
+
})
|
|
1135
|
+
);
|
|
1101
1136
|
const signature = this._aptos.sign({
|
|
1102
1137
|
signer: apiKey,
|
|
1103
1138
|
transaction: tx
|
|
@@ -1186,10 +1221,17 @@ var Client = class _Client {
|
|
|
1186
1221
|
}
|
|
1187
1222
|
// needs to be signed by user and sent to blockchain
|
|
1188
1223
|
async addApiKey(params) {
|
|
1189
|
-
return (0,
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1224
|
+
return await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1225
|
+
aptosConfig: this._aptos.config,
|
|
1226
|
+
abi: parseEntryFunctionAbi({
|
|
1227
|
+
moduleAbi: addApiKey_default,
|
|
1228
|
+
functionName: addApiKey_default.name,
|
|
1229
|
+
moduleAddress: addApiKey_default.address,
|
|
1230
|
+
moduleName: addApiKey_default.name
|
|
1231
|
+
}),
|
|
1232
|
+
function: `${addApiKey_default.address}::${addApiKey_default.name}::add_api_key`,
|
|
1233
|
+
typeArguments: [],
|
|
1234
|
+
functionArguments: [params.userId, params.expiration]
|
|
1193
1235
|
});
|
|
1194
1236
|
}
|
|
1195
1237
|
async removeApiKey(params) {
|
|
@@ -1463,10 +1505,17 @@ var Client = class _Client {
|
|
|
1463
1505
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1464
1506
|
}
|
|
1465
1507
|
async depositTokenPayload(params) {
|
|
1466
|
-
return (0,
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1508
|
+
return await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1509
|
+
aptosConfig: this._aptos.config,
|
|
1510
|
+
abi: parseEntryFunctionAbi({
|
|
1511
|
+
moduleAbi: depositToken_default,
|
|
1512
|
+
functionName: depositToken_default.name,
|
|
1513
|
+
moduleAddress: depositToken_default.address,
|
|
1514
|
+
moduleName: depositToken_default.name
|
|
1515
|
+
}),
|
|
1516
|
+
function: `${depositToken_default.address}::${depositToken_default.name}::deposit_token`,
|
|
1517
|
+
typeArguments: [],
|
|
1518
|
+
functionArguments: [params.userId, params.amount, params.tokenAddress]
|
|
1470
1519
|
});
|
|
1471
1520
|
}
|
|
1472
1521
|
async depositToVault(params) {
|
|
@@ -1935,7 +1984,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1935
1984
|
constructor(connection, url, ws, apiKey) {
|
|
1936
1985
|
super(connection, url, ws, apiKey);
|
|
1937
1986
|
}
|
|
1938
|
-
static async create(connection, apiKey, url = "
|
|
1987
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1939
1988
|
let ws = void 0;
|
|
1940
1989
|
if (enableWs) {
|
|
1941
1990
|
ws = await client_default.initWebSocket(url);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _aptos_labs_ts_sdk from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { Account, Aptos,
|
|
2
|
+
import { Account, Aptos, SimpleTransaction, AccountAuthenticator, MoveModule, EntryFunctionABI } from '@aptos-labs/ts-sdk';
|
|
3
3
|
import * as _thalalabs_surf_build_types_core from '@thalalabs/surf/build/types/core';
|
|
4
4
|
import * as _thalalabs_surf from '@thalalabs/surf';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
@@ -297,6 +297,36 @@ interface GetTokensConfigResponse {
|
|
|
297
297
|
tokens: Record<string, TokenConfigEntry>;
|
|
298
298
|
usdcAddress?: string;
|
|
299
299
|
}
|
|
300
|
+
interface GetUserAggregatedReferralStatsRequest {
|
|
301
|
+
userId: string;
|
|
302
|
+
paginationCursor?: PaginationCursor;
|
|
303
|
+
}
|
|
304
|
+
interface UserAggregatedReferralStats {
|
|
305
|
+
referralOwnerId: string;
|
|
306
|
+
referralUserId: string;
|
|
307
|
+
accReferralValue: string;
|
|
308
|
+
referredUserVolume: string;
|
|
309
|
+
}
|
|
310
|
+
interface GetUserAggregatedReferralStatsResponse {
|
|
311
|
+
stats: UserAggregatedReferralStats[];
|
|
312
|
+
paginationCursor?: PaginationCursor;
|
|
313
|
+
}
|
|
314
|
+
interface GetUserAggregatedStatsRequest {
|
|
315
|
+
userId: string;
|
|
316
|
+
}
|
|
317
|
+
interface UserAggregatedStats {
|
|
318
|
+
userId: string;
|
|
319
|
+
spotVolume: string;
|
|
320
|
+
perpVolume: string;
|
|
321
|
+
liquidationVolume: string;
|
|
322
|
+
depositValue: string;
|
|
323
|
+
paidFee: string;
|
|
324
|
+
spotTradesCount: string;
|
|
325
|
+
perpTradesCount: string;
|
|
326
|
+
}
|
|
327
|
+
interface GetUserAggregatedStatsResponse {
|
|
328
|
+
userAggregatedStats: UserAggregatedStats;
|
|
329
|
+
}
|
|
300
330
|
interface GetUserDataRequest {
|
|
301
331
|
userId: string;
|
|
302
332
|
}
|
|
@@ -390,6 +420,41 @@ interface GetUserPortfolioValueResponse {
|
|
|
390
420
|
portfolioValues: UserPortfolioValue[];
|
|
391
421
|
paginationCursor?: PaginationCursor;
|
|
392
422
|
}
|
|
423
|
+
interface GetUserReferralStatsHistoryRequest {
|
|
424
|
+
userId: string;
|
|
425
|
+
timestampStartMs?: string;
|
|
426
|
+
timestampEndMs?: string;
|
|
427
|
+
paginationCursor?: PaginationCursor;
|
|
428
|
+
}
|
|
429
|
+
interface HistoricalReferralStats {
|
|
430
|
+
userId: string;
|
|
431
|
+
referralsValue: Record<string, string>;
|
|
432
|
+
timestampOpen: string;
|
|
433
|
+
timestampClose: string;
|
|
434
|
+
}
|
|
435
|
+
interface GetUserReferralStatsHistoryResponse {
|
|
436
|
+
stats: HistoricalReferralStats[];
|
|
437
|
+
paginationCursor?: PaginationCursor;
|
|
438
|
+
}
|
|
439
|
+
interface GetUserTradeStatsHistoryRequest {
|
|
440
|
+
userId: string;
|
|
441
|
+
timestampStartMs?: string;
|
|
442
|
+
timestampEndMs?: string;
|
|
443
|
+
paginationCursor?: PaginationCursor;
|
|
444
|
+
}
|
|
445
|
+
interface HistoricalTradeStats {
|
|
446
|
+
userId: string;
|
|
447
|
+
tradeVolumeSpot: string;
|
|
448
|
+
tradeVolumePerp: string;
|
|
449
|
+
tradeCountSpot: string;
|
|
450
|
+
tradeCountPerp: string;
|
|
451
|
+
timestampOpen: string;
|
|
452
|
+
timestampClose: string;
|
|
453
|
+
}
|
|
454
|
+
interface GetUserTradeStatsHistoryResponse {
|
|
455
|
+
stats: HistoricalTradeStats[];
|
|
456
|
+
paginationCursor?: PaginationCursor;
|
|
457
|
+
}
|
|
393
458
|
interface GetUserWithdrawalsRequest {
|
|
394
459
|
userId: string;
|
|
395
460
|
paginationCursor?: PaginationCursor;
|
|
@@ -559,7 +624,11 @@ declare enum EndpointsV1 {
|
|
|
559
624
|
GetUserWithdrawals = "/v1/get_user_withdrawals",
|
|
560
625
|
GetUserFundingHistory = "/v1/get_user_funding_history",
|
|
561
626
|
GetUserPortfolioValue = "/v1/get_user_portfolio_value",
|
|
562
|
-
SyncStatus = "/v1/sync_status"
|
|
627
|
+
SyncStatus = "/v1/sync_status",
|
|
628
|
+
GetUserAggregatedReferral = "/v1/get_user_aggregated_referral",
|
|
629
|
+
GetUserAggregatedStats = "/v1/get_user_aggregated_stats",
|
|
630
|
+
GetUserReferralStats = "/v1/get_user_referral_stats",
|
|
631
|
+
GetUserTradeStats = "/v1/get_user_trade_stats"
|
|
563
632
|
}
|
|
564
633
|
type Topic = {
|
|
565
634
|
type: "Market";
|
|
@@ -811,7 +880,7 @@ declare class Client {
|
|
|
811
880
|
getApiKeySequenceNumber(): Promise<bigint | null>;
|
|
812
881
|
fetchApiKeySequenceNumber(): Promise<number>;
|
|
813
882
|
createUser(params: CreateUserParams): Promise<{
|
|
814
|
-
tx:
|
|
883
|
+
tx: SimpleTransaction;
|
|
815
884
|
signature: AccountAuthenticator;
|
|
816
885
|
apiKey: _aptos_labs_ts_sdk.Ed25519Account;
|
|
817
886
|
}>;
|
|
@@ -823,7 +892,7 @@ declare class Client {
|
|
|
823
892
|
unsubscribeUserUpdates(userId: string): Promise<void>;
|
|
824
893
|
subscribePerpMarketUpdates(market: string, callback: (data: WsPerpMarketUpdates) => void): Promise<() => Promise<void>>;
|
|
825
894
|
unsubscribePerpMarketUpdates(market: string): Promise<void>;
|
|
826
|
-
addApiKey(params: AddApiKeyParams): Promise<
|
|
895
|
+
addApiKey(params: AddApiKeyParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
827
896
|
removeApiKey(params: RemoveApiKeyParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
828
897
|
setAliasName(params: SetAliasNameParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
829
898
|
placePerpLimitOrder(params: PlacePerpLimitOrderParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
@@ -832,7 +901,7 @@ declare class Client {
|
|
|
832
901
|
cancelPerpOrders(params: CancelPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
833
902
|
cancelAllPerpOrders(params: CancelAllPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
834
903
|
setAutolend(params: SetAutolendParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
835
|
-
depositTokenPayload(params: DepositTokenParams): Promise<
|
|
904
|
+
depositTokenPayload(params: DepositTokenParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
836
905
|
depositToVault(params: DepositToVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
837
906
|
withdrawFromVault(params: WithdrawFromVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
838
907
|
redeemToken(params: RedeemTokenParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
@@ -859,6 +928,10 @@ declare class Client {
|
|
|
859
928
|
getUserHistoricalDeposits: (request: GetUserDepositsRequest) => Promise<GetUserDepositsResponse>;
|
|
860
929
|
getUserWithdrawalsHistory: (request: GetUserWithdrawalsRequest) => Promise<GetUserWithdrawalsResponse>;
|
|
861
930
|
getUserPortfolioValueHistory: (request: GetUserPortfolioValueRequest) => Promise<GetUserPortfolioValueResponse>;
|
|
931
|
+
getUserTradeStatsHistory: (request: GetUserTradeStatsHistoryRequest) => Promise<GetUserTradeStatsHistoryResponse>;
|
|
932
|
+
getUserAggregatedStats: (request: GetUserAggregatedStatsRequest) => Promise<GetUserAggregatedStatsResponse>;
|
|
933
|
+
getUserReferralStatsHistory: (request: GetUserReferralStatsHistoryRequest) => Promise<GetUserReferralStatsHistoryResponse>;
|
|
934
|
+
getUserAggregatedReferralStats: (request: GetUserAggregatedReferralStatsRequest) => Promise<GetUserAggregatedReferralStatsResponse>;
|
|
862
935
|
getTime: () => Promise<string>;
|
|
863
936
|
}
|
|
864
937
|
interface ChangePerpOrderPriceParams {
|
|
@@ -992,4 +1065,4 @@ declare const generateApiKey: () => _aptos_labs_ts_sdk.Ed25519Account;
|
|
|
992
1065
|
declare const getTopicFromCommand: (data: WsCommand) => string;
|
|
993
1066
|
declare const getTopicFromMessage: (data: WsMessage) => string;
|
|
994
1067
|
|
|
995
|
-
export { type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, type ChangePerpOrderPriceParams, type ChartCandle, ChartInterval, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type HistoricalDeposit, type HistoricalFunding, type HistoricalWithdraw, type IGetChartCandlesInRange, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PaginationCursor, type PerpFill, type PerpMarketData, type PerpOrder, type PerpOrderBookData, type PerpPosition, type PerpTrade, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKey, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, type UserPortfolioValue, UserStatus, type UtilizationCurve, type Vault, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsBorrowLendUpdate, type WsCommand, type WsFill, type WsMessage, type WsOracleUpdates, type WsPerpMarketUpdates, type WsUserUpdates, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
|
|
1068
|
+
export { type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, type ChangePerpOrderPriceParams, type ChartCandle, ChartInterval, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserAggregatedReferralStatsRequest, type GetUserAggregatedReferralStatsResponse, type GetUserAggregatedStatsRequest, type GetUserAggregatedStatsResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserReferralStatsHistoryRequest, type GetUserReferralStatsHistoryResponse, type GetUserTradeStatsHistoryRequest, type GetUserTradeStatsHistoryResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type HistoricalDeposit, type HistoricalFunding, type HistoricalReferralStats, type HistoricalTradeStats, type HistoricalWithdraw, type IGetChartCandlesInRange, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PaginationCursor, type PerpFill, type PerpMarketData, type PerpOrder, type PerpOrderBookData, type PerpPosition, type PerpTrade, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKey, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, type UserAggregatedReferralStats, type UserAggregatedStats, type UserPortfolioValue, UserStatus, type UtilizationCurve, type Vault, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsBorrowLendUpdate, type WsCommand, type WsFill, type WsMessage, type WsOracleUpdates, type WsPerpMarketUpdates, type WsUserUpdates, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _aptos_labs_ts_sdk from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { Account, Aptos,
|
|
2
|
+
import { Account, Aptos, SimpleTransaction, AccountAuthenticator, MoveModule, EntryFunctionABI } from '@aptos-labs/ts-sdk';
|
|
3
3
|
import * as _thalalabs_surf_build_types_core from '@thalalabs/surf/build/types/core';
|
|
4
4
|
import * as _thalalabs_surf from '@thalalabs/surf';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
@@ -297,6 +297,36 @@ interface GetTokensConfigResponse {
|
|
|
297
297
|
tokens: Record<string, TokenConfigEntry>;
|
|
298
298
|
usdcAddress?: string;
|
|
299
299
|
}
|
|
300
|
+
interface GetUserAggregatedReferralStatsRequest {
|
|
301
|
+
userId: string;
|
|
302
|
+
paginationCursor?: PaginationCursor;
|
|
303
|
+
}
|
|
304
|
+
interface UserAggregatedReferralStats {
|
|
305
|
+
referralOwnerId: string;
|
|
306
|
+
referralUserId: string;
|
|
307
|
+
accReferralValue: string;
|
|
308
|
+
referredUserVolume: string;
|
|
309
|
+
}
|
|
310
|
+
interface GetUserAggregatedReferralStatsResponse {
|
|
311
|
+
stats: UserAggregatedReferralStats[];
|
|
312
|
+
paginationCursor?: PaginationCursor;
|
|
313
|
+
}
|
|
314
|
+
interface GetUserAggregatedStatsRequest {
|
|
315
|
+
userId: string;
|
|
316
|
+
}
|
|
317
|
+
interface UserAggregatedStats {
|
|
318
|
+
userId: string;
|
|
319
|
+
spotVolume: string;
|
|
320
|
+
perpVolume: string;
|
|
321
|
+
liquidationVolume: string;
|
|
322
|
+
depositValue: string;
|
|
323
|
+
paidFee: string;
|
|
324
|
+
spotTradesCount: string;
|
|
325
|
+
perpTradesCount: string;
|
|
326
|
+
}
|
|
327
|
+
interface GetUserAggregatedStatsResponse {
|
|
328
|
+
userAggregatedStats: UserAggregatedStats;
|
|
329
|
+
}
|
|
300
330
|
interface GetUserDataRequest {
|
|
301
331
|
userId: string;
|
|
302
332
|
}
|
|
@@ -390,6 +420,41 @@ interface GetUserPortfolioValueResponse {
|
|
|
390
420
|
portfolioValues: UserPortfolioValue[];
|
|
391
421
|
paginationCursor?: PaginationCursor;
|
|
392
422
|
}
|
|
423
|
+
interface GetUserReferralStatsHistoryRequest {
|
|
424
|
+
userId: string;
|
|
425
|
+
timestampStartMs?: string;
|
|
426
|
+
timestampEndMs?: string;
|
|
427
|
+
paginationCursor?: PaginationCursor;
|
|
428
|
+
}
|
|
429
|
+
interface HistoricalReferralStats {
|
|
430
|
+
userId: string;
|
|
431
|
+
referralsValue: Record<string, string>;
|
|
432
|
+
timestampOpen: string;
|
|
433
|
+
timestampClose: string;
|
|
434
|
+
}
|
|
435
|
+
interface GetUserReferralStatsHistoryResponse {
|
|
436
|
+
stats: HistoricalReferralStats[];
|
|
437
|
+
paginationCursor?: PaginationCursor;
|
|
438
|
+
}
|
|
439
|
+
interface GetUserTradeStatsHistoryRequest {
|
|
440
|
+
userId: string;
|
|
441
|
+
timestampStartMs?: string;
|
|
442
|
+
timestampEndMs?: string;
|
|
443
|
+
paginationCursor?: PaginationCursor;
|
|
444
|
+
}
|
|
445
|
+
interface HistoricalTradeStats {
|
|
446
|
+
userId: string;
|
|
447
|
+
tradeVolumeSpot: string;
|
|
448
|
+
tradeVolumePerp: string;
|
|
449
|
+
tradeCountSpot: string;
|
|
450
|
+
tradeCountPerp: string;
|
|
451
|
+
timestampOpen: string;
|
|
452
|
+
timestampClose: string;
|
|
453
|
+
}
|
|
454
|
+
interface GetUserTradeStatsHistoryResponse {
|
|
455
|
+
stats: HistoricalTradeStats[];
|
|
456
|
+
paginationCursor?: PaginationCursor;
|
|
457
|
+
}
|
|
393
458
|
interface GetUserWithdrawalsRequest {
|
|
394
459
|
userId: string;
|
|
395
460
|
paginationCursor?: PaginationCursor;
|
|
@@ -559,7 +624,11 @@ declare enum EndpointsV1 {
|
|
|
559
624
|
GetUserWithdrawals = "/v1/get_user_withdrawals",
|
|
560
625
|
GetUserFundingHistory = "/v1/get_user_funding_history",
|
|
561
626
|
GetUserPortfolioValue = "/v1/get_user_portfolio_value",
|
|
562
|
-
SyncStatus = "/v1/sync_status"
|
|
627
|
+
SyncStatus = "/v1/sync_status",
|
|
628
|
+
GetUserAggregatedReferral = "/v1/get_user_aggregated_referral",
|
|
629
|
+
GetUserAggregatedStats = "/v1/get_user_aggregated_stats",
|
|
630
|
+
GetUserReferralStats = "/v1/get_user_referral_stats",
|
|
631
|
+
GetUserTradeStats = "/v1/get_user_trade_stats"
|
|
563
632
|
}
|
|
564
633
|
type Topic = {
|
|
565
634
|
type: "Market";
|
|
@@ -811,7 +880,7 @@ declare class Client {
|
|
|
811
880
|
getApiKeySequenceNumber(): Promise<bigint | null>;
|
|
812
881
|
fetchApiKeySequenceNumber(): Promise<number>;
|
|
813
882
|
createUser(params: CreateUserParams): Promise<{
|
|
814
|
-
tx:
|
|
883
|
+
tx: SimpleTransaction;
|
|
815
884
|
signature: AccountAuthenticator;
|
|
816
885
|
apiKey: _aptos_labs_ts_sdk.Ed25519Account;
|
|
817
886
|
}>;
|
|
@@ -823,7 +892,7 @@ declare class Client {
|
|
|
823
892
|
unsubscribeUserUpdates(userId: string): Promise<void>;
|
|
824
893
|
subscribePerpMarketUpdates(market: string, callback: (data: WsPerpMarketUpdates) => void): Promise<() => Promise<void>>;
|
|
825
894
|
unsubscribePerpMarketUpdates(market: string): Promise<void>;
|
|
826
|
-
addApiKey(params: AddApiKeyParams): Promise<
|
|
895
|
+
addApiKey(params: AddApiKeyParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
827
896
|
removeApiKey(params: RemoveApiKeyParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
828
897
|
setAliasName(params: SetAliasNameParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
829
898
|
placePerpLimitOrder(params: PlacePerpLimitOrderParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
@@ -832,7 +901,7 @@ declare class Client {
|
|
|
832
901
|
cancelPerpOrders(params: CancelPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
833
902
|
cancelAllPerpOrders(params: CancelAllPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
834
903
|
setAutolend(params: SetAutolendParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
835
|
-
depositTokenPayload(params: DepositTokenParams): Promise<
|
|
904
|
+
depositTokenPayload(params: DepositTokenParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
836
905
|
depositToVault(params: DepositToVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
837
906
|
withdrawFromVault(params: WithdrawFromVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
838
907
|
redeemToken(params: RedeemTokenParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
@@ -859,6 +928,10 @@ declare class Client {
|
|
|
859
928
|
getUserHistoricalDeposits: (request: GetUserDepositsRequest) => Promise<GetUserDepositsResponse>;
|
|
860
929
|
getUserWithdrawalsHistory: (request: GetUserWithdrawalsRequest) => Promise<GetUserWithdrawalsResponse>;
|
|
861
930
|
getUserPortfolioValueHistory: (request: GetUserPortfolioValueRequest) => Promise<GetUserPortfolioValueResponse>;
|
|
931
|
+
getUserTradeStatsHistory: (request: GetUserTradeStatsHistoryRequest) => Promise<GetUserTradeStatsHistoryResponse>;
|
|
932
|
+
getUserAggregatedStats: (request: GetUserAggregatedStatsRequest) => Promise<GetUserAggregatedStatsResponse>;
|
|
933
|
+
getUserReferralStatsHistory: (request: GetUserReferralStatsHistoryRequest) => Promise<GetUserReferralStatsHistoryResponse>;
|
|
934
|
+
getUserAggregatedReferralStats: (request: GetUserAggregatedReferralStatsRequest) => Promise<GetUserAggregatedReferralStatsResponse>;
|
|
862
935
|
getTime: () => Promise<string>;
|
|
863
936
|
}
|
|
864
937
|
interface ChangePerpOrderPriceParams {
|
|
@@ -992,4 +1065,4 @@ declare const generateApiKey: () => _aptos_labs_ts_sdk.Ed25519Account;
|
|
|
992
1065
|
declare const getTopicFromCommand: (data: WsCommand) => string;
|
|
993
1066
|
declare const getTopicFromMessage: (data: WsMessage) => string;
|
|
994
1067
|
|
|
995
|
-
export { type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, type ChangePerpOrderPriceParams, type ChartCandle, ChartInterval, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type HistoricalDeposit, type HistoricalFunding, type HistoricalWithdraw, type IGetChartCandlesInRange, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PaginationCursor, type PerpFill, type PerpMarketData, type PerpOrder, type PerpOrderBookData, type PerpPosition, type PerpTrade, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKey, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, type UserPortfolioValue, UserStatus, type UtilizationCurve, type Vault, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsBorrowLendUpdate, type WsCommand, type WsFill, type WsMessage, type WsOracleUpdates, type WsPerpMarketUpdates, type WsUserUpdates, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
|
|
1068
|
+
export { type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, type ChangePerpOrderPriceParams, type ChartCandle, ChartInterval, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserAggregatedReferralStatsRequest, type GetUserAggregatedReferralStatsResponse, type GetUserAggregatedStatsRequest, type GetUserAggregatedStatsResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserReferralStatsHistoryRequest, type GetUserReferralStatsHistoryResponse, type GetUserTradeStatsHistoryRequest, type GetUserTradeStatsHistoryResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type HistoricalDeposit, type HistoricalFunding, type HistoricalReferralStats, type HistoricalTradeStats, type HistoricalWithdraw, type IGetChartCandlesInRange, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PaginationCursor, type PerpFill, type PerpMarketData, type PerpOrder, type PerpOrderBookData, type PerpPosition, type PerpTrade, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKey, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, type UserAggregatedReferralStats, type UserAggregatedStats, type UserPortfolioValue, UserStatus, type UtilizationCurve, type Vault, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsBorrowLendUpdate, type WsCommand, type WsFill, type WsMessage, type WsOracleUpdates, type WsPerpMarketUpdates, type WsUserUpdates, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
AccountAddress,
|
|
4
4
|
ChainId,
|
|
5
5
|
findFirstNonSignerArg,
|
|
6
|
+
generateRawTransaction,
|
|
6
7
|
generateTransactionPayload,
|
|
7
8
|
parseTypeTag,
|
|
8
9
|
RawTransaction,
|
|
9
10
|
SimpleTransaction
|
|
10
11
|
} from "@aptos-labs/ts-sdk";
|
|
11
|
-
import {
|
|
12
|
+
import { createSurfClient } from "@thalalabs/surf";
|
|
12
13
|
import WebSocket from "isomorphic-ws";
|
|
13
14
|
import { v4 as uuidv4 } from "uuid";
|
|
14
15
|
|
|
@@ -439,6 +440,10 @@ var EndpointsV1 = /* @__PURE__ */ ((EndpointsV12) => {
|
|
|
439
440
|
EndpointsV12["GetUserFundingHistory"] = "/v1/get_user_funding_history";
|
|
440
441
|
EndpointsV12["GetUserPortfolioValue"] = "/v1/get_user_portfolio_value";
|
|
441
442
|
EndpointsV12["SyncStatus"] = "/v1/sync_status";
|
|
443
|
+
EndpointsV12["GetUserAggregatedReferral"] = "/v1/get_user_aggregated_referral";
|
|
444
|
+
EndpointsV12["GetUserAggregatedStats"] = "/v1/get_user_aggregated_stats";
|
|
445
|
+
EndpointsV12["GetUserReferralStats"] = "/v1/get_user_referral_stats";
|
|
446
|
+
EndpointsV12["GetUserTradeStats"] = "/v1/get_user_trade_stats";
|
|
442
447
|
return EndpointsV12;
|
|
443
448
|
})(EndpointsV1 || {});
|
|
444
449
|
var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
@@ -939,6 +944,28 @@ var Client = class _Client {
|
|
|
939
944
|
const response = await this.sendGetJson("/v1/get_user_portfolio_value" /* GetUserPortfolioValue */, request);
|
|
940
945
|
return response;
|
|
941
946
|
};
|
|
947
|
+
this.getUserTradeStatsHistory = async (request) => {
|
|
948
|
+
if (request.timestampEndMs && request.timestampStartMs && request.timestampEndMs > request.timestampStartMs) {
|
|
949
|
+
throw new Error("timestampEndMs must be lower than timestampStartMs");
|
|
950
|
+
}
|
|
951
|
+
const response = await this.sendGetJson("/v1/get_user_trade_stats" /* GetUserTradeStats */, request);
|
|
952
|
+
return response;
|
|
953
|
+
};
|
|
954
|
+
this.getUserAggregatedStats = async (request) => {
|
|
955
|
+
const response = await this.sendGetJson("/v1/get_user_aggregated_stats" /* GetUserAggregatedStats */, request);
|
|
956
|
+
return response;
|
|
957
|
+
};
|
|
958
|
+
this.getUserReferralStatsHistory = async (request) => {
|
|
959
|
+
if (request.timestampEndMs && request.timestampStartMs && request.timestampEndMs > request.timestampStartMs) {
|
|
960
|
+
throw new Error("timestampEndMs must be lower than timestampStartMs");
|
|
961
|
+
}
|
|
962
|
+
const response = await this.sendGetJson("/v1/get_user_referral_stats" /* GetUserReferralStats */, request);
|
|
963
|
+
return response;
|
|
964
|
+
};
|
|
965
|
+
this.getUserAggregatedReferralStats = async (request) => {
|
|
966
|
+
const response = await this.sendGetJson("/v1/get_user_aggregated_referral" /* GetUserAggregatedReferral */, request);
|
|
967
|
+
return response;
|
|
968
|
+
};
|
|
942
969
|
// Meta
|
|
943
970
|
this.getTime = async () => {
|
|
944
971
|
const response = await this.sendGetJson("/time" /* Time */);
|
|
@@ -1016,7 +1043,7 @@ var Client = class _Client {
|
|
|
1016
1043
|
this._ws?.send(JSON.stringify(message));
|
|
1017
1044
|
});
|
|
1018
1045
|
}
|
|
1019
|
-
static async create(connection, apiKey, url = "
|
|
1046
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1020
1047
|
return _Client.init(connection, apiKey, url, enableWs);
|
|
1021
1048
|
}
|
|
1022
1049
|
async setApiKey(apiKey) {
|
|
@@ -1037,16 +1064,25 @@ var Client = class _Client {
|
|
|
1037
1064
|
// needs to be signed by user and sent to blockchain
|
|
1038
1065
|
async createUser(params) {
|
|
1039
1066
|
const apiKey = generateApiKey();
|
|
1040
|
-
const payload =
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1067
|
+
const payload = await generateTransactionPayload({
|
|
1068
|
+
aptosConfig: this._aptos.config,
|
|
1069
|
+
abi: parseEntryFunctionAbi({
|
|
1070
|
+
moduleAbi: createUser_default,
|
|
1071
|
+
functionName: createUser_default.name,
|
|
1072
|
+
moduleAddress: createUser_default.address,
|
|
1073
|
+
moduleName: createUser_default.name
|
|
1074
|
+
}),
|
|
1075
|
+
function: `${createUser_default.address}::${createUser_default.name}::create_user`,
|
|
1076
|
+
typeArguments: [],
|
|
1077
|
+
functionArguments: [params.name, params.referralId]
|
|
1049
1078
|
});
|
|
1079
|
+
const tx = new SimpleTransaction(
|
|
1080
|
+
await generateRawTransaction({
|
|
1081
|
+
sender: params.sender,
|
|
1082
|
+
aptosConfig: this._aptos.config,
|
|
1083
|
+
payload
|
|
1084
|
+
})
|
|
1085
|
+
);
|
|
1050
1086
|
const signature = this._aptos.sign({
|
|
1051
1087
|
signer: apiKey,
|
|
1052
1088
|
transaction: tx
|
|
@@ -1135,10 +1171,17 @@ var Client = class _Client {
|
|
|
1135
1171
|
}
|
|
1136
1172
|
// needs to be signed by user and sent to blockchain
|
|
1137
1173
|
async addApiKey(params) {
|
|
1138
|
-
return
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1174
|
+
return await generateTransactionPayload({
|
|
1175
|
+
aptosConfig: this._aptos.config,
|
|
1176
|
+
abi: parseEntryFunctionAbi({
|
|
1177
|
+
moduleAbi: addApiKey_default,
|
|
1178
|
+
functionName: addApiKey_default.name,
|
|
1179
|
+
moduleAddress: addApiKey_default.address,
|
|
1180
|
+
moduleName: addApiKey_default.name
|
|
1181
|
+
}),
|
|
1182
|
+
function: `${addApiKey_default.address}::${addApiKey_default.name}::add_api_key`,
|
|
1183
|
+
typeArguments: [],
|
|
1184
|
+
functionArguments: [params.userId, params.expiration]
|
|
1142
1185
|
});
|
|
1143
1186
|
}
|
|
1144
1187
|
async removeApiKey(params) {
|
|
@@ -1412,10 +1455,17 @@ var Client = class _Client {
|
|
|
1412
1455
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1413
1456
|
}
|
|
1414
1457
|
async depositTokenPayload(params) {
|
|
1415
|
-
return
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1458
|
+
return await generateTransactionPayload({
|
|
1459
|
+
aptosConfig: this._aptos.config,
|
|
1460
|
+
abi: parseEntryFunctionAbi({
|
|
1461
|
+
moduleAbi: depositToken_default,
|
|
1462
|
+
functionName: depositToken_default.name,
|
|
1463
|
+
moduleAddress: depositToken_default.address,
|
|
1464
|
+
moduleName: depositToken_default.name
|
|
1465
|
+
}),
|
|
1466
|
+
function: `${depositToken_default.address}::${depositToken_default.name}::deposit_token`,
|
|
1467
|
+
typeArguments: [],
|
|
1468
|
+
functionArguments: [params.userId, params.amount, params.tokenAddress]
|
|
1419
1469
|
});
|
|
1420
1470
|
}
|
|
1421
1471
|
async depositToVault(params) {
|
|
@@ -1593,7 +1643,7 @@ function parseEntryFunctionAbi(args) {
|
|
|
1593
1643
|
}
|
|
1594
1644
|
|
|
1595
1645
|
// src/testFaucet.ts
|
|
1596
|
-
import { createEntryPayload
|
|
1646
|
+
import { createEntryPayload } from "@thalalabs/surf";
|
|
1597
1647
|
|
|
1598
1648
|
// generated_types/faucetEntrypoints.ts
|
|
1599
1649
|
var ABI16 = {
|
|
@@ -1884,7 +1934,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1884
1934
|
constructor(connection, url, ws, apiKey) {
|
|
1885
1935
|
super(connection, url, ws, apiKey);
|
|
1886
1936
|
}
|
|
1887
|
-
static async create(connection, apiKey, url = "
|
|
1937
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1888
1938
|
let ws = void 0;
|
|
1889
1939
|
if (enableWs) {
|
|
1890
1940
|
ws = await client_default.initWebSocket(url);
|
|
@@ -1892,7 +1942,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1892
1942
|
return new _TestFaucet(connection, url, ws, apiKey);
|
|
1893
1943
|
}
|
|
1894
1944
|
initFaucetPayload() {
|
|
1895
|
-
return
|
|
1945
|
+
return createEntryPayload(faucetEntrypoints_default, {
|
|
1896
1946
|
function: "initialize_faucet",
|
|
1897
1947
|
functionArguments: [],
|
|
1898
1948
|
typeArguments: []
|
|
@@ -1913,7 +1963,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1913
1963
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1914
1964
|
}
|
|
1915
1965
|
mintTokenPayload(receiver, token, amount) {
|
|
1916
|
-
return
|
|
1966
|
+
return createEntryPayload(faucetEntrypoints_default, {
|
|
1917
1967
|
function: "mint_test_token",
|
|
1918
1968
|
functionArguments: [receiver, token, amount],
|
|
1919
1969
|
typeArguments: []
|