Skip to content

Commit 53a1347

Browse files
committed
Refactor
1 parent d604858 commit 53a1347

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

packages/v3/contracts/pools/PoolCollection.sol

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ contract PoolCollection is IPoolCollection, OwnedUpgradeable, ReentrancyGuardUpg
4343
uint32 private constant DEFAULT_TRADING_FEE_PPM = 2000; // 0.2%
4444

4545
// trading enabling/disabling reasons
46-
uint8 private constant TRADING_ENABLED_BY_OWNER = 0;
47-
uint8 private constant TRADING_ENABLED_BY_MINIMUM_LIQUIDITY = 1;
46+
uint8 private constant TRADING_STATUS_UPDATE_OWNER = 0;
47+
uint8 private constant TRADING_STATUS_UPDATE_MIN_LIQUIDITY = 1;
4848

4949
// withdrawal-related input data
5050
struct PoolWithdrawalParams {
@@ -261,7 +261,7 @@ contract PoolCollection is IPoolCollection, OwnedUpgradeable, ReentrancyGuardUpg
261261

262262
// although the owner-controlled flag is set to true, we want to emphasize that the trading in a newly created
263263
// pool is disabled
264-
emit TradingEnabled({ pool: reserveToken, newStatus: false, reason: TRADING_ENABLED_BY_OWNER });
264+
emit TradingEnabled({ pool: reserveToken, newStatus: false, reason: TRADING_STATUS_UPDATE_OWNER });
265265

266266
emit TradingFeePPMUpdated({ pool: reserveToken, prevFeePPM: 0, newFeePPM: newPool.tradingFeePPM });
267267
emit DepositingEnabled({ pool: reserveToken, newStatus: newPool.depositingEnabled });
@@ -348,7 +348,7 @@ contract PoolCollection is IPoolCollection, OwnedUpgradeable, ReentrancyGuardUpg
348348

349349
poolData.tradingEnabled = status;
350350

351-
emit TradingEnabled({ pool: pool, newStatus: status, reason: TRADING_ENABLED_BY_OWNER });
351+
emit TradingEnabled({ pool: pool, newStatus: status, reason: TRADING_STATUS_UPDATE_OWNER });
352352
}
353353

354354
/**
@@ -461,7 +461,7 @@ contract PoolCollection is IPoolCollection, OwnedUpgradeable, ReentrancyGuardUpg
461461
poolData.liquidity.networkTokenTradingLiquidity.add(depositParams.baseTokenDeltaAmount) >=
462462
minLiquidityForTrading
463463
) {
464-
emit TradingEnabled({ pool: pool, newStatus: true, reason: TRADING_ENABLED_BY_MINIMUM_LIQUIDITY });
464+
emit TradingEnabled({ pool: pool, newStatus: true, reason: TRADING_STATUS_UPDATE_MIN_LIQUIDITY });
465465
}
466466
}
467467

@@ -691,11 +691,7 @@ contract PoolCollection is IPoolCollection, OwnedUpgradeable, ReentrancyGuardUpg
691691
bool currEnabled = networkTokenCurrTradingLiquidity >= minLiquidityForTrading;
692692
bool newEnabled = networkTokenNewTradingLiquidity >= minLiquidityForTrading;
693693
if (newEnabled != currEnabled) {
694-
emit TradingEnabled({
695-
pool: pool,
696-
newStatus: newEnabled,
697-
reason: TRADING_ENABLED_BY_MINIMUM_LIQUIDITY
698-
});
694+
emit TradingEnabled({ pool: pool, newStatus: newEnabled, reason: TRADING_STATUS_UPDATE_MIN_LIQUIDITY });
699695
}
700696
}
701697
}

packages/v3/test/pools/PoolCollection.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ describe('PoolCollection', () => {
1919
const MIN_LIQUIDITY_FOR_TRADING = toWei(BigNumber.from(100_000));
2020
const INITIAL_RATE = { n: BigNumber.from(1), d: BigNumber.from(2) };
2121

22-
const TRADING_ENABLED_BY_OWNER = 0;
23-
const TRADING_ENABLED_BY_MINIMUM_LIQUIDITY = 1;
22+
const TRADING_STATUS_UPDATE_OWNER = 0;
23+
const TRADING_STATUS_UPDATE_MIN_LIQUIDITY = 1;
2424

2525
let deployer: SignerWithAddress;
2626
let nonOwner: SignerWithAddress;
@@ -190,7 +190,7 @@ describe('PoolCollection', () => {
190190
.withArgs(reserveToken.address, BigNumber.from(0), pool.tradingFeePPM);
191191
await expect(res)
192192
.to.emit(poolCollection, 'TradingEnabled')
193-
.withArgs(reserveToken.address, false, TRADING_ENABLED_BY_OWNER);
193+
.withArgs(reserveToken.address, false, TRADING_STATUS_UPDATE_OWNER);
194194
await expect(res)
195195
.to.emit(poolCollection, 'DepositingEnabled')
196196
.withArgs(reserveToken.address, pool.depositingEnabled);
@@ -404,7 +404,7 @@ describe('PoolCollection', () => {
404404
const res = await poolCollection.enableTrading(reserveToken.address, false);
405405
await expect(res)
406406
.to.emit(poolCollection, 'TradingEnabled')
407-
.withArgs(reserveToken.address, false, TRADING_ENABLED_BY_OWNER);
407+
.withArgs(reserveToken.address, false, TRADING_STATUS_UPDATE_OWNER);
408408

409409
pool = await poolCollection.poolData(reserveToken.address);
410410
({ tradingEnabled } = pool);
@@ -413,7 +413,7 @@ describe('PoolCollection', () => {
413413
const res2 = await poolCollection.enableTrading(reserveToken.address, true);
414414
await expect(res2)
415415
.to.emit(poolCollection, 'TradingEnabled')
416-
.withArgs(reserveToken.address, true, TRADING_ENABLED_BY_OWNER);
416+
.withArgs(reserveToken.address, true, TRADING_STATUS_UPDATE_OWNER);
417417

418418
pool = await poolCollection.poolData(reserveToken.address);
419419
({ tradingEnabled } = pool);
@@ -998,7 +998,7 @@ describe('PoolCollection', () => {
998998
) {
999999
await expect(res)
10001000
.to.emit(poolCollection, 'TradingEnabled')
1001-
.withArgs(reserveToken.address, true, TRADING_ENABLED_BY_MINIMUM_LIQUIDITY);
1001+
.withArgs(reserveToken.address, true, TRADING_STATUS_UPDATE_MIN_LIQUIDITY);
10021002
}
10031003

10041004
let rate;

0 commit comments

Comments
 (0)