@gainsnetwork/sdk 0.2.22 → 0.2.24-rc1

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 (40) hide show
  1. package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +62 -1
  2. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +115 -0
  3. package/lib/trade/fees/tiers/index.js +5 -2
  4. package/lib/trade/fees/tiers/types.d.ts +7 -0
  5. package/lib/trade/fees/tiers/types.js +6 -0
  6. package/lib/trade/spread.js +2 -4
  7. package/lib/trade/types.d.ts +2 -1
  8. package/package.json +1 -1
  9. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.d.ts +0 -979
  10. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.js +0 -2
  11. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.d.ts +0 -1058
  12. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.js +0 -2
  13. package/lib/contracts/types/generated/GNSPairInfosV6_1.d.ts +0 -911
  14. package/lib/contracts/types/generated/GNSPairInfosV6_1.js +0 -2
  15. package/lib/contracts/types/generated/GNSPairsStorageV6.d.ts +0 -660
  16. package/lib/contracts/types/generated/GNSPairsStorageV6.js +0 -2
  17. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.d.ts +0 -806
  18. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.js +0 -2
  19. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.d.ts +0 -821
  20. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.js +0 -2
  21. package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +0 -1838
  22. package/lib/contracts/types/generated/GTokenV6_3_2.js +0 -2
  23. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.d.ts +0 -88
  24. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.js +0 -1654
  25. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.d.ts +0 -113
  26. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.js +0 -1742
  27. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.d.ts +0 -98
  28. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.js +0 -1485
  29. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.d.ts +0 -117
  30. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.js +0 -1265
  31. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.d.ts +0 -82
  32. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.js +0 -1273
  33. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.d.ts +0 -82
  34. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.js +0 -1326
  35. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +0 -110
  36. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +0 -2682
  37. package/lib/contracts/utils/openLimitOrders.d.ts +0 -8
  38. package/lib/contracts/utils/openLimitOrders.js +0 -88
  39. package/lib/trade/openLimitOrder.d.ts +0 -2
  40. package/lib/trade/openLimitOrder.js +0 -23
@@ -1,8 +0,0 @@
1
- import { LimitOrder } from "../../trade/types";
2
- import { BlockTag, Contracts } from "../types";
3
- export type FetchOpenLimitOrdersOverrides = {
4
- blockTag?: BlockTag;
5
- useMulticall?: boolean;
6
- };
7
- export declare const fetchOpenLimitOrders: (contracts: Contracts, overrides?: FetchOpenLimitOrdersOverrides) => Promise<LimitOrder[]>;
8
- export declare const fetchOpenLimitOrdersRaw: (contracts: Contracts, overrides?: FetchOpenLimitOrdersOverrides) => Promise<any[]>;
@@ -1,88 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-unsafe-call */
3
- /* eslint-disable @typescript-eslint/no-unsafe-return */
4
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.fetchOpenLimitOrdersRaw = exports.fetchOpenLimitOrders = void 0;
16
- const ethcall_1 = require("ethcall");
17
- const fetchOpenLimitOrders = (contracts, overrides = {}) => __awaiter(void 0, void 0, void 0, function* () {
18
- const openLimitOrdersRaw = yield (0, exports.fetchOpenLimitOrdersRaw)(contracts, overrides);
19
- return openLimitOrdersRaw.map((order) => ({
20
- block: parseInt(order.block.toString()),
21
- buy: order.buy,
22
- index: parseInt(order.index.toString()),
23
- leverage: parseInt(order.leverage.toString()),
24
- maxPrice: parseFloat(order.maxPrice.toString()) / 1e10,
25
- minPrice: parseFloat(order.minPrice.toString()) / 1e10,
26
- pairIndex: parseInt(order.pairIndex.toString()),
27
- positionSize: parseFloat(order.positionSize.toString()) / 1e18,
28
- sl: parseFloat(order.sl.toString()) / 1e10,
29
- spreadReductionP: parseInt(order.spreadReductionP.toString()) / 100,
30
- tp: parseFloat(order.tp.toString()) / 1e10,
31
- trader: order.trader,
32
- type: parseInt(order.type.toString()),
33
- maxSlippageP: parseFloat(order.maxSlippageP.toString()) / 1e10,
34
- }));
35
- });
36
- exports.fetchOpenLimitOrders = fetchOpenLimitOrders;
37
- const fetchOpenLimitOrdersRaw = (contracts, overrides = {}) => __awaiter(void 0, void 0, void 0, function* () {
38
- if (!contracts) {
39
- return [];
40
- }
41
- console.time("fetchOpenLimitOrdersRaw");
42
- const { useMulticall = false, blockTag = "latest" } = overrides;
43
- const { gfarmTradingStorageV5: storageContract, gnsNftRewards: nftRewards, gnsTradingCallbacks: callbacks, } = contracts;
44
- const openLimitOrders = yield storageContract.getOpenLimitOrders({
45
- blockTag,
46
- });
47
- let openLimitOrderTypes = [];
48
- let openLimitOrderTradeData = [];
49
- if (useMulticall) {
50
- const multicallProvider = new ethcall_1.Provider();
51
- yield multicallProvider.init(storageContract.provider);
52
- const nftRewardsContractMulticall = new ethcall_1.Contract(nftRewards.address, [
53
- ...nftRewards.interface.fragments,
54
- ]);
55
- const callbacksContractMulticall = new ethcall_1.Contract(callbacks.address, [
56
- ...callbacks.interface.fragments,
57
- ]);
58
- openLimitOrderTypes = yield multicallProvider.all(openLimitOrders.map(order => nftRewardsContractMulticall.openLimitOrderTypes(order.trader, order.pairIndex, order.index)), blockTag);
59
- openLimitOrderTradeData = yield multicallProvider.all(openLimitOrders.map(order => callbacksContractMulticall.tradeData(order.trader, order.pairIndex, order.index, 1)), blockTag);
60
- }
61
- else {
62
- openLimitOrderTypes = yield Promise.all(openLimitOrders.map(order => nftRewards.openLimitOrderTypes(order.trader, order.pairIndex, order.index, { blockTag })));
63
- openLimitOrderTradeData = yield Promise.all(openLimitOrders.map(order => callbacks.tradeData(order.trader, order.pairIndex, order.index, 1, {
64
- blockTag,
65
- })));
66
- }
67
- return openLimitOrderTypes.map((openLimitOrderType, index) => {
68
- const openLimitOrder = openLimitOrders[index];
69
- const tradeData = openLimitOrderTradeData[index];
70
- return {
71
- trader: openLimitOrder.trader,
72
- pairIndex: openLimitOrder.pairIndex,
73
- index: openLimitOrder.index,
74
- positionSize: openLimitOrder.positionSize,
75
- spreadReductionP: openLimitOrder.spreadReductionP,
76
- buy: openLimitOrder.buy,
77
- leverage: openLimitOrder.leverage,
78
- tp: openLimitOrder.tp,
79
- sl: openLimitOrder.sl,
80
- minPrice: openLimitOrder.minPrice,
81
- maxPrice: openLimitOrder.maxPrice,
82
- block: openLimitOrder.block,
83
- type: openLimitOrderType,
84
- maxSlippageP: tradeData.maxSlippageP,
85
- };
86
- });
87
- });
88
- exports.fetchOpenLimitOrdersRaw = fetchOpenLimitOrdersRaw;
@@ -1,2 +0,0 @@
1
- import { LimitOrder, Pair, PairDepth, OiWindowsSettings, OiWindows } from "./types";
2
- export declare const getFulfillmentPrice: (order: LimitOrder, pair: Pair, pairDepth: PairDepth, oiWindowsSettings?: OiWindowsSettings, oiWindows?: OiWindows) => number;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFulfillmentPrice = void 0;
4
- const spread_1 = require("./spread");
5
- const types_1 = require("./types");
6
- const getFulfillmentPrice = (order, pair, pairDepth, oiWindowsSettings, oiWindows) => {
7
- if (!order || !pair) {
8
- return 0;
9
- }
10
- // Get spread percentage
11
- const spreadWithPriceImpactP = (0, spread_1.getSpreadWithPriceImpactP)(pair.spreadP, order.buy, order.positionSize, order.leverage, pairDepth, oiWindowsSettings, oiWindows);
12
- if (spreadWithPriceImpactP === 0) {
13
- return 0;
14
- }
15
- const askingPrice = (order.buy && order.type === types_1.OpenLimitOrderType.REVERSAL) ||
16
- (!order.buy && order.type === types_1.OpenLimitOrderType.MOMENTUM)
17
- ? order.maxPrice
18
- : order.minPrice;
19
- return order.buy
20
- ? askingPrice * (1 + spreadWithPriceImpactP)
21
- : askingPrice * (1 - spreadWithPriceImpactP);
22
- };
23
- exports.getFulfillmentPrice = getFulfillmentPrice;