aftermath-ts-sdk 1.2.57 → 1.2.58-limit.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.
Files changed (50) hide show
  1. package/dist/general/providers/aftermath.d.ts +4 -0
  2. package/dist/general/providers/aftermath.d.ts.map +1 -1
  3. package/dist/general/providers/aftermath.js +4 -0
  4. package/dist/general/providers/aftermathApi.d.ts +4 -0
  5. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  6. package/dist/general/providers/aftermathApi.js +4 -0
  7. package/dist/general/types/configTypes.d.ts +9 -0
  8. package/dist/general/types/configTypes.d.ts.map +1 -1
  9. package/dist/general/utils/caller.d.ts.map +1 -1
  10. package/dist/general/utils/casting.d.ts +0 -2
  11. package/dist/general/utils/casting.d.ts.map +1 -1
  12. package/dist/general/utils/casting.js +0 -2
  13. package/dist/packages/dca/api/dcaApi.d.ts +2 -0
  14. package/dist/packages/dca/api/dcaApi.d.ts.map +1 -1
  15. package/dist/packages/dca/api/dcaApi.js +6 -3
  16. package/dist/packages/dca/dca.d.ts +5 -4
  17. package/dist/packages/dca/dca.d.ts.map +1 -1
  18. package/dist/packages/dca/dca.js +13 -11
  19. package/dist/packages/dca/dcaTypes.d.ts +30 -40
  20. package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
  21. package/dist/packages/limitOrders/api/limitOrdersApi.d.ts +12 -0
  22. package/dist/packages/limitOrders/api/limitOrdersApi.d.ts.map +1 -0
  23. package/dist/packages/limitOrders/api/limitOrdersApi.js +25 -0
  24. package/dist/packages/limitOrders/index.d.ts +2 -0
  25. package/dist/packages/limitOrders/index.d.ts.map +1 -0
  26. package/dist/packages/limitOrders/index.js +17 -0
  27. package/dist/packages/limitOrders/limitOrders.d.ts +56 -0
  28. package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -0
  29. package/dist/packages/limitOrders/limitOrders.js +102 -0
  30. package/dist/packages/limitOrders/limitOrdersTypes.d.ts +69 -0
  31. package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -0
  32. package/dist/packages/userData/api/userDataApi.d.ts +6 -0
  33. package/dist/packages/userData/api/userDataApi.d.ts.map +1 -0
  34. package/dist/packages/userData/api/userDataApi.js +12 -0
  35. package/dist/packages/userData/index.d.ts +2 -0
  36. package/dist/packages/userData/index.d.ts.map +1 -0
  37. package/dist/packages/userData/index.js +17 -0
  38. package/dist/packages/userData/userData.d.ts +35 -0
  39. package/dist/packages/userData/userData.d.ts.map +1 -0
  40. package/dist/packages/userData/userData.js +65 -0
  41. package/dist/packages/userData/userDataTypes.d.ts +10 -0
  42. package/dist/packages/userData/userDataTypes.d.ts.map +1 -0
  43. package/dist/packages/userData/userDataTypes.js +2 -0
  44. package/package.json +1 -1
  45. package/dist/packages/dca/api/dcaApiCasting.d.ts +0 -11
  46. package/dist/packages/dca/api/dcaApiCasting.d.ts.map +0 -1
  47. package/dist/packages/dca/api/dcaApiCasting.js +0 -186
  48. package/dist/packages/dca/api/dcaApiCastingTypes.d.ts +0 -142
  49. package/dist/packages/dca/api/dcaApiCastingTypes.d.ts.map +0 -1
  50. /package/dist/packages/{dca/api/dcaApiCastingTypes.js → limitOrders/limitOrdersTypes.js} +0 -0
@@ -0,0 +1,56 @@
1
+ import { CallerConfig, ObjectId } from "../../types";
2
+ import { Caller } from "../../general/utils/caller";
3
+ import { SuiAddress } from "../../types";
4
+ import { ApiLimitOrdersCreateOrderTransactionBody, ApiLimitOrdersCancelOrderTransactionBody, LimitOrderObject, ApiLimitOrdersActiveOrdersOwnedBody } from "./limitOrdersTypes";
5
+ import { Transaction } from "@mysten/sui/transactions";
6
+ export declare class LimitOrders extends Caller {
7
+ static readonly constants: {
8
+ gasAmount: bigint;
9
+ };
10
+ constructor(config?: CallerConfig);
11
+ /**
12
+ * Fetches the API for dollar cost averaging active orders list.
13
+ * @async
14
+ * @param { LimitOrderObject } inputs - An object containing the walletAddress.
15
+ * @returns { Promise<LimitOrderObject[]> } A promise that resolves to object with array of fetched events for active limit orders
16
+ */
17
+ getActiveLimitOrders(inputs: ApiLimitOrdersActiveOrdersOwnedBody): Promise<LimitOrderObject[]>;
18
+ /**
19
+ * Fetches the API for limit cost finished orders list.
20
+ * @async
21
+ * @param { LimitOrderObject } inputs - An object containing the walletAddress.
22
+ * @returns { Promise<LimitOrderObject[]> } A promise that resolves to object with array of fetched events for past limit orders
23
+ */
24
+ getPastLimitOrders(inputs: {
25
+ walletAddress: SuiAddress;
26
+ }): Promise<LimitOrderObject[]>;
27
+ /**
28
+ * Fetches the API transaction for creating Limit order.
29
+ * @param { ApiLimitOrdersCreateOrderTransactionBody } inputs - The inputs for the transaction.
30
+ * @returns { Promise<Transaction> } A promise that resolves with the API transaction.
31
+ */
32
+ getCreateLimitOrderTx(inputs: ApiLimitOrdersCreateOrderTransactionBody): Promise<Transaction>;
33
+ /**
34
+ * Fetches the API for canceling Limit order.
35
+ * @param inputs - The inputs for the transaction.
36
+ * @returns { Promise<boolean> } A promise that resolves with transaction execution status.
37
+ */
38
+ cancelLimitOrder(inputs: ApiLimitOrdersCancelOrderTransactionBody): Promise<boolean>;
39
+ /**
40
+ * Method for getting the cancellation limit order message to sign.
41
+ * @param inputs - The inputs for the message.
42
+ * @returns Message to sign.
43
+ */
44
+ cancelLimitOrdersMessageToSign(inputs: {
45
+ orderIds: ObjectId[];
46
+ }): {
47
+ action: string;
48
+ order_object_ids: string[];
49
+ };
50
+ /**
51
+ * Method for getting a minimum allowable order size.
52
+ * @returns Minimum order size in usd.
53
+ */
54
+ getMinOrderSizeUsd(): Promise<number | undefined>;
55
+ }
56
+ //# sourceMappingURL=limitOrders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitOrders.d.ts","sourceRoot":"","sources":["../../../src/packages/limitOrders/limitOrders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAEN,wCAAwC,EACxC,wCAAwC,EACxC,gBAAgB,EAChB,mCAAmC,EACnC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,qBAAa,WAAY,SAAQ,MAAM;IAKtC,gBAAuB,SAAS;;MAE9B;gBAMU,MAAM,CAAC,EAAE,YAAY;IAQjC;;;;;OAKG;IAEU,oBAAoB,CAChC,MAAM,EAAE,mCAAmC;IAQ5C;;;;;OAKG;IAEU,kBAAkB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE;IAWrE;;;;OAIG;IAEU,qBAAqB,CACjC,MAAM,EAAE,wCAAwC,GAC9C,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;OAIG;IAEU,gBAAgB,CAC5B,MAAM,EAAE,wCAAwC,GAC9C,OAAO,CAAC,OAAO,CAAC;IAWnB;;;;OAIG;IAEI,8BAA8B,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;KAAE,GAAG;QACxE,MAAM,EAAE,MAAM,CAAC;QACf,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC3B;IAWD;;;OAGG;IAEU,kBAAkB;CAG/B"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LimitOrders = void 0;
13
+ const caller_1 = require("../../general/utils/caller");
14
+ class LimitOrders extends caller_1.Caller {
15
+ // =========================================================================
16
+ // Constructor
17
+ // =========================================================================
18
+ constructor(config) {
19
+ super(config, "limit-orders");
20
+ }
21
+ // =========================================================================
22
+ // Class Objects
23
+ // =========================================================================
24
+ /**
25
+ * Fetches the API for dollar cost averaging active orders list.
26
+ * @async
27
+ * @param { LimitOrderObject } inputs - An object containing the walletAddress.
28
+ * @returns { Promise<LimitOrderObject[]> } A promise that resolves to object with array of fetched events for active limit orders
29
+ */
30
+ getActiveLimitOrders(inputs) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ return this.fetchApi("active", inputs);
33
+ });
34
+ }
35
+ /**
36
+ * Fetches the API for limit cost finished orders list.
37
+ * @async
38
+ * @param { LimitOrderObject } inputs - An object containing the walletAddress.
39
+ * @returns { Promise<LimitOrderObject[]> } A promise that resolves to object with array of fetched events for past limit orders
40
+ */
41
+ getPastLimitOrders(inputs) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ return this.fetchApi("past", inputs);
44
+ });
45
+ }
46
+ // =========================================================================
47
+ // Transactions
48
+ // =========================================================================
49
+ /**
50
+ * Fetches the API transaction for creating Limit order.
51
+ * @param { ApiLimitOrdersCreateOrderTransactionBody } inputs - The inputs for the transaction.
52
+ * @returns { Promise<Transaction> } A promise that resolves with the API transaction.
53
+ */
54
+ getCreateLimitOrderTx(inputs) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return this.fetchApiTransaction("transactions/create-order", inputs);
57
+ });
58
+ }
59
+ /**
60
+ * Fetches the API for canceling Limit order.
61
+ * @param inputs - The inputs for the transaction.
62
+ * @returns { Promise<boolean> } A promise that resolves with transaction execution status.
63
+ */
64
+ cancelLimitOrder(inputs) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ return this.fetchApi(`cancel`, inputs);
67
+ });
68
+ }
69
+ // =========================================================================
70
+ // Interactions
71
+ // =========================================================================
72
+ /**
73
+ * Method for getting the cancellation limit order message to sign.
74
+ * @param inputs - The inputs for the message.
75
+ * @returns Message to sign.
76
+ */
77
+ cancelLimitOrdersMessageToSign(inputs) {
78
+ return {
79
+ action: "CANCEL_LIMIT_ORDERS",
80
+ order_object_ids: inputs.orderIds,
81
+ };
82
+ }
83
+ // =========================================================================
84
+ // Configuration
85
+ // =========================================================================
86
+ /**
87
+ * Method for getting a minimum allowable order size.
88
+ * @returns Minimum order size in usd.
89
+ */
90
+ getMinOrderSizeUsd() {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ return this.fetchApi("min-order-size-usd", {});
93
+ });
94
+ }
95
+ }
96
+ exports.LimitOrders = LimitOrders;
97
+ // =========================================================================
98
+ // Constants
99
+ // =========================================================================
100
+ LimitOrders.constants = {
101
+ gasAmount: BigInt(50000000),
102
+ };
@@ -0,0 +1,69 @@
1
+ import { ObjectId, SuiAddress } from "../../types";
2
+ import { CoinType } from "../coin/coinTypes";
3
+ import { Balance, Timestamp, TransactionDigest } from "../../general/types/generalTypes";
4
+ export interface LimitOrdersIntegratorFeeData {
5
+ feeBps: number;
6
+ feeRecipient: SuiAddress;
7
+ }
8
+ export interface ApiLimitOrdersCreateOrderTransactionBody {
9
+ walletAddress: SuiAddress;
10
+ allocateCoinType: CoinType;
11
+ allocateCoinAmount: Balance;
12
+ buyCoinType: CoinType;
13
+ customRecipient?: SuiAddress;
14
+ expiryDurationMs: number;
15
+ isSponsoredTx?: boolean;
16
+ integratorFee?: LimitOrdersIntegratorFeeData;
17
+ outputToInputExchangeRate: number;
18
+ outputToInputStopLossExchangeRate?: number;
19
+ }
20
+ export interface ApiLimitOrdersSubOrdersBody {
21
+ orderPrice: Balance;
22
+ ordersAmount: number;
23
+ }
24
+ export interface ApiLimitLaddersOrdersBody {
25
+ price: Balance;
26
+ quantity: Balance;
27
+ }
28
+ export interface ApiLimitOrdersCancelOrderTransactionBody {
29
+ walletAddress: SuiAddress;
30
+ bytes: string;
31
+ signature: string;
32
+ }
33
+ export type LimitOrdersOrderStatus = "Active" | "Canceled" | "Failed" | "Filled" | "Expired" | "StopLossTriggered";
34
+ export interface LimitOrderObject {
35
+ objectId: ObjectId;
36
+ allocatedCoin: {
37
+ coin: CoinType;
38
+ amount: Balance;
39
+ };
40
+ buyCoin: {
41
+ coin: CoinType;
42
+ amount: Balance;
43
+ };
44
+ currentAmountSold: Balance;
45
+ currentAmountBought: Balance;
46
+ recipient: SuiAddress;
47
+ created: {
48
+ timestamp: Timestamp;
49
+ txnDigest: TransactionDigest;
50
+ };
51
+ finished?: {
52
+ timestamp: Timestamp;
53
+ txnDigest: TransactionDigest;
54
+ };
55
+ expiryTimestamp: Timestamp;
56
+ status: LimitOrdersOrderStatus;
57
+ error?: string;
58
+ integratorFee?: LimitOrdersIntegratorFeeData;
59
+ outputToInputStopLossExchangeRate?: number;
60
+ }
61
+ export interface ApiLimitOrdersPastOrdersOwnedBody {
62
+ walletAddress: SuiAddress;
63
+ }
64
+ export interface ApiLimitOrdersActiveOrdersOwnedBody {
65
+ walletAddress: SuiAddress;
66
+ bytes: string;
67
+ signature: string;
68
+ }
69
+ //# sourceMappingURL=limitOrdersTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitOrdersTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/limitOrders/limitOrdersTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACN,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,MAAM,kCAAkC,CAAC;AAM1C,MAAM,WAAW,4BAA4B;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,UAAU,CAAC;CACzB;AAMD,MAAM,WAAW,wCAAwC;IACxD,aAAa,EAAE,UAAU,CAAC;IAC1B,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,QAAQ,CAAC;IACtB,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,4BAA4B,CAAC;IAC7C,yBAAyB,EAAE,MAAM,CAAC;IAClC,iCAAiC,CAAC,EAAE,MAAM,CAAC;CAC3C;AAED,MAAM,WAAW,2BAA2B;IAC3C,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACrB;AAMD,MAAM,WAAW,yBAAyB;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CAClB;AAMD,MAAM,WAAW,wCAAwC;IACxD,aAAa,EAAE,UAAU,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CAClB;AAMD,MAAM,MAAM,sBAAsB,GAC/B,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,mBAAmB,CAAC;AAEvB,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE;QACd,IAAI,EAAE,QAAQ,CAAC;QACf,MAAM,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,OAAO,EAAE;QACR,IAAI,EAAE,QAAQ,CAAC;QACf,MAAM,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE;QACR,SAAS,EAAE,SAAS,CAAC;QACrB,SAAS,EAAE,iBAAiB,CAAC;KAC7B,CAAC;IACF,QAAQ,CAAC,EAAE;QACV,SAAS,EAAE,SAAS,CAAC;QACrB,SAAS,EAAE,iBAAiB,CAAC;KAC7B,CAAC;IACF,eAAe,EAAE,SAAS,CAAC;IAC3B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,4BAA4B,CAAC;IAC7C,iCAAiC,CAAC,EAAE,MAAM,CAAC;CAC3C;AAMD,MAAM,WAAW,iCAAiC;IACjD,aAAa,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,WAAW,mCAAmC;IACnD,aAAa,EAAE,UAAU,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,6 @@
1
+ import { AftermathApi } from "../../../general/providers/aftermathApi";
2
+ export declare class UserDataApi {
3
+ private readonly Provider;
4
+ constructor(Provider: AftermathApi);
5
+ }
6
+ //# sourceMappingURL=userDataApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userDataApi.d.ts","sourceRoot":"","sources":["../../../../src/packages/userData/api/userDataApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,qBAAa,WAAW;IAKX,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;CACnD"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserDataApi = void 0;
4
+ class UserDataApi {
5
+ // =========================================================================
6
+ // Constructor
7
+ // =========================================================================
8
+ constructor(Provider) {
9
+ this.Provider = Provider;
10
+ }
11
+ }
12
+ exports.UserDataApi = UserDataApi;
@@ -0,0 +1,2 @@
1
+ export * from "./userData";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/userData/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./userData"), exports);
@@ -0,0 +1,35 @@
1
+ import { Caller } from "../../general/utils/caller";
2
+ import { CallerConfig } from "../../types";
3
+ import { ApiUserDataCreateUserBody, ApiUserDataPublicKeyBody } from "./userDataTypes";
4
+ export declare class UserData extends Caller {
5
+ constructor(config?: CallerConfig);
6
+ /**
7
+ * Fetches the API for users public key.
8
+ * @async
9
+ * @param { SuiAddress } inputs - An object containing the walletAddress.
10
+ * @returns { Promise<string | undefined> } A promise that resolves users public key.
11
+ */
12
+ getUserPublicKey(inputs: ApiUserDataPublicKeyBody): Promise<string | undefined>;
13
+ /**
14
+ * Fetches the API to create users public key.
15
+ * @async
16
+ * @param { ApiUserDataCreateUserBody } inputs - The inputs for creating users public key on BE side.
17
+ * @returns { Promise<boolean> } A promise that resolves to result if user pk has been created.
18
+ */
19
+ createUserPublicKey(inputs: ApiUserDataCreateUserBody): Promise<boolean>;
20
+ /**
21
+ * Fetches the API for user create message to sign.
22
+ * @returns { string } message to sign with action related to the service you interact with.
23
+ */
24
+ createUserAccountMessageToSign(): {
25
+ action: string;
26
+ };
27
+ /**
28
+ * Fetches the API for creating sign and terms message to sign.
29
+ * @returns { string } message to sign with action related to the service you interact with.
30
+ */
31
+ createSignTermsAndConditionsMessageToSign(): {
32
+ action: string;
33
+ };
34
+ }
35
+ //# sourceMappingURL=userData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userData.d.ts","sourceRoot":"","sources":["../../../src/packages/userData/userData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,QAAS,SAAQ,MAAM;gBAKvB,MAAM,CAAC,EAAE,YAAY;IAOjC;;;;;OAKG;IAEU,gBAAgB,CAC5B,MAAM,EAAE,wBAAwB,GAC9B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAO9B;;;;;OAKG;IAEU,mBAAmB,CAC/B,MAAM,EAAE,yBAAyB,GAC/B,OAAO,CAAC,OAAO,CAAC;IAOnB;;;OAGG;IAEI,8BAA8B;;;IAMrC;;;OAGG;IAEI,yCAAyC,IAAI;QACnD,MAAM,EAAE,MAAM,CAAC;KACf;CAKD"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UserData = void 0;
13
+ const caller_1 = require("../../general/utils/caller");
14
+ class UserData extends caller_1.Caller {
15
+ // =========================================================================
16
+ // Constructor
17
+ // =========================================================================
18
+ constructor(config) {
19
+ super(config, "user-data");
20
+ }
21
+ // =========================================================================
22
+ // API
23
+ // =========================================================================
24
+ /**
25
+ * Fetches the API for users public key.
26
+ * @async
27
+ * @param { SuiAddress } inputs - An object containing the walletAddress.
28
+ * @returns { Promise<string | undefined> } A promise that resolves users public key.
29
+ */
30
+ getUserPublicKey(inputs) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ return this.fetchApi(`public-key`, inputs);
33
+ });
34
+ }
35
+ /**
36
+ * Fetches the API to create users public key.
37
+ * @async
38
+ * @param { ApiUserDataCreateUserBody } inputs - The inputs for creating users public key on BE side.
39
+ * @returns { Promise<boolean> } A promise that resolves to result if user pk has been created.
40
+ */
41
+ createUserPublicKey(inputs) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ return this.fetchApi(`save-public-key`, inputs);
44
+ });
45
+ }
46
+ /**
47
+ * Fetches the API for user create message to sign.
48
+ * @returns { string } message to sign with action related to the service you interact with.
49
+ */
50
+ createUserAccountMessageToSign() {
51
+ return {
52
+ action: `CREATE_USER_ACCOUNT`,
53
+ };
54
+ }
55
+ /**
56
+ * Fetches the API for creating sign and terms message to sign.
57
+ * @returns { string } message to sign with action related to the service you interact with.
58
+ */
59
+ createSignTermsAndConditionsMessageToSign() {
60
+ return {
61
+ action: `SIGN_TERMS_AND_CONDITIONS`,
62
+ };
63
+ }
64
+ }
65
+ exports.UserData = UserData;
@@ -0,0 +1,10 @@
1
+ import { SuiAddress } from "../../types";
2
+ export interface ApiUserDataCreateUserBody {
3
+ walletAddress: SuiAddress;
4
+ bytes: string;
5
+ signature: string;
6
+ }
7
+ export interface ApiUserDataPublicKeyBody {
8
+ walletAddress: SuiAddress;
9
+ }
10
+ //# sourceMappingURL=userDataTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userDataTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/userData/userDataTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,MAAM,WAAW,yBAAyB;IACzC,aAAa,EAAE,UAAU,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB;IACxC,aAAa,EAAE,UAAU,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aftermath-ts-sdk",
3
- "version": "1.2.57",
3
+ "version": "1.2.58-limit.1",
4
4
  "description": "Aftermath TypeScript SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,11 +0,0 @@
1
- import { DcaClosedOrderEvent, DcaCreatedOrderEvent, DcaExecutedTradeEvent, DcaOrderObject, DcaOrderTradeObject } from "../dcaTypes";
2
- import { DcaClosedOrderEventOnChain, DcaCreatedOrderEventOnChain, DcaExecutedTradeEventOnChain, DcaIndexerOrderResponse, DcaIndexerOrderTradeResponse } from "./dcaApiCastingTypes";
3
- import { CoinType } from "../../../types";
4
- export declare class DcaApiCasting {
5
- static createdDcaOrderEventFromOnChain: (eventOnChain: DcaCreatedOrderEventOnChain) => DcaCreatedOrderEvent;
6
- static closedDcaOrderEventFromOnChain: (eventOnChain: DcaClosedOrderEventOnChain) => DcaClosedOrderEvent;
7
- static executedTradeEventFromOnChain: (eventOnChain: DcaExecutedTradeEventOnChain) => DcaExecutedTradeEvent;
8
- static createdOrderEventOnIndexer: (response: DcaIndexerOrderResponse) => DcaOrderObject;
9
- static createdOrderTradeEventOnIndexer: (response: DcaIndexerOrderTradeResponse, inputCoinType: CoinType, outputCoinType: CoinType) => DcaOrderTradeObject;
10
- }
11
- //# sourceMappingURL=dcaApiCasting.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dcaApiCasting.d.ts","sourceRoot":"","sources":["../../../../src/packages/dca/api/dcaApiCasting.ts"],"names":[],"mappings":"AACA,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EAEnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAW,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGnD,qBAAa,aAAa;IAKzB,OAAc,+BAA+B,iDAE1C,oBAAoB,CAyBrB;IAEF,OAAc,8BAA8B,gDAEzC,mBAAmB,CAwBpB;IAEF,OAAc,6BAA6B,kDAExC,qBAAqB,CAiBtB;IAMF,OAAc,0BAA0B,aAC7B,uBAAuB,KAC/B,cAAc,CAuHf;IAEF,OAAc,+BAA+B,aAClC,4BAA4B,iBACvB,QAAQ,kBACP,QAAQ,KACtB,mBAAmB,CAgBpB;CACF"}
@@ -1,186 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.DcaApiCasting = void 0;
5
- const utils_1 = require("../../../general/utils");
6
- const sui_1 = require("../../sui");
7
- class DcaApiCasting {
8
- }
9
- exports.DcaApiCasting = DcaApiCasting;
10
- _a = DcaApiCasting;
11
- // =========================================================================
12
- // Chain Event objects
13
- // =========================================================================
14
- DcaApiCasting.createdDcaOrderEventFromOnChain = (eventOnChain) => {
15
- const fields = eventOnChain.parsedJson;
16
- return {
17
- orderId: utils_1.Helpers.addLeadingZeroesToType(fields.order_id),
18
- owner: utils_1.Helpers.addLeadingZeroesToType(fields.user),
19
- inputValue: BigInt(fields.input_amount),
20
- inputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.input_type).toString()),
21
- outputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.output_type).toString()),
22
- gasValue: BigInt(fields.gas_amount),
23
- frequencyMs: Number(fields.frequency_ms),
24
- startTimestampMs: Number(fields.start_timestamp_ms),
25
- amountPerTrade: BigInt(fields.amount_per_trade),
26
- maxAllowableSlippageBps: BigInt(fields.max_allowable_slippage_bps),
27
- minAmountOut: BigInt(fields.min_amount_out),
28
- maxAmountOut: BigInt(fields.max_amount_out),
29
- remainingTrades: BigInt(fields.remaining_trades),
30
- timestamp: eventOnChain.timestampMs,
31
- txnDigest: eventOnChain.id.txDigest,
32
- type: eventOnChain.type,
33
- recipient: utils_1.Helpers.addLeadingZeroesToType(fields.recipient),
34
- };
35
- };
36
- DcaApiCasting.closedDcaOrderEventFromOnChain = (eventOnChain) => {
37
- const fields = eventOnChain.parsedJson;
38
- return {
39
- orderId: utils_1.Helpers.addLeadingZeroesToType(fields.order_id),
40
- owner: utils_1.Helpers.addLeadingZeroesToType(fields.user),
41
- remainingValue: BigInt(fields.remaining_amount),
42
- inputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.input_type).toString()),
43
- outputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.output_type).toString()),
44
- gasValue: BigInt(fields.gas_amount),
45
- frequencyMs: Number(fields.frequency_ms),
46
- lastTradeTimestampMs: Number(fields.last_trade_timestamp_ms),
47
- amountPerTrade: BigInt(fields.amount_per_trade),
48
- maxAllowableSlippageBps: BigInt(fields.max_allowable_slippage_bps),
49
- minAmountOut: BigInt(fields.min_amount_out),
50
- maxAmountOut: BigInt(fields.max_amount_out),
51
- remainingTrades: BigInt(fields.remaining_trades),
52
- timestamp: eventOnChain.timestampMs,
53
- txnDigest: eventOnChain.id.txDigest,
54
- type: eventOnChain.type,
55
- };
56
- };
57
- DcaApiCasting.executedTradeEventFromOnChain = (eventOnChain) => {
58
- const fields = eventOnChain.parsedJson;
59
- return {
60
- orderId: utils_1.Helpers.addLeadingZeroesToType(fields.order_id),
61
- user: utils_1.Helpers.addLeadingZeroesToType(fields.user),
62
- inputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.input_type).toString()),
63
- inputAmount: BigInt(fields.input_amount),
64
- outputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.output_type).toString()),
65
- outputAmount: BigInt(fields.output_amount),
66
- timestamp: eventOnChain.timestampMs,
67
- txnDigest: eventOnChain.id.txDigest,
68
- type: eventOnChain.type,
69
- };
70
- };
71
- // =========================================================================
72
- // Indexer
73
- // =========================================================================
74
- DcaApiCasting.createdOrderEventOnIndexer = (response) => {
75
- const totalOrdersAmount = Number(response.orders_num);
76
- const ordersLeft = Number(response.orders_left);
77
- const progress = totalOrdersAmount > 0
78
- ? (totalOrdersAmount - ordersLeft) / totalOrdersAmount
79
- : 1;
80
- const inputCoinType = utils_1.Helpers.addLeadingZeroesToType(String(response.coin_sell));
81
- const outputCoinType = utils_1.Helpers.addLeadingZeroesToType(String(response.coin_buy));
82
- const strategy = BigInt(response.min_amount_out) === BigInt(0) &&
83
- BigInt(response.max_amount_out) === utils_1.Casting.u64MaxBigInt
84
- ? undefined
85
- : {
86
- minPrice: BigInt(response.min_amount_out),
87
- maxPrice: BigInt(response.max_amount_out),
88
- };
89
- const { totalSpent, totalBought } = response.trades.reduce((total, order) => {
90
- total.totalSpent += BigInt(order.input_amount);
91
- total.totalBought += BigInt(order.output_amount);
92
- return total;
93
- }, {
94
- totalSpent: BigInt(0),
95
- totalBought: BigInt(0),
96
- });
97
- const tradesPrepared = response.trades.map((trade) => {
98
- return _a.createdOrderTradeEventOnIndexer(trade, inputCoinType, outputCoinType);
99
- });
100
- const started = tradesPrepared.length > 0
101
- ? {
102
- timestamp: tradesPrepared[0].tnxDate,
103
- digest: tradesPrepared[0].tnxDigest,
104
- }
105
- : {
106
- timestamp: Number(response.next_execution_timestamp_ms),
107
- digest: "",
108
- };
109
- const lastTrade = tradesPrepared.length > 0
110
- ? {
111
- timestamp: tradesPrepared[tradesPrepared.length - 1].tnxDate,
112
- digest: tradesPrepared[tradesPrepared.length - 1]
113
- .tnxDigest,
114
- }
115
- : undefined;
116
- const failed = response.failed.map((element) => {
117
- return {
118
- timestamp: element.timestamp_ms,
119
- reason: element.reason,
120
- };
121
- });
122
- const integratorFeeRecipient = response.integrator_fee_recipient.length === 0 ||
123
- response.integrator_fee_recipient === sui_1.Sui.constants.addresses.zero
124
- ? undefined
125
- : utils_1.Helpers.addLeadingZeroesToType(response.integrator_fee_recipient);
126
- return {
127
- objectId: utils_1.Helpers.addLeadingZeroesToType(response.order_object_id),
128
- overview: {
129
- allocatedCoin: {
130
- coin: inputCoinType,
131
- amount: BigInt(response.coin_sell_amount),
132
- },
133
- buyCoin: {
134
- coin: outputCoinType,
135
- amount: totalBought,
136
- },
137
- totalSpent: totalSpent,
138
- intervalMs: Number(response.frequency_ms),
139
- totalTrades: totalOrdersAmount,
140
- tradesRemaining: ordersLeft,
141
- maxSlippageBps: Number(response.slippage),
142
- strategy: strategy,
143
- progress: progress,
144
- recipient: utils_1.Helpers.addLeadingZeroesToType(response.recipient),
145
- created: {
146
- time: response.created.timestamp,
147
- tnxDigest: response.created.tx_digest,
148
- },
149
- nextTrade: {
150
- time: started.timestamp,
151
- tnxDigest: started.digest,
152
- },
153
- lastExecutedTrade: lastTrade
154
- ? {
155
- time: lastTrade.timestamp,
156
- tnxDigest: lastTrade.digest,
157
- }
158
- : undefined,
159
- integratorFee: !integratorFeeRecipient
160
- ? undefined
161
- : {
162
- feeBps: response.integrator_fee_bps,
163
- feeRecipient: integratorFeeRecipient,
164
- },
165
- },
166
- failed: failed,
167
- trades: tradesPrepared,
168
- };
169
- };
170
- DcaApiCasting.createdOrderTradeEventOnIndexer = (response, inputCoinType, outputCoinType) => {
171
- const inputAmount = BigInt(response.input_amount);
172
- const outputAmount = BigInt(response.output_amount);
173
- return {
174
- allocatedCoin: {
175
- coin: inputCoinType,
176
- amount: inputAmount,
177
- },
178
- buyCoin: {
179
- coin: outputCoinType,
180
- amount: outputAmount,
181
- },
182
- tnxDigest: response.event.tx_digest,
183
- tnxDate: response.event.timestamp,
184
- rate: undefined,
185
- };
186
- };