@nadohq/client 0.1.0-alpha.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/apis/base.cjs.map +1 -1
  2. package/dist/apis/base.js.map +1 -1
  3. package/dist/apis/market/MarketExecuteAPI.cjs +45 -0
  4. package/dist/apis/market/MarketExecuteAPI.cjs.map +1 -1
  5. package/dist/apis/market/MarketExecuteAPI.d.cts +15 -4
  6. package/dist/apis/market/MarketExecuteAPI.d.ts +15 -4
  7. package/dist/apis/market/MarketExecuteAPI.js +45 -0
  8. package/dist/apis/market/MarketExecuteAPI.js.map +1 -1
  9. package/dist/apis/market/MarketQueryAPI.d.cts +2 -1
  10. package/dist/apis/market/MarketQueryAPI.d.ts +2 -1
  11. package/dist/apis/market/index.d.cts +2 -1
  12. package/dist/apis/market/index.d.ts +2 -1
  13. package/dist/apis/market/types.cjs.map +1 -1
  14. package/dist/apis/market/types.d.cts +9 -1
  15. package/dist/apis/market/types.d.ts +9 -1
  16. package/dist/apis/spot/BaseSpotAPI.cjs +1 -2
  17. package/dist/apis/spot/BaseSpotAPI.cjs.map +1 -1
  18. package/dist/apis/spot/BaseSpotAPI.js +4 -2
  19. package/dist/apis/spot/BaseSpotAPI.js.map +1 -1
  20. package/dist/apis/spot/SpotExecuteAPI.cjs +2 -3
  21. package/dist/apis/spot/SpotExecuteAPI.cjs.map +1 -1
  22. package/dist/apis/spot/SpotExecuteAPI.js +3 -2
  23. package/dist/apis/spot/SpotExecuteAPI.js.map +1 -1
  24. package/dist/apis/spot/SpotQueryAPI.cjs +1 -1
  25. package/dist/apis/spot/SpotQueryAPI.cjs.map +1 -1
  26. package/dist/apis/spot/SpotQueryAPI.d.cts +5 -4
  27. package/dist/apis/spot/SpotQueryAPI.d.ts +5 -4
  28. package/dist/apis/spot/SpotQueryAPI.js +2 -2
  29. package/dist/apis/spot/SpotQueryAPI.js.map +1 -1
  30. package/dist/apis/spot/index.d.cts +1 -0
  31. package/dist/apis/spot/index.d.ts +1 -0
  32. package/dist/apis/spot/types.cjs.map +1 -1
  33. package/dist/apis/spot/types.d.cts +3 -3
  34. package/dist/apis/spot/types.d.ts +3 -3
  35. package/dist/apis/subaccount/index.cjs +1 -2
  36. package/dist/apis/subaccount/index.cjs.map +1 -1
  37. package/dist/apis/subaccount/index.js +4 -2
  38. package/dist/apis/subaccount/index.js.map +1 -1
  39. package/dist/apis/subaccount/types.cjs.map +1 -1
  40. package/dist/apis/subaccount/types.d.cts +1 -1
  41. package/dist/apis/subaccount/types.d.ts +1 -1
  42. package/dist/apis/ws/WebSocketExecuteAPI.cjs.map +1 -1
  43. package/dist/apis/ws/WebSocketExecuteAPI.js.map +1 -1
  44. package/dist/apis/ws/index.d.cts +1 -1
  45. package/dist/apis/ws/index.d.ts +1 -1
  46. package/dist/client.d.cts +1 -0
  47. package/dist/client.d.ts +1 -0
  48. package/dist/context.cjs +1 -1
  49. package/dist/context.cjs.map +1 -1
  50. package/dist/context.d.cts +1 -1
  51. package/dist/context.d.ts +1 -1
  52. package/dist/context.js +4 -4
  53. package/dist/context.js.map +1 -1
  54. package/dist/createNadoClient.d.cts +3 -2
  55. package/dist/createNadoClient.d.ts +3 -2
  56. package/dist/index.cjs +4 -4
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +4 -3
  59. package/dist/index.d.ts +4 -3
  60. package/dist/index.js +2 -2
  61. package/dist/index.js.map +1 -1
  62. package/package.json +15 -9
  63. package/src/apis/base.ts +1 -2
  64. package/src/apis/market/MarketExecuteAPI.ts +52 -0
  65. package/src/apis/market/types.ts +10 -0
  66. package/src/apis/spot/BaseSpotAPI.ts +5 -3
  67. package/src/apis/spot/SpotExecuteAPI.ts +2 -1
  68. package/src/apis/spot/SpotQueryAPI.ts +4 -3
  69. package/src/apis/spot/types.ts +3 -3
  70. package/src/apis/subaccount/index.ts +4 -2
  71. package/src/apis/subaccount/types.ts +1 -1
  72. package/src/apis/ws/WebSocketExecuteAPI.ts +1 -1
  73. package/src/context.ts +5 -5
  74. package/src/index.ts +2 -2
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- export { createNadoClient } from './createNadoClient.js';
2
1
  export { NadoClient } from './client.js';
3
2
  export { CreateNadoClientContextAccountOpts, CreateNadoClientContextOpts, NadoClientContext, createClientContext } from './context.js';
3
+ export { createNadoClient } from './createNadoClient.js';
4
4
  export { MarketAPI } from './apis/market/index.js';
5
5
  export { PerpAPI } from './apis/perp/index.js';
6
6
  export { SpotAPI } from './apis/spot/index.js';
7
7
  export { SubaccountAPI } from './apis/subaccount/index.js';
8
- export * from '@nadohq/shared';
9
8
  export * from '@nadohq/engine-client';
10
9
  export * from '@nadohq/indexer-client';
10
+ export * from '@nadohq/shared';
11
11
  export * from '@nadohq/trigger-client';
12
- export { CancelAndPlaceOrderParams, CancelOrdersParams, CancelProductOrdersParams, CancelTriggerOrdersParams, CancelTriggerProductOrdersParams, GetTriggerOrdersParams, PlaceOrderParams, PlaceTriggerOrderParams } from './apis/market/types.js';
13
12
  export { ApproveAllowanceParams, BurnNlpParams, GetTokenAllowanceParams, GetTokenWalletBalanceParams, MintMockERC20Params, MintNlpParams, ProductIdOrTokenAddress, TransferQuoteParams, WithdrawCollateralParams } from './apis/spot/types.js';
13
+ export { CancelAndPlaceOrderParams, CancelOrdersParams, CancelProductOrdersParams, CancelTriggerOrdersParams, CancelTriggerProductOrdersParams, GetTriggerOrdersParams, PlaceOrderParams, PlaceOrdersParams, PlaceTriggerOrderParams, PlaceTriggerOrdersParams } from './apis/market/types.js';
14
14
  export { CreateStandardLinkedSignerResult, LinkSignerParams, LiquidateSubaccountParams } from './apis/subaccount/types.js';
15
15
  import './apis/ws/index.js';
16
16
  import './apis/base.js';
@@ -22,6 +22,7 @@ import 'ts-mixer/dist/types/types';
22
22
  import './apis/market/MarketExecuteAPI.js';
23
23
  import './apis/types.js';
24
24
  import './apis/market/MarketQueryAPI.js';
25
+ import 'bignumber.js';
25
26
  import './apis/perp/PerpExecuteAPI.js';
26
27
  import './apis/perp/PerpQueryAPI.js';
27
28
  import './apis/spot/SpotExecuteAPI.js';
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  // src/index.ts
2
- export * from "./createNadoClient.js";
3
2
  export * from "./client.js";
4
3
  export * from "./context.js";
4
+ export * from "./createNadoClient.js";
5
5
  export * from "./apis/market/index.js";
6
6
  export * from "./apis/perp/index.js";
7
7
  export * from "./apis/spot/index.js";
8
8
  export * from "./apis/subaccount/index.js";
9
- export * from "@nadohq/shared";
10
9
  export * from "@nadohq/engine-client";
11
10
  export * from "@nadohq/indexer-client";
11
+ export * from "@nadohq/shared";
12
12
  export * from "@nadohq/trigger-client";
13
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './createNadoClient';\nexport * from './client';\nexport * from './context';\n\nexport * from './apis/market';\nexport * from './apis/perp';\nexport * from './apis/spot';\nexport * from './apis/subaccount';\n\n// Subpackage exports\nexport * from '@nadohq/shared';\nexport * from '@nadohq/engine-client';\nexport * from '@nadohq/indexer-client';\nexport * from '@nadohq/trigger-client';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './client';\nexport * from './context';\nexport * from './createNadoClient';\n\nexport * from './apis/market';\nexport * from './apis/perp';\nexport * from './apis/spot';\nexport * from './apis/subaccount';\n\n// Subpackage exports\nexport * from '@nadohq/engine-client';\nexport * from '@nadohq/indexer-client';\nexport * from '@nadohq/shared';\nexport * from '@nadohq/trigger-client';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/client",
3
- "version": "0.1.0-alpha.8",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "> TODO: description",
@@ -36,18 +36,24 @@
36
36
  }
37
37
  }
38
38
  },
39
+ "react-native": "./dist/index.js",
40
+ "main": "./dist/index.cjs",
41
+ "module": "./dist/index.js",
42
+ "types": "./dist/index.d.ts",
39
43
  "dependencies": {
40
- "@nadohq/engine-client": "^0.1.0-alpha.8",
41
- "@nadohq/indexer-client": "^0.1.0-alpha.8",
42
- "@nadohq/shared": "^0.1.0-alpha.8",
43
- "@nadohq/trigger-client": "^0.1.0-alpha.8",
44
- "ts-mixer": "*"
44
+ "@nadohq/engine-client": "0.1.0",
45
+ "@nadohq/indexer-client": "0.1.0",
46
+ "@nadohq/shared": "0.1.0",
47
+ "@nadohq/trigger-client": "0.1.0",
48
+ "ts-mixer": "catalog:"
45
49
  },
46
50
  "peerDependencies": {
47
- "viem": "*"
51
+ "bignumber.js": "catalog:",
52
+ "viem": "catalog:"
48
53
  },
49
54
  "devDependencies": {
50
- "viem": "*"
55
+ "bignumber.js": "catalog:",
56
+ "viem": "catalog:"
51
57
  },
52
- "gitHead": "3488a83313ef5c199b2fc9a3cd70f477e80e74db"
58
+ "gitHead": "be24947f588c4fcc294607e985e572c81760f45a"
53
59
  }
package/src/apis/base.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { WithContracts } from '@nadohq/shared';
2
- import { WalletNotProvidedError } from '@nadohq/shared';
1
+ import { WalletNotProvidedError, WithContracts } from '@nadohq/shared';
3
2
 
4
3
  import { NadoClientContext } from '../context';
5
4
 
@@ -1,3 +1,4 @@
1
+ import { EngineServerExecuteSuccessResult } from '@nadohq/engine-client';
1
2
  import { getOrderVerifyingAddress } from '@nadohq/shared';
2
3
  import { BaseNadoAPI } from '../base';
3
4
  import {
@@ -7,7 +8,9 @@ import {
7
8
  CancelTriggerOrdersParams,
8
9
  CancelTriggerProductOrdersParams,
9
10
  PlaceOrderParams,
11
+ PlaceOrdersParams,
10
12
  PlaceTriggerOrderParams,
13
+ PlaceTriggerOrdersParams,
11
14
  } from './types';
12
15
 
13
16
  export class MarketExecuteAPI extends BaseNadoAPI {
@@ -32,6 +35,33 @@ export class MarketExecuteAPI extends BaseNadoAPI {
32
35
  });
33
36
  }
34
37
 
38
+ /**
39
+ * Places multiple orders through the engine
40
+ * @param params
41
+ */
42
+ async placeOrders(
43
+ params: PlaceOrdersParams,
44
+ ): Promise<EngineServerExecuteSuccessResult<'place_orders'>> {
45
+ return this.context.engineClient.placeOrders({
46
+ orders: params.orders.map((orderParams) => {
47
+ const { id, productId, order, nonce, spotLeverage } = orderParams;
48
+ return {
49
+ id,
50
+ order: {
51
+ ...order,
52
+ subaccountOwner: this.getSubaccountOwnerIfNeeded(order),
53
+ },
54
+ chainId: this.getWalletClientChainIdIfNeeded(orderParams),
55
+ verifyingAddr: getOrderVerifyingAddress(productId),
56
+ productId,
57
+ spotLeverage,
58
+ nonce,
59
+ };
60
+ }),
61
+ stopOnFailure: params.stopOnFailure,
62
+ });
63
+ }
64
+
35
65
  /**
36
66
  * Cancels orders through the engine
37
67
  * @param params
@@ -107,6 +137,28 @@ export class MarketExecuteAPI extends BaseNadoAPI {
107
137
  });
108
138
  }
109
139
 
140
+ /**
141
+ * Places multiple trigger orders through the trigger service
142
+ * @param params
143
+ */
144
+ async placeTriggerOrders(params: PlaceTriggerOrdersParams) {
145
+ return this.context.triggerClient.placeTriggerOrders({
146
+ orders: params.orders.map((orderParams) => {
147
+ const { productId, order } = orderParams;
148
+ return {
149
+ ...orderParams,
150
+ chainId: this.getWalletClientChainIdIfNeeded(orderParams),
151
+ verifyingAddr: getOrderVerifyingAddress(productId),
152
+ order: {
153
+ subaccountOwner: this.getSubaccountOwnerIfNeeded(order),
154
+ ...order,
155
+ },
156
+ };
157
+ }),
158
+ stopOnFailure: params.stopOnFailure,
159
+ });
160
+ }
161
+
110
162
  /**
111
163
  * Cancels all trigger orders for provided digests through the trigger service.
112
164
  * @param params
@@ -24,6 +24,11 @@ type ClientOrderParams<T extends { order: EngineOrderParams }> = Omit<
24
24
 
25
25
  export type PlaceOrderParams = ClientOrderParams<EnginePlaceOrderParams>;
26
26
 
27
+ export type PlaceOrdersParams = {
28
+ orders: PlaceOrderParams[];
29
+ stopOnFailure?: boolean;
30
+ };
31
+
27
32
  export type CancelOrdersParams = OptionalSignatureParams<
28
33
  OptionalSubaccountOwner<EngineCancelOrdersParams>
29
34
  >;
@@ -40,6 +45,11 @@ export interface CancelAndPlaceOrderParams {
40
45
  export type PlaceTriggerOrderParams =
41
46
  ClientOrderParams<TriggerPlaceOrderParams>;
42
47
 
48
+ export interface PlaceTriggerOrdersParams {
49
+ orders: PlaceTriggerOrderParams[];
50
+ stopOnFailure?: boolean;
51
+ }
52
+
43
53
  export type CancelTriggerOrdersParams = OptionalSignatureParams<
44
54
  OptionalSubaccountOwner<TriggerCancelOrdersParams>
45
55
  >;
@@ -1,6 +1,8 @@
1
- import { ERC20_ABI } from '@nadohq/shared';
2
- import { ContractInstance } from '@nadohq/shared';
3
- import { getValidatedAddress } from '@nadohq/shared';
1
+ import {
2
+ ContractInstance,
3
+ ERC20_ABI,
4
+ getValidatedAddress,
5
+ } from '@nadohq/shared';
4
6
  import { getContract } from 'viem';
5
7
  import { BaseNadoAPI } from '../base';
6
8
  import { ProductIdOrTokenAddress } from './types';
@@ -4,8 +4,9 @@ import {
4
4
  DepositCollateralParams,
5
5
  isWriteableContract,
6
6
  MOCK_ERC20_ABI,
7
+ toBigInt,
8
+ WalletNotProvidedError,
7
9
  } from '@nadohq/shared';
8
- import { toBigInt, WalletNotProvidedError } from '@nadohq/shared';
9
10
  import { BaseSpotAPI } from './BaseSpotAPI';
10
11
  import {
11
12
  ApproveAllowanceParams,
@@ -2,7 +2,8 @@ import {
2
2
  GetEngineMaxMintNlpAmountParams,
3
3
  GetEngineMaxWithdrawableParams,
4
4
  } from '@nadohq/engine-client';
5
- import { BigDecimal, getValidatedAddress, toBigDecimal } from '@nadohq/shared';
5
+ import { getValidatedAddress, toBigNumber } from '@nadohq/shared';
6
+ import BigNumber from 'bignumber.js';
6
7
  import { BaseSpotAPI } from './BaseSpotAPI';
7
8
  import { GetTokenAllowanceParams, GetTokenWalletBalanceParams } from './types';
8
9
 
@@ -41,9 +42,9 @@ export class SpotQueryAPI extends BaseSpotAPI {
41
42
  async getTokenAllowance({
42
43
  address,
43
44
  ...rest
44
- }: GetTokenAllowanceParams): Promise<BigDecimal> {
45
+ }: GetTokenAllowanceParams): Promise<BigNumber> {
45
46
  const token = await this.getTokenContractForProduct(rest);
46
- return toBigDecimal(
47
+ return toBigNumber(
47
48
  await token.read.allowance([
48
49
  getValidatedAddress(address),
49
50
  this.getEndpointAddress(),
@@ -4,7 +4,7 @@ import {
4
4
  EngineTransferQuoteParams,
5
5
  EngineWithdrawCollateralParams,
6
6
  } from '@nadohq/engine-client';
7
- import { BigDecimalish } from '@nadohq/shared';
7
+ import { BigNumberish } from '@nadohq/shared';
8
8
  import { OptionalSignatureParams, OptionalSubaccountOwner } from '../types';
9
9
 
10
10
  export type ProductIdOrTokenAddress =
@@ -20,7 +20,7 @@ type TokenQueryParams = {
20
20
  } & ProductIdOrTokenAddress;
21
21
 
22
22
  export type ApproveAllowanceParams = ProductIdOrTokenAddress & {
23
- amount: BigDecimalish;
23
+ amount: BigNumberish;
24
24
  };
25
25
 
26
26
  export type GetTokenWalletBalanceParams = TokenQueryParams;
@@ -45,5 +45,5 @@ export type BurnNlpParams = OptionalSignatureParams<
45
45
 
46
46
  export interface MintMockERC20Params {
47
47
  productId: number;
48
- amount: BigDecimalish;
48
+ amount: BigNumberish;
49
49
  }
@@ -1,5 +1,7 @@
1
- import { createDeterministicLinkedSignerPrivateKey } from '@nadohq/shared';
2
- import { WalletNotProvidedError } from '@nadohq/shared';
1
+ import {
2
+ createDeterministicLinkedSignerPrivateKey,
3
+ WalletNotProvidedError,
4
+ } from '@nadohq/shared';
3
5
  import { Mixin } from 'ts-mixer';
4
6
  import { privateKeyToAccount } from 'viem/accounts';
5
7
  import { SubaccountExecuteAPI } from './SubaccountExecuteAPI';
@@ -1,8 +1,8 @@
1
- import { AccountWithPrivateKey } from '@nadohq/shared';
2
1
  import {
3
2
  EngineLinkSignerParams,
4
3
  EngineLiquidateSubaccountParams,
5
4
  } from '@nadohq/engine-client';
5
+ import { AccountWithPrivateKey } from '@nadohq/shared';
6
6
  import { OptionalSignatureParams, OptionalSubaccountOwner } from '../types';
7
7
 
8
8
  export type LinkSignerParams = OptionalSignatureParams<
@@ -1,8 +1,8 @@
1
- import { EIP712OrderParams } from '@nadohq/shared';
2
1
  import {
3
2
  EngineExecuteRequestParamsByType,
4
3
  WithSignature,
5
4
  } from '@nadohq/engine-client';
5
+ import { EIP712OrderParams } from '@nadohq/shared';
6
6
  import { BaseNadoAPI } from '../base';
7
7
 
8
8
  /**
package/src/context.ts CHANGED
@@ -1,3 +1,8 @@
1
+ import { ENGINE_CLIENT_ENDPOINTS, EngineClient } from '@nadohq/engine-client';
2
+ import {
3
+ INDEXER_CLIENT_ENDPOINTS,
4
+ IndexerClient,
5
+ } from '@nadohq/indexer-client';
1
6
  import {
2
7
  ChainEnv,
3
8
  NADO_ABIS,
@@ -7,11 +12,6 @@ import {
7
12
  NadoDeploymentAddresses,
8
13
  WalletClientWithAccount,
9
14
  } from '@nadohq/shared';
10
- import { ENGINE_CLIENT_ENDPOINTS, EngineClient } from '@nadohq/engine-client';
11
- import {
12
- INDEXER_CLIENT_ENDPOINTS,
13
- IndexerClient,
14
- } from '@nadohq/indexer-client';
15
15
  import {
16
16
  TRIGGER_CLIENT_ENDPOINTS,
17
17
  TriggerClient,
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './createNadoClient';
2
1
  export * from './client';
3
2
  export * from './context';
3
+ export * from './createNadoClient';
4
4
 
5
5
  export * from './apis/market';
6
6
  export * from './apis/perp';
@@ -8,7 +8,7 @@ export * from './apis/spot';
8
8
  export * from './apis/subaccount';
9
9
 
10
10
  // Subpackage exports
11
- export * from '@nadohq/shared';
12
11
  export * from '@nadohq/engine-client';
13
12
  export * from '@nadohq/indexer-client';
13
+ export * from '@nadohq/shared';
14
14
  export * from '@nadohq/trigger-client';