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