@d8x/perpetuals-sdk 0.5.0 → 0.5.2

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 (39) hide show
  1. package/README.md +0 -12
  2. package/dist/cjs/abi/testnet/ShareToken.json +428 -0
  3. package/dist/cjs/abi/zkevmTestnet/ShareToken.json +428 -0
  4. package/dist/cjs/config/defaultConfig.json +2 -0
  5. package/dist/cjs/liquidityProviderTool.d.ts +0 -26
  6. package/dist/cjs/liquidityProviderTool.js +0 -54
  7. package/dist/cjs/liquidityProviderTool.js.map +1 -1
  8. package/dist/cjs/marketData.d.ts +45 -0
  9. package/dist/cjs/marketData.js +116 -1
  10. package/dist/cjs/marketData.js.map +1 -1
  11. package/dist/cjs/nodeSDKTypes.d.ts +2 -0
  12. package/dist/cjs/nodeSDKTypes.js +1 -0
  13. package/dist/cjs/nodeSDKTypes.js.map +1 -1
  14. package/dist/cjs/perpetualDataHandler.d.ts +9 -3
  15. package/dist/cjs/perpetualDataHandler.js +13 -5
  16. package/dist/cjs/perpetualDataHandler.js.map +1 -1
  17. package/dist/cjs/version.d.ts +1 -1
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/esm/abi/testnet/ShareToken.json +428 -0
  20. package/dist/esm/abi/zkevmTestnet/ShareToken.json +428 -0
  21. package/dist/esm/config/defaultConfig.json +2 -0
  22. package/dist/esm/liquidityProviderTool.d.ts +0 -26
  23. package/dist/esm/liquidityProviderTool.js +1 -55
  24. package/dist/esm/liquidityProviderTool.js.map +1 -1
  25. package/dist/esm/marketData.d.ts +45 -0
  26. package/dist/esm/marketData.js +117 -2
  27. package/dist/esm/marketData.js.map +1 -1
  28. package/dist/esm/nodeSDKTypes.d.ts +2 -0
  29. package/dist/esm/nodeSDKTypes.js +1 -0
  30. package/dist/esm/nodeSDKTypes.js.map +1 -1
  31. package/dist/esm/perpetualDataHandler.d.ts +9 -3
  32. package/dist/esm/perpetualDataHandler.js +13 -5
  33. package/dist/esm/perpetualDataHandler.js.map +1 -1
  34. package/dist/esm/version.d.ts +1 -1
  35. package/dist/esm/version.js +1 -1
  36. package/doc/d8x-perpetuals-sdk.md +322 -83
  37. package/doc/liquidityProviderTool.md +0 -30
  38. package/doc/marketData.md +70 -0
  39. package/package.json +1 -1
@@ -9,7 +9,6 @@ smart-contract interactions that require gas-payments.</p>
9
9
 
10
10
  * [LiquidityProviderTool](#LiquidityProviderTool) ⇐ <code>WriteAccessHandler</code>
11
11
  * [new LiquidityProviderTool(config, privateKey)](#new_LiquidityProviderTool_new)
12
- * [.getParticipationValue(poolSymbolName)](#LiquidityProviderTool+getParticipationValue) ⇒
13
12
  * [.addLiquidity(poolSymbolName, amountCC)](#LiquidityProviderTool+addLiquidity) ⇒
14
13
  * [.initiateLiquidityWithdrawal(poolSymbolName, amountPoolShares)](#LiquidityProviderTool+initiateLiquidityWithdrawal) ⇒
15
14
  * [.executeLiquidityWithdrawal(poolSymbolName)](#LiquidityProviderTool+executeLiquidityWithdrawal) ⇒
@@ -40,35 +39,6 @@ async function main() {
40
39
  }
41
40
  main();
42
41
  ```
43
- <a name="LiquidityProviderTool+getParticipationValue"></a>
44
-
45
- ### liquidityProviderTool.getParticipationValue(poolSymbolName) ⇒
46
- <p>Value of the pool share tokens for this liquidity provider
47
- in poolSymbol-currency (e.g. MATIC, USDC).</p>
48
-
49
- **Kind**: instance method of [<code>LiquidityProviderTool</code>](#LiquidityProviderTool)
50
- **Returns**: <p>Value in poolSymbol-currency (e.g. MATIC, USDC), balance of pool share tokens, and share token symbol.</p>
51
-
52
- | Param | Type | Description |
53
- | --- | --- | --- |
54
- | poolSymbolName | <code>string</code> | <p>Pool symbol name (e.g. MATIC).</p> |
55
-
56
- **Example**
57
- ```js
58
- import { LiquidityProviderTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
59
- async function main() {
60
- console.log(LiquidityProviderTool);
61
- // setup (authentication required, PK is an environment variable with a private key)
62
- const config = PerpetualDataHandler.readSDKConfig("testnet");
63
- const pk: string = <string>process.env.PK;
64
- let lqudtProviderTool = new LiquidityProviderTool(config, pk);
65
- await lqudtProviderTool.createProxyInstance();
66
- // get value of pool share token
67
- let shareToken = await lqudtProviderTool.getParticipationValue("MATIC");
68
- console.log(shareToken);
69
- }
70
- main();
71
- ```
72
42
  <a name="LiquidityProviderTool+addLiquidity"></a>
73
43
 
74
44
  ### liquidityProviderTool.addLiquidity(poolSymbolName, amountCC) ⇒
package/doc/marketData.md CHANGED
@@ -21,6 +21,10 @@ No gas required for the queries here.</p>
21
21
  * [.positionRiskOnTrade(traderAddr, order, account, indexPriceInfo)](#MarketData+positionRiskOnTrade) ⇒ <code>MarginAccount</code>
22
22
  * [.positionRiskOnCollateralAction(traderAddr, deltaCollateral, currentPositionRisk)](#MarketData+positionRiskOnCollateralAction) ⇒ <code>MarginAccount</code>
23
23
  * [.getWalletBalance(address, symbol)](#MarketData+getWalletBalance) ⇒
24
+ * [.getPoolShareTokenBalance(address, symbolOrId)](#MarketData+getPoolShareTokenBalance)
25
+ * [._getPoolShareTokenBalanceFromId(address, poolId)](#MarketData+_getPoolShareTokenBalanceFromId) ⇒
26
+ * [.getShareTokenPrice(symbolOrId)](#MarketData+getShareTokenPrice) ⇒
27
+ * [.getParticipationValue(address, symbolOrId)](#MarketData+getParticipationValue) ⇒
24
28
  * [.maxOrderSizeForTrader(side, positionRisk)](#MarketData+maxOrderSizeForTrader) ⇒
25
29
  * [.maxSignedPosition(side, symbol)](#MarketData+maxSignedPosition) ⇒
26
30
  * [.getOraclePrice(base, quote)](#MarketData+getOraclePrice) ⇒ <code>number</code>
@@ -236,6 +240,72 @@ main();
236
240
  | address | <p>Address to check</p> |
237
241
  | symbol | <p>Symbol of the form ETH-USD-MATIC.</p> |
238
242
 
243
+ <a name="MarketData+getPoolShareTokenBalance"></a>
244
+
245
+ ### marketData.getPoolShareTokenBalance(address, symbolOrId)
246
+ <p>Get the address' balance of the pool share token</p>
247
+
248
+ **Kind**: instance method of [<code>MarketData</code>](#MarketData)
249
+
250
+ | Param | Description |
251
+ | --- | --- |
252
+ | address | <p>address of the liquidity provider</p> |
253
+ | symbolOrId | <p>Symbol of the form ETH-USD-MATIC, or MATIC (collateral only), or Pool-Id</p> |
254
+
255
+ <a name="MarketData+_getPoolShareTokenBalanceFromId"></a>
256
+
257
+ ### marketData.\_getPoolShareTokenBalanceFromId(address, poolId) ⇒
258
+ <p>Query the pool share token holdings of address</p>
259
+
260
+ **Kind**: instance method of [<code>MarketData</code>](#MarketData)
261
+ **Returns**: <p>pool share token balance of address</p>
262
+
263
+ | Param | Description |
264
+ | --- | --- |
265
+ | address | <p>address of token holder</p> |
266
+ | poolId | <p>pool id</p> |
267
+
268
+ <a name="MarketData+getShareTokenPrice"></a>
269
+
270
+ ### marketData.getShareTokenPrice(symbolOrId) ⇒
271
+ <p>Value of pool token in collateral currency</p>
272
+
273
+ **Kind**: instance method of [<code>MarketData</code>](#MarketData)
274
+ **Returns**: <p>current pool share token price in collateral currency</p>
275
+
276
+ | Param | Description |
277
+ | --- | --- |
278
+ | symbolOrId | <p>symbol of the form ETH-USD-MATIC, MATIC (collateral), or poolId</p> |
279
+
280
+ <a name="MarketData+getParticipationValue"></a>
281
+
282
+ ### marketData.getParticipationValue(address, symbolOrId) ⇒
283
+ <p>Value of the pool share tokens for this liquidity provider
284
+ in poolSymbol-currency (e.g. MATIC, USDC).</p>
285
+
286
+ **Kind**: instance method of [<code>MarketData</code>](#MarketData)
287
+ **Returns**: <p>the value (in collateral tokens) of the pool share, #share tokens, shareTokenAddress</p>
288
+
289
+ | Param | Description |
290
+ | --- | --- |
291
+ | address | <p>address of liquidity provider</p> |
292
+ | symbolOrId | <p>symbol of the form ETH-USD-MATIC, MATIC (collateral), or poolId</p> |
293
+
294
+ **Example**
295
+ ```js
296
+ import { MarketData, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
297
+ async function main() {
298
+ console.log(MarketData);
299
+ // setup (authentication required, PK is an environment variable with a private key)
300
+ const config = PerpetualDataHandler.readSDKConfig("testnet");
301
+ let md = new MarketData(config);
302
+ await md.createProxyInstance();
303
+ // get value of pool share token
304
+ let shareToken = await md.getParticipationValue(myaddress, "MATIC");
305
+ console.log(shareToken);
306
+ }
307
+ main();
308
+ ```
239
309
  <a name="MarketData+maxOrderSizeForTrader"></a>
240
310
 
241
311
  ### marketData.maxOrderSizeForTrader(side, positionRisk) ⇒
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d8x/perpetuals-sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Node TypeScript SDK for D8X Perpetual Futures",
5
5
  "author": "D8X",
6
6
  "homepage": "https://github.com/D8-X/d8x-futures-node-sdk#readme",