@gearbox-protocol/sdk 0.0.100 → 0.0.103

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 (163) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +52 -0
  3. package/.husky/pre-push +4 -0
  4. package/lib/apy/convexAPY.d.ts +8 -0
  5. package/lib/apy/convexAPY.js +200 -0
  6. package/lib/apy/lidoAPY.d.ts +4 -0
  7. package/lib/apy/lidoAPY.js +103 -0
  8. package/lib/config.d.ts +1 -0
  9. package/lib/config.js +2 -1
  10. package/lib/contracts/contracts.d.ts +9 -4
  11. package/lib/contracts/contracts.js +52 -14
  12. package/lib/contracts/contractsRegister.js +16 -4
  13. package/lib/core/constants.d.ts +7 -1
  14. package/lib/core/constants.js +11 -5
  15. package/lib/core/creditAccount.d.ts +3 -1
  16. package/lib/core/creditAccount.js +33 -31
  17. package/lib/core/creditManager.d.ts +13 -2
  18. package/lib/core/creditManager.js +77 -33
  19. package/lib/core/creditSession.js +14 -3
  20. package/lib/core/errors.d.ts +10 -0
  21. package/lib/core/errors.js +16 -1
  22. package/lib/core/eventOrTx.d.ts +1 -1
  23. package/lib/core/events.d.ts +19 -19
  24. package/lib/core/events.js +32 -30
  25. package/lib/core/multicall.d.ts +1 -1
  26. package/lib/core/pool.d.ts +2 -2
  27. package/lib/core/pool.js +8 -12
  28. package/lib/core/price.d.ts +2 -0
  29. package/lib/core/price.js +14 -0
  30. package/lib/core/strategy.d.ts +36 -0
  31. package/lib/core/strategy.js +57 -0
  32. package/lib/core/tokenDistributor.js +1 -1
  33. package/lib/core/transactions.d.ts +18 -3
  34. package/lib/core/transactions.js +39 -3
  35. package/lib/index.d.ts +8 -3
  36. package/lib/index.js +9 -4
  37. package/lib/oracles/priceFeeds.js +1 -1
  38. package/lib/pathfinder/convexLP.d.ts +1 -1
  39. package/lib/pathfinder/convexLP.js +26 -29
  40. package/lib/pathfinder/curveLP.d.ts +1 -1
  41. package/lib/pathfinder/curveLP.js +5 -7
  42. package/lib/pathfinder/path.d.ts +1 -1
  43. package/lib/pathfinder/path.js +38 -42
  44. package/lib/pathfinder/trade.d.ts +1 -2
  45. package/lib/pathfinder/tradeTypes.d.ts +5 -5
  46. package/lib/pathfinder/yVault.d.ts +2 -2
  47. package/lib/pathfinder/yVault.js +22 -19
  48. package/lib/payload/creditAccount.d.ts +4 -26
  49. package/lib/payload/creditManager.d.ts +3 -25
  50. package/lib/payload/pool.d.ts +2 -17
  51. package/lib/payload/pool.js +0 -1
  52. package/lib/strategies/curve.d.ts +6 -60
  53. package/lib/strategies/curve.js +6 -0
  54. package/lib/strategies/uniswapV2.js +3 -19
  55. package/lib/strategies/uniswapV3.js +1 -1
  56. package/lib/strategies/yearn.js +15 -11
  57. package/lib/tokens/convex.d.ts +3 -3
  58. package/lib/tokens/curveLP.d.ts +2 -2
  59. package/lib/tokens/curveLP.js +1 -1
  60. package/lib/tokens/gear.d.ts +2 -2
  61. package/lib/tokens/gear.js +1 -1
  62. package/lib/tokens/normal.d.ts +1 -1
  63. package/lib/tokens/token.js +9 -9
  64. package/lib/tokens/tokenData.d.ts +3 -1
  65. package/lib/tokens/tokenData.js +10 -8
  66. package/lib/tokens/yearn.d.ts +3 -3
  67. package/lib/utils/errors.d.ts +6 -0
  68. package/lib/utils/errors.js +13 -0
  69. package/lib/utils/formatter.d.ts +2 -1
  70. package/lib/utils/formatter.js +23 -15
  71. package/lib/utils/loading.d.ts +2 -1
  72. package/lib/utils/loading.js +9 -13
  73. package/lib/utils/mappers.d.ts +2 -1
  74. package/lib/utils/mappers.js +13 -5
  75. package/lib/utils/multicall.js +4 -3
  76. package/lib/utils/network.js +2 -2
  77. package/lib/utils/repeater.js +12 -24
  78. package/lib/utils/types.d.ts +1 -0
  79. package/lib/utils/validate.js +1 -1
  80. package/package.json +26 -8
  81. package/src/apy/convexAPY.ts +250 -0
  82. package/src/apy/lidoAPY.ts +89 -0
  83. package/src/config.ts +2 -1
  84. package/src/contracts/contracts.ts +73 -19
  85. package/src/contracts/contractsRegister.ts +19 -4
  86. package/src/core/constants.ts +11 -4
  87. package/src/core/creditAccount.ts +69 -37
  88. package/src/core/creditManager.ts +256 -148
  89. package/src/core/creditOperation.ts +7 -7
  90. package/src/core/creditSession.ts +25 -5
  91. package/src/core/errors.ts +25 -0
  92. package/src/core/eventOrTx.ts +8 -5
  93. package/src/core/events.ts +978 -911
  94. package/src/core/history.ts +46 -46
  95. package/src/core/multicall.ts +1 -1
  96. package/src/core/operations.ts +6 -0
  97. package/src/core/pool.ts +75 -58
  98. package/src/core/price.ts +13 -0
  99. package/src/core/strategy.ts +134 -0
  100. package/src/core/tokenDistributor.ts +2 -2
  101. package/src/core/transactions.ts +427 -350
  102. package/src/index.ts +9 -4
  103. package/src/oracles/priceFeeds.ts +523 -523
  104. package/src/pathfinder/contracts.ts +15 -13
  105. package/src/pathfinder/convexLP.ts +29 -25
  106. package/src/pathfinder/curveLP.ts +57 -53
  107. package/src/pathfinder/path.ts +158 -150
  108. package/src/pathfinder/priority.ts +11 -11
  109. package/src/pathfinder/trade.ts +84 -77
  110. package/src/pathfinder/tradeTypes.ts +98 -94
  111. package/src/pathfinder/yVault.ts +79 -63
  112. package/src/payload/creditAccount.ts +4 -26
  113. package/src/payload/creditManager.ts +4 -26
  114. package/src/payload/pool.ts +2 -19
  115. package/src/payload/token.ts +3 -3
  116. package/src/strategies/convex.ts +217 -210
  117. package/src/strategies/creditFacade.ts +70 -53
  118. package/src/strategies/curve.ts +263 -194
  119. package/src/strategies/lido.ts +33 -37
  120. package/src/strategies/uniswapV2.ts +90 -112
  121. package/src/strategies/uniswapV3.ts +114 -91
  122. package/src/strategies/yearn.ts +58 -62
  123. package/src/tokens/connectors.ts +6 -6
  124. package/src/tokens/convex.ts +297 -296
  125. package/src/tokens/curveLP.ts +170 -165
  126. package/src/tokens/gear.ts +47 -45
  127. package/src/tokens/normal.ts +801 -802
  128. package/src/tokens/token.ts +19 -10
  129. package/src/tokens/tokenData.ts +19 -9
  130. package/src/tokens/tokenType.ts +11 -11
  131. package/src/tokens/yearn.ts +126 -124
  132. package/src/utils/errors.ts +11 -0
  133. package/src/utils/formatter.ts +26 -18
  134. package/src/utils/loading.ts +14 -6
  135. package/src/utils/mappers.ts +15 -6
  136. package/src/utils/multicall.ts +6 -9
  137. package/src/utils/network.ts +21 -21
  138. package/src/utils/repeater.ts +2 -2
  139. package/src/utils/types.ts +6 -2
  140. package/src/utils/validate.ts +1 -1
  141. package/lib/core/adapters.d.ts +0 -15
  142. package/lib/core/adapters.js +0 -19
  143. package/lib/core/contracts.d.ts +0 -67
  144. package/lib/core/contracts.js +0 -254
  145. package/lib/core/contractsRegister.d.ts +0 -2
  146. package/lib/core/contractsRegister.js +0 -58
  147. package/lib/core/creditCard.d.ts +0 -13
  148. package/lib/core/creditCard.js +0 -2
  149. package/lib/core/oracles.d.ts +0 -38
  150. package/lib/core/oracles.js +0 -12
  151. package/lib/core/priceFeeds.d.ts +0 -3
  152. package/lib/core/priceFeeds.js +0 -492
  153. package/lib/core/protocols.d.ts +0 -13
  154. package/lib/core/protocols.js +0 -39
  155. package/lib/core/swap.d.ts +0 -4
  156. package/lib/core/swap.js +0 -8
  157. package/lib/core/trade.d.ts +0 -35
  158. package/lib/core/trade.js +0 -62
  159. package/lib/core/tradeTypes.d.ts +0 -79
  160. package/lib/core/tradeTypes.js +0 -21
  161. package/lib/utils/events.d.ts +0 -2
  162. package/lib/utils/events.js +0 -13
  163. package/src/utils/events.ts +0 -10
@@ -1,403 +1,418 @@
1
- import {TokenData} from "../tokens/tokenData";
2
- import {BigNumber} from "ethers";
3
- import {formatBN} from "../utils/formatter";
4
- import {LEVERAGE_DECIMALS} from "./constants";
5
- import {EVMEvent, EVMTx, EVMEventProps} from "./eventOrTx";
6
- import {getContractName} from "../contracts/contractsRegister";
1
+ import { BigNumber } from "ethers";
2
+ import { TokenData } from "../tokens/tokenData";
3
+ import { formatBN } from "../utils/formatter";
4
+ import { LEVERAGE_DECIMALS, PERCENTAGE_DECIMALS } from "./constants";
5
+ import { EVMEvent, EVMTx, EVMEventProps } from "./eventOrTx";
6
+ import { getContractName } from "../contracts/contractsRegister";
7
7
 
8
8
  export interface EventSerialized {
9
- type:
10
- | "EventAddLiquidity"
11
- | "EventRemoveLiquidity"
12
- | "EventOpenCreditAccount"
13
- | "EventCloseCreditAccount"
14
- | "EventLiquidateCreditAccount"
15
- | "EventRepayCreditAccount"
16
- | "EventAddCollateral"
17
- | "EventIncreaseBorrowAmount"
18
- | "EventCMNewParameters"
19
- | "EventTokenAllowed"
20
- | "EventTokenForbidden"
21
- | "EventContractAllowed"
22
- | "EventContractForbidden"
23
- | "EventNewFastCheckParameters"
24
- | "EventPriceOracleUpdated"
25
- | "EventTransferPluginAllowed"
26
- | "EventNewInterestRateModel"
27
- | "EventNewCreditManagerConnected"
28
- | "EventBorrowForbidden"
29
- | "EventNewExpectedLiquidityLimit"
30
- | "EventNewWithdrawFee"
31
- | "EventNewPriceFeed"
32
- | "EventTakeForever"
33
- | "EventPaused"
34
- | "EventUnPaused"
35
- | "EventPausableAdminAdded"
36
- | "EventPausableAdminRemoved"
37
- | "EventUnpausableAdminAdded"
38
- | "EventUnpausableAdminRemoved"
39
- | "EventOwnershipTransferred";
40
-
41
- content: any;
9
+ type:
10
+ | "EventAddLiquidity"
11
+ | "EventRemoveLiquidity"
12
+ | "EventOpenCreditAccount"
13
+ | "EventCloseCreditAccount"
14
+ | "EventLiquidateCreditAccount"
15
+ | "EventRepayCreditAccount"
16
+ | "EventAddCollateral"
17
+ | "EventIncreaseBorrowAmount"
18
+ | "EventCMNewParameters"
19
+ | "EventTokenAllowed"
20
+ | "EventTokenForbidden"
21
+ | "EventContractAllowed"
22
+ | "EventContractForbidden"
23
+ | "EventNewFastCheckParameters"
24
+ | "EventPriceOracleUpdated"
25
+ | "EventTransferPluginAllowed"
26
+ | "EventNewInterestRateModel"
27
+ | "EventNewCreditManagerConnected"
28
+ | "EventBorrowForbidden"
29
+ | "EventNewExpectedLiquidityLimit"
30
+ | "EventNewWithdrawFee"
31
+ | "EventNewPriceFeed"
32
+ | "EventTakeForever"
33
+ | "EventPaused"
34
+ | "EventUnPaused"
35
+ | "EventPausableAdminAdded"
36
+ | "EventPausableAdminRemoved"
37
+ | "EventUnpausableAdminAdded"
38
+ | "EventUnpausableAdminRemoved"
39
+ | "EventOwnershipTransferred";
40
+
41
+ content: any;
42
42
  }
43
43
 
44
44
  export class EventParser {
45
- static serialize(items: Array<EVMTx>): string {
46
- return JSON.stringify(items.map(i => i.serialize()));
45
+ static serialize(items: Array<EVMTx>): string {
46
+ return JSON.stringify(items.map(i => i.serialize()));
47
+ }
48
+
49
+ static deserialize(data: EventSerialized): EVMEvent {
50
+ const params = data.content;
51
+ switch (data.type) {
52
+ case "EventAddLiquidity":
53
+ return new EventAddLiquidity(params);
54
+ case "EventRemoveLiquidity":
55
+ return new EventRemoveLiquidity(params);
56
+ case "EventOpenCreditAccount":
57
+ return new EventOpenCreditAccount(params);
58
+ case "EventCloseCreditAccount":
59
+ return new EventCloseCreditAccount(params);
60
+ case "EventLiquidateCreditAccount":
61
+ return new EventLiquidateCreditAccount(params);
62
+ case "EventRepayCreditAccount":
63
+ return new EventRepayCreditAccount(params);
64
+ case "EventAddCollateral":
65
+ return new EventAddCollateral(params);
66
+ case "EventIncreaseBorrowAmount":
67
+ return new EventIncreaseBorrowAmount(params);
68
+ case "EventCMNewParameters":
69
+ return new EventCMNewParameters(params);
70
+ case "EventTokenAllowed":
71
+ return new EventTokenAllowed(params);
72
+ case "EventTokenForbidden":
73
+ return new EventTokenForbidden(params);
74
+ case "EventContractAllowed":
75
+ return new EventContractAllowed(params);
76
+ case "EventContractForbidden":
77
+ return new EventContractForbidden(params);
78
+ case "EventNewFastCheckParameters":
79
+ return new EventNewFastCheckParameters(params);
80
+ case "EventPriceOracleUpdated":
81
+ return new EventPriceOracleUpdated(params);
82
+ case "EventTransferPluginAllowed":
83
+ return new EventTransferPluginAllowed(params);
84
+ case "EventNewInterestRateModel":
85
+ return new EventNewInterestRateModel(params);
86
+ case "EventNewCreditManagerConnected":
87
+ return new EventNewCreditManagerConnected(params);
88
+ case "EventBorrowForbidden":
89
+ return new EventBorrowForbidden(params);
90
+ case "EventNewExpectedLiquidityLimit":
91
+ return new EventNewExpectedLiquidityLimit(params);
92
+ case "EventNewWithdrawFee":
93
+ return new EventNewWithdrawFee(params);
94
+ case "EventNewPriceFeed":
95
+ return new EventNewPriceFeed(params);
96
+ case "EventTakeForever":
97
+ return new EventTakeForever(params);
98
+ case "EventPaused":
99
+ return new EventPaused(params);
100
+ case "EventUnPaused":
101
+ return new EventUnPaused(params);
102
+ case "EventPausableAdminAdded":
103
+ return new EventPausableAdminAdded(params);
104
+ case "EventPausableAdminRemoved":
105
+ return new EventPausableAdminRemoved(params);
106
+ case "EventUnpausableAdminAdded":
107
+ return new EventUnPausableAdminAdded(params);
108
+ case "EventUnpausableAdminRemoved":
109
+ return new EventUnPausableAdminRemoved(params);
110
+ case "EventOwnershipTransferred":
111
+ return new EventTransferOwnership(params);
112
+
113
+ default:
114
+ throw new Error("Unknown transaction for parsing");
47
115
  }
116
+ }
48
117
 
49
- static deserialize(data: EventSerialized): EVMEvent {
50
- const params = data.content;
51
- switch (data.type) {
52
- case "EventAddLiquidity":
53
- return new EventAddLiquidity(params);
54
- case "EventRemoveLiquidity":
55
- return new EventRemoveLiquidity(params);
56
- case "EventOpenCreditAccount":
57
- return new EventOpenCreditAccount(params);
58
- case "EventCloseCreditAccount":
59
- return new EventCloseCreditAccount(params);
60
- case "EventLiquidateCreditAccount":
61
- return new EventLiquidateCreditAccount(params);
62
- case "EventRepayCreditAccount":
63
- return new EventRepayCreditAccount(params);
64
- case "EventAddCollateral":
65
- return new EventAddCollateral(params);
66
- case "EventIncreaseBorrowAmount":
67
- return new EventIncreaseBorrowAmount(params);
68
- case "EventCMNewParameters":
69
- return new EventCMNewParameters(params);
70
- case "EventTokenAllowed":
71
- return new EventTokenAllowed(params);
72
- case "EventTokenForbidden":
73
- return new EventTokenForbidden(params);
74
- case "EventContractAllowed":
75
- return new EventContractAllowed(params);
76
- case "EventContractForbidden":
77
- return new EventContractForbidden(params);
78
- case "EventNewFastCheckParameters":
79
- return new EventNewFastCheckParameters(params);
80
- case "EventPriceOracleUpdated":
81
- return new EventPriceOracleUpdated(params);
82
- case "EventTransferPluginAllowed":
83
- return new EventTransferPluginAllowed(params);
84
- case "EventNewInterestRateModel":
85
- return new EventNewInterestRateModel(params);
86
- case "EventNewCreditManagerConnected":
87
- return new EventNewCreditManagerConnected(params);
88
- case "EventBorrowForbidden":
89
- return new EventBorrowForbidden(params);
90
- case "EventNewExpectedLiquidityLimit":
91
- return new EventNewExpectedLiquidityLimit(params);
92
- case "EventNewWithdrawFee":
93
- return new EventNewWithdrawFee(params);
94
- case "EventNewPriceFeed":
95
- return new EventNewPriceFeed(params);
96
- case "EventTakeForever":
97
- return new EventTakeForever(params);
98
- case "EventPaused":
99
- return new EventPaused(params);
100
- case "EventUnPaused":
101
- return new EventUnPaused(params);
102
- case "EventPausableAdminAdded":
103
- return new EventPausableAdminAdded(params);
104
- case "EventPausableAdminRemoved":
105
- return new EventPausableAdminRemoved(params);
106
- case "EventUnpausableAdminAdded":
107
- return new EventUnPausableAdminAdded(params);
108
- case "EventUnpausableAdminRemoved":
109
- return new EventUnPausableAdminRemoved(params);
110
- case "EventOwnershipTransferred":
111
- return new EventTransferOwnership(params);
112
-
113
- default:
114
- throw new Error("Unknown transaction for parsing");
115
- }
116
- }
117
-
118
- static deserializeArray(data: Array<EventSerialized>): Array<EVMEvent> {
119
- return data.map(e => {
120
- return EventParser.deserialize(e);
121
- });
122
- }
118
+ static deserializeArray(data: Array<EventSerialized>): Array<EVMEvent> {
119
+ return data.map(e => EventParser.deserialize(e));
120
+ }
123
121
  }
124
122
 
125
123
  // POOL EVENTS
126
124
  interface EventAddLiquidityProps extends EVMEventProps {
127
- amount: string;
128
- underlyingToken: string;
129
- pool: string;
125
+ amount: string;
126
+ underlyingToken: string;
127
+ pool: string;
130
128
  }
131
129
 
132
130
  export class EventAddLiquidity extends EVMEvent {
133
- public readonly amount: BigNumber;
134
- public readonly underlyingToken: string;
135
- public readonly pool: string;
136
-
137
- constructor(opts: EventAddLiquidityProps) {
138
- super({
139
- block: opts.block,
140
- txHash: opts.txHash,
141
- timestamp: opts.timestamp
142
- });
143
- this.amount = BigNumber.from(opts.amount);
144
- this.underlyingToken = opts.underlyingToken;
145
- this.pool = opts.pool;
146
- }
147
-
148
- toString(tokenData: Record<string, TokenData>): string {
149
- const {decimals = 18, symbol} =
150
- tokenData[this.underlyingToken.toLowerCase()] || {};
151
-
152
- return `Pool ${getContractName(this.pool)}: Deposit ${formatBN(
153
- this.amount,
154
- decimals
155
- )} ${symbol}`;
156
- }
131
+ public readonly amount: BigNumber;
132
+
133
+ public readonly underlyingToken: string;
134
+
135
+ public readonly pool: string;
136
+
137
+ constructor(opts: EventAddLiquidityProps) {
138
+ super({
139
+ block: opts.block,
140
+ txHash: opts.txHash,
141
+ timestamp: opts.timestamp
142
+ });
143
+ this.amount = BigNumber.from(opts.amount);
144
+ this.underlyingToken = opts.underlyingToken;
145
+ this.pool = opts.pool;
146
+ }
147
+
148
+ toString(tokenData: Record<string, TokenData>): string {
149
+ const { decimals = 18, symbol } =
150
+ tokenData[this.underlyingToken.toLowerCase()] || {};
151
+
152
+ return `Pool ${getContractName(this.pool)}: Deposit ${formatBN(
153
+ this.amount,
154
+ decimals
155
+ )} ${symbol}`;
156
+ }
157
157
  }
158
158
 
159
159
  interface RemoveLiquidityProps extends EVMEventProps {
160
- amount: string;
161
- underlyingToken: string;
162
- dieselToken: string;
163
- pool: string;
160
+ amount: string;
161
+ underlyingToken: string;
162
+ dieselToken: string;
163
+ pool: string;
164
164
  }
165
165
 
166
166
  export class EventRemoveLiquidity extends EVMEvent {
167
- public readonly amount: BigNumber;
168
- public readonly underlyingToken: string;
169
- public readonly dieselToken: string;
170
- public readonly pool: string;
171
-
172
- constructor(opts: RemoveLiquidityProps) {
173
- super({
174
- block: opts.block,
175
- txHash: opts.txHash,
176
- timestamp: opts.timestamp
177
- });
178
- this.amount = BigNumber.from(opts.amount);
179
- this.underlyingToken = opts.underlyingToken;
180
- this.dieselToken = opts.dieselToken;
181
- this.pool = opts.pool;
182
- }
183
-
184
- toString(tokenData: Record<string, TokenData>): string {
185
- const {decimals = 18, symbol} =
186
- tokenData[this.dieselToken.toLowerCase()] || {};
187
-
188
- return `Pool ${getContractName(this.pool)}: withdraw ${formatBN(
189
- this.amount,
190
- decimals
191
- )} ${symbol}`;
192
- }
167
+ public readonly amount: BigNumber;
168
+
169
+ public readonly underlyingToken: string;
170
+
171
+ public readonly dieselToken: string;
172
+
173
+ public readonly pool: string;
174
+
175
+ constructor(opts: RemoveLiquidityProps) {
176
+ super({
177
+ block: opts.block,
178
+ txHash: opts.txHash,
179
+ timestamp: opts.timestamp
180
+ });
181
+ this.amount = BigNumber.from(opts.amount);
182
+ this.underlyingToken = opts.underlyingToken;
183
+ this.dieselToken = opts.dieselToken;
184
+ this.pool = opts.pool;
185
+ }
186
+
187
+ toString(tokenData: Record<string, TokenData>): string {
188
+ const { decimals = 18, symbol } =
189
+ tokenData[this.dieselToken.toLowerCase()] || {};
190
+
191
+ return `Pool ${getContractName(this.pool)}: withdraw ${formatBN(
192
+ this.amount,
193
+ decimals
194
+ )} ${symbol}`;
195
+ }
193
196
  }
194
197
 
195
198
  // CREDIT MANAGER EVENTS
196
199
 
197
200
  interface OpenCreditAccountProps extends EVMEventProps {
198
- amount: string;
199
- underlyingToken: string;
200
- leverage: number;
201
- creditManager: string;
201
+ amount: string;
202
+ underlyingToken: string;
203
+ leverage: number;
204
+ creditManager: string;
202
205
  }
203
206
 
204
207
  export class EventOpenCreditAccount extends EVMEvent {
205
- public readonly amount: BigNumber;
206
- public readonly underlyingToken: string;
207
- public readonly leverage: number;
208
- public readonly creditManager: string;
209
-
210
- constructor(opts: OpenCreditAccountProps) {
211
- super({
212
- block: opts.block,
213
- txHash: opts.txHash,
214
- timestamp: opts.timestamp
215
- });
216
- this.amount = BigNumber.from(opts.amount);
217
- this.underlyingToken = opts.underlyingToken;
218
- this.leverage = opts.leverage;
219
- this.creditManager = opts.creditManager;
220
- }
221
-
222
- toString(tokenData: Record<string, TokenData>): string {
223
- const {decimals = 18, symbol} =
224
- tokenData[this.underlyingToken.toLowerCase()] || {};
225
-
226
- return `Credit account ${getContractName(
227
- this.creditManager
228
- )}: open ${formatBN(
229
- this.amount,
230
- decimals
231
- )} ${symbol} x ${this.leverage.toFixed(2)} ⇒
208
+ public readonly amount: BigNumber;
209
+
210
+ public readonly underlyingToken: string;
211
+
212
+ public readonly leverage: number;
213
+
214
+ public readonly creditManager: string;
215
+
216
+ constructor(opts: OpenCreditAccountProps) {
217
+ super({
218
+ block: opts.block,
219
+ txHash: opts.txHash,
220
+ timestamp: opts.timestamp
221
+ });
222
+ this.amount = BigNumber.from(opts.amount);
223
+ this.underlyingToken = opts.underlyingToken;
224
+ this.leverage = opts.leverage;
225
+ this.creditManager = opts.creditManager;
226
+ }
227
+
228
+ toString(tokenData: Record<string, TokenData>): string {
229
+ const { decimals = 18, symbol } =
230
+ tokenData[this.underlyingToken.toLowerCase()] || {};
231
+
232
+ return `Credit account ${getContractName(
233
+ this.creditManager
234
+ )}: open ${formatBN(
235
+ this.amount,
236
+ decimals
237
+ )} ${symbol} x ${this.leverage.toFixed(2)} ⇒
232
238
  ${formatBN(
233
- this.amount
234
- .mul(Math.floor(this.leverage + LEVERAGE_DECIMALS))
235
- .div(LEVERAGE_DECIMALS),
236
- decimals + 2
237
- )} ${symbol}`;
238
- }
239
+ this.amount
240
+ .mul(Math.floor(this.leverage + LEVERAGE_DECIMALS))
241
+ .div(LEVERAGE_DECIMALS),
242
+ decimals + 2
243
+ )} ${symbol}`;
244
+ }
239
245
  }
240
246
 
241
247
  interface CloseCreditAccountProps extends EVMEventProps {
242
- amount: string;
243
- underlyingToken: string;
244
- creditManager: string;
248
+ amount: string;
249
+ underlyingToken: string;
250
+ creditManager: string;
245
251
  }
246
252
 
247
253
  export class EventCloseCreditAccount extends EVMEvent {
248
- public readonly amount: BigNumber;
249
- public readonly underlyingToken: string;
250
- public readonly creditManager: string;
251
-
252
- constructor(opts: CloseCreditAccountProps) {
253
- super({
254
- block: opts.block,
255
- txHash: opts.txHash,
256
- timestamp: opts.timestamp
257
- });
258
- this.amount = BigNumber.from(opts.amount);
259
- this.underlyingToken = opts.underlyingToken;
260
- this.creditManager = opts.creditManager;
261
- }
262
-
263
- toString(tokenData: Record<string, TokenData>): string {
264
- const {decimals = 18, symbol} =
265
- tokenData[this.underlyingToken.toLowerCase()] || {};
266
-
267
- return `Credit account ${getContractName(
268
- this.creditManager
269
- )}: was closed and got ${formatBN(
270
- this.amount,
271
- decimals
272
- )} ${symbol} as remaining funds`;
273
- }
254
+ public readonly amount: BigNumber;
255
+
256
+ public readonly underlyingToken: string;
257
+
258
+ public readonly creditManager: string;
259
+
260
+ constructor(opts: CloseCreditAccountProps) {
261
+ super({
262
+ block: opts.block,
263
+ txHash: opts.txHash,
264
+ timestamp: opts.timestamp
265
+ });
266
+ this.amount = BigNumber.from(opts.amount);
267
+ this.underlyingToken = opts.underlyingToken;
268
+ this.creditManager = opts.creditManager;
269
+ }
270
+
271
+ toString(tokenData: Record<string, TokenData>): string {
272
+ const { decimals = 18, symbol } =
273
+ tokenData[this.underlyingToken.toLowerCase()] || {};
274
+
275
+ return `Credit account ${getContractName(
276
+ this.creditManager
277
+ )}: was closed and got ${formatBN(
278
+ this.amount,
279
+ decimals
280
+ )} ${symbol} as remaining funds`;
281
+ }
274
282
  }
275
283
 
276
284
  interface LiquidateCreditAccountProps extends EVMEventProps {
277
- amount: string;
278
- underlyingToken: string;
279
- creditManager: string;
285
+ amount: string;
286
+ underlyingToken: string;
287
+ creditManager: string;
280
288
  }
281
289
 
282
290
  export class EventLiquidateCreditAccount extends EVMEvent {
283
- public readonly amount: BigNumber;
284
- public readonly underlyingToken: string;
285
- public readonly creditManager: string;
286
-
287
- constructor(opts: LiquidateCreditAccountProps) {
288
- super({
289
- block: opts.block,
290
- txHash: opts.txHash,
291
- timestamp: opts.timestamp
292
- });
293
- this.amount = BigNumber.from(opts.amount);
294
- this.underlyingToken = opts.underlyingToken;
295
- this.creditManager = opts.creditManager;
296
- }
297
-
298
- toString(tokenData: Record<string, TokenData>): string {
299
- const {decimals = 18, symbol} =
300
- tokenData[this.underlyingToken.toLowerCase()] || {};
301
-
302
- return `Credit account ${getContractName(
303
- this.creditManager
304
- )}: was liquidated. ${formatBN(
305
- this.amount,
306
- decimals
307
- )} ${symbol} were paid back as remaining funds`;
308
- }
291
+ public readonly amount: BigNumber;
292
+
293
+ public readonly underlyingToken: string;
294
+
295
+ public readonly creditManager: string;
296
+
297
+ constructor(opts: LiquidateCreditAccountProps) {
298
+ super({
299
+ block: opts.block,
300
+ txHash: opts.txHash,
301
+ timestamp: opts.timestamp
302
+ });
303
+ this.amount = BigNumber.from(opts.amount);
304
+ this.underlyingToken = opts.underlyingToken;
305
+ this.creditManager = opts.creditManager;
306
+ }
307
+
308
+ toString(tokenData: Record<string, TokenData>): string {
309
+ const { decimals = 18, symbol } =
310
+ tokenData[this.underlyingToken.toLowerCase()] || {};
311
+
312
+ return `Credit account ${getContractName(
313
+ this.creditManager
314
+ )}: was liquidated. ${formatBN(
315
+ this.amount,
316
+ decimals
317
+ )} ${symbol} were paid back as remaining funds`;
318
+ }
309
319
  }
310
320
 
311
321
  interface RepayCreditAccountProps extends EVMEventProps {
312
- underlyingToken: string;
313
- creditManager: string;
322
+ underlyingToken: string;
323
+ creditManager: string;
314
324
  }
315
325
 
316
326
  export class EventRepayCreditAccount extends EVMEvent {
317
- public readonly underlyingToken: string;
318
- public readonly creditManager: string;
319
-
320
- constructor(opts: RepayCreditAccountProps) {
321
- super({
322
- block: opts.block,
323
- txHash: opts.txHash,
324
- timestamp: opts.timestamp
325
- });
326
- this.underlyingToken = opts.underlyingToken;
327
- this.creditManager = opts.creditManager;
328
- }
329
-
330
- toString(_: Record<string, TokenData>): string {
331
- return `Credit account ${getContractName(this.creditManager)}: was repaid`;
332
- }
327
+ public readonly underlyingToken: string;
328
+
329
+ public readonly creditManager: string;
330
+
331
+ constructor(opts: RepayCreditAccountProps) {
332
+ super({
333
+ block: opts.block,
334
+ txHash: opts.txHash,
335
+ timestamp: opts.timestamp
336
+ });
337
+ this.underlyingToken = opts.underlyingToken;
338
+ this.creditManager = opts.creditManager;
339
+ }
340
+
341
+ toString(): string {
342
+ return `Credit account ${getContractName(this.creditManager)}: was repaid`;
343
+ }
333
344
  }
334
345
 
335
346
  interface AddCollateralProps extends EVMEventProps {
336
- amount: string;
337
- addedToken: string;
338
- creditManager: string;
347
+ amount: string;
348
+ addedToken: string;
349
+ creditManager: string;
339
350
  }
340
351
 
341
352
  export class EventAddCollateral extends EVMEvent {
342
- public readonly amount: BigNumber;
343
- public readonly addedToken: string;
344
- public readonly creditManager: string;
345
-
346
- constructor(opts: AddCollateralProps) {
347
- super({
348
- block: opts.block,
349
- txHash: opts.txHash,
350
- timestamp: opts.timestamp
351
- });
352
- this.amount = BigNumber.from(opts.amount);
353
-
354
- this.addedToken = opts.addedToken;
355
- this.creditManager = opts.creditManager;
356
- }
353
+ public readonly amount: BigNumber;
357
354
 
358
- toString(tokenData: Record<string, TokenData>): string {
359
- const {decimals = 18, symbol} =
360
- tokenData[this.addedToken.toLowerCase()] || {};
355
+ public readonly addedToken: string;
361
356
 
362
- return `Credit account ${getContractName(
363
- this.creditManager
364
- )}: added ${formatBN(this.amount, decimals)} ${symbol} as collateral`;
365
- }
357
+ public readonly creditManager: string;
358
+
359
+ constructor(opts: AddCollateralProps) {
360
+ super({
361
+ block: opts.block,
362
+ txHash: opts.txHash,
363
+ timestamp: opts.timestamp
364
+ });
365
+ this.amount = BigNumber.from(opts.amount);
366
+
367
+ this.addedToken = opts.addedToken;
368
+ this.creditManager = opts.creditManager;
369
+ }
370
+
371
+ toString(tokenData: Record<string, TokenData>): string {
372
+ const { decimals = 18, symbol } =
373
+ tokenData[this.addedToken.toLowerCase()] || {};
374
+
375
+ return `Credit account ${getContractName(
376
+ this.creditManager
377
+ )}: added ${formatBN(this.amount, decimals)} ${symbol} as collateral`;
378
+ }
366
379
  }
367
380
 
368
381
  interface IncreaseBorrowAmountProps extends EVMEventProps {
369
- amount: string;
370
- underlyingToken: string;
371
- creditManager: string;
382
+ amount: string;
383
+ underlyingToken: string;
384
+ creditManager: string;
372
385
  }
373
386
 
374
387
  export class EventIncreaseBorrowAmount extends EVMEvent {
375
- public readonly amount: BigNumber;
376
- public readonly underlyingToken: string;
377
- public readonly creditManager: string;
378
-
379
- constructor(opts: IncreaseBorrowAmountProps) {
380
- super({
381
- block: opts.block,
382
- txHash: opts.txHash,
383
- timestamp: opts.timestamp
384
- });
385
- this.amount = BigNumber.from(opts.amount);
386
- this.underlyingToken = opts.underlyingToken;
387
- this.creditManager = opts.creditManager;
388
- }
389
-
390
- toString(tokenData: Record<string, TokenData>): string {
391
- const {decimals = 18, symbol} =
392
- tokenData[this.underlyingToken.toLowerCase()] || {};
393
-
394
- return `Credit account ${getContractName(
395
- this.creditManager
396
- )}: borrowed amount was increased for ${formatBN(
397
- this.amount,
398
- decimals
399
- )} ${symbol}`;
400
- }
388
+ public readonly amount: BigNumber;
389
+
390
+ public readonly underlyingToken: string;
391
+
392
+ public readonly creditManager: string;
393
+
394
+ constructor(opts: IncreaseBorrowAmountProps) {
395
+ super({
396
+ block: opts.block,
397
+ txHash: opts.txHash,
398
+ timestamp: opts.timestamp
399
+ });
400
+ this.amount = BigNumber.from(opts.amount);
401
+ this.underlyingToken = opts.underlyingToken;
402
+ this.creditManager = opts.creditManager;
403
+ }
404
+
405
+ toString(tokenData: Record<string, TokenData>): string {
406
+ const { decimals = 18, symbol } =
407
+ tokenData[this.underlyingToken.toLowerCase()] || {};
408
+
409
+ return `Credit account ${getContractName(
410
+ this.creditManager
411
+ )}: borrowed amount was increased for ${formatBN(
412
+ this.amount,
413
+ decimals
414
+ )} ${symbol}`;
415
+ }
401
416
  }
402
417
 
403
418
  // // Emits each time when new fees are set
@@ -411,105 +426,120 @@ export class EventIncreaseBorrowAmount extends EVMEvent {
411
426
  // );
412
427
 
413
428
  interface CMNewParametersProps extends EVMEventProps {
414
- creditManager: string;
415
- underlyingToken: string;
416
- minAmount: string;
417
- maxAmount: string;
418
- maxLeverage: number;
419
- feeInterest: number;
420
- feeLiquidation: number;
421
- liquidationDiscount: number;
422
- prevMinAmount: string;
423
- prevMaxAmount: string;
424
- prevMaxLeverage: number;
425
- prevFeeInterest: number;
426
- prevFeeLiquidation: number;
427
- prevLiquidationDiscount: number;
429
+ creditManager: string;
430
+ underlyingToken: string;
431
+ minAmount: string;
432
+ maxAmount: string;
433
+ maxLeverage: number;
434
+ feeInterest: number;
435
+ feeLiquidation: number;
436
+ liquidationDiscount: number;
437
+ prevMinAmount: string;
438
+ prevMaxAmount: string;
439
+ prevMaxLeverage: number;
440
+ prevFeeInterest: number;
441
+ prevFeeLiquidation: number;
442
+ prevLiquidationDiscount: number;
428
443
  }
429
444
 
430
445
  export class EventCMNewParameters extends EVMEvent {
431
- public readonly creditManager: string;
432
- public readonly underlyingToken: string;
433
- public readonly minAmount: BigNumber;
434
- public readonly maxAmount: BigNumber;
435
- public readonly maxLeverage: number;
436
- public readonly feeInterest: number;
437
- public readonly feeLiquidation: number;
438
- public readonly liquidationDiscount: number;
439
- public readonly prevMinAmount: BigNumber;
440
- public readonly prevMaxAmount: BigNumber;
441
- public readonly prevMaxLeverage: number;
442
- public readonly prevFeeInterest: number;
443
- public readonly prevFeeLiquidation: number;
444
- public readonly prevLiquidationDiscount: number;
445
-
446
- constructor(opts: CMNewParametersProps) {
447
- super({
448
- block: opts.block,
449
- txHash: opts.txHash,
450
- timestamp: opts.timestamp
451
- });
452
- this.creditManager = opts.creditManager;
453
- this.underlyingToken = opts.underlyingToken;
454
- this.minAmount = BigNumber.from(opts.minAmount);
455
- this.maxAmount = BigNumber.from(opts.maxAmount);
456
- this.maxLeverage = opts.maxLeverage;
457
- this.feeInterest = opts.feeInterest;
458
- this.feeLiquidation = opts.feeLiquidation;
459
- this.liquidationDiscount = opts.liquidationDiscount;
460
-
461
- this.prevMinAmount = BigNumber.from(opts.prevMinAmount);
462
- this.prevMaxAmount = BigNumber.from(opts.prevMaxAmount);
463
- this.prevMaxLeverage = opts.prevMaxLeverage;
464
- this.prevFeeInterest = opts.prevFeeInterest;
465
- this.prevFeeLiquidation = opts.prevFeeLiquidation;
466
- this.prevLiquidationDiscount = opts.prevLiquidationDiscount;
446
+ public readonly creditManager: string;
447
+
448
+ public readonly underlyingToken: string;
449
+
450
+ public readonly minAmount: BigNumber;
451
+
452
+ public readonly maxAmount: BigNumber;
453
+
454
+ public readonly maxLeverage: number;
455
+
456
+ public readonly feeInterest: number;
457
+
458
+ public readonly feeLiquidation: number;
459
+
460
+ public readonly liquidationDiscount: number;
461
+
462
+ public readonly prevMinAmount: BigNumber;
463
+
464
+ public readonly prevMaxAmount: BigNumber;
465
+
466
+ public readonly prevMaxLeverage: number;
467
+
468
+ public readonly prevFeeInterest: number;
469
+
470
+ public readonly prevFeeLiquidation: number;
471
+
472
+ public readonly prevLiquidationDiscount: number;
473
+
474
+ constructor(opts: CMNewParametersProps) {
475
+ super({
476
+ block: opts.block,
477
+ txHash: opts.txHash,
478
+ timestamp: opts.timestamp
479
+ });
480
+ this.creditManager = opts.creditManager;
481
+ this.underlyingToken = opts.underlyingToken;
482
+ this.minAmount = BigNumber.from(opts.minAmount);
483
+ this.maxAmount = BigNumber.from(opts.maxAmount);
484
+ this.maxLeverage = opts.maxLeverage;
485
+ this.feeInterest = opts.feeInterest;
486
+ this.feeLiquidation = opts.feeLiquidation;
487
+ this.liquidationDiscount = opts.liquidationDiscount;
488
+
489
+ this.prevMinAmount = BigNumber.from(opts.prevMinAmount);
490
+ this.prevMaxAmount = BigNumber.from(opts.prevMaxAmount);
491
+ this.prevMaxLeverage = opts.prevMaxLeverage;
492
+ this.prevFeeInterest = opts.prevFeeInterest;
493
+ this.prevFeeLiquidation = opts.prevFeeLiquidation;
494
+ this.prevLiquidationDiscount = opts.prevLiquidationDiscount;
495
+ }
496
+
497
+ toString(tokenData: Record<string, TokenData>): string {
498
+ const token = tokenData[this.underlyingToken.toLowerCase()];
499
+ let msg = `Credit manager ${getContractName(this.creditManager)} updated: `;
500
+
501
+ if (this.minAmount !== this.prevMinAmount) {
502
+ msg += `min amount: ${formatBN(
503
+ this.prevMinAmount,
504
+ token.decimals
505
+ )} => ${formatBN(this.minAmount, token.decimals)} ${token.symbol}, `;
506
+ }
507
+
508
+ if (this.maxAmount !== this.prevMaxAmount) {
509
+ msg += `max amount: ${formatBN(
510
+ this.prevMaxAmount,
511
+ token.decimals
512
+ )} => ${formatBN(this.maxAmount, token.decimals)} ${token.symbol}, `;
467
513
  }
468
514
 
469
- toString(tokenData: Record<string, TokenData>): string {
470
- const token = tokenData[this.underlyingToken.toLowerCase()];
471
- let msg = `Credit manager ${getContractName(this.creditManager)} updated: `;
472
-
473
- if (this.minAmount !== this.prevMinAmount) {
474
- msg += `min amount: ${formatBN(
475
- this.prevMinAmount,
476
- token.decimals
477
- )} => ${formatBN(this.minAmount, token.decimals)} ${token.symbol}, `;
478
- }
479
-
480
- if (this.maxAmount !== this.prevMaxAmount) {
481
- msg += `max amount: ${formatBN(
482
- this.prevMaxAmount,
483
- token.decimals
484
- )} => ${formatBN(this.maxAmount, token.decimals)} ${token.symbol}, `;
485
- }
486
-
487
- if (this.maxLeverage !== this.prevMaxLeverage) {
488
- msg += `max leverage: ${this.prevMaxLeverage / 100 + 1} => ${
489
- this.maxLeverage / 100 + 1
490
- }, `;
491
- }
492
-
493
- if (this.feeInterest !== this.prevFeeInterest) {
494
- msg += `interest fee: ${this.prevFeeInterest / 100}% => ${
495
- this.feeInterest / 100
496
- }%, `;
497
- }
498
-
499
- if (this.feeLiquidation !== this.prevFeeLiquidation) {
500
- msg += `liquidation fee: ${this.prevFeeLiquidation / 100}% => ${
501
- this.feeLiquidation / 100
502
- }%, `;
503
- }
504
-
505
- if (this.liquidationDiscount !== this.prevLiquidationDiscount) {
506
- msg += `liquidation premium: ${
507
- 100 - this.prevLiquidationDiscount / 100
508
- }% => ${100 - this.liquidationDiscount / 100}%, `;
509
- }
510
-
511
- return msg.slice(0, msg.length - 2);
515
+ if (this.maxLeverage !== this.prevMaxLeverage) {
516
+ msg += `max leverage: ${
517
+ this.prevMaxLeverage / LEVERAGE_DECIMALS + 1
518
+ } => ${this.maxLeverage / LEVERAGE_DECIMALS + 1}, `;
512
519
  }
520
+
521
+ if (this.feeInterest !== this.prevFeeInterest) {
522
+ msg += `interest fee: ${this.prevFeeInterest / PERCENTAGE_DECIMALS}% => ${
523
+ this.feeInterest / PERCENTAGE_DECIMALS
524
+ }%, `;
525
+ }
526
+
527
+ if (this.feeLiquidation !== this.prevFeeLiquidation) {
528
+ msg += `liquidation fee: ${
529
+ this.prevFeeLiquidation / PERCENTAGE_DECIMALS
530
+ }% => ${this.feeLiquidation / PERCENTAGE_DECIMALS}%, `;
531
+ }
532
+
533
+ if (this.liquidationDiscount !== this.prevLiquidationDiscount) {
534
+ msg += `liquidation premium: ${
535
+ PERCENTAGE_DECIMALS - this.prevLiquidationDiscount / PERCENTAGE_DECIMALS
536
+ }% => ${
537
+ PERCENTAGE_DECIMALS - this.liquidationDiscount / PERCENTAGE_DECIMALS
538
+ }%, `;
539
+ }
540
+
541
+ return msg.slice(0, msg.length - 2);
542
+ }
513
543
  }
514
544
 
515
545
  // // Emits each time token is allowed or liquidation threshold changed
@@ -518,83 +548,94 @@ export class EventCMNewParameters extends EVMEvent {
518
548
  export type TokenAllowanceType = "NewToken" | "LTUpdated" | "Allowed";
519
549
 
520
550
  interface TokenAllowedProps extends EVMEventProps {
521
- creditManager: string;
522
- token: string;
523
- liquidityThreshold: number;
524
- prevLiquidationThreshold?: number;
525
- status: TokenAllowanceType;
551
+ creditManager: string;
552
+ token: string;
553
+ liquidityThreshold: number;
554
+ prevLiquidationThreshold?: number;
555
+ status: TokenAllowanceType;
526
556
  }
527
557
 
528
558
  export class EventTokenAllowed extends EVMEvent {
529
- public readonly creditManager: string;
530
- public readonly token: string;
531
- public readonly liquidityThreshold: number;
532
- public readonly prevLiquidationThreshold?: number;
533
- public readonly status: TokenAllowanceType;
534
-
535
- constructor(opts: TokenAllowedProps) {
536
- super({
537
- block: opts.block,
538
- txHash: opts.txHash,
539
- timestamp: opts.timestamp
540
- });
541
- this.creditManager = opts.creditManager;
542
- this.token = opts.token;
543
- this.liquidityThreshold = opts.liquidityThreshold;
544
- this.prevLiquidationThreshold = opts.prevLiquidationThreshold;
545
- this.status = opts.status;
546
- }
547
-
548
- toString(tokenData: Record<string, TokenData>): string {
549
- const token = tokenData[this.token.toLowerCase()];
550
- let msg = `Credit manager ${getContractName(this.creditManager)} updated `;
551
- switch (this.status) {
552
- case "NewToken":
553
- return `${msg}: New token allowed: ${
554
- token.symbol
555
- }, liquidation threshold: ${this.liquidityThreshold / 100}%`;
556
- case "Allowed":
557
- return `${msg}: ${
558
- token.symbol
559
- } is allowed now, liquidation threshold: ${
560
- this.liquidityThreshold / 100
561
- }%`;
562
- case "LTUpdated":
563
- return `${msg}: ${token.symbol} liquidation threshold: ${
564
- (this.prevLiquidationThreshold || 0) / 100
565
- } => ${this.liquidityThreshold / 100}%`;
566
- }
559
+ public readonly creditManager: string;
560
+
561
+ public readonly token: string;
562
+
563
+ public readonly liquidityThreshold: number;
564
+
565
+ public readonly prevLiquidationThreshold?: number;
566
+
567
+ public readonly status: TokenAllowanceType;
568
+
569
+ constructor(opts: TokenAllowedProps) {
570
+ super({
571
+ block: opts.block,
572
+ txHash: opts.txHash,
573
+ timestamp: opts.timestamp
574
+ });
575
+ this.creditManager = opts.creditManager;
576
+ this.token = opts.token;
577
+ this.liquidityThreshold = opts.liquidityThreshold;
578
+ this.prevLiquidationThreshold = opts.prevLiquidationThreshold;
579
+ this.status = opts.status;
580
+ }
581
+
582
+ toString(tokenData: Record<string, TokenData>): string {
583
+ const token = tokenData[this.token.toLowerCase()];
584
+ const msg = `Credit manager ${getContractName(
585
+ this.creditManager
586
+ )} updated `;
587
+ switch (this.status) {
588
+ case "NewToken":
589
+ return `${msg}: New token allowed: ${
590
+ token.symbol
591
+ }, liquidation threshold: ${
592
+ this.liquidityThreshold / PERCENTAGE_DECIMALS
593
+ }%`;
594
+ case "Allowed":
595
+ return `${msg}: ${
596
+ token.symbol
597
+ } is allowed now, liquidation threshold: ${
598
+ this.liquidityThreshold / PERCENTAGE_DECIMALS
599
+ }%`;
600
+ case "LTUpdated":
601
+ return `${msg}: ${token.symbol} liquidation threshold: ${
602
+ (this.prevLiquidationThreshold || 0) / PERCENTAGE_DECIMALS
603
+ } => ${this.liquidityThreshold / PERCENTAGE_DECIMALS}%`;
604
+ default:
605
+ return "Error: TokenAllowedProps";
567
606
  }
607
+ }
568
608
  }
569
609
 
570
610
  // // Emits each time token is allowed or liquidtion threshold changed
571
611
  // event TokenForbidden(address indexed token);
572
612
 
573
613
  interface TokenForbiddenProps extends EVMEventProps {
574
- creditManager: string;
575
- token: string;
614
+ creditManager: string;
615
+ token: string;
576
616
  }
577
617
 
578
618
  export class EventTokenForbidden extends EVMEvent {
579
- public readonly creditManager: string;
580
- public readonly token: string;
581
-
582
- constructor(opts: TokenForbiddenProps) {
583
- super({
584
- block: opts.block,
585
- txHash: opts.txHash,
586
- timestamp: opts.timestamp
587
- });
588
- this.creditManager = opts.creditManager;
589
- this.token = opts.token;
590
- }
591
-
592
- toString(tokenData: Record<string, TokenData>): string {
593
- const token = tokenData[this.token.toLowerCase()];
594
- return `Credit manager ${getContractName(this.creditManager)} updated ${
595
- token.symbol
596
- } forbidden`;
597
- }
619
+ public readonly creditManager: string;
620
+
621
+ public readonly token: string;
622
+
623
+ constructor(opts: TokenForbiddenProps) {
624
+ super({
625
+ block: opts.block,
626
+ txHash: opts.txHash,
627
+ timestamp: opts.timestamp
628
+ });
629
+ this.creditManager = opts.creditManager;
630
+ this.token = opts.token;
631
+ }
632
+
633
+ toString(tokenData: Record<string, TokenData>): string {
634
+ const token = tokenData[this.token.toLowerCase()];
635
+ return `Credit manager ${getContractName(this.creditManager)} updated ${
636
+ token.symbol
637
+ } forbidden`;
638
+ }
598
639
  }
599
640
 
600
641
  //
@@ -604,44 +645,49 @@ export class EventTokenForbidden extends EVMEvent {
604
645
  export type EventContractAllowedStatus = "Connected" | "AdapterUpdate";
605
646
 
606
647
  interface ContractAllowedProps extends EVMEventProps {
607
- creditManager: string;
608
- protocol: string;
609
- adapter: string;
610
- status: EventContractAllowedStatus;
648
+ creditManager: string;
649
+ protocol: string;
650
+ adapter: string;
651
+ status: EventContractAllowedStatus;
611
652
  }
612
653
 
613
654
  export class EventContractAllowed extends EVMEvent {
614
- public readonly creditManager: string;
615
- public readonly protocol: string;
616
- public readonly adapter: string;
617
- public readonly status: EventContractAllowedStatus;
618
-
619
- constructor(opts: ContractAllowedProps) {
620
- super({
621
- block: opts.block,
622
- txHash: opts.txHash,
623
- timestamp: opts.timestamp
624
- });
625
- this.creditManager = opts.creditManager;
626
- this.protocol = opts.protocol;
627
- this.adapter = opts.adapter;
628
- this.status = opts.status;
629
- }
630
-
631
- toString(_: Record<string, TokenData>): string {
632
- let msg = `Credit manager ${getContractName(this.creditManager)} updated`;
633
-
634
- switch (this.status) {
635
- case "Connected":
636
- return `${msg} : ${getContractName(
637
- this.protocol
638
- )} was connected. Adapter at: ${this.adapter}`;
639
- case "AdapterUpdate":
640
- return `${msg} : ${getContractName(
641
- this.protocol
642
- )} adapter was updated. New adapter: ${this.adapter}`;
643
- }
655
+ public readonly creditManager: string;
656
+
657
+ public readonly protocol: string;
658
+
659
+ public readonly adapter: string;
660
+
661
+ public readonly status: EventContractAllowedStatus;
662
+
663
+ constructor(opts: ContractAllowedProps) {
664
+ super({
665
+ block: opts.block,
666
+ txHash: opts.txHash,
667
+ timestamp: opts.timestamp
668
+ });
669
+ this.creditManager = opts.creditManager;
670
+ this.protocol = opts.protocol;
671
+ this.adapter = opts.adapter;
672
+ this.status = opts.status;
673
+ }
674
+
675
+ toString(): string {
676
+ const msg = `Credit manager ${getContractName(this.creditManager)} updated`;
677
+
678
+ switch (this.status) {
679
+ case "Connected":
680
+ return `${msg} : ${getContractName(
681
+ this.protocol
682
+ )} was connected. Adapter at: ${this.adapter}`;
683
+ case "AdapterUpdate":
684
+ return `${msg} : ${getContractName(
685
+ this.protocol
686
+ )} adapter was updated. New adapter: ${this.adapter}`;
687
+ default:
688
+ return "Error: EventContractAllowed";
644
689
  }
690
+ }
645
691
  }
646
692
 
647
693
  //
@@ -649,29 +695,30 @@ export class EventContractAllowed extends EVMEvent {
649
695
  // event ContractForbidden(address indexed protocol);
650
696
 
651
697
  interface ContractForbiddenProps extends EVMEventProps {
652
- creditManager: string;
653
- protocol: string;
698
+ creditManager: string;
699
+ protocol: string;
654
700
  }
655
701
 
656
702
  export class EventContractForbidden extends EVMEvent {
657
- public readonly creditManager: string;
658
- public readonly protocol: string;
659
-
660
- constructor(opts: ContractForbiddenProps) {
661
- super({
662
- block: opts.block,
663
- txHash: opts.txHash,
664
- timestamp: opts.timestamp
665
- });
666
- this.creditManager = opts.creditManager;
667
- this.protocol = opts.protocol;
668
- }
669
-
670
- toString(_: Record<string, TokenData>): string {
671
- return `Credit manager ${getContractName(
672
- this.creditManager
673
- )} updated: ${getContractName(this.protocol)}`;
674
- }
703
+ public readonly creditManager: string;
704
+
705
+ public readonly protocol: string;
706
+
707
+ constructor(opts: ContractForbiddenProps) {
708
+ super({
709
+ block: opts.block,
710
+ txHash: opts.txHash,
711
+ timestamp: opts.timestamp
712
+ });
713
+ this.creditManager = opts.creditManager;
714
+ this.protocol = opts.protocol;
715
+ }
716
+
717
+ toString(): string {
718
+ return `Credit manager ${getContractName(
719
+ this.creditManager
720
+ )} updated: ${getContractName(this.protocol)}`;
721
+ }
675
722
  }
676
723
 
677
724
  //
@@ -679,76 +726,81 @@ export class EventContractForbidden extends EVMEvent {
679
726
  // event NewFastCheckParameters(uint256 chiThreshold, uint256 fastCheckDelay);
680
727
 
681
728
  interface NewFastCheckParametersProps extends EVMEventProps {
682
- creditManager: string;
683
- chiThreshold: number;
684
- fastCheckDelay: number;
685
- prevChiThreshold?: number;
686
- prevFastCheckDelay?: number;
729
+ creditManager: string;
730
+ chiThreshold: number;
731
+ fastCheckDelay: number;
732
+ prevChiThreshold?: number;
733
+ prevFastCheckDelay?: number;
687
734
  }
688
735
 
689
736
  export class EventNewFastCheckParameters extends EVMEvent {
690
- public readonly creditManager: string;
691
- public readonly chiThreshold: number;
692
- public readonly fastCheckDelay: number;
693
- public readonly prevChiThreshold?: number;
694
- public readonly prevFastCheckDelay?: number;
695
-
696
- constructor(opts: NewFastCheckParametersProps) {
697
- super({
698
- block: opts.block,
699
- txHash: opts.txHash,
700
- timestamp: opts.timestamp
701
- });
702
- this.creditManager = opts.creditManager;
703
- this.chiThreshold = opts.chiThreshold;
704
- this.fastCheckDelay = opts.fastCheckDelay;
705
- this.prevChiThreshold = opts.prevChiThreshold;
706
- this.prevFastCheckDelay = opts.prevFastCheckDelay;
707
- }
737
+ public readonly creditManager: string;
738
+
739
+ public readonly chiThreshold: number;
740
+
741
+ public readonly fastCheckDelay: number;
742
+
743
+ public readonly prevChiThreshold?: number;
708
744
 
709
- toString(_: Record<string, TokenData>): string {
710
- let msg = `Credit manager ${getContractName(this.creditManager)} updated: `;
745
+ public readonly prevFastCheckDelay?: number;
711
746
 
712
- if (this.chiThreshold !== this.prevChiThreshold) {
713
- msg += `Chi threshold: ${this.prevChiThreshold} => ${this.chiThreshold}, `;
714
- }
747
+ constructor(opts: NewFastCheckParametersProps) {
748
+ super({
749
+ block: opts.block,
750
+ txHash: opts.txHash,
751
+ timestamp: opts.timestamp
752
+ });
753
+ this.creditManager = opts.creditManager;
754
+ this.chiThreshold = opts.chiThreshold;
755
+ this.fastCheckDelay = opts.fastCheckDelay;
756
+ this.prevChiThreshold = opts.prevChiThreshold;
757
+ this.prevFastCheckDelay = opts.prevFastCheckDelay;
758
+ }
715
759
 
716
- if (this.fastCheckDelay !== this.prevFastCheckDelay) {
717
- msg += `fast check delay: ${this.prevFastCheckDelay} => ${this.fastCheckDelay}, `;
718
- }
760
+ toString(): string {
761
+ let msg = `Credit manager ${getContractName(this.creditManager)} updated: `;
719
762
 
720
- return msg.slice(0, msg.length - 2);
763
+ if (this.chiThreshold !== this.prevChiThreshold) {
764
+ msg += `Chi threshold: ${this.prevChiThreshold} => ${this.chiThreshold}, `;
721
765
  }
766
+
767
+ if (this.fastCheckDelay !== this.prevFastCheckDelay) {
768
+ msg += `fast check delay: ${this.prevFastCheckDelay} => ${this.fastCheckDelay}, `;
769
+ }
770
+
771
+ return msg.slice(0, msg.length - 2);
772
+ }
722
773
  }
723
774
 
724
775
  // event PriceOracleUpdated(address indexed newPriceOracle);
725
776
 
726
777
  interface PriceOracleUpdatedProps extends EVMEventProps {
727
- creditManager: string;
728
- priceOracle: string;
778
+ creditManager: string;
779
+ priceOracle: string;
729
780
  }
730
781
 
731
782
  export class EventPriceOracleUpdated extends EVMEvent {
732
- public readonly creditManager: string;
733
- public readonly priceOracle: string;
734
-
735
- constructor(opts: PriceOracleUpdatedProps) {
736
- super({
737
- block: opts.block,
738
- txHash: opts.txHash,
739
- timestamp: opts.timestamp
740
- });
741
- this.creditManager = opts.creditManager;
742
- this.priceOracle = opts.priceOracle;
743
- }
744
-
745
- toString(_: Record<string, TokenData>): string {
746
- return `Credit manager ${getContractName(
747
- this.creditManager
748
- )} updated: price oracle was updated. New price oracle ${getContractName(
749
- this.priceOracle
750
- )}`;
751
- }
783
+ public readonly creditManager: string;
784
+
785
+ public readonly priceOracle: string;
786
+
787
+ constructor(opts: PriceOracleUpdatedProps) {
788
+ super({
789
+ block: opts.block,
790
+ txHash: opts.txHash,
791
+ timestamp: opts.timestamp
792
+ });
793
+ this.creditManager = opts.creditManager;
794
+ this.priceOracle = opts.priceOracle;
795
+ }
796
+
797
+ toString(): string {
798
+ return `Credit manager ${getContractName(
799
+ this.creditManager
800
+ )} updated: price oracle was updated. New price oracle ${getContractName(
801
+ this.priceOracle
802
+ )}`;
803
+ }
752
804
  }
753
805
 
754
806
  // event TransferPluginAllowed(
@@ -757,65 +809,68 @@ export class EventPriceOracleUpdated extends EVMEvent {
757
809
  // );
758
810
 
759
811
  interface TransferPluginAllowedProps extends EVMEventProps {
760
- creditManager: string;
761
- priceOracle: string;
762
- state: boolean;
812
+ creditManager: string;
813
+ priceOracle: string;
814
+ state: boolean;
763
815
  }
764
816
 
765
817
  export class EventTransferPluginAllowed extends EVMEvent {
766
- public readonly creditManager: string;
767
- public readonly plugin: string;
768
- public readonly state: boolean;
769
-
770
- constructor(opts: TransferPluginAllowedProps) {
771
- super({
772
- block: opts.block,
773
- txHash: opts.txHash,
774
- timestamp: opts.timestamp
775
- });
776
- this.creditManager = opts.creditManager;
777
- this.plugin = opts.priceOracle;
778
- this.state = opts.state;
779
- }
780
-
781
- toString(_: Record<string, TokenData>): string {
782
- return `Credit manager ${getContractName(
783
- this.creditManager
784
- )} updated: transfer plugin ${getContractName(this.plugin)} was ${
785
- this.state ? "allowed" : "forbidden"
786
- }`;
787
- }
818
+ public readonly creditManager: string;
819
+
820
+ public readonly plugin: string;
821
+
822
+ public readonly state: boolean;
823
+
824
+ constructor(opts: TransferPluginAllowedProps) {
825
+ super({
826
+ block: opts.block,
827
+ txHash: opts.txHash,
828
+ timestamp: opts.timestamp
829
+ });
830
+ this.creditManager = opts.creditManager;
831
+ this.plugin = opts.priceOracle;
832
+ this.state = opts.state;
833
+ }
834
+
835
+ toString(): string {
836
+ return `Credit manager ${getContractName(
837
+ this.creditManager
838
+ )} updated: transfer plugin ${getContractName(this.plugin)} was ${
839
+ this.state ? "allowed" : "forbidden"
840
+ }`;
841
+ }
788
842
  }
789
843
 
790
844
  // // Emits each time when Interest Rate model was changed
791
845
  // event NewInterestRateModel(address indexed newInterestRateModel);
792
846
 
793
847
  interface NewInterestRateModelProps extends EVMEventProps {
794
- pool: string;
795
- newInterestRateModel: string;
848
+ pool: string;
849
+ newInterestRateModel: string;
796
850
  }
797
851
 
798
852
  export class EventNewInterestRateModel extends EVMEvent {
799
- public readonly pool: string;
800
- public readonly newInterestRateModel: string;
801
-
802
- constructor(opts: NewInterestRateModelProps) {
803
- super({
804
- block: opts.block,
805
- txHash: opts.txHash,
806
- timestamp: opts.timestamp
807
- });
808
- this.pool = opts.pool;
809
- this.newInterestRateModel = opts.newInterestRateModel;
810
- }
811
-
812
- toString(_: Record<string, TokenData>): string {
813
- return `Pool ${getContractName(
814
- this.pool
815
- )} updated: interest rate model was updated. New model: ${getContractName(
816
- this.newInterestRateModel
817
- )}`;
818
- }
853
+ public readonly pool: string;
854
+
855
+ public readonly newInterestRateModel: string;
856
+
857
+ constructor(opts: NewInterestRateModelProps) {
858
+ super({
859
+ block: opts.block,
860
+ txHash: opts.txHash,
861
+ timestamp: opts.timestamp
862
+ });
863
+ this.pool = opts.pool;
864
+ this.newInterestRateModel = opts.newInterestRateModel;
865
+ }
866
+
867
+ toString(): string {
868
+ return `Pool ${getContractName(
869
+ this.pool
870
+ )} updated: interest rate model was updated. New model: ${getContractName(
871
+ this.newInterestRateModel
872
+ )}`;
873
+ }
819
874
  }
820
875
 
821
876
  //
@@ -823,31 +878,32 @@ export class EventNewInterestRateModel extends EVMEvent {
823
878
  // event NewCreditManagerConnected(address indexed creditManager);
824
879
 
825
880
  interface NewCreditManagerConnectedProps extends EVMEventProps {
826
- pool: string;
827
- creditManager: string;
881
+ pool: string;
882
+ creditManager: string;
828
883
  }
829
884
 
830
885
  export class EventNewCreditManagerConnected extends EVMEvent {
831
- public readonly pool: string;
832
- public readonly creditManager: string;
833
-
834
- constructor(opts: NewCreditManagerConnectedProps) {
835
- super({
836
- block: opts.block,
837
- txHash: opts.txHash,
838
- timestamp: opts.timestamp
839
- });
840
- this.pool = opts.pool;
841
- this.creditManager = opts.creditManager;
842
- }
843
-
844
- toString(_: Record<string, TokenData>): string {
845
- return `Pool ${getContractName(
846
- this.pool
847
- )} updated: new credit manager ${getContractName(
848
- this.creditManager
849
- )} was connected`;
850
- }
886
+ public readonly pool: string;
887
+
888
+ public readonly creditManager: string;
889
+
890
+ constructor(opts: NewCreditManagerConnectedProps) {
891
+ super({
892
+ block: opts.block,
893
+ txHash: opts.txHash,
894
+ timestamp: opts.timestamp
895
+ });
896
+ this.pool = opts.pool;
897
+ this.creditManager = opts.creditManager;
898
+ }
899
+
900
+ toString(): string {
901
+ return `Pool ${getContractName(
902
+ this.pool
903
+ )} updated: new credit manager ${getContractName(
904
+ this.creditManager
905
+ )} was connected`;
906
+ }
851
907
  }
852
908
 
853
909
  //
@@ -855,338 +911,349 @@ export class EventNewCreditManagerConnected extends EVMEvent {
855
911
  // event BorrowForbidden(address indexed creditManager);
856
912
 
857
913
  interface BorrowForbiddenProps extends EVMEventProps {
858
- pool: string;
859
- creditManager: string;
914
+ pool: string;
915
+ creditManager: string;
860
916
  }
861
917
 
862
918
  export class EventBorrowForbidden extends EVMEvent {
863
- public readonly pool: string;
864
- public readonly creditManager: string;
865
-
866
- constructor(opts: BorrowForbiddenProps) {
867
- super({
868
- block: opts.block,
869
- txHash: opts.txHash,
870
- timestamp: opts.timestamp
871
- });
872
- this.pool = opts.pool;
873
- this.creditManager = opts.creditManager;
874
- }
875
-
876
- toString(_: Record<string, TokenData>): string {
877
- return `Pool ${getContractName(
878
- this.pool
879
- )} updated: credit manager ${getContractName(
880
- this.creditManager
881
- )} was forbidden to borrow`;
882
- }
919
+ public readonly pool: string;
920
+
921
+ public readonly creditManager: string;
922
+
923
+ constructor(opts: BorrowForbiddenProps) {
924
+ super({
925
+ block: opts.block,
926
+ txHash: opts.txHash,
927
+ timestamp: opts.timestamp
928
+ });
929
+ this.pool = opts.pool;
930
+ this.creditManager = opts.creditManager;
931
+ }
932
+
933
+ toString(): string {
934
+ return `Pool ${getContractName(
935
+ this.pool
936
+ )} updated: credit manager ${getContractName(
937
+ this.creditManager
938
+ )} was forbidden to borrow`;
939
+ }
883
940
  }
884
941
 
885
942
  // // Emits after expected liquidity limit update
886
943
  // event NewExpectedLiquidityLimit(uint256 newLimit);
887
944
 
888
945
  interface NewExpectedLiquidityLimitProps extends EVMEventProps {
889
- pool: string;
890
- underlyingToken: string;
891
- newLimit: string;
892
- oldLimit: string;
946
+ pool: string;
947
+ underlyingToken: string;
948
+ newLimit: string;
949
+ oldLimit: string;
893
950
  }
894
951
 
895
952
  export class EventNewExpectedLiquidityLimit extends EVMEvent {
896
- public readonly pool: string;
897
- public readonly underlyingToken: string;
898
- public readonly newLimit: BigNumber;
899
- public readonly prevLimit: BigNumber;
900
-
901
- constructor(opts: NewExpectedLiquidityLimitProps) {
902
- super({
903
- block: opts.block,
904
- txHash: opts.txHash,
905
- timestamp: opts.timestamp
906
- });
907
- this.pool = opts.pool;
908
- this.underlyingToken = opts.underlyingToken;
909
- this.newLimit = BigNumber.from(opts.newLimit);
910
- this.prevLimit = BigNumber.from(opts.oldLimit);
911
- }
912
-
913
- toString(tokenData: Record<string, TokenData>): string {
914
- const {decimals = 18, symbol} =
915
- tokenData[this.underlyingToken.toLowerCase()] || {};
916
-
917
- return this.prevLimit.isZero()
918
- ? `Pool ${getContractName(
919
- this.pool
920
- )} updated: expected liquidity limit was set to ${formatBN(
921
- this.newLimit,
922
- decimals
923
- )} ${symbol}`
924
- : `Pool ${getContractName(
925
- this.pool
926
- )} updated: expected liquidity limit was ${
927
- this.newLimit.gt(this.prevLimit) ? "increased" : "decreased"
928
- }: ${formatBN(this.prevLimit, decimals)} ${symbol} => ${formatBN(
929
- this.newLimit,
930
- decimals
931
- )} ${symbol}`;
932
- }
953
+ public readonly pool: string;
954
+
955
+ public readonly underlyingToken: string;
956
+
957
+ public readonly newLimit: BigNumber;
958
+
959
+ public readonly prevLimit: BigNumber;
960
+
961
+ constructor(opts: NewExpectedLiquidityLimitProps) {
962
+ super({
963
+ block: opts.block,
964
+ txHash: opts.txHash,
965
+ timestamp: opts.timestamp
966
+ });
967
+ this.pool = opts.pool;
968
+ this.underlyingToken = opts.underlyingToken;
969
+ this.newLimit = BigNumber.from(opts.newLimit);
970
+ this.prevLimit = BigNumber.from(opts.oldLimit);
971
+ }
972
+
973
+ toString(tokenData: Record<string, TokenData>): string {
974
+ const { decimals = 18, symbol } =
975
+ tokenData[this.underlyingToken.toLowerCase()] || {};
976
+
977
+ return this.prevLimit.isZero()
978
+ ? `Pool ${getContractName(
979
+ this.pool
980
+ )} updated: expected liquidity limit was set to ${formatBN(
981
+ this.newLimit,
982
+ decimals
983
+ )} ${symbol}`
984
+ : `Pool ${getContractName(
985
+ this.pool
986
+ )} updated: expected liquidity limit was ${
987
+ this.newLimit.gt(this.prevLimit) ? "increased" : "decreased"
988
+ }: ${formatBN(this.prevLimit, decimals)} ${symbol} => ${formatBN(
989
+ this.newLimit,
990
+ decimals
991
+ )} ${symbol}`;
992
+ }
933
993
  }
934
994
 
935
995
  // // Emits each time when withdraw fee is udpated
936
996
  // event NewWithdrawFee(uint256 fee);
937
997
 
938
998
  interface NewWithdrawFeeProps extends EVMEventProps {
939
- pool: string;
940
- underlyingToken: string;
941
- newFee: string;
942
- oldFee: string;
999
+ pool: string;
1000
+ underlyingToken: string;
1001
+ newFee: string;
1002
+ oldFee: string;
943
1003
  }
944
1004
 
945
1005
  export class EventNewWithdrawFee extends EVMEvent {
946
- public readonly pool: string;
947
- public readonly underlyingToken: string;
948
- public readonly newFee: number;
949
- public readonly prevFee: number;
950
-
951
- constructor(opts: NewWithdrawFeeProps) {
952
- super({
953
- block: opts.block,
954
- txHash: opts.txHash,
955
- timestamp: opts.timestamp
956
- });
957
- this.pool = opts.pool;
958
- this.underlyingToken = opts.underlyingToken;
959
- this.newFee = Number(opts.newFee);
960
- this.prevFee = Number(opts.oldFee);
961
- }
962
-
963
- toString(_: Record<string, TokenData>): string {
964
- return this.prevFee === 0
965
- ? `Pool ${getContractName(this.pool)} updated: withdraw fee was set to: ${
966
- this.newFee / 100
967
- }%`
968
- : `Pool ${getContractName(this.pool)} updated: withdraw fee was ${
969
- this.newFee > this.prevFee ? "increased" : "decreased"
970
- }: ${this.prevFee / 100}% => ${this.newFee / 100}%`;
971
- }
1006
+ public readonly pool: string;
1007
+
1008
+ public readonly underlyingToken: string;
1009
+
1010
+ public readonly newFee: number;
1011
+
1012
+ public readonly prevFee: number;
1013
+
1014
+ constructor(opts: NewWithdrawFeeProps) {
1015
+ super({
1016
+ block: opts.block,
1017
+ txHash: opts.txHash,
1018
+ timestamp: opts.timestamp
1019
+ });
1020
+ this.pool = opts.pool;
1021
+ this.underlyingToken = opts.underlyingToken;
1022
+ this.newFee = Number(opts.newFee);
1023
+ this.prevFee = Number(opts.oldFee);
1024
+ }
1025
+
1026
+ toString(): string {
1027
+ return this.prevFee === 0
1028
+ ? `Pool ${getContractName(this.pool)} updated: withdraw fee was set to: ${
1029
+ this.newFee / PERCENTAGE_DECIMALS
1030
+ }%`
1031
+ : `Pool ${getContractName(this.pool)} updated: withdraw fee was ${
1032
+ this.newFee > this.prevFee ? "increased" : "decreased"
1033
+ }: ${this.prevFee / PERCENTAGE_DECIMALS}% => ${
1034
+ this.newFee / PERCENTAGE_DECIMALS
1035
+ }%`;
1036
+ }
972
1037
  }
973
1038
 
974
1039
  // // Emits each time new configurator is set up
975
1040
  // event NewPriceFeed(address indexed token, address indexed priceFeed);
976
1041
 
977
1042
  interface NewPriceFeedProps extends EVMEventProps {
978
- token: string;
979
- priceFeed: string;
1043
+ token: string;
1044
+ priceFeed: string;
980
1045
  }
981
1046
 
982
1047
  export class EventNewPriceFeed extends EVMEvent {
983
- public readonly token: string;
984
- public readonly priceFeed: string;
985
-
986
- constructor(opts: NewPriceFeedProps) {
987
- super({
988
- block: opts.block,
989
- txHash: opts.txHash,
990
- timestamp: opts.timestamp
991
- });
992
- this.token = opts.token;
993
- this.priceFeed = opts.priceFeed;
994
- }
995
-
996
- toString(tokenData: Record<string, TokenData>): string {
997
- const {symbol} = tokenData[this.token.toLowerCase()] || {};
998
-
999
- return `PriceOracle: oracle for ${symbol} was updated to ${getContractName(
1000
- this.priceFeed
1001
- )}`;
1002
- }
1048
+ public readonly token: string;
1049
+
1050
+ public readonly priceFeed: string;
1051
+
1052
+ constructor(opts: NewPriceFeedProps) {
1053
+ super({
1054
+ block: opts.block,
1055
+ txHash: opts.txHash,
1056
+ timestamp: opts.timestamp
1057
+ });
1058
+ this.token = opts.token;
1059
+ this.priceFeed = opts.priceFeed;
1060
+ }
1061
+
1062
+ toString(tokenData: Record<string, TokenData>): string {
1063
+ const { symbol } = tokenData[this.token.toLowerCase()] || {};
1064
+
1065
+ return `PriceOracle: oracle for ${symbol} was updated to ${getContractName(
1066
+ this.priceFeed
1067
+ )}`;
1068
+ }
1003
1069
  }
1004
1070
 
1005
1071
  // // emits each time when DAO takes account from account factory forever
1006
1072
  // event TakeForever(address indexed creditAccount, address indexed to);
1007
1073
 
1008
1074
  interface TakeForeverProps extends EVMEventProps {
1009
- creditAccount: string;
1010
- to: string;
1075
+ creditAccount: string;
1076
+ to: string;
1011
1077
  }
1012
1078
 
1013
1079
  export class EventTakeForever extends EVMEvent {
1014
- public readonly creditAccount: string;
1015
- public readonly to: string;
1016
-
1017
- constructor(opts: TakeForeverProps) {
1018
- super({
1019
- block: opts.block,
1020
- txHash: opts.txHash,
1021
- timestamp: opts.timestamp
1022
- });
1023
- this.creditAccount = opts.creditAccount;
1024
- this.to = opts.to;
1025
- }
1026
-
1027
- toString(_: Record<string, TokenData>): string {
1028
- return `AccountFactory: account ${this.creditAccount} was taken forever and transferred to ${this.to}`;
1029
- }
1080
+ public readonly creditAccount: string;
1081
+
1082
+ public readonly to: string;
1083
+
1084
+ constructor(opts: TakeForeverProps) {
1085
+ super({
1086
+ block: opts.block,
1087
+ txHash: opts.txHash,
1088
+ timestamp: opts.timestamp
1089
+ });
1090
+ this.creditAccount = opts.creditAccount;
1091
+ this.to = opts.to;
1092
+ }
1093
+
1094
+ toString(): string {
1095
+ return `AccountFactory: account ${this.creditAccount} was taken forever and transferred to ${this.to}`;
1096
+ }
1030
1097
  }
1031
1098
 
1032
1099
  // Paused / Unpaused event (!)
1033
1100
 
1034
1101
  interface PausedProps extends EVMEventProps {
1035
- contract: string;
1102
+ contract: string;
1036
1103
  }
1037
1104
 
1038
1105
  export class EventPaused extends EVMEvent {
1039
- public readonly contract: string;
1040
-
1041
- constructor(opts: PausedProps) {
1042
- super({
1043
- block: opts.block,
1044
- txHash: opts.txHash,
1045
- timestamp: opts.timestamp
1046
- });
1047
- this.contract = opts.contract;
1048
- }
1049
-
1050
- toString(_: Record<string, TokenData>): string {
1051
- return `${getContractName(this.contract)} was paused`;
1052
- }
1106
+ public readonly contract: string;
1107
+
1108
+ constructor(opts: PausedProps) {
1109
+ super({
1110
+ block: opts.block,
1111
+ txHash: opts.txHash,
1112
+ timestamp: opts.timestamp
1113
+ });
1114
+ this.contract = opts.contract;
1115
+ }
1116
+
1117
+ toString(): string {
1118
+ return `${getContractName(this.contract)} was paused`;
1119
+ }
1053
1120
  }
1054
1121
 
1055
1122
  interface UnPausedProps extends EVMEventProps {
1056
- contract: string;
1123
+ contract: string;
1057
1124
  }
1058
1125
 
1059
1126
  export class EventUnPaused extends EVMEvent {
1060
- public readonly contract: string;
1061
-
1062
- constructor(opts: UnPausedProps) {
1063
- super({
1064
- block: opts.block,
1065
- txHash: opts.txHash,
1066
- timestamp: opts.timestamp
1067
- });
1068
- this.contract = opts.contract;
1069
- }
1070
-
1071
- toString(_: Record<string, TokenData>): string {
1072
- return `${getContractName(this.contract)} was unpaused`;
1073
- }
1127
+ public readonly contract: string;
1128
+
1129
+ constructor(opts: UnPausedProps) {
1130
+ super({
1131
+ block: opts.block,
1132
+ txHash: opts.txHash,
1133
+ timestamp: opts.timestamp
1134
+ });
1135
+ this.contract = opts.contract;
1136
+ }
1137
+
1138
+ toString(): string {
1139
+ return `${getContractName(this.contract)} was unpaused`;
1140
+ }
1074
1141
  }
1075
1142
 
1076
1143
  // // emits each time when new pausable admin added
1077
1144
  // event PausableAdminAdded(address indexed newAdmin);
1078
1145
 
1079
1146
  interface PausableAdminAddedProps extends EVMEventProps {
1080
- admin: string;
1147
+ admin: string;
1081
1148
  }
1082
1149
 
1083
1150
  export class EventPausableAdminAdded extends EVMEvent {
1084
- public readonly admin: string;
1085
-
1086
- constructor(opts: PausableAdminAddedProps) {
1087
- super({
1088
- block: opts.block,
1089
- txHash: opts.txHash,
1090
- timestamp: opts.timestamp
1091
- });
1092
- this.admin = opts.admin;
1093
- }
1094
-
1095
- toString(_: Record<string, TokenData>): string {
1096
- return `ACL: pausable admin ${this.admin} was added`;
1097
- }
1151
+ public readonly admin: string;
1152
+
1153
+ constructor(opts: PausableAdminAddedProps) {
1154
+ super({
1155
+ block: opts.block,
1156
+ txHash: opts.txHash,
1157
+ timestamp: opts.timestamp
1158
+ });
1159
+ this.admin = opts.admin;
1160
+ }
1161
+
1162
+ toString(): string {
1163
+ return `ACL: pausable admin ${this.admin} was added`;
1164
+ }
1098
1165
  }
1099
1166
 
1100
1167
  // emits each time when pausable admin removed
1101
1168
  // event PausableAdminRemoved(address indexed admin);
1102
1169
 
1103
1170
  interface PausableAdminRemovedProps extends EVMEventProps {
1104
- admin: string;
1171
+ admin: string;
1105
1172
  }
1106
1173
 
1107
1174
  export class EventPausableAdminRemoved extends EVMEvent {
1108
- public readonly admin: string;
1109
-
1110
- constructor(opts: PausableAdminRemovedProps) {
1111
- super({
1112
- block: opts.block,
1113
- txHash: opts.txHash,
1114
- timestamp: opts.timestamp
1115
- });
1116
- this.admin = opts.admin;
1117
- }
1118
-
1119
- toString(_: Record<string, TokenData>): string {
1120
- return `ACL: pausable admin ${this.admin} was removed`;
1121
- }
1175
+ public readonly admin: string;
1176
+
1177
+ constructor(opts: PausableAdminRemovedProps) {
1178
+ super({
1179
+ block: opts.block,
1180
+ txHash: opts.txHash,
1181
+ timestamp: opts.timestamp
1182
+ });
1183
+ this.admin = opts.admin;
1184
+ }
1185
+
1186
+ toString(): string {
1187
+ return `ACL: pausable admin ${this.admin} was removed`;
1188
+ }
1122
1189
  }
1123
1190
 
1124
1191
  // // emits each time when new unpausable admin added
1125
1192
  // event UnpausableAdminAdded(address indexed newAdmin);
1126
1193
 
1127
1194
  interface UnPausableAdminAddedProps extends EVMEventProps {
1128
- admin: string;
1195
+ admin: string;
1129
1196
  }
1130
1197
 
1131
1198
  export class EventUnPausableAdminAdded extends EVMEvent {
1132
- public readonly admin: string;
1133
-
1134
- constructor(opts: UnPausableAdminAddedProps) {
1135
- super({
1136
- block: opts.block,
1137
- txHash: opts.txHash,
1138
- timestamp: opts.timestamp
1139
- });
1140
- this.admin = opts.admin;
1141
- }
1142
-
1143
- toString(_: Record<string, TokenData>): string {
1144
- return `ACL: unpausable admin ${this.admin} was added`;
1145
- }
1199
+ public readonly admin: string;
1200
+
1201
+ constructor(opts: UnPausableAdminAddedProps) {
1202
+ super({
1203
+ block: opts.block,
1204
+ txHash: opts.txHash,
1205
+ timestamp: opts.timestamp
1206
+ });
1207
+ this.admin = opts.admin;
1208
+ }
1209
+
1210
+ toString(): string {
1211
+ return `ACL: unpausable admin ${this.admin} was added`;
1212
+ }
1146
1213
  }
1147
1214
 
1148
1215
  // emits each times when unpausable admin removed
1149
1216
  // event UnpausableAdminRemoved(address indexed admin);
1150
1217
 
1151
1218
  interface UnPausableAdminRemovedProps extends EVMEventProps {
1152
- admin: string;
1219
+ admin: string;
1153
1220
  }
1154
1221
 
1155
1222
  export class EventUnPausableAdminRemoved extends EVMEvent {
1156
- public readonly admin: string;
1157
-
1158
- constructor(opts: UnPausableAdminRemovedProps) {
1159
- super({
1160
- block: opts.block,
1161
- txHash: opts.txHash,
1162
- timestamp: opts.timestamp
1163
- });
1164
- this.admin = opts.admin;
1165
- }
1166
-
1167
- toString(_: Record<string, TokenData>): string {
1168
- return `ACL: unpausable admin ${this.admin} was removed`;
1169
- }
1223
+ public readonly admin: string;
1224
+
1225
+ constructor(opts: UnPausableAdminRemovedProps) {
1226
+ super({
1227
+ block: opts.block,
1228
+ txHash: opts.txHash,
1229
+ timestamp: opts.timestamp
1230
+ });
1231
+ this.admin = opts.admin;
1232
+ }
1233
+
1234
+ toString(): string {
1235
+ return `ACL: unpausable admin ${this.admin} was removed`;
1236
+ }
1170
1237
  }
1171
1238
 
1172
1239
  interface TransferOwnershipProps extends EVMEventProps {
1173
- admin: string;
1240
+ admin: string;
1174
1241
  }
1175
1242
 
1176
1243
  // ACL: Transfer ownership
1177
1244
  export class EventTransferOwnership extends EVMEvent {
1178
- public readonly newOwner: string;
1179
-
1180
- constructor(opts: TransferOwnershipProps) {
1181
- super({
1182
- block: opts.block,
1183
- txHash: opts.txHash,
1184
- timestamp: opts.timestamp
1185
- });
1186
- this.newOwner = opts.admin;
1187
- }
1188
-
1189
- toString(_: Record<string, TokenData>): string {
1190
- return `ACL: configurator was changed to ${this.newOwner}`;
1191
- }
1245
+ public readonly newOwner: string;
1246
+
1247
+ constructor(opts: TransferOwnershipProps) {
1248
+ super({
1249
+ block: opts.block,
1250
+ txHash: opts.txHash,
1251
+ timestamp: opts.timestamp
1252
+ });
1253
+ this.newOwner = opts.admin;
1254
+ }
1255
+
1256
+ toString(): string {
1257
+ return `ACL: configurator was changed to ${this.newOwner}`;
1258
+ }
1192
1259
  }