lynx-client 0.0.5 → 0.0.6

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 (131) hide show
  1. package/dist/cjs/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/AcceptableImplementationClaimableAdminService.js +53 -0
  2. package/dist/cjs/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/IAcceptableImplementationClaimableAdminService.js +2 -0
  3. package/dist/cjs/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/index.js +5 -0
  4. package/dist/cjs/lib/contractsIntegration/LexPoolV1Service/ILexPoolV1Service.js +2 -0
  5. package/dist/cjs/lib/contractsIntegration/LexPoolV1Service/LexPoolV1Service.js +210 -0
  6. package/dist/cjs/lib/contractsIntegration/LexPoolV1Service/index.js +5 -0
  7. package/dist/cjs/lib/contractsIntegration/PNLRService/IPNLRService.js +2 -0
  8. package/dist/cjs/lib/contractsIntegration/PNLRService/PNLRService.js +124 -0
  9. package/dist/cjs/lib/contractsIntegration/PNLRService/index.js +5 -0
  10. package/dist/cjs/lib/contractsIntegration/PoolAccountantV1Service/IPoolAccountantV1Service.js +2 -0
  11. package/dist/cjs/lib/contractsIntegration/PoolAccountantV1Service/PoolAccountantV1Service.js +254 -0
  12. package/dist/cjs/lib/contractsIntegration/PoolAccountantV1Service/index.js +5 -0
  13. package/dist/cjs/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.js +9 -9
  14. package/dist/cjs/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.js +9 -9
  15. package/dist/cjs/lib/typechain/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin.js +2 -0
  16. package/dist/cjs/lib/typechain/contracts/Lynx/Lex/PNLR/PNLR.js +2 -0
  17. package/dist/cjs/lib/typechain/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1.js +2 -0
  18. package/dist/cjs/lib/typechain/contracts/Lynx/interfaces/IPriceValidatorV1.js +2 -0
  19. package/dist/cjs/lib/typechain/factories/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin__factory.js +232 -0
  20. package/dist/cjs/lib/typechain/factories/contracts/Lynx/Lex/PNLR/PNLR__factory.js +585 -0
  21. package/dist/cjs/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.js +3762 -0
  22. package/dist/cjs/lib/typechain/factories/contracts/Lynx/interfaces/IPriceValidatorV1__factory.js +116 -0
  23. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/AcceptableImplementationClaimableAdminService.d.ts +10 -0
  24. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/AcceptableImplementationClaimableAdminService.d.ts.map +1 -0
  25. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/AcceptableImplementationClaimableAdminService.js +53 -0
  26. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/IAcceptableImplementationClaimableAdminService.d.ts +21 -0
  27. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/IAcceptableImplementationClaimableAdminService.d.ts.map +1 -0
  28. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/IAcceptableImplementationClaimableAdminService.js +2 -0
  29. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/index.d.ts +3 -0
  30. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/index.d.ts.map +1 -0
  31. package/dist/esm/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/index.js +5 -0
  32. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/ILexPoolV1Service.d.ts +124 -0
  33. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/ILexPoolV1Service.d.ts.map +1 -0
  34. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/ILexPoolV1Service.js +2 -0
  35. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/LexPoolV1Service.d.ts +24 -0
  36. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/LexPoolV1Service.d.ts.map +1 -0
  37. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/LexPoolV1Service.js +210 -0
  38. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/index.d.ts +3 -0
  39. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/index.d.ts.map +1 -0
  40. package/dist/esm/lib/contractsIntegration/LexPoolV1Service/index.js +5 -0
  41. package/dist/esm/lib/contractsIntegration/PNLRService/IPNLRService.d.ts +49 -0
  42. package/dist/esm/lib/contractsIntegration/PNLRService/IPNLRService.d.ts.map +1 -0
  43. package/dist/esm/lib/contractsIntegration/PNLRService/IPNLRService.js +2 -0
  44. package/dist/esm/lib/contractsIntegration/PNLRService/PNLRService.d.ts +14 -0
  45. package/dist/esm/lib/contractsIntegration/PNLRService/PNLRService.d.ts.map +1 -0
  46. package/dist/esm/lib/contractsIntegration/PNLRService/PNLRService.js +124 -0
  47. package/dist/esm/lib/contractsIntegration/PNLRService/index.d.ts +3 -0
  48. package/dist/esm/lib/contractsIntegration/PNLRService/index.d.ts.map +1 -0
  49. package/dist/esm/lib/contractsIntegration/PNLRService/index.js +5 -0
  50. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/IPoolAccountantV1Service.d.ts +160 -0
  51. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/IPoolAccountantV1Service.d.ts.map +1 -0
  52. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/IPoolAccountantV1Service.js +2 -0
  53. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/PoolAccountantV1Service.d.ts +31 -0
  54. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/PoolAccountantV1Service.d.ts.map +1 -0
  55. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/PoolAccountantV1Service.js +254 -0
  56. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/index.d.ts +3 -0
  57. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/index.d.ts.map +1 -0
  58. package/dist/esm/lib/contractsIntegration/PoolAccountantV1Service/index.js +5 -0
  59. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts +2 -11
  60. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts.map +1 -1
  61. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.js +9 -9
  62. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.d.ts.map +1 -1
  63. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.js +9 -9
  64. package/dist/esm/lib/typechain/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin.d.ts +143 -0
  65. package/dist/esm/lib/typechain/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin.d.ts.map +1 -0
  66. package/dist/esm/lib/typechain/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin.js +2 -0
  67. package/dist/esm/lib/typechain/contracts/Lynx/Lex/PNLR/PNLR.d.ts +266 -0
  68. package/dist/esm/lib/typechain/contracts/Lynx/Lex/PNLR/PNLR.d.ts.map +1 -0
  69. package/dist/esm/lib/typechain/contracts/Lynx/Lex/PNLR/PNLR.js +2 -0
  70. package/dist/esm/lib/typechain/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1.d.ts +2085 -0
  71. package/dist/esm/lib/typechain/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1.d.ts.map +1 -0
  72. package/dist/esm/lib/typechain/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1.js +2 -0
  73. package/dist/esm/lib/typechain/contracts/Lynx/interfaces/IPriceValidatorV1.d.ts +72 -0
  74. package/dist/esm/lib/typechain/contracts/Lynx/interfaces/IPriceValidatorV1.d.ts.map +1 -0
  75. package/dist/esm/lib/typechain/contracts/Lynx/interfaces/IPriceValidatorV1.js +2 -0
  76. package/dist/esm/lib/typechain/factories/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin__factory.d.ts +173 -0
  77. package/dist/esm/lib/typechain/factories/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin__factory.d.ts.map +1 -0
  78. package/dist/esm/lib/typechain/factories/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin__factory.js +232 -0
  79. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PNLR/PNLR__factory.d.ts +439 -0
  80. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PNLR/PNLR__factory.d.ts.map +1 -0
  81. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PNLR/PNLR__factory.js +585 -0
  82. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.d.ts +2899 -0
  83. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.d.ts.map +1 -0
  84. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.js +3762 -0
  85. package/dist/esm/lib/typechain/factories/contracts/Lynx/interfaces/IPriceValidatorV1__factory.d.ts +81 -0
  86. package/dist/esm/lib/typechain/factories/contracts/Lynx/interfaces/IPriceValidatorV1__factory.d.ts.map +1 -0
  87. package/dist/esm/lib/typechain/factories/contracts/Lynx/interfaces/IPriceValidatorV1__factory.js +116 -0
  88. package/dist/types/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/AcceptableImplementationClaimableAdminService.d.ts +10 -0
  89. package/dist/types/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/AcceptableImplementationClaimableAdminService.d.ts.map +1 -0
  90. package/dist/types/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/IAcceptableImplementationClaimableAdminService.d.ts +21 -0
  91. package/dist/types/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/IAcceptableImplementationClaimableAdminService.d.ts.map +1 -0
  92. package/dist/types/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/index.d.ts +3 -0
  93. package/dist/types/lib/contractsIntegration/AcceptableImplementationClaimableAdminService/index.d.ts.map +1 -0
  94. package/dist/types/lib/contractsIntegration/LexPoolV1Service/ILexPoolV1Service.d.ts +124 -0
  95. package/dist/types/lib/contractsIntegration/LexPoolV1Service/ILexPoolV1Service.d.ts.map +1 -0
  96. package/dist/types/lib/contractsIntegration/LexPoolV1Service/LexPoolV1Service.d.ts +24 -0
  97. package/dist/types/lib/contractsIntegration/LexPoolV1Service/LexPoolV1Service.d.ts.map +1 -0
  98. package/dist/types/lib/contractsIntegration/LexPoolV1Service/index.d.ts +3 -0
  99. package/dist/types/lib/contractsIntegration/LexPoolV1Service/index.d.ts.map +1 -0
  100. package/dist/types/lib/contractsIntegration/PNLRService/IPNLRService.d.ts +49 -0
  101. package/dist/types/lib/contractsIntegration/PNLRService/IPNLRService.d.ts.map +1 -0
  102. package/dist/types/lib/contractsIntegration/PNLRService/PNLRService.d.ts +14 -0
  103. package/dist/types/lib/contractsIntegration/PNLRService/PNLRService.d.ts.map +1 -0
  104. package/dist/types/lib/contractsIntegration/PNLRService/index.d.ts +3 -0
  105. package/dist/types/lib/contractsIntegration/PNLRService/index.d.ts.map +1 -0
  106. package/dist/types/lib/contractsIntegration/PoolAccountantV1Service/IPoolAccountantV1Service.d.ts +160 -0
  107. package/dist/types/lib/contractsIntegration/PoolAccountantV1Service/IPoolAccountantV1Service.d.ts.map +1 -0
  108. package/dist/types/lib/contractsIntegration/PoolAccountantV1Service/PoolAccountantV1Service.d.ts +31 -0
  109. package/dist/types/lib/contractsIntegration/PoolAccountantV1Service/PoolAccountantV1Service.d.ts.map +1 -0
  110. package/dist/types/lib/contractsIntegration/PoolAccountantV1Service/index.d.ts +3 -0
  111. package/dist/types/lib/contractsIntegration/PoolAccountantV1Service/index.d.ts.map +1 -0
  112. package/dist/types/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts +2 -11
  113. package/dist/types/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts.map +1 -1
  114. package/dist/types/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.d.ts.map +1 -1
  115. package/dist/types/lib/typechain/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin.d.ts +143 -0
  116. package/dist/types/lib/typechain/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin.d.ts.map +1 -0
  117. package/dist/types/lib/typechain/contracts/Lynx/Lex/PNLR/PNLR.d.ts +266 -0
  118. package/dist/types/lib/typechain/contracts/Lynx/Lex/PNLR/PNLR.d.ts.map +1 -0
  119. package/dist/types/lib/typechain/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1.d.ts +2085 -0
  120. package/dist/types/lib/typechain/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1.d.ts.map +1 -0
  121. package/dist/types/lib/typechain/contracts/Lynx/interfaces/IPriceValidatorV1.d.ts +72 -0
  122. package/dist/types/lib/typechain/contracts/Lynx/interfaces/IPriceValidatorV1.d.ts.map +1 -0
  123. package/dist/types/lib/typechain/factories/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin__factory.d.ts +173 -0
  124. package/dist/types/lib/typechain/factories/contracts/AdministrationContracts/AcceptableImplementationClaimableAdmin__factory.d.ts.map +1 -0
  125. package/dist/types/lib/typechain/factories/contracts/Lynx/Lex/PNLR/PNLR__factory.d.ts +439 -0
  126. package/dist/types/lib/typechain/factories/contracts/Lynx/Lex/PNLR/PNLR__factory.d.ts.map +1 -0
  127. package/dist/types/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.d.ts +2899 -0
  128. package/dist/types/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.d.ts.map +1 -0
  129. package/dist/types/lib/typechain/factories/contracts/Lynx/interfaces/IPriceValidatorV1__factory.d.ts +81 -0
  130. package/dist/types/lib/typechain/factories/contracts/Lynx/interfaces/IPriceValidatorV1__factory.d.ts.map +1 -0
  131. package/package.json +1 -1
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PoolAccountantV1Service = void 0;
4
+ const PoolAccountantV1__factory_1 = require("../../typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory");
5
+ // Note: registerOpenTrade, registerCloseTrade, and registerUpdateTp are internal protocol functions
6
+ // called only by other Lynx contracts and are not exposed for external use
7
+ class PoolAccountantV1FunctionsGroup_TradeUtilities {
8
+ constructor(contract) {
9
+ this.contract = contract;
10
+ }
11
+ async adjustClosePrice(closePrice, tp, long) {
12
+ return this.contract.adjustClosePrice(closePrice, tp, long);
13
+ }
14
+ async generatePositionHashId(settlementAsset, trader, pairId, index) {
15
+ return this.contract.generatePositionHashId(settlementAsset, trader, pairId, index);
16
+ }
17
+ }
18
+ class PoolAccountantV1FunctionsGroup_FeeCalculations {
19
+ constructor(contract) {
20
+ this.contract = contract;
21
+ }
22
+ async calcClosingFee(pairId, collateral, leverage) {
23
+ return this.contract.calcClosingFee(pairId, collateral, leverage);
24
+ }
25
+ async calcPerformanceFee(pairId, collateral, profitPrecision) {
26
+ return this.contract.calcPerformanceFee(pairId, collateral, profitPrecision);
27
+ }
28
+ async calcTradeDynamicFees(positionId, pairId, long, collateral, leverage, openPrice, tp) {
29
+ const result = await this.contract.calcTradeDynamicFees.staticCall(positionId, pairId, long, collateral, leverage, openPrice, tp);
30
+ return {
31
+ interest: result.interest,
32
+ funding: result.funding,
33
+ };
34
+ }
35
+ async calcBorrowAmount(collateral, leverage, long, openPrice, tp) {
36
+ return this.contract.calcBorrowAmount(collateral, leverage, long, openPrice, tp);
37
+ }
38
+ async calcAbsoluteSkew(openInterestLong, openInterestShort, additionIsLong, additionOpenInterest) {
39
+ return this.contract.calcAbsoluteSkew(openInterestLong, openInterestShort, additionIsLong, additionOpenInterest);
40
+ }
41
+ async calcAccrueFundingValues(pairId) {
42
+ const result = await this.contract.calcAccrueFundingValues(pairId);
43
+ return {
44
+ freshened: result.freshened,
45
+ valueLong: result.valueLong,
46
+ valueShort: result.valueShort,
47
+ protocolFundingShare: result.protocolFundingShare,
48
+ };
49
+ }
50
+ }
51
+ // Similarly implement other groups...
52
+ // For brevity, I'll create a simplified version with the main structure
53
+ class PoolAccountantV1Service {
54
+ constructor(signerOrProvider, address) {
55
+ this.poolAccountantContract = PoolAccountantV1__factory_1.PoolAccountantV1__factory.connect(address, signerOrProvider);
56
+ this.tradeUtilities = new PoolAccountantV1FunctionsGroup_TradeUtilities(this.poolAccountantContract);
57
+ this.feeCalculations = new PoolAccountantV1FunctionsGroup_FeeCalculations(this.poolAccountantContract);
58
+ this.verification = this.createVerificationGroup();
59
+ // Initialize other groups with direct method mappings
60
+ this.funding = this.createFundingGroup();
61
+ this.interest = this.createInterestGroup();
62
+ this.liquidation = this.createLiquidationGroup();
63
+ this.tradeValues = this.createTradeValuesGroup();
64
+ this.pairManagement = this.createPairManagementGroup();
65
+ this.adminConfiguration = this.createAdminConfigurationGroup();
66
+ this.poolInteraction = this.createPoolInteractionGroup();
67
+ this.stateVariables = this.createStateVariablesGroup();
68
+ this.contractInfo = this.createContractInfoGroup();
69
+ this.constants = this.createConstantsGroup();
70
+ }
71
+ createVerificationGroup() {
72
+ return {
73
+ verifyLeveragedPosition: async (pairIndex, collateral, leverage) => {
74
+ const result = await this.poolAccountantContract.verifyLeveragedPosition(pairIndex, collateral, leverage);
75
+ return result;
76
+ },
77
+ verifyOpenFee: async (pairIndex, leveragedPosition) => {
78
+ const result = await this.poolAccountantContract.verifyOpenFee(pairIndex, leveragedPosition);
79
+ return {
80
+ openFee: result[0],
81
+ lexPartFee: result[1],
82
+ };
83
+ },
84
+ verifyPerformanceFee: (pairIndex, collateral) => this.poolAccountantContract.verifyPerformanceFee(pairIndex, collateral),
85
+ verifyMaxPercentProfit: (openPrice, targetPrice, leverage, long) => this.poolAccountantContract.verifyMaxPercentProfit(openPrice, targetPrice, leverage, long),
86
+ verifyUtilizationForTraders: (totalBorrows, totalReserves, unrealizedFunding) => this.poolAccountantContract.verifyUtilizationForTraders(totalBorrows, totalReserves, unrealizedFunding),
87
+ };
88
+ }
89
+ createFundingGroup() {
90
+ return {
91
+ accrueFunding: async (pairId) => {
92
+ const result = await this.poolAccountantContract.accrueFunding.staticCall(pairId);
93
+ return {
94
+ valueLong: result[0],
95
+ valueShort: result[1],
96
+ protocolFundingShare: result[2],
97
+ };
98
+ },
99
+ calcAccrueFundingValues: (pairId) => this.poolAccountantContract
100
+ .calcAccrueFundingValues(pairId)
101
+ .then((r) => ({
102
+ freshened: r.freshened,
103
+ valueLong: r.valueLong,
104
+ valueShort: r.valueShort,
105
+ protocolFundingShare: r.protocolFundingShare,
106
+ })),
107
+ fundingIndicesCalculation: (oiLong, oiShort, fundingRate, timeDiff) => this.poolAccountantContract
108
+ .fundingIndicesCalculation(oiLong, oiShort, fundingRate, timeDiff)
109
+ .then((r) => ({
110
+ indexLongChange: r.indexLongChange,
111
+ indexShortChange: r.indexShortChange,
112
+ protocolFundingShare: r.protocolFundingShare,
113
+ })),
114
+ getTradeFunding: (positionId, pairId, long, collateral, leverage) => this.poolAccountantContract.getTradeFunding.staticCall(positionId, pairId, long, collateral, leverage),
115
+ getTradeFundingPure: (accFundingPerOi, endAccFundingPerOi, collateral, leverage) => this.poolAccountantContract.getTradeFundingPure(accFundingPerOi, endAccFundingPerOi, collateral, leverage),
116
+ getTradeInitialAccFundingPerOi: (positionId) => this.poolAccountantContract.getTradeInitialAccFundingPerOi(positionId),
117
+ getAccFundingLong: (pairIndex) => this.poolAccountantContract.getAccFundingLong(pairIndex),
118
+ getAccFundingShort: (pairIndex) => this.poolAccountantContract.getAccFundingShort(pairIndex),
119
+ getAccFundingUpdateBlock: (pairIndex) => this.poolAccountantContract.getAccFundingUpdateBlock(pairIndex),
120
+ };
121
+ }
122
+ createInterestGroup() {
123
+ return {
124
+ getTradeInterest: (positionId, borrowAmount) => this.poolAccountantContract.getTradeInterest.staticCall(positionId, borrowAmount),
125
+ getTradeInterestPure: (tradeAccInterest, borrowsAndInterestShare, borrowIndex, accBorrowIndex) => this.poolAccountantContract.getTradeInterestPure(tradeAccInterest, borrowsAndInterestShare, borrowIndex, accBorrowIndex),
126
+ getTradeInitialAccBorrowIndex: (positionId) => this.poolAccountantContract.getTradeInitialAccBorrowIndex(positionId),
127
+ accrueInterest: async (availableCash) => {
128
+ const result = await this.poolAccountantContract["accrueInterest(uint256)"].staticCall(availableCash);
129
+ return {
130
+ totalInterestNew: result[0],
131
+ interestShareNew: result[1],
132
+ borrowIndexNew: result[2],
133
+ };
134
+ },
135
+ };
136
+ }
137
+ createLiquidationGroup() {
138
+ return {
139
+ getTradeLiquidationPrice: (positionId, pairId, openPrice, tp, long, collateral, leverage) => this.poolAccountantContract.getTradeLiquidationPrice.staticCall(positionId, pairId, openPrice, tp, long, collateral, leverage),
140
+ getTradeLiquidationPriceView: (openPrice, long, collateral, leverage, interest, funding, closingFee) => this.poolAccountantContract.getTradeLiquidationPriceView(openPrice, long, collateral, leverage, interest, funding, closingFee),
141
+ };
142
+ }
143
+ createTradeValuesGroup() {
144
+ return {
145
+ getTradeValueView: (collateral, profitPrecision, interest, funding, closingFee, liquidation) => this.poolAccountantContract.getTradeValueView(collateral, profitPrecision, interest, funding, closingFee, liquidation),
146
+ getTradeClosingValues: async (positionId, pairId, collateral, leverage, long, openPrice, tp, closePrice, isLiquidation) => {
147
+ const params = {
148
+ collateral,
149
+ leverage,
150
+ long,
151
+ openPrice,
152
+ tp,
153
+ };
154
+ const result = await this.poolAccountantContract.getTradeClosingValues.staticCall(positionId, pairId, params, closePrice, isLiquidation);
155
+ return {
156
+ tradeValue: result[0],
157
+ safeClosingFee: result[1],
158
+ profitPrecision: result[2],
159
+ interest: result[3],
160
+ funding: result[4],
161
+ };
162
+ },
163
+ };
164
+ }
165
+ createPairManagementGroup() {
166
+ return {
167
+ pairTotalOpenInterest: (pairIndex) => this.poolAccountantContract.pairTotalOpenInterest(pairIndex),
168
+ calcAbsoluteSkew: (openInterestLong, openInterestShort, additionIsLong, additionOpenInterest) => this.poolAccountantContract.calcAbsoluteSkew(openInterestLong, openInterestShort, additionIsLong, additionOpenInterest),
169
+ pricePnL: (pairId, price) => this.poolAccountantContract.pricePnL(pairId, price),
170
+ };
171
+ }
172
+ createAdminConfigurationGroup() {
173
+ return {
174
+ setTradeIncentivizer: (incentivizer) => this.poolAccountantContract.setTradeIncentivizer(incentivizer),
175
+ setMaxGainF: (maxGainF) => this.poolAccountantContract.setMaxGainF(maxGainF),
176
+ setFrm: (frm) => this.poolAccountantContract.setFrm(frm),
177
+ setMinOpenFee: (min) => this.poolAccountantContract.setMinOpenFee(min),
178
+ setLexPartF: (partF) => this.poolAccountantContract.setLexPartF(partF),
179
+ setFundingRateMax: (maxValue) => this.poolAccountantContract.setFundingRateMax(maxValue),
180
+ setLiquidationThresholdF: (threshold) => this.poolAccountantContract.setLiquidationThresholdF(threshold),
181
+ setLiquidationFeeF: (fee) => this.poolAccountantContract.setLiquidationFeeF(fee),
182
+ setIrm: (irm) => this.poolAccountantContract.setIrm(irm),
183
+ setIrmHard: (irm) => this.poolAccountantContract.setIrmHard(irm),
184
+ setInterestShareFactor: (factor) => this.poolAccountantContract.setInterestShareFactor(factor),
185
+ setFundingShareFactor: (factor) => this.poolAccountantContract.setFundingShareFactor(factor),
186
+ setBorrowRateMax: (rate) => this.poolAccountantContract.setBorrowRateMax(rate),
187
+ setMaxTotalBorrows: (maxBorrows) => this.poolAccountantContract.setMaxTotalBorrows(maxBorrows),
188
+ setMaxVirtualUtilization: (maxUtilization) => this.poolAccountantContract.setMaxVirtualUtilization(maxUtilization),
189
+ };
190
+ }
191
+ createPoolInteractionGroup() {
192
+ return {
193
+ readAndZeroReserves: async () => {
194
+ const result = await this.poolAccountantContract.readAndZeroReserves.staticCall();
195
+ return {
196
+ accumulatedInterestShare: result[0],
197
+ accFundingShare: result[1],
198
+ };
199
+ },
200
+ };
201
+ }
202
+ createStateVariablesGroup() {
203
+ return {
204
+ // Interest and borrowing state
205
+ borrowIndex: () => this.poolAccountantContract.borrowIndex(),
206
+ borrowRateMax: () => this.poolAccountantContract.borrowRateMax(),
207
+ totalBorrows: () => this.poolAccountantContract.totalBorrows(),
208
+ totalInterest: () => this.poolAccountantContract.totalInterest(),
209
+ interestShare: () => this.poolAccountantContract.interestShare(),
210
+ interestShareFactor: () => this.poolAccountantContract.interestShareFactor(),
211
+ // Funding state
212
+ fundingRateMax: () => this.poolAccountantContract.fundingRateMax(),
213
+ fundingShare: () => this.poolAccountantContract.fundingShare(),
214
+ fundingShareFactor: () => this.poolAccountantContract.fundingShareFactor(),
215
+ unrealizedFunding: () => this.poolAccountantContract.unrealizedFunding(),
216
+ realizedFundingSurplusDeficit: () => this.poolAccountantContract.realizedFundingSurplusDeficit(),
217
+ // Configuration
218
+ maxGainF: () => this.poolAccountantContract.maxGainF(),
219
+ liquidationFeeF: () => this.poolAccountantContract.liquidationFeeF(),
220
+ liquidationThresholdF: () => this.poolAccountantContract.liquidationThresholdF(),
221
+ maxTotalBorrows: () => this.poolAccountantContract.maxTotalBorrows(),
222
+ maxVirtualUtilization: () => this.poolAccountantContract.maxVirtualUtilization(),
223
+ minOpenFee: () => this.poolAccountantContract.minOpenFee(),
224
+ lexPartF: () => this.poolAccountantContract.lexPartF(),
225
+ // Contract references
226
+ lexPool: () => this.poolAccountantContract.lexPool(),
227
+ tradingFloor: () => this.poolAccountantContract.tradingFloor(),
228
+ tradeIncentivizer: () => this.poolAccountantContract.tradeIncentivizer(),
229
+ frm: () => this.poolAccountantContract.frm(),
230
+ irm: () => this.poolAccountantContract.irm(),
231
+ underlying: () => this.poolAccountantContract.underlying(),
232
+ // Timestamps
233
+ accrualBlockTimestamp: () => this.poolAccountantContract.accrualBlockTimestamp(),
234
+ };
235
+ }
236
+ createContractInfoGroup() {
237
+ return {
238
+ admin: () => this.poolAccountantContract.admin(),
239
+ pendingAdmin: () => this.poolAccountantContract.pendingAdmin(),
240
+ implementation: () => this.poolAccountantContract.implementation(),
241
+ pendingImplementation: () => this.poolAccountantContract.pendingImplementation(),
242
+ registry: () => this.poolAccountantContract.registry(),
243
+ };
244
+ }
245
+ createConstantsGroup() {
246
+ return {
247
+ ACCURACY_IMPROVEMENT_SCALE: () => this.poolAccountantContract.ACCURACY_IMPROVEMENT_SCALE(),
248
+ FRACTION_SCALE: () => this.poolAccountantContract.FRACTION_SCALE(),
249
+ LEVERAGE_SCALE: () => this.poolAccountantContract.LEVERAGE_SCALE(),
250
+ PRECISION: () => this.poolAccountantContract.PRECISION(),
251
+ };
252
+ }
253
+ }
254
+ exports.PoolAccountantV1Service = PoolAccountantV1Service;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PoolAccountantV1Service = void 0;
4
+ var PoolAccountantV1Service_1 = require("./PoolAccountantV1Service");
5
+ Object.defineProperty(exports, "PoolAccountantV1Service", { enumerable: true, get: function () { return PoolAccountantV1Service_1.PoolAccountantV1Service; } });
@@ -11,23 +11,23 @@ exports.EMPTY_COMPLETE_POSITION_DATA = {
11
11
  collateral: 0n,
12
12
  phase: 0,
13
13
  inPhaseSince: 0,
14
- leverage: 0,
14
+ leverage: 0n,
15
15
  long: false,
16
- openPrice: 0,
17
- spreadReductionF: 0,
18
- minPrice: 0,
19
- maxPrice: 0,
16
+ openPrice: 0n,
17
+ spreadReductionF: 0n,
18
+ minPrice: 0n,
19
+ maxPrice: 0n,
20
20
  tpLastUpdated: 0,
21
21
  slLastUpdated: 0,
22
- tp: 0,
23
- sl: 0,
22
+ tp: 0n,
23
+ sl: 0n,
24
24
  pendingUpdateOrderType: 0,
25
25
  pendingUpdateOrderTimestamp: 0,
26
26
  pendingUpdateOrderFieldAValue: 0n,
27
27
  pendingUpdateOrderFieldBValue: 0n,
28
28
  funding: 0n,
29
29
  borrowInterest: 0n,
30
- liquidationPrice: 0,
30
+ liquidationPrice: 0n,
31
31
  };
32
32
  exports.EMPTY_POSITIONS_RESULT = {
33
33
  positions: [],
@@ -40,7 +40,7 @@ exports.EMPTY_POSITION_LIQUIDATION_INFO = {
40
40
  phase: 0,
41
41
  funding: 0n,
42
42
  borrowInterest: 0n,
43
- liquidationPrice: 0,
43
+ liquidationPrice: 0n,
44
44
  };
45
45
  exports.EMPTY_LIQUIDATION_RESULT = {
46
46
  positionsLiquidationInfo: [],
@@ -13,18 +13,18 @@ function convertPositionData(pos) {
13
13
  positionIndex: Number(baseStruct.positionIndex),
14
14
  phase: Number(baseStruct.phase),
15
15
  inPhaseSince: Number(baseStruct.inPhaseSince),
16
- leverage: Number(baseStruct.leverage),
17
- openPrice: Number(baseStruct.openPrice),
18
- spreadReductionF: Number(baseStruct.spreadReductionF),
19
- minPrice: Number(baseStruct.minPrice),
20
- maxPrice: Number(baseStruct.maxPrice),
16
+ leverage: baseStruct.leverage,
17
+ openPrice: baseStruct.openPrice,
18
+ spreadReductionF: baseStruct.spreadReductionF,
19
+ minPrice: baseStruct.minPrice,
20
+ maxPrice: baseStruct.maxPrice,
21
21
  tpLastUpdated: Number(baseStruct.tpLastUpdated),
22
22
  slLastUpdated: Number(baseStruct.slLastUpdated),
23
- tp: Number(baseStruct.tp),
24
- sl: Number(baseStruct.sl),
23
+ tp: baseStruct.tp,
24
+ sl: baseStruct.sl,
25
25
  pendingUpdateOrderType: Number(baseStruct.pendingUpdateOrderType),
26
26
  pendingUpdateOrderTimestamp: Number(baseStruct.pendingUpdateOrderTimestamp),
27
- liquidationPrice: Number(baseStruct.liquidationPrice),
27
+ liquidationPrice: baseStruct.liquidationPrice,
28
28
  };
29
29
  }
30
30
  function convertLiquidationInfo(pos) {
@@ -32,7 +32,7 @@ function convertLiquidationInfo(pos) {
32
32
  return {
33
33
  ...baseStruct,
34
34
  phase: Number(baseStruct.phase),
35
- liquidationPrice: Number(baseStruct.liquidationPrice),
35
+ liquidationPrice: baseStruct.liquidationPrice,
36
36
  };
37
37
  }
38
38
  class TradingFloorLensService {
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AcceptableImplementationClaimableAdmin__factory = void 0;
4
+ /* Autogenerated file. Do not edit manually. */
5
+ /* tslint:disable */
6
+ /* eslint-disable */
7
+ const ethers_1 = require("ethers");
8
+ const _abi = [
9
+ {
10
+ inputs: [
11
+ {
12
+ internalType: "address",
13
+ name: "_initialAdmin",
14
+ type: "address",
15
+ },
16
+ ],
17
+ stateMutability: "nonpayable",
18
+ type: "constructor",
19
+ },
20
+ {
21
+ anonymous: false,
22
+ inputs: [
23
+ {
24
+ indexed: false,
25
+ internalType: "address",
26
+ name: "oldAdmin",
27
+ type: "address",
28
+ },
29
+ {
30
+ indexed: false,
31
+ internalType: "address",
32
+ name: "newAdmin",
33
+ type: "address",
34
+ },
35
+ ],
36
+ name: "NewAdmin",
37
+ type: "event",
38
+ },
39
+ {
40
+ anonymous: false,
41
+ inputs: [
42
+ {
43
+ indexed: false,
44
+ internalType: "address",
45
+ name: "oldImplementation",
46
+ type: "address",
47
+ },
48
+ {
49
+ indexed: false,
50
+ internalType: "address",
51
+ name: "newImplementation",
52
+ type: "address",
53
+ },
54
+ ],
55
+ name: "NewImplementation",
56
+ type: "event",
57
+ },
58
+ {
59
+ anonymous: false,
60
+ inputs: [
61
+ {
62
+ indexed: false,
63
+ internalType: "address",
64
+ name: "oldPendingAdmin",
65
+ type: "address",
66
+ },
67
+ {
68
+ indexed: false,
69
+ internalType: "address",
70
+ name: "newPendingAdmin",
71
+ type: "address",
72
+ },
73
+ ],
74
+ name: "NewPendingAdmin",
75
+ type: "event",
76
+ },
77
+ {
78
+ anonymous: false,
79
+ inputs: [
80
+ {
81
+ indexed: false,
82
+ internalType: "address",
83
+ name: "oldPendingImplementation",
84
+ type: "address",
85
+ },
86
+ {
87
+ indexed: false,
88
+ internalType: "address",
89
+ name: "newPendingImplementation",
90
+ type: "address",
91
+ },
92
+ ],
93
+ name: "NewPendingImplementation",
94
+ type: "event",
95
+ },
96
+ {
97
+ stateMutability: "payable",
98
+ type: "fallback",
99
+ },
100
+ {
101
+ inputs: [],
102
+ name: "_acceptAdmin",
103
+ outputs: [],
104
+ stateMutability: "nonpayable",
105
+ type: "function",
106
+ },
107
+ {
108
+ inputs: [],
109
+ name: "_acceptImplementation",
110
+ outputs: [
111
+ {
112
+ internalType: "uint256",
113
+ name: "",
114
+ type: "uint256",
115
+ },
116
+ ],
117
+ stateMutability: "nonpayable",
118
+ type: "function",
119
+ },
120
+ {
121
+ inputs: [
122
+ {
123
+ internalType: "address",
124
+ name: "newPendingAdmin",
125
+ type: "address",
126
+ },
127
+ ],
128
+ name: "_setPendingAdmin",
129
+ outputs: [],
130
+ stateMutability: "nonpayable",
131
+ type: "function",
132
+ },
133
+ {
134
+ inputs: [
135
+ {
136
+ internalType: "address",
137
+ name: "newPendingImplementation",
138
+ type: "address",
139
+ },
140
+ ],
141
+ name: "_setPendingImplementation",
142
+ outputs: [],
143
+ stateMutability: "nonpayable",
144
+ type: "function",
145
+ },
146
+ {
147
+ inputs: [],
148
+ name: "admin",
149
+ outputs: [
150
+ {
151
+ internalType: "address",
152
+ name: "",
153
+ type: "address",
154
+ },
155
+ ],
156
+ stateMutability: "view",
157
+ type: "function",
158
+ },
159
+ {
160
+ inputs: [],
161
+ name: "implementation",
162
+ outputs: [
163
+ {
164
+ internalType: "address",
165
+ name: "",
166
+ type: "address",
167
+ },
168
+ ],
169
+ stateMutability: "view",
170
+ type: "function",
171
+ },
172
+ {
173
+ inputs: [],
174
+ name: "pendingAdmin",
175
+ outputs: [
176
+ {
177
+ internalType: "address",
178
+ name: "",
179
+ type: "address",
180
+ },
181
+ ],
182
+ stateMutability: "view",
183
+ type: "function",
184
+ },
185
+ {
186
+ inputs: [],
187
+ name: "pendingImplementation",
188
+ outputs: [
189
+ {
190
+ internalType: "address",
191
+ name: "",
192
+ type: "address",
193
+ },
194
+ ],
195
+ stateMutability: "view",
196
+ type: "function",
197
+ },
198
+ {
199
+ stateMutability: "payable",
200
+ type: "receive",
201
+ },
202
+ ];
203
+ const _bytecode = "0x608060405234801561001057600080fd5b5060405161070838038061070883398101604081905261002f91610093565b600080546001600160a01b031990811633909116176001600160a01b03831690811782556040805192835260208301919091527ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a1506100c3565b6000602082840312156100a557600080fd5b81516001600160a01b03811681146100bc57600080fd5b9392505050565b610636806100d26000396000f3fe60806040526004361061007f5760003560e01c8063c1e803341161004e578063c1e80334146101a0578063e992a041146101c3578063e9c714f2146101e3578063f851a440146101f857610086565b80632678224714610103578063396f7b23146101405780635c60da1b14610160578063b71d1a0c1461018057610086565b3661008657005b6002546040516000916001600160a01b0316906100a690839036906105c0565b600060405180830381855af49150503d80600081146100e1576040519150601f19603f3d011682016040523d82523d6000602084013e6100e6565b606091505b505090506040513d6000823e8180156100fd573d82f35b3d82fd5b005b34801561010f57600080fd5b50600154610123906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561014c57600080fd5b50600354610123906001600160a01b031681565b34801561016c57600080fd5b50600254610123906001600160a01b031681565b34801561018c57600080fd5b5061010161019b3660046105d0565b610218565b3480156101ac57600080fd5b506101b56102c5565b604051908152602001610137565b3480156101cf57600080fd5b506101016101de3660046105d0565b610402565b3480156101ef57600080fd5b506101016104a2565b34801561020457600080fd5b50600054610123906001600160a01b031681565b6000546001600160a01b031633146102635760405162461bcd60e51b81526020600482015260096024820152682737ba1020b236b4b760b91b60448201526064015b60405180910390fd5b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a991015b60405180910390a15050565b6003546000906001600160a01b0316331480156102ec57506003546001600160a01b031615155b6103485760405162461bcd60e51b815260206004820152602760248201527f4e6f7420746865204558495354494e472070656e64696e6720696d706c656d65604482015266373a30ba34b7b760c91b606482015260840161025a565b60028054600380546001600160a01b038082166001600160a01b031980861682179096559490911690915560408051919092168082526020820184905292917fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a910160405180910390a1600354604080516001600160a01b03808516825290921660208301527fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d815910160405180910390a160009250505090565b6000546001600160a01b031633146104485760405162461bcd60e51b81526020600482015260096024820152683737ba1030b236b4b760b91b604482015260640161025a565b600380546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d81591016102b9565b6001546001600160a01b0316331480156104c657506001546001600160a01b031615155b6105125760405162461bcd60e51b815260206004820152601e60248201527f4e6f7420746865204558495354494e472070656e64696e672061646d696e0000604482015260640161025a565b60008054600180546001600160a01b038082166001600160a01b031980861682179096559490911690915560408051919092168082526020820184905292917ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a1600154604080516001600160a01b03808516825290921660208301527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a991016102b9565b8183823760009101908152919050565b6000602082840312156105e257600080fd5b81356001600160a01b03811681146105f957600080fd5b939250505056fea26469706673582212209691a59874acb4b592f58b61afd1b9e743432cff87e25089a2d254875f2c8fcb64736f6c63430008180033";
204
+ const isSuperArgs = (xs) => xs.length > 1;
205
+ class AcceptableImplementationClaimableAdmin__factory extends ethers_1.ContractFactory {
206
+ constructor(...args) {
207
+ if (isSuperArgs(args)) {
208
+ super(...args);
209
+ }
210
+ else {
211
+ super(_abi, _bytecode, args[0]);
212
+ }
213
+ }
214
+ getDeployTransaction(_initialAdmin, overrides) {
215
+ return super.getDeployTransaction(_initialAdmin, overrides || {});
216
+ }
217
+ deploy(_initialAdmin, overrides) {
218
+ return super.deploy(_initialAdmin, overrides || {});
219
+ }
220
+ connect(runner) {
221
+ return super.connect(runner);
222
+ }
223
+ static createInterface() {
224
+ return new ethers_1.Interface(_abi);
225
+ }
226
+ static connect(address, runner) {
227
+ return new ethers_1.Contract(address, _abi, runner);
228
+ }
229
+ }
230
+ exports.AcceptableImplementationClaimableAdmin__factory = AcceptableImplementationClaimableAdmin__factory;
231
+ AcceptableImplementationClaimableAdmin__factory.bytecode = _bytecode;
232
+ AcceptableImplementationClaimableAdmin__factory.abi = _abi;