@gainsnetwork/sdk 0.0.0-v10.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 (81) hide show
  1. package/README.md +11 -0
  2. package/lib/constants.d.ts +403 -0
  3. package/lib/constants.js +436 -0
  4. package/lib/contracts/addresses.d.ts +3 -0
  5. package/lib/contracts/addresses.js +31 -0
  6. package/lib/contracts/addresses.json +127 -0
  7. package/lib/contracts/index.d.ts +14 -0
  8. package/lib/contracts/index.js +83 -0
  9. package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +8716 -0
  10. package/lib/contracts/types/generated/GNSMultiCollatDiamond.js +2 -0
  11. package/lib/contracts/types/generated/GToken.d.ts +1917 -0
  12. package/lib/contracts/types/generated/GToken.js +2 -0
  13. package/lib/contracts/types/generated/GTokenOpenPnlFeed.d.ts +557 -0
  14. package/lib/contracts/types/generated/GTokenOpenPnlFeed.js +2 -0
  15. package/lib/contracts/types/generated/common.d.ts +22 -0
  16. package/lib/contracts/types/generated/common.js +2 -0
  17. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.d.ts +284 -0
  18. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +19330 -0
  19. package/lib/contracts/types/generated/factories/GTokenOpenPnlFeed__factory.d.ts +59 -0
  20. package/lib/contracts/types/generated/factories/GTokenOpenPnlFeed__factory.js +765 -0
  21. package/lib/contracts/types/generated/factories/GToken__factory.d.ts +128 -0
  22. package/lib/contracts/types/generated/factories/GToken__factory.js +2871 -0
  23. package/lib/contracts/types/generated/factories/index.d.ts +3 -0
  24. package/lib/contracts/types/generated/factories/index.js +12 -0
  25. package/lib/contracts/types/generated/index.d.ts +7 -0
  26. package/lib/contracts/types/generated/index.js +33 -0
  27. package/lib/contracts/types/index.d.ts +32 -0
  28. package/lib/contracts/types/index.js +25 -0
  29. package/lib/contracts/utils/borrowingFees.d.ts +9 -0
  30. package/lib/contracts/utils/borrowingFees.js +54 -0
  31. package/lib/contracts/utils/index.d.ts +3 -0
  32. package/lib/contracts/utils/index.js +19 -0
  33. package/lib/contracts/utils/openTrades.d.ts +10 -0
  34. package/lib/contracts/utils/openTrades.js +126 -0
  35. package/lib/contracts/utils/pairs.d.ts +7 -0
  36. package/lib/contracts/utils/pairs.js +478 -0
  37. package/lib/index.d.ts +7 -0
  38. package/lib/index.js +24 -0
  39. package/lib/markets/commodities.d.ts +1 -0
  40. package/lib/markets/commodities.js +33 -0
  41. package/lib/markets/crypto.d.ts +1 -0
  42. package/lib/markets/crypto.js +6 -0
  43. package/lib/markets/forex.d.ts +3 -0
  44. package/lib/markets/forex.js +45 -0
  45. package/lib/markets/index.d.ts +5 -0
  46. package/lib/markets/index.js +21 -0
  47. package/lib/markets/indices.d.ts +1 -0
  48. package/lib/markets/indices.js +6 -0
  49. package/lib/markets/stocks.d.ts +3 -0
  50. package/lib/markets/stocks.js +58 -0
  51. package/lib/trade/fees/borrowing/converter.d.ts +17 -0
  52. package/lib/trade/fees/borrowing/converter.js +42 -0
  53. package/lib/trade/fees/borrowing/index.d.ts +58 -0
  54. package/lib/trade/fees/borrowing/index.js +209 -0
  55. package/lib/trade/fees/borrowing/types.d.ts +36 -0
  56. package/lib/trade/fees/borrowing/types.js +2 -0
  57. package/lib/trade/fees/index.d.ts +4 -0
  58. package/lib/trade/fees/index.js +34 -0
  59. package/lib/trade/fees/tiers/index.d.ts +12 -0
  60. package/lib/trade/fees/tiers/index.js +54 -0
  61. package/lib/trade/fees/tiers/types.d.ts +15 -0
  62. package/lib/trade/fees/tiers/types.js +8 -0
  63. package/lib/trade/index.d.ts +7 -0
  64. package/lib/trade/index.js +23 -0
  65. package/lib/trade/liquidation.d.ts +12 -0
  66. package/lib/trade/liquidation.js +55 -0
  67. package/lib/trade/oiWindows.d.ts +3 -0
  68. package/lib/trade/oiWindows.js +20 -0
  69. package/lib/trade/pnl.d.ts +10 -0
  70. package/lib/trade/pnl.js +33 -0
  71. package/lib/trade/spread.d.ts +18 -0
  72. package/lib/trade/spread.js +108 -0
  73. package/lib/trade/types.d.ts +598 -0
  74. package/lib/trade/types.js +402 -0
  75. package/lib/utils/index.d.ts +1 -0
  76. package/lib/utils/index.js +17 -0
  77. package/lib/utils/packing.d.ts +2 -0
  78. package/lib/utils/packing.js +39 -0
  79. package/lib/vault/index.d.ts +8 -0
  80. package/lib/vault/index.js +10 -0
  81. package/package.json +105 -0
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.CollateralTypes = exports.COLLATERAL_TO_COLLATERAL_INDEX = exports.COLLATERAL_TO_CHAIN_COLLATERAL_INDEX = exports.getCollateralIndexAndContractsForChainByRequester = exports.getContractsForChainByRequester = exports.getContractsForChain = void 0;
18
+ const addresses_1 = require("./addresses");
19
+ const factories_1 = require("./types/generated/factories");
20
+ const types_1 = require("./types");
21
+ // @todo rework this to return all
22
+ const getContractsForChain = (chainId, signerOrProvider, collateral) => {
23
+ const addresses = (0, addresses_1.getContractAddressesForChain)(chainId, collateral);
24
+ return {
25
+ gnsMultiCollatDiamond: factories_1.GNSMultiCollatDiamond__factory.connect(addresses.gnsMultiCollatDiamond, signerOrProvider),
26
+ gTokenOpenPnlFeed: factories_1.GTokenOpenPnlFeed__factory.connect(addresses.gTokenOpenPnlFeed, signerOrProvider),
27
+ gToken: factories_1.GToken__factory.connect(addresses.gToken, signerOrProvider),
28
+ };
29
+ };
30
+ exports.getContractsForChain = getContractsForChain;
31
+ const getContractsForChainByRequester = (chainId, requester, signerOrProvider) => {
32
+ const { contracts } = (0, exports.getCollateralIndexAndContractsForChainByRequester)(chainId, requester, signerOrProvider);
33
+ return contracts;
34
+ };
35
+ exports.getContractsForChainByRequester = getContractsForChainByRequester;
36
+ const getCollateralIndexAndContractsForChainByRequester = (chainId, requester, signerOrProvider) => {
37
+ var _a;
38
+ const collateral = (0, addresses_1.getCollateralByAddressForChain)(chainId, requester);
39
+ return {
40
+ contracts: (0, exports.getContractsForChain)(chainId, signerOrProvider, collateral),
41
+ collateralIndex: ((_a = exports.COLLATERAL_TO_CHAIN_COLLATERAL_INDEX[chainId]) === null || _a === void 0 ? void 0 : _a[collateral]) ||
42
+ 0,
43
+ };
44
+ };
45
+ exports.getCollateralIndexAndContractsForChainByRequester = getCollateralIndexAndContractsForChainByRequester;
46
+ exports.COLLATERAL_TO_CHAIN_COLLATERAL_INDEX = {
47
+ [types_1.ChainId.POLYGON]: {
48
+ [types_1.CollateralTypes.DAI]: 1,
49
+ [types_1.CollateralTypes.ETH]: 2,
50
+ [types_1.CollateralTypes.USDC]: 3,
51
+ },
52
+ [types_1.ChainId.ARBITRUM]: {
53
+ [types_1.CollateralTypes.DAI]: 1,
54
+ [types_1.CollateralTypes.ETH]: 2,
55
+ [types_1.CollateralTypes.USDC]: 3,
56
+ [types_1.CollateralTypes.GNS]: 4,
57
+ },
58
+ [types_1.ChainId.ARBITRUM_SEPOLIA]: {
59
+ [types_1.CollateralTypes.DAI]: 1,
60
+ [types_1.CollateralTypes.ETH]: 2,
61
+ [types_1.CollateralTypes.USDC]: 3,
62
+ [types_1.CollateralTypes.GNS]: 4,
63
+ },
64
+ [types_1.ChainId.BASE]: {
65
+ [types_1.CollateralTypes.USDC]: 1,
66
+ },
67
+ [types_1.ChainId.APECHAIN]: {
68
+ [types_1.CollateralTypes.APE]: 1,
69
+ },
70
+ };
71
+ // @deprecated use `COLLATERAL_TO_CHAIN_COLLATERAL_INDEX` instead
72
+ exports.COLLATERAL_TO_COLLATERAL_INDEX = {
73
+ [types_1.CollateralTypes.DAI]: 1,
74
+ [types_1.CollateralTypes.ETH]: 2,
75
+ [types_1.CollateralTypes.USDC]: 3,
76
+ [types_1.CollateralTypes.ARB]: 0,
77
+ [types_1.CollateralTypes.APE]: 0,
78
+ [types_1.CollateralTypes.GNS]: 0, // not in use
79
+ };
80
+ __exportStar(require("./utils"), exports);
81
+ __exportStar(require("./addresses"), exports);
82
+ var types_2 = require("./types");
83
+ Object.defineProperty(exports, "CollateralTypes", { enumerable: true, get: function () { return types_2.CollateralTypes; } });