@gainsnetwork/sdk 0.2.43-rc5 → 0.2.44-rc2
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/lib/constants.d.ts +6 -0
- package/lib/constants.js +6 -0
- package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +133 -1
- package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +180 -0
- package/lib/contracts/utils/pairs.js +6 -0
- package/lib/trade/types.d.ts +7 -1
- package/lib/trade/types.js +6 -0
- package/package.json +1 -1
- package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +0 -1911
- package/lib/contracts/types/generated/GFarmTradingStorageV5.js +0 -2
- package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +0 -1067
- package/lib/contracts/types/generated/GNSBorrowingFees.js +0 -2
- package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.d.ts +0 -979
- package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.js +0 -2
- package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.d.ts +0 -1058
- package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.js +0 -2
- package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +0 -533
- package/lib/contracts/types/generated/GNSNftRewardsV6.js +0 -2
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +0 -613
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +0 -2
- package/lib/contracts/types/generated/GNSPairInfosV6_1.d.ts +0 -911
- package/lib/contracts/types/generated/GNSPairInfosV6_1.js +0 -2
- package/lib/contracts/types/generated/GNSPairsStorageV6.d.ts +0 -660
- package/lib/contracts/types/generated/GNSPairsStorageV6.js +0 -2
- package/lib/contracts/types/generated/GNSTrading.d.ts +0 -758
- package/lib/contracts/types/generated/GNSTrading.js +0 -2
- package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +0 -875
- package/lib/contracts/types/generated/GNSTradingCallbacks.js +0 -2
- package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.d.ts +0 -806
- package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.js +0 -2
- package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.d.ts +0 -821
- package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.js +0 -2
- package/lib/contracts/types/generated/GNSTradingStorage.d.ts +0 -1387
- package/lib/contracts/types/generated/GNSTradingStorage.js +0 -2
- package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +0 -1838
- package/lib/contracts/types/generated/GTokenV6_3_2.js +0 -2
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +0 -83
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +0 -2691
- package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.d.ts +0 -88
- package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.js +0 -1654
- package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.d.ts +0 -113
- package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.js +0 -1742
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +0 -124
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -1784
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +0 -100
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +0 -1116
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +0 -100
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +0 -1003
- package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.d.ts +0 -98
- package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.js +0 -1485
- package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.d.ts +0 -117
- package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.js +0 -1265
- package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.d.ts +0 -82
- package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.js +0 -1273
- package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.d.ts +0 -82
- package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.js +0 -1326
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +0 -113
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +0 -1428
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +0 -96
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +0 -2241
- package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +0 -95
- package/lib/contracts/types/generated/factories/GNSTrading__factory.js +0 -1071
- package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +0 -110
- package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +0 -2682
- package/lib/contracts/utils/openLimitOrders.d.ts +0 -8
- package/lib/contracts/utils/openLimitOrders.js +0 -88
- package/lib/trade/openLimitOrder.d.ts +0 -2
- 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,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;
|