@d8x/perpetuals-sdk 0.1.10 → 0.1.12

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/bundle.js CHANGED
@@ -4072,20 +4072,23 @@ var PerpetualDataHandler = /** @class */ (function () {
4072
4072
  */
4073
4073
  PerpetualDataHandler.prototype._fillSymbolMaps = function (proxyContract) {
4074
4074
  return __awaiter(this, void 0, void 0, function () {
4075
- var _a, requiredPairs, _loop_1, this_1, j;
4075
+ var oracleFactoryAddr, _a, requiredPairs, _loop_1, this_1, j;
4076
4076
  return __generator(this, function (_b) {
4077
4077
  switch (_b.label) {
4078
4078
  case 0:
4079
4079
  if (proxyContract == null || this.lobFactoryContract == null) {
4080
4080
  throw Error("proxy or limit order book not defined");
4081
4081
  }
4082
+ return [4 /*yield*/, proxyContract.getOracleFactory()];
4083
+ case 1:
4084
+ oracleFactoryAddr = _b.sent();
4082
4085
  _a = this;
4083
4086
  return [4 /*yield*/, PerpetualDataHandler.getNestedPerpetualIds(proxyContract)];
4084
- case 1:
4087
+ case 2:
4085
4088
  _a.nestedPerpetualIDs = _b.sent();
4086
4089
  requiredPairs = new Set();
4087
4090
  _loop_1 = function (j) {
4088
- var pool, poolMarginTokenAddr, perpetualIDs, poolCCY, currentSymbols, currentSymbolsS3, currentLimitOrderBookAddr, ccy, initRate, mgnRate, lotSizes, refRebates, k, perp, base, quote, base3, quote3, sym, sym3, lobAddr, oracleFactoryAddr, info, currentSymbols3, k, idsB32, isPyth;
4091
+ var pool, poolMarginTokenAddr, perpetualIDs, poolCCY, currentSymbols, currentSymbolsS3, currentLimitOrderBookAddr, ccy, initRate, mgnRate, lotSizes, refRebates, k, perp, base, quote, base3, quote3, sym, sym3, lobAddr, info, currentSymbols3, k, idsB32, isPyth;
4089
4092
  var _c;
4090
4093
  return __generator(this, function (_d) {
4091
4094
  switch (_d.label) {
@@ -4157,9 +4160,6 @@ var PerpetualDataHandler = /** @class */ (function () {
4157
4160
  if (perpetualIDs.length == 0) {
4158
4161
  return [2 /*return*/, "continue"];
4159
4162
  }
4160
- return [4 /*yield*/, proxyContract.getOracleFactory()];
4161
- case 7:
4162
- oracleFactoryAddr = _d.sent();
4163
4163
  info = {
4164
4164
  poolId: j + 1,
4165
4165
  poolMarginSymbol: poolCCY,
@@ -4170,12 +4170,12 @@ var PerpetualDataHandler = /** @class */ (function () {
4170
4170
  this_1.poolStaticInfos.push(info);
4171
4171
  currentSymbols3 = currentSymbols.map(function (x) { return x + "-" + poolCCY; });
4172
4172
  k = 0;
4173
- _d.label = 8;
4174
- case 8:
4175
- if (!(k < perpetualIDs.length)) return [3 /*break*/, 11];
4173
+ _d.label = 7;
4174
+ case 7:
4175
+ if (!(k < perpetualIDs.length)) return [3 /*break*/, 10];
4176
4176
  idsB32 = void 0, isPyth = void 0;
4177
4177
  return [4 /*yield*/, proxyContract.getPriceInfo(perpetualIDs[k])];
4178
- case 9:
4178
+ case 8:
4179
4179
  _c = __read.apply(void 0, [_d.sent(), 2]), idsB32 = _c[0], isPyth = _c[1];
4180
4180
  this_1.symbolToPerpStaticInfo.set(currentSymbols3[k], {
4181
4181
  id: perpetualIDs[k],
@@ -4189,11 +4189,11 @@ var PerpetualDataHandler = /** @class */ (function () {
4189
4189
  referralRebate: refRebates[k],
4190
4190
  priceIds: idsB32,
4191
4191
  });
4192
- _d.label = 10;
4193
- case 10:
4192
+ _d.label = 9;
4193
+ case 9:
4194
4194
  k++;
4195
- return [3 /*break*/, 8];
4196
- case 11:
4195
+ return [3 /*break*/, 7];
4196
+ case 10:
4197
4197
  // push margin token address into map
4198
4198
  this_1.symbolToTokenAddrMap.set(poolCCY, poolMarginTokenAddr);
4199
4199
  return [2 /*return*/];
@@ -4202,17 +4202,17 @@ var PerpetualDataHandler = /** @class */ (function () {
4202
4202
  };
4203
4203
  this_1 = this;
4204
4204
  j = 0;
4205
- _b.label = 2;
4206
- case 2:
4207
- if (!(j < this.nestedPerpetualIDs.length)) return [3 /*break*/, 5];
4208
- return [5 /*yield**/, _loop_1(j)];
4205
+ _b.label = 3;
4209
4206
  case 3:
4210
- _b.sent();
4211
- _b.label = 4;
4207
+ if (!(j < this.nestedPerpetualIDs.length)) return [3 /*break*/, 6];
4208
+ return [5 /*yield**/, _loop_1(j)];
4212
4209
  case 4:
4213
- j++;
4214
- return [3 /*break*/, 2];
4210
+ _b.sent();
4211
+ _b.label = 5;
4215
4212
  case 5:
4213
+ j++;
4214
+ return [3 /*break*/, 3];
4215
+ case 6:
4216
4216
  // pre-calculate all triangulation paths so we can easily get from
4217
4217
  // the prices of price-feeds to the index price required, e.g.
4218
4218
  // BTC-USDC : BTC-USD / USDC-USD
@@ -6810,7 +6810,7 @@ exports.containsFlag = containsFlag;
6810
6810
 
6811
6811
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6812
6812
  exports.D8X_SDK_VERSION = void 0;
6813
- exports.D8X_SDK_VERSION = "0.1.10";
6813
+ exports.D8X_SDK_VERSION = "0.1.12";
6814
6814
  //# sourceMappingURL=version.js.map
6815
6815
 
6816
6816
  /***/ }),
@@ -6901,7 +6901,6 @@ var WriteAccessHandler = /** @class */ (function (_super) {
6901
6901
  _this.traderAddr = "";
6902
6902
  _this.signer = null;
6903
6903
  _this.gasLimit = 15000000;
6904
- _this.chainId = 0;
6905
6904
  if (privateKey) {
6906
6905
  _this.privateKey = privateKey;
6907
6906
  }
@@ -6924,9 +6923,9 @@ var WriteAccessHandler = /** @class */ (function (_super) {
6924
6923
  */
6925
6924
  WriteAccessHandler.prototype.createProxyInstance = function (provider) {
6926
6925
  return __awaiter(this, void 0, void 0, function () {
6927
- var wallet, _a, _b;
6928
- return __generator(this, function (_c) {
6929
- switch (_c.label) {
6926
+ var wallet, _a;
6927
+ return __generator(this, function (_b) {
6928
+ switch (_b.label) {
6930
6929
  case 0:
6931
6930
  if (provider == undefined) {
6932
6931
  this.provider = new ethers_1.ethers.providers.JsonRpcBatchProvider(this.nodeURL);
@@ -6940,15 +6939,11 @@ var WriteAccessHandler = /** @class */ (function (_super) {
6940
6939
  }
6941
6940
  return [4 /*yield*/, this.initContractsAndData(this.signer)];
6942
6941
  case 1:
6943
- _c.sent();
6942
+ _b.sent();
6944
6943
  _a = this;
6945
6944
  return [4 /*yield*/, this.signer.getAddress()];
6946
6945
  case 2:
6947
- _a.traderAddr = _c.sent();
6948
- _b = this;
6949
- return [4 /*yield*/, this.provider.getNetwork()];
6950
- case 3:
6951
- _b.chainId = (_c.sent()).chainId;
6946
+ _a.traderAddr = _b.sent();
6952
6947
  return [2 /*return*/];
6953
6948
  }
6954
6949
  });
@@ -159,20 +159,23 @@ var PerpetualDataHandler = /** @class */ (function () {
159
159
  */
160
160
  PerpetualDataHandler.prototype._fillSymbolMaps = function (proxyContract) {
161
161
  return __awaiter(this, void 0, void 0, function () {
162
- var _a, requiredPairs, _loop_1, this_1, j;
162
+ var oracleFactoryAddr, _a, requiredPairs, _loop_1, this_1, j;
163
163
  return __generator(this, function (_b) {
164
164
  switch (_b.label) {
165
165
  case 0:
166
166
  if (proxyContract == null || this.lobFactoryContract == null) {
167
167
  throw Error("proxy or limit order book not defined");
168
168
  }
169
+ return [4 /*yield*/, proxyContract.getOracleFactory()];
170
+ case 1:
171
+ oracleFactoryAddr = _b.sent();
169
172
  _a = this;
170
173
  return [4 /*yield*/, PerpetualDataHandler.getNestedPerpetualIds(proxyContract)];
171
- case 1:
174
+ case 2:
172
175
  _a.nestedPerpetualIDs = _b.sent();
173
176
  requiredPairs = new Set();
174
177
  _loop_1 = function (j) {
175
- var pool, poolMarginTokenAddr, perpetualIDs, poolCCY, currentSymbols, currentSymbolsS3, currentLimitOrderBookAddr, ccy, initRate, mgnRate, lotSizes, refRebates, k, perp, base, quote, base3, quote3, sym, sym3, lobAddr, oracleFactoryAddr, info, currentSymbols3, k, idsB32, isPyth;
178
+ var pool, poolMarginTokenAddr, perpetualIDs, poolCCY, currentSymbols, currentSymbolsS3, currentLimitOrderBookAddr, ccy, initRate, mgnRate, lotSizes, refRebates, k, perp, base, quote, base3, quote3, sym, sym3, lobAddr, info, currentSymbols3, k, idsB32, isPyth;
176
179
  var _c;
177
180
  return __generator(this, function (_d) {
178
181
  switch (_d.label) {
@@ -244,9 +247,6 @@ var PerpetualDataHandler = /** @class */ (function () {
244
247
  if (perpetualIDs.length == 0) {
245
248
  return [2 /*return*/, "continue"];
246
249
  }
247
- return [4 /*yield*/, proxyContract.getOracleFactory()];
248
- case 7:
249
- oracleFactoryAddr = _d.sent();
250
250
  info = {
251
251
  poolId: j + 1,
252
252
  poolMarginSymbol: poolCCY,
@@ -257,12 +257,12 @@ var PerpetualDataHandler = /** @class */ (function () {
257
257
  this_1.poolStaticInfos.push(info);
258
258
  currentSymbols3 = currentSymbols.map(function (x) { return x + "-" + poolCCY; });
259
259
  k = 0;
260
- _d.label = 8;
261
- case 8:
262
- if (!(k < perpetualIDs.length)) return [3 /*break*/, 11];
260
+ _d.label = 7;
261
+ case 7:
262
+ if (!(k < perpetualIDs.length)) return [3 /*break*/, 10];
263
263
  idsB32 = void 0, isPyth = void 0;
264
264
  return [4 /*yield*/, proxyContract.getPriceInfo(perpetualIDs[k])];
265
- case 9:
265
+ case 8:
266
266
  _c = __read.apply(void 0, [_d.sent(), 2]), idsB32 = _c[0], isPyth = _c[1];
267
267
  this_1.symbolToPerpStaticInfo.set(currentSymbols3[k], {
268
268
  id: perpetualIDs[k],
@@ -276,11 +276,11 @@ var PerpetualDataHandler = /** @class */ (function () {
276
276
  referralRebate: refRebates[k],
277
277
  priceIds: idsB32,
278
278
  });
279
- _d.label = 10;
280
- case 10:
279
+ _d.label = 9;
280
+ case 9:
281
281
  k++;
282
- return [3 /*break*/, 8];
283
- case 11:
282
+ return [3 /*break*/, 7];
283
+ case 10:
284
284
  // push margin token address into map
285
285
  this_1.symbolToTokenAddrMap.set(poolCCY, poolMarginTokenAddr);
286
286
  return [2 /*return*/];
@@ -289,17 +289,17 @@ var PerpetualDataHandler = /** @class */ (function () {
289
289
  };
290
290
  this_1 = this;
291
291
  j = 0;
292
- _b.label = 2;
293
- case 2:
294
- if (!(j < this.nestedPerpetualIDs.length)) return [3 /*break*/, 5];
295
- return [5 /*yield**/, _loop_1(j)];
292
+ _b.label = 3;
296
293
  case 3:
297
- _b.sent();
298
- _b.label = 4;
294
+ if (!(j < this.nestedPerpetualIDs.length)) return [3 /*break*/, 6];
295
+ return [5 /*yield**/, _loop_1(j)];
299
296
  case 4:
300
- j++;
301
- return [3 /*break*/, 2];
297
+ _b.sent();
298
+ _b.label = 5;
302
299
  case 5:
300
+ j++;
301
+ return [3 /*break*/, 3];
302
+ case 6:
303
303
  // pre-calculate all triangulation paths so we can easily get from
304
304
  // the prices of price-feeds to the index price required, e.g.
305
305
  // BTC-USDC : BTC-USD / USDC-USD
@@ -1 +1 @@
1
- export declare const D8X_SDK_VERSION = "0.1.10";
1
+ export declare const D8X_SDK_VERSION = "0.1.12";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.D8X_SDK_VERSION = void 0;
4
- exports.D8X_SDK_VERSION = "0.1.10";
4
+ exports.D8X_SDK_VERSION = "0.1.12";
5
5
  //# sourceMappingURL=version.js.map
@@ -13,7 +13,6 @@ export default class WriteAccessHandler extends PerpetualDataHandler {
13
13
  protected traderAddr: string;
14
14
  protected signer: ethers.Signer | null;
15
15
  protected gasLimit: number;
16
- protected chainId: number;
17
16
  /**
18
17
  * Constructor
19
18
  * @param {NodeSDKConfig} config configuration
@@ -77,7 +77,6 @@ var WriteAccessHandler = /** @class */ (function (_super) {
77
77
  _this.traderAddr = "";
78
78
  _this.signer = null;
79
79
  _this.gasLimit = 15000000;
80
- _this.chainId = 0;
81
80
  if (privateKey) {
82
81
  _this.privateKey = privateKey;
83
82
  }
@@ -100,9 +99,9 @@ var WriteAccessHandler = /** @class */ (function (_super) {
100
99
  */
101
100
  WriteAccessHandler.prototype.createProxyInstance = function (provider) {
102
101
  return __awaiter(this, void 0, void 0, function () {
103
- var wallet, _a, _b;
104
- return __generator(this, function (_c) {
105
- switch (_c.label) {
102
+ var wallet, _a;
103
+ return __generator(this, function (_b) {
104
+ switch (_b.label) {
106
105
  case 0:
107
106
  if (provider == undefined) {
108
107
  this.provider = new ethers_1.ethers.providers.JsonRpcBatchProvider(this.nodeURL);
@@ -116,15 +115,11 @@ var WriteAccessHandler = /** @class */ (function (_super) {
116
115
  }
117
116
  return [4 /*yield*/, this.initContractsAndData(this.signer)];
118
117
  case 1:
119
- _c.sent();
118
+ _b.sent();
120
119
  _a = this;
121
120
  return [4 /*yield*/, this.signer.getAddress()];
122
121
  case 2:
123
- _a.traderAddr = _c.sent();
124
- _b = this;
125
- return [4 /*yield*/, this.provider.getNetwork()];
126
- case 3:
127
- _b.chainId = (_c.sent()).chainId;
122
+ _a.traderAddr = _b.sent();
128
123
  return [2 /*return*/];
129
124
  }
130
125
  });
@@ -0,0 +1,249 @@
1
+ <a name="AccountTrade"></a>
2
+
3
+ ## AccountTrade ⇐ <code>WriteAccessHandler</code>
4
+ <p>Functions to create, submit and cancel orders on the exchange.
5
+ This class requires a private key and executes smart-contract interactions that
6
+ require gas-payments.</p>
7
+
8
+ **Kind**: global class
9
+ **Extends**: <code>WriteAccessHandler</code>
10
+
11
+ * [AccountTrade](#AccountTrade) ⇐ <code>WriteAccessHandler</code>
12
+ * [new AccountTrade(config, privateKey)](#new_AccountTrade_new)
13
+ * [.cancelOrder(symbol, orderId)](#AccountTrade+cancelOrder) ⇒ <code>ContractTransaction</code>
14
+ * [.order(order)](#AccountTrade+order) ⇒ <code>ContractTransaction</code>
15
+ * [.queryExchangeFee(poolSymbolName, [brokerAddr])](#AccountTrade+queryExchangeFee) ⇒
16
+ * [.getCurrentTraderVolume(poolSymbolName)](#AccountTrade+getCurrentTraderVolume) ⇒ <code>number</code>
17
+ * [.getOrderIds(symbol)](#AccountTrade+getOrderIds) ⇒ <code>Array.&lt;string&gt;</code>
18
+ * [.addCollateral(symbol, amount)](#AccountTrade+addCollateral)
19
+ * [.removeCollateral(symbol, amount)](#AccountTrade+removeCollateral)
20
+
21
+ <a name="new_AccountTrade_new"></a>
22
+
23
+ ### new AccountTrade(config, privateKey)
24
+ <p>Constructor</p>
25
+
26
+
27
+ | Param | Type | Description |
28
+ | --- | --- | --- |
29
+ | config | <code>NodeSDKConfig</code> | <p>Configuration object, see PerpetualDataHandler. readSDKConfig.</p> |
30
+ | privateKey | <code>string</code> | <p>Private key of account that trades.</p> |
31
+
32
+ **Example**
33
+ ```js
34
+ import { AccountTrade, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
35
+ async function main() {
36
+ console.log(AccountTrade);
37
+ // load configuration for testnet
38
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
39
+ // AccountTrade (authentication required, PK is an environment variable with a private key)
40
+ const pk: string = <string>process.env.PK;
41
+ let accTrade = new AccountTrade(config, pk);
42
+ // Create a proxy instance to access the blockchain
43
+ await accTrade.createProxyInstance();
44
+ }
45
+ main();
46
+ ```
47
+ <a name="AccountTrade+cancelOrder"></a>
48
+
49
+ ### accountTrade.cancelOrder(symbol, orderId) ⇒ <code>ContractTransaction</code>
50
+ <p>Cancels an existing order on the exchange.</p>
51
+
52
+ **Kind**: instance method of [<code>AccountTrade</code>](#AccountTrade)
53
+ **Returns**: <code>ContractTransaction</code> - <p>Contract Transaction (containing events).</p>
54
+
55
+ | Param | Type | Description |
56
+ | --- | --- | --- |
57
+ | symbol | <code>string</code> | <p>Symbol of the form ETH-USD-MATIC.</p> |
58
+ | orderId | <code>string</code> | <p>ID of the order to be cancelled.</p> |
59
+
60
+ **Example**
61
+ ```js
62
+ import { AccountTrade, PerpetualDataHandler, Order } from '@d8x/perpetuals-sdk';
63
+ async function main() {
64
+ console.log(AccountTrade);
65
+ // setup (authentication required, PK is an environment variable with a private key)
66
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
67
+ const pk: string = <string>process.env.PK;
68
+ let accTrade = new AccountTrade(config, pk);
69
+ await accTrade.createProxyInstance();
70
+ // cancel order
71
+ let cancelTransaction = accTrade.cancelOrder("MATIC-USD-MATIC",
72
+ "0x4639061a58dcf34f4c9c703f49f1cb00d6a4fba490d62c0eb4a4fb06e1c76c19")
73
+ console.log(cancelTransaction);
74
+ }
75
+ main();
76
+ ```
77
+ <a name="AccountTrade+order"></a>
78
+
79
+ ### accountTrade.order(order) ⇒ <code>ContractTransaction</code>
80
+ <p>Submits an order to the exchange.</p>
81
+
82
+ **Kind**: instance method of [<code>AccountTrade</code>](#AccountTrade)
83
+ **Returns**: <code>ContractTransaction</code> - <p>Contract Transaction (containing events).</p>
84
+
85
+ | Param | Type | Description |
86
+ | --- | --- | --- |
87
+ | order | <code>Order</code> | <p>Order structure. As a minimum the structure needs to specify symbol, side, type and quantity.</p> |
88
+
89
+ **Example**
90
+ ```js
91
+ import { AccountTrade, PerpetualDataHandler, Order } from '@d8x/perpetuals-sdk';
92
+ async function main() {
93
+ console.log(AccountTrade);
94
+ // setup (authentication required, PK is an environment variable with a private key)
95
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
96
+ const pk: string = <string>process.env.PK;
97
+ let accTrade = new AccountTrade(config, pk);
98
+ await accTrade.createProxyInstance();
99
+ // set allowance
100
+ await accTrade.setAllowance("MATIC");
101
+ // set an order
102
+ let order: Order = {
103
+ symbol: "MATIC-USD-MATIC",
104
+ side: "BUY",
105
+ type: "MARKET",
106
+ quantity: 100,
107
+ leverage: 2,
108
+ timestamp: Date.now()/1000,
109
+ };
110
+ let orderTransaction = await accTrade.order(order);
111
+ console.log(orderTransaction);
112
+ }
113
+ main();
114
+ ```
115
+ **Example**
116
+ ```js
117
+ import { AccountTrade, PerpetualDataHandler, Order } from '@d8x/perpetuals-sdk';
118
+ async function main() {
119
+ console.log(AccountTrade);
120
+ // setup (authentication required, PK is an environment variable with a private key)
121
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
122
+ const pk: string = <string>process.env.PK;
123
+ let accTrade = new AccountTrade(config, pk);
124
+ await accTrade.createProxyInstance();
125
+ // set allowance
126
+ await accTrade.setAllowance("MATIC");
127
+ // set an order
128
+ let order: Order = {
129
+ symbol: "MATIC-USD-MATIC",
130
+ side: "BUY",
131
+ type: "LIMIT",
132
+ limitPrice: 1,
133
+ quantity: 5,
134
+ leverage: 2,
135
+ timestamp: Date.now() / 1000,
136
+ deadline: Date.now() / 1000 + 8*60*60, // order expires 8 hours from now
137
+ };
138
+ let orderTransaction = await accTrade.order(order);
139
+ console.log(orderTransaction);
140
+ }
141
+ main();
142
+ ```
143
+ <a name="AccountTrade+queryExchangeFee"></a>
144
+
145
+ ### accountTrade.queryExchangeFee(poolSymbolName, [brokerAddr]) ⇒
146
+ <p>Fee charged by the exchange for trading any perpetual on a given pool.
147
+ It accounts for the current trader's fee tier (based on the trader's D8X balance and trading volume).
148
+ If trading with a broker, it also accounts for the selected broker's fee tier.
149
+ Note that this result only includes exchange fees, additional broker fees are not included.</p>
150
+
151
+ **Kind**: instance method of [<code>AccountTrade</code>](#AccountTrade)
152
+ **Returns**: <p>Exchange fee, in decimals (i.e. 0.1% is 0.001).</p>
153
+
154
+ | Param | Type | Description |
155
+ | --- | --- | --- |
156
+ | poolSymbolName | <code>string</code> | <p>Pool symbol name (e.g. MATIC, USDC, etc).</p> |
157
+ | [brokerAddr] | <code>string</code> | <p>Optional address of a broker this trader may use to trade under.</p> |
158
+
159
+ **Example**
160
+ ```js
161
+ import { AccountTrade, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
162
+ async function main() {
163
+ console.log(AccountTrade);
164
+ // setup (authentication required, PK is an environment variable with a private key)
165
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
166
+ const pk: string = <string>process.env.PK;
167
+ let accTrade = new AccountTrade(config, pk);
168
+ await accTrade.createProxyInstance();
169
+ // query exchange fee
170
+ let fees = await accTrade.queryExchangeFee("MATIC");
171
+ console.log(fees);
172
+ }
173
+ main();
174
+ ```
175
+ <a name="AccountTrade+getCurrentTraderVolume"></a>
176
+
177
+ ### accountTrade.getCurrentTraderVolume(poolSymbolName) ⇒ <code>number</code>
178
+ <p>Exponentially weighted EMA of the total USD trading volume of all trades performed by this trader.
179
+ The weights are chosen so that in average this coincides with the 30 day volume.</p>
180
+
181
+ **Kind**: instance method of [<code>AccountTrade</code>](#AccountTrade)
182
+ **Returns**: <code>number</code> - <p>Current trading volume for this trader, in USD.</p>
183
+
184
+ | Param | Type | Description |
185
+ | --- | --- | --- |
186
+ | poolSymbolName | <code>string</code> | <p>Pool symbol name (e.g. MATIC, USDC, etc).</p> |
187
+
188
+ **Example**
189
+ ```js
190
+ import { AccountTrade, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
191
+ async function main() {
192
+ console.log(AccountTrade);
193
+ // setup (authentication required, PK is an environment variable with a private key)
194
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
195
+ const pk: string = <string>process.env.PK;
196
+ let accTrade = new AccountTrade(config, pk);
197
+ await accTrade.createProxyInstance();
198
+ // query 30 day volume
199
+ let vol = await accTrade.getCurrentTraderVolume("MATIC");
200
+ console.log(vol);
201
+ }
202
+ main();
203
+ ```
204
+ <a name="AccountTrade+getOrderIds"></a>
205
+
206
+ ### accountTrade.getOrderIds(symbol) ⇒ <code>Array.&lt;string&gt;</code>
207
+ **Kind**: instance method of [<code>AccountTrade</code>](#AccountTrade)
208
+ **Returns**: <code>Array.&lt;string&gt;</code> - <p>Array of Ids for all the orders currently open by this trader.</p>
209
+
210
+ | Param | Description |
211
+ | --- | --- |
212
+ | symbol | <p>Symbol of the form ETH-USD-MATIC.</p> |
213
+
214
+ **Example**
215
+ ```js
216
+ import { AccountTrade, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
217
+ async function main() {
218
+ console.log(AccountTrade);
219
+ // setup (authentication required, PK is an environment variable with a private key)
220
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
221
+ const pk: string = <string>process.env.PK;
222
+ let accTrade = new AccountTrade(config, pk);
223
+ await accTrade.createProxyInstance();
224
+ // get order IDs
225
+ let orderIds = await accTrade.getOrderIds("MATIC-USD-MATIC");
226
+ console.log(orderIds);
227
+ }
228
+ main();
229
+ ```
230
+ <a name="AccountTrade+addCollateral"></a>
231
+
232
+ ### accountTrade.addCollateral(symbol, amount)
233
+ **Kind**: instance method of [<code>AccountTrade</code>](#AccountTrade)
234
+
235
+ | Param | Type | Description |
236
+ | --- | --- | --- |
237
+ | symbol | <code>string</code> | <p>Symbol of the form ETH-USD-MATIC.</p> |
238
+ | amount | <code>number</code> | <p>How much collateral to add, in units of collateral currency, e.g. MATIC</p> |
239
+
240
+ <a name="AccountTrade+removeCollateral"></a>
241
+
242
+ ### accountTrade.removeCollateral(symbol, amount)
243
+ **Kind**: instance method of [<code>AccountTrade</code>](#AccountTrade)
244
+
245
+ | Param | Type | Description |
246
+ | --- | --- | --- |
247
+ | symbol | <code>string</code> | <p>Symbol of the form ETH-USD-MATIC.</p> |
248
+ | amount | <code>number</code> | <p>How much collateral to remove, in units of collateral currency, e.g. MATIC</p> |
249
+