@dhedge/v2-sdk 1.8.1 → 1.8.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.
@@ -1,3 +1 @@
1
- import { BigNumber } from "ethers";
2
- export declare const PRICE_IMPACT_DELTA: BigNumber;
3
1
  export declare const FUTURES_TRACKING = "DHEDGE";
@@ -1,2 +1,2 @@
1
- import { ethers } from "../..";
2
- export declare function getFuturesChangePositionTxData(amount: ethers.BigNumber | string): string;
1
+ import { Pool, ethers } from "../..";
2
+ export declare function getFuturesChangePositionTxData(amount: ethers.BigNumber | string, market: string, pool: Pool): Promise<string>;
@@ -19143,11 +19143,38 @@ function getFuturesChangeMarginTxData(amount) {
19143
19143
  return new ethers.ethers.utils.Interface(ISynthetixFuturesMarketV2.abi).encodeFunctionData("transferMargin", [amount]);
19144
19144
  }
19145
19145
 
19146
- var PRICE_IMPACT_DELTA = /*#__PURE__*/ethers.BigNumber.from("500000000000000000");
19147
19146
  var FUTURES_TRACKING = "DHEDGE";
19148
19147
 
19149
- function getFuturesChangePositionTxData(amount) {
19150
- return new ethers.ethers.utils.Interface(ISynthetixFuturesMarketV2.abi).encodeFunctionData("submitOffchainDelayedOrderWithTracking", [amount, PRICE_IMPACT_DELTA, ethers.ethers.utils.formatBytes32String(FUTURES_TRACKING)]);
19148
+ function getFuturesChangePositionTxData(_x, _x2, _x3) {
19149
+ return _getFuturesChangePositionTxData.apply(this, arguments);
19150
+ }
19151
+
19152
+ function _getFuturesChangePositionTxData() {
19153
+ _getFuturesChangePositionTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(amount, market, pool) {
19154
+ var futuresMarket, fillPrice, adjustmentFactor, desiredFillPrice;
19155
+ return runtime_1.wrap(function _callee$(_context) {
19156
+ while (1) {
19157
+ switch (_context.prev = _context.next) {
19158
+ case 0:
19159
+ futuresMarket = new ethers.ethers.Contract(market, ISynthetixFuturesMarketV2.abi, pool.signer);
19160
+ _context.next = 3;
19161
+ return futuresMarket.fillPrice(amount);
19162
+
19163
+ case 3:
19164
+ fillPrice = _context.sent;
19165
+ //Allows for +-0.5% price movements on the desired fill price
19166
+ adjustmentFactor = ethers.ethers.BigNumber.from(amount).lt(0) ? 995 : 1005;
19167
+ desiredFillPrice = fillPrice.price.mul(adjustmentFactor).div(1000);
19168
+ return _context.abrupt("return", new ethers.ethers.utils.Interface(ISynthetixFuturesMarketV2.abi).encodeFunctionData("submitOffchainDelayedOrderWithTracking", [amount, desiredFillPrice, ethers.ethers.utils.formatBytes32String(FUTURES_TRACKING)]));
19169
+
19170
+ case 7:
19171
+ case "end":
19172
+ return _context.stop();
19173
+ }
19174
+ }
19175
+ }, _callee);
19176
+ }));
19177
+ return _getFuturesChangePositionTxData.apply(this, arguments);
19151
19178
  }
19152
19179
 
19153
19180
  var Pool = /*#__PURE__*/function () {
@@ -21151,7 +21178,7 @@ var Pool = /*#__PURE__*/function () {
21151
21178
  /*#__PURE__*/
21152
21179
  function () {
21153
21180
  var _changeFuturesPosition = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee37(market, changeAmount, options) {
21154
- var tx;
21181
+ var txData, tx;
21155
21182
  return runtime_1.wrap(function _callee37$(_context37) {
21156
21183
  while (1) {
21157
21184
  switch (_context37.prev = _context37.next) {
@@ -21161,13 +21188,18 @@ var Pool = /*#__PURE__*/function () {
21161
21188
  }
21162
21189
 
21163
21190
  _context37.next = 3;
21164
- return this.poolLogic.execTransaction(market, getFuturesChangePositionTxData(changeAmount), options);
21191
+ return getFuturesChangePositionTxData(changeAmount, market, this);
21165
21192
 
21166
21193
  case 3:
21194
+ txData = _context37.sent;
21195
+ _context37.next = 6;
21196
+ return this.poolLogic.execTransaction(market, txData, options);
21197
+
21198
+ case 6:
21167
21199
  tx = _context37.sent;
21168
21200
  return _context37.abrupt("return", tx);
21169
21201
 
21170
- case 5:
21202
+ case 8:
21171
21203
  case "end":
21172
21204
  return _context37.stop();
21173
21205
  }