Skip to content

Commit

Permalink
fix: replace Tokens enum with uint256 in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Van0k committed Nov 27, 2024
1 parent a60af54 commit 357ece6
Show file tree
Hide file tree
Showing 24 changed files with 415 additions and 430 deletions.
48 changes: 24 additions & 24 deletions contracts/test/config/MockCreditConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.17;

import {TokensTestSuite} from "../suites/TokensTestSuite.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Tokens} from "@gearbox-protocol/sdk-gov/contracts/Tokens.sol";
import "@gearbox-protocol/sdk-gov/contracts/Tokens.sol";
import {NetworkDetector} from "@gearbox-protocol/sdk-gov/contracts/NetworkDetector.sol";
import {Contracts} from "@gearbox-protocol/sdk-gov/contracts/SupportedContracts.sol";
import "forge-std/console.sol";
Expand All @@ -30,7 +30,7 @@ contract MockCreditConfig is Test, IPoolV3DeployConfig {
string public name = "Diesel DAI v3";

uint256 public chainId;
Tokens public underlying = Tokens.DAI;
uint256 public underlying = TOKEN_DAI;
bool public constant supportsQuotas = true;
uint256 public constant getAccountAmount = DAI_ACCOUNT_AMOUNT;

Expand All @@ -54,21 +54,21 @@ contract MockCreditConfig is Test, IPoolV3DeployConfig {
NetworkDetector nd = new NetworkDetector();
chainId = nd.chainId();

_gaugeRates.push(GaugeRate({token: Tokens.USDC, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: Tokens.USDT, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: Tokens.WETH, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: Tokens.LINK, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: Tokens.CRV, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: Tokens.CVX, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: Tokens.STETH, minRate: 1, maxRate: 10_000}));

_quotaLimits.push(PoolQuotaLimit({token: Tokens.USDC, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.USDT, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.WETH, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.LINK, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.CRV, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.CVX, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.STETH, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_gaugeRates.push(GaugeRate({token: TOKEN_USDC, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: TOKEN_USDT, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: TOKEN_WETH, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: TOKEN_LINK, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: TOKEN_CRV, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: TOKEN_CVX, minRate: 1, maxRate: 10_000}));
_gaugeRates.push(GaugeRate({token: TOKEN_STETH, minRate: 1, maxRate: 10_000}));

_quotaLimits.push(PoolQuotaLimit({token: TOKEN_USDC, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: TOKEN_USDT, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: TOKEN_WETH, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: TOKEN_LINK, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: TOKEN_CRV, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: TOKEN_CVX, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));
_quotaLimits.push(PoolQuotaLimit({token: TOKEN_STETH, quotaIncreaseFee: 0, limit: uint96(type(int96).max)}));

CreditManagerV3DeployParams storage cp = _creditManagers.push();

Expand All @@ -87,13 +87,13 @@ contract MockCreditConfig is Test, IPoolV3DeployConfig {
cp.name = "Mock Credit Manager DAI";

CollateralTokenHuman[] storage cts = cp.collateralTokens;
cts.push(CollateralTokenHuman({token: Tokens.USDC, lt: 90_00}));
cts.push(CollateralTokenHuman({token: Tokens.USDT, lt: 88_00}));
cts.push(CollateralTokenHuman({token: Tokens.WETH, lt: 83_00}));
cts.push(CollateralTokenHuman({token: Tokens.LINK, lt: 73_00}));
cts.push(CollateralTokenHuman({token: Tokens.CRV, lt: 73_00}));
cts.push(CollateralTokenHuman({token: Tokens.CVX, lt: 73_00}));
cts.push(CollateralTokenHuman({token: Tokens.STETH, lt: 73_00}));
cts.push(CollateralTokenHuman({token: TOKEN_USDC, lt: 90_00}));
cts.push(CollateralTokenHuman({token: TOKEN_USDT, lt: 88_00}));
cts.push(CollateralTokenHuman({token: TOKEN_WETH, lt: 83_00}));
cts.push(CollateralTokenHuman({token: TOKEN_LINK, lt: 73_00}));
cts.push(CollateralTokenHuman({token: TOKEN_CRV, lt: 73_00}));
cts.push(CollateralTokenHuman({token: TOKEN_CVX, lt: 73_00}));
cts.push(CollateralTokenHuman({token: TOKEN_STETH, lt: 73_00}));
}

function poolParams() external view override returns (PoolV3DeployParams memory) {
Expand Down
36 changes: 15 additions & 21 deletions contracts/test/config/MockTokensData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,46 @@
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;

import {Tokens} from "@gearbox-protocol/sdk-gov/contracts/Tokens.sol";
import "@gearbox-protocol/sdk-gov/contracts/Tokens.sol";
import "../lib/constants.sol";

struct MockToken {
Tokens index;
uint256 index;
string symbol;
uint8 decimals;
int256 price;
Tokens underlying;
uint256 underlying;
}

library MockTokensData {
function getTokenData() internal pure returns (MockToken[] memory result) {
MockToken[9] memory testTokensData = [
MockToken({index: Tokens.DAI, symbol: "DAI", decimals: 18, price: 10 ** 8, underlying: Tokens.NO_TOKEN}),
MockToken({index: Tokens.USDC, symbol: "USDC", decimals: 6, price: 10 ** 8, underlying: Tokens.NO_TOKEN}),
MockToken({index: TOKEN_DAI, symbol: "DAI", decimals: 18, price: 10 ** 8, underlying: TOKEN_NO_TOKEN}),
MockToken({index: TOKEN_USDC, symbol: "USDC", decimals: 6, price: 10 ** 8, underlying: TOKEN_NO_TOKEN}),
MockToken({
index: Tokens.WETH,
index: TOKEN_WETH,
symbol: "WETH",
decimals: 18,
price: int256(DAI_WETH_RATE) * 10 ** 8,
underlying: Tokens.NO_TOKEN
underlying: TOKEN_NO_TOKEN
}),
MockToken({index: Tokens.LINK, symbol: "LINK", decimals: 18, price: 15 * 10 ** 8, underlying: Tokens.NO_TOKEN}),
MockToken({index: TOKEN_LINK, symbol: "LINK", decimals: 18, price: 15 * 10 ** 8, underlying: TOKEN_NO_TOKEN}),
MockToken({
index: Tokens.USDT,
index: TOKEN_USDT,
symbol: "USDT",
decimals: 18,
price: 99 * 10 ** 7, // .99 for test purposes
underlying: Tokens.NO_TOKEN
underlying: TOKEN_NO_TOKEN
}),
MockToken({index: TOKEN_STETH, symbol: "stETH", decimals: 18, price: 3300 * 10 ** 8, underlying: TOKEN_NO_TOKEN}),
MockToken({index: TOKEN_CRV, symbol: "CRV", decimals: 18, price: 14 * 10 ** 7, underlying: TOKEN_NO_TOKEN}),
MockToken({index: TOKEN_CVX, symbol: "CVX", decimals: 18, price: 7 * 10 ** 8, underlying: TOKEN_NO_TOKEN}),
MockToken({
index: Tokens.STETH,
symbol: "stETH",
decimals: 18,
price: 3300 * 10 ** 8,
underlying: Tokens.NO_TOKEN
}),
MockToken({index: Tokens.CRV, symbol: "CRV", decimals: 18, price: 14 * 10 ** 7, underlying: Tokens.NO_TOKEN}),
MockToken({index: Tokens.CVX, symbol: "CVX", decimals: 18, price: 7 * 10 ** 8, underlying: Tokens.NO_TOKEN}),
MockToken({
index: Tokens.wstETH,
index: TOKEN_wstETH,
symbol: "wstETH",
decimals: 18,
price: 3300 * 10 ** 8,
underlying: Tokens.NO_TOKEN
underlying: TOKEN_NO_TOKEN
})
];

Expand Down
Loading

0 comments on commit 357ece6

Please sign in to comment.