@dydxprotocol/v4-client-js 1.0.28 → 1.1.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 (63) hide show
  1. package/__native__/__ios__/v4-native-client.js +1428 -55
  2. package/build/examples/gov_add_new_market.js +3 -1
  3. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/cosmos/bundle.d.ts +158 -158
  4. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/cosmos/bundle.js +126 -126
  5. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/bundle.d.ts +789 -584
  6. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/bundle.js +170 -155
  7. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/block_rate_limit_config.d.ts +8 -0
  8. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/block_rate_limit_config.js +11 -3
  9. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.d.ts +49 -0
  10. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.js +93 -2
  11. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.rpc.Query.d.ts +5 -1
  12. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.rpc.Query.js +10 -1
  13. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/tx.d.ts +81 -0
  14. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/tx.js +153 -2
  15. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/tx.rpc.msg.d.ts +4 -1
  16. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/tx.rpc.msg.js +7 -1
  17. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/events/events.d.ts +7 -3
  18. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/events/events.js +16 -8
  19. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/protocol/v1/perpetual.d.ts +16 -0
  20. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/protocol/v1/perpetual.js +51 -0
  21. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/perpetuals/perpetual.d.ts +31 -0
  22. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/perpetuals/perpetual.js +82 -7
  23. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.query.d.ts +2 -0
  24. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.query.js +2 -1
  25. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.tx.d.ts +1 -0
  26. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.tx.js +2 -1
  27. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/subaccount.d.ts +2 -2
  28. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/genesis.d.ts +13 -0
  29. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/genesis.js +54 -0
  30. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.d.ts +1 -0
  31. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.js +3 -0
  32. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.rpc.Query.d.ts +10 -0
  33. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.rpc.Query.js +17 -0
  34. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.d.ts +35 -0
  35. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.js +108 -0
  36. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.rpc.msg.d.ts +12 -0
  37. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.rpc.msg.js +41 -0
  38. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/vault.d.ts +44 -0
  39. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/vault.js +145 -0
  40. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/gogoproto/bundle.js +2 -2
  41. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/google/bundle.d.ts +174 -174
  42. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/google/bundle.js +12 -12
  43. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/tendermint/bundle.d.ts +365 -365
  44. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/tendermint/bundle.js +22 -22
  45. package/build/src/clients/composite-client.js +2 -2
  46. package/build/src/clients/modules/composer.d.ts +2 -1
  47. package/build/src/clients/modules/composer.js +3 -2
  48. package/build/src/clients/modules/get.d.ts +1 -1
  49. package/build/src/clients/modules/get.js +5 -3
  50. package/build/src/clients/native.d.ts +2 -0
  51. package/build/src/clients/native.js +24 -2
  52. package/build/src/clients/types.d.ts +2 -0
  53. package/build/src/clients/types.js +1 -1
  54. package/examples/gov_add_new_market.ts +2 -0
  55. package/package.json +2 -2
  56. package/src/clients/composite-client.ts +1 -0
  57. package/src/clients/modules/composer.ts +3 -0
  58. package/src/clients/modules/get.ts +4 -2
  59. package/src/clients/native.ts +20 -0
  60. package/src/clients/types.ts +3 -0
  61. package/src/codegen/helpers.ts +242 -0
  62. package/src/codegen/index.ts +6 -0
  63. package/dydxprotocol-v4-client-js-1.0.10.tgz +0 -0
@@ -1,3 +1,4 @@
1
+ import { PerpetualMarketType } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/perpetuals/perpetual';
1
2
  import Long from 'long';
2
3
 
3
4
  import { GovAddNewMarketParams, LocalWallet, ProposalStatus } from '../src';
@@ -30,6 +31,7 @@ const MOCK_DATA: GovAddNewMarketParams = {
30
31
  // x/perpetuals
31
32
  liquidityTier: 2,
32
33
  atomicResolution: -1,
34
+ marketType: PerpetualMarketType.PERPETUAL_MARKET_TYPE_CROSS,
33
35
 
34
36
  // x/clob
35
37
  quantumConversionExponent: -9,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dydxprotocol/v4-client-js",
3
- "version": "1.0.28",
3
+ "version": "1.1.1",
4
4
  "description": "General client library for the new dYdX system (v4 decentralized)",
5
5
  "main": "build/src/index.js",
6
6
  "scripts": {
@@ -37,7 +37,7 @@
37
37
  "@cosmjs/stargate": "^0.32.1",
38
38
  "@cosmjs/tendermint-rpc": "^0.32.1",
39
39
  "@cosmjs/utils": "^0.32.1",
40
- "@dydxprotocol/v4-proto": "4.0.0-dev.0",
40
+ "@dydxprotocol/v4-proto": "5.0.0-dev.0",
41
41
  "@osmonauts/lcd": "^0.6.0",
42
42
  "@scure/bip32": "^1.1.5",
43
43
  "@scure/bip39": "^1.1.1",
@@ -1065,6 +1065,7 @@ export class CompositeClient {
1065
1065
  params.ticker,
1066
1066
  params.atomicResolution,
1067
1067
  params.liquidityTier,
1068
+ params.marketType,
1068
1069
  );
1069
1070
 
1070
1071
  // x/clob.MsgCreateClobPair
@@ -10,6 +10,7 @@ import {
10
10
  MsgUpdateClobPair,
11
11
  } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/tx';
12
12
  import { MsgDelayMessage } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/delaymsg/tx';
13
+ import { PerpetualMarketType } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/perpetuals/perpetual';
13
14
  import { MsgCreatePerpetual } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/perpetuals/tx';
14
15
  import { MsgCreateOracleMarket } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/prices/tx';
15
16
  import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx';
@@ -342,6 +343,7 @@ export class Composer {
342
343
  ticker: string,
343
344
  atomicResolution: number,
344
345
  liquidityTier: number,
346
+ marketType: PerpetualMarketType,
345
347
  ): EncodeObject {
346
348
  const msg: MsgCreatePerpetual = {
347
349
  // uses x/gov module account since creating the perpetual is a governance action.
@@ -353,6 +355,7 @@ export class Composer {
353
355
  atomicResolution,
354
356
  defaultFundingPpm: 0, // default funding should be 0 to start.
355
357
  liquidityTier,
358
+ marketType,
356
359
  },
357
360
  };
358
361
 
@@ -13,6 +13,7 @@ import { Any } from 'cosmjs-types/google/protobuf/any';
13
13
  import Long from 'long';
14
14
  import protobuf from 'protobufjs';
15
15
 
16
+ import { ByteArrayEncoding, encodeJson } from '../../lib/helpers';
16
17
  import { PAGE_REQUEST } from '../constants';
17
18
  import { UnexpectedClientError } from '../lib/errors';
18
19
  import {
@@ -504,7 +505,7 @@ export class Get {
504
505
  return GovV1Module.QueryProposalsResponse.decode(data);
505
506
  }
506
507
 
507
- async GetWithdrawalAndTransferGatingStatus(
508
+ async getWithdrawalAndTransferGatingStatus(
508
509
  ): Promise<SubaccountsModule.QueryGetWithdrawalAndTransfersBlockedInfoResponse> {
509
510
  const requestData = Uint8Array.from(
510
511
  SubaccountsModule.QueryGetWithdrawalAndTransfersBlockedInfoRequest
@@ -536,7 +537,8 @@ export class Get {
536
537
  requestData,
537
538
  );
538
539
 
539
- return RateLimitModule.QueryCapacityByDenomResponse.decode(data);
540
+ const decodedResponse = RateLimitModule.QueryCapacityByDenomResponse.decode(data);
541
+ return JSON.parse(encodeJson(decodedResponse, ByteArrayEncoding.BIGINT));
540
542
  }
541
543
 
542
544
  private async sendQuery(requestUrl: string, requestData: Uint8Array): Promise<Uint8Array> {
@@ -1184,3 +1184,23 @@ export async function cctpWithdraw(squidPayload: string): Promise<String> {
1184
1184
  return wrappedError(error);
1185
1185
  }
1186
1186
  }
1187
+
1188
+ export async function getWithdrawalCapacityByDenom(denom: string): Promise<string> {
1189
+ try {
1190
+ const validatorClient = globalThis.client.validatorClient;
1191
+ const result = await validatorClient.get.getWithdrawalCapacityByDenom(denom);
1192
+ return encodeJson(result, ByteArrayEncoding.BIGINT);
1193
+ } catch (e) {
1194
+ return wrappedError(e);
1195
+ }
1196
+ }
1197
+
1198
+ export async function getWithdrawalAndTransferGatingStatus(): Promise<string> {
1199
+ try {
1200
+ const validatorClient = globalThis.client.validatorClient;
1201
+ const result = await validatorClient.get.getWithdrawalAndTransferGatingStatus();
1202
+ return encodeJson(result, ByteArrayEncoding.BIGINT);
1203
+ } catch (e) {
1204
+ return wrappedError(e);
1205
+ }
1206
+ }
@@ -1,6 +1,7 @@
1
1
  import { Coin } from '@cosmjs/proto-signing';
2
2
  import { Method } from '@cosmjs/tendermint-rpc';
3
3
  import { Order_ConditionType, Order_Side, Order_TimeInForce } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';
4
+ import { PerpetualMarketType } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/perpetuals/perpetual';
4
5
  import BigNumber from 'bignumber.js';
5
6
  import Long from 'long';
6
7
 
@@ -111,6 +112,7 @@ export type SquidIBCPayload = {
111
112
  };
112
113
 
113
114
  // ------------ x/gov: Add New Market ------------ //
115
+
114
116
  export type GovAddNewMarketParams = {
115
117
  // common
116
118
  id: number;
@@ -125,6 +127,7 @@ export type GovAddNewMarketParams = {
125
127
  // x/perpetuals
126
128
  liquidityTier: number;
127
129
  atomicResolution: number;
130
+ marketType: PerpetualMarketType;
128
131
 
129
132
  // x/clob
130
133
  quantumConversionExponent: number;
@@ -0,0 +1,242 @@
1
+ /**
2
+ * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
+ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
+ * and run the transpile command or yarn proto command to regenerate this bundle.
5
+ */
6
+
7
+ import * as _m0 from "protobufjs/minimal";
8
+ import Long from 'long';
9
+
10
+ // @ts-ignore
11
+ if (_m0.util.Long !== Long) {
12
+ _m0.util.Long = (Long as any);
13
+
14
+ _m0.configure();
15
+ }
16
+
17
+ export { Long };
18
+
19
+ declare var self: any | undefined;
20
+ declare var window: any | undefined;
21
+ declare var global: any | undefined;
22
+ var globalThis: any = (() => {
23
+ if (typeof globalThis !== 'undefined') return globalThis;
24
+ if (typeof self !== 'undefined') return self;
25
+ if (typeof window !== 'undefined') return window;
26
+ if (typeof global !== 'undefined') return global;
27
+ throw 'Unable to locate global object';
28
+ })();
29
+
30
+ const atob: (b64: string) => string =
31
+ globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
32
+
33
+ export function bytesFromBase64(b64: string): Uint8Array {
34
+ const bin = atob(b64);
35
+ const arr = new Uint8Array(bin.length);
36
+ for (let i = 0; i < bin.length; ++i) {
37
+ arr[i] = bin.charCodeAt(i);
38
+ }
39
+ return arr;
40
+ }
41
+
42
+ const btoa: (bin: string) => string =
43
+ globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
44
+
45
+ export function base64FromBytes(arr: Uint8Array): string {
46
+ const bin: string[] = [];
47
+ arr.forEach((byte) => {
48
+ bin.push(String.fromCharCode(byte));
49
+ });
50
+ return btoa(bin.join(''));
51
+ }
52
+
53
+ export interface AminoHeight {
54
+ readonly revision_number?: string;
55
+ readonly revision_height?: string;
56
+ };
57
+
58
+ export function omitDefault<T extends string | number | Long>(input: T): T | undefined {
59
+ if (typeof input === "string") {
60
+ return input === "" ? undefined : input;
61
+ }
62
+
63
+ if (typeof input === "number") {
64
+ return input === 0 ? undefined : input;
65
+ }
66
+
67
+ if (Long.isLong(input)) {
68
+ return input.isZero() ? undefined : input;
69
+ }
70
+
71
+ throw new Error(`Got unsupported type ${typeof input}`);
72
+ };
73
+
74
+ interface Duration {
75
+ /**
76
+ * Signed seconds of the span of time. Must be from -315,576,000,000
77
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
78
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
79
+ */
80
+ seconds: Long;
81
+ /**
82
+ * Signed fractions of a second at nanosecond resolution of the span
83
+ * of time. Durations less than one second are represented with a 0
84
+ * `seconds` field and a positive or negative `nanos` field. For durations
85
+ * of one second or more, a non-zero value for the `nanos` field must be
86
+ * of the same sign as the `seconds` field. Must be from -999,999,999
87
+ * to +999,999,999 inclusive.
88
+ */
89
+
90
+ nanos: number;
91
+ }
92
+
93
+ export function toDuration(duration: string): Duration {
94
+ return {
95
+ seconds: Long.fromNumber(Math.floor(parseInt(duration) / 1000000000)),
96
+ nanos: parseInt(duration) % 1000000000
97
+ };
98
+ };
99
+
100
+ export function fromDuration(duration: Duration): string {
101
+ return (parseInt(duration.seconds.toString()) * 1000000000 + duration.nanos).toString();
102
+ };
103
+
104
+ export function isSet(value: any): boolean {
105
+ return value !== null && value !== undefined;
106
+ };
107
+
108
+ export function isObject(value: any): boolean {
109
+ return typeof value === 'object' && value !== null;
110
+ };
111
+
112
+ export interface PageRequest {
113
+ key: Uint8Array;
114
+ offset: Long;
115
+ limit: Long;
116
+ countTotal: boolean;
117
+ reverse: boolean;
118
+ };
119
+
120
+ export interface PageRequestParams {
121
+ "pagination.key"?: string;
122
+ "pagination.offset"?: string;
123
+ "pagination.limit"?: string;
124
+ "pagination.count_total"?: boolean;
125
+ "pagination.reverse"?: boolean;
126
+ };
127
+
128
+ export interface Params {
129
+ params: PageRequestParams;
130
+ };
131
+
132
+ export const setPaginationParams = (options: Params, pagination?: PageRequest) => {
133
+
134
+ if (!pagination) {
135
+ return options;
136
+ }
137
+
138
+ if (typeof pagination?.countTotal !== "undefined") {
139
+ options.params['pagination.count_total'] = pagination.countTotal;
140
+ }
141
+ if (typeof pagination?.key !== "undefined") {
142
+ // String to Uint8Array
143
+ // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
144
+
145
+ // Uint8Array to String
146
+ options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
147
+ }
148
+ if (typeof pagination?.limit !== "undefined") {
149
+ options.params["pagination.limit"] = pagination.limit.toString()
150
+ }
151
+ if (typeof pagination?.offset !== "undefined") {
152
+ options.params["pagination.offset"] = pagination.offset.toString()
153
+ }
154
+ if (typeof pagination?.reverse !== "undefined") {
155
+ options.params['pagination.reverse'] = pagination.reverse;
156
+ }
157
+
158
+ return options;
159
+ };
160
+
161
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
162
+
163
+ export type DeepPartial<T> = T extends Builtin
164
+ ? T
165
+ : T extends Long
166
+ ? string | number | Long
167
+ : T extends Array<infer U>
168
+ ? Array<DeepPartial<U>>
169
+ : T extends ReadonlyArray<infer U>
170
+ ? ReadonlyArray<DeepPartial<U>>
171
+ : T extends {}
172
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
173
+ : Partial<T>;
174
+
175
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
176
+ export type Exact<P, I extends P> = P extends Builtin
177
+ ? P
178
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
179
+
180
+ export interface Rpc {
181
+ request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
182
+ };
183
+
184
+ interface Timestamp {
185
+ /**
186
+ * Represents seconds of UTC time since Unix epoch
187
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
188
+ * 9999-12-31T23:59:59Z inclusive.
189
+ */
190
+ seconds: Long;
191
+ /**
192
+ * Non-negative fractions of a second at nanosecond resolution. Negative
193
+ * second values with fractions must still have non-negative nanos values
194
+ * that count forward in time. Must be from 0 to 999,999,999
195
+ * inclusive.
196
+ */
197
+
198
+ nanos: number;
199
+ }
200
+
201
+ export function toTimestamp(date: Date): Timestamp {
202
+ const seconds = numberToLong(date.getTime() / 1_000);
203
+ const nanos = date.getTime() % 1000 * 1000000;
204
+ return {
205
+ seconds,
206
+ nanos
207
+ };
208
+ };
209
+
210
+ export function fromTimestamp(t: Timestamp): Date {
211
+ let millis = t.seconds.toNumber() * 1000;
212
+ millis += t.nanos / 1000000;
213
+ return new Date(millis);
214
+ };
215
+
216
+ const fromJSON = (object: any): Timestamp => {
217
+ return {
218
+ seconds: isSet(object.seconds) ? Long.fromString(object.seconds) : Long.ZERO,
219
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0
220
+ };
221
+ };
222
+
223
+ const timestampFromJSON = (object: any): Timestamp => {
224
+ return {
225
+ seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO,
226
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
227
+ };
228
+ }
229
+
230
+ export function fromJsonTimestamp(o: any): Timestamp {
231
+ if (o instanceof Date) {
232
+ return toTimestamp(o);
233
+ } else if (typeof o === "string") {
234
+ return toTimestamp(new Date(o));
235
+ } else {
236
+ return timestampFromJSON(o);
237
+ }
238
+ }
239
+
240
+ function numberToLong(number: number) {
241
+ return Long.fromNumber(number);
242
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
+ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
+ * and run the transpile command or yarn proto command to regenerate this bundle.
5
+ */
6
+