Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sogipec committed May 10, 2024
1 parent 1512405 commit 31899c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 51 deletions.
64 changes: 17 additions & 47 deletions scripts/mainnet-fork/routerUpgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import yargs from 'yargs';
/* simulation script to run on mainnet fork */
import { network, ethers, deployments } from 'hardhat';
// eslint-disable-next-line camelcase
import { AngleRouter, AngleRouter__factory, ProxyAdmin, ProxyAdmin__factory } from '../../typechain';
import { BigNumber } from 'ethers';
import { ChainId, CONTRACTS_ADDRESSES } from '@angleprotocol/sdk';
import { AngleRouterMainnet, AngleRouterMainnet__factory, ProxyAdmin, ProxyAdmin__factory } from '../../typechain';
import { ChainId, registry } from '@angleprotocol/sdk';
import { expect } from '../../utils/chai-setup';

const argv = yargs.env('').boolean('ci').parseSync();
Expand All @@ -13,74 +12,45 @@ async function main() {
const { deploy } = deployments;
const [deployer] = await ethers.getSigners();

const collaterals = ['USDC', 'FRAX', 'DAI', 'FEI'] as const;
const chainIdNetwork = ChainId.MAINNET;

const proxyAdminAddress = CONTRACTS_ADDRESSES[chainIdNetwork].ProxyAdmin!;
const governor = CONTRACTS_ADDRESSES[ChainId.MAINNET].GovernanceMultiSig! as string;
const guardian = CONTRACTS_ADDRESSES[ChainId.MAINNET].Guardian! as string;
const proxyAdminAddress = registry(ChainId.MAINNET)?.ProxyAdmin!
const governor = registry(ChainId.MAINNET)?.Governor
const router = registry(ChainId.MAINNET)?.AngleRouterV2!
const core = registry(ChainId.MAINNET)?.CoreBorrow!

await network.provider.request({
method: 'hardhat_impersonateAccount',
params: [governor],
});
await network.provider.send('hardhat_setBalance', [governor, '0x10000000000000000000000000000']);
const governorSigner = await ethers.provider.getSigner(governor);

const proxyAngleRouterAddress = CONTRACTS_ADDRESSES[chainIdNetwork].AngleRouter!;

await deploy('AngleRouter_Implementation', {
contract: 'AngleRouter',
await deploy('AngleRouterMainnet_Implementation', {
contract: 'AngleRouterMainnet',
from: deployer.address,
log: !argv.ci,
});
const AngleRouterImplementation = (await deployments.get('AngleRouter_Implementation')).address;
const AngleRouterImplementation = (await deployments.get('AngleRouterMainnet_Implementation')).address;
const contractProxyAdmin = new ethers.Contract(
proxyAdminAddress,
ProxyAdmin__factory.createInterface(),
governorSigner,
) as ProxyAdmin;

await (
await contractProxyAdmin.connect(governorSigner).upgrade(proxyAngleRouterAddress, AngleRouterImplementation)
await contractProxyAdmin.connect(governorSigner).upgrade(router, AngleRouterImplementation)
).wait();

// eslint-disable-next-line camelcase
const angleRouter = new ethers.Contract(
proxyAngleRouterAddress,
AngleRouter__factory.createInterface(),
router,
AngleRouterMainnet__factory.createInterface(),
governorSigner,
) as AngleRouter;

const angleAddress = CONTRACTS_ADDRESSES[chainIdNetwork].ANGLE!;
const veAngleAddress = CONTRACTS_ADDRESSES[chainIdNetwork].veANGLE!;
const WETH9Address = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
const WSTETHAddress = '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0';
const agEURAddress = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR.AgToken as string;
const stableMasterEURAddress = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR.StableMaster as string;

const json = await import('../../deploy/networks/mainnet.json');

expect(await angleRouter.governor()).to.be.equal(governor);
expect(await angleRouter.guardian()).to.be.equal(guardian);
expect(await angleRouter.ANGLE()).to.be.equal(angleAddress);
expect(await angleRouter.VEANGLE()).to.be.equal(veAngleAddress);
expect(await angleRouter.WETH9()).to.be.equal(WETH9Address);
expect(await angleRouter.WSTETH()).to.be.equal(WSTETHAddress);
expect(await angleRouter.oneInch()).to.be.equal(json.oneInch.Aggregatorv4);
expect(await angleRouter.uniswapV3Router()).to.be.equal(json.Uniswap.RouterV3);
) as AngleRouterMainnet;

expect(await angleRouter.mapStableMasters(agEURAddress)).to.be.equal(stableMasterEURAddress);
for (const col of collaterals) {
const pair = await angleRouter.mapPoolManagers(stableMasterEURAddress, json[col]);
const poolManager = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.PoolManager as string;
const perpetualManager = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.PerpetualManager as string;
const gauge = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.LiquidityGauge as string;
const sanToken = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.SanToken as string;
expect(pair[0]).to.be.equal(poolManager);
expect(pair[1]).to.be.equal(perpetualManager);
expect(pair[2]).to.be.equal(sanToken);
expect(pair[3]).to.be.equal(gauge);
}
expect(await angleRouter.core()).to.be.equal(core);
expect(await angleRouter.oneInch()).to.be.equal("0x111111125421cA6dc452d289314280a0f8842A65");
expect(await angleRouter.uniswapV3Router()).to.be.equal("0xE592427A0AEce92De3Edee1F18E0157C05861564");

console.log('Success');
console.log('');
Expand Down
8 changes: 4 additions & 4 deletions test/foundry/RouterSidechainSavingsRateActions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest {
address to,
uint256 gainOrLoss
) public {
vm.assume(to != address(0));
vm.assume(to != address(0) && to != address(savingsRate));
uint256 balanceUsers = BASE_TOKENS * 1 ether;
deal(address(token), address(_alice), balanceUsers);

Expand Down Expand Up @@ -119,7 +119,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest {
address to,
uint256 gainOrLoss
) public {
vm.assume(to != address(0));
vm.assume(to != address(0) && to != address(savingsRate));
uint256 balanceUsers = BASE_TOKENS * 1 ether;
deal(address(token), address(_alice), balanceUsers);

Expand Down Expand Up @@ -170,7 +170,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest {
uint256 gainOrLoss,
uint256 gainOrLoss2
) public {
vm.assume(to != address(0));
vm.assume(to != address(0) && to != address(savingsRate));
uint256 balanceUsers = BASE_TOKENS * 1 ether;
deal(address(token), address(_alice), balanceUsers);

Expand Down Expand Up @@ -248,7 +248,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest {
uint256 gainOrLoss,
uint256 gainOrLoss2
) public {
vm.assume(to != address(0));
vm.assume(to != address(0) && to != address(savingsRate));
uint256 balanceUsers = BASE_TOKENS * 1 ether;
deal(address(token), address(_alice), balanceUsers);

Expand Down

0 comments on commit 31899c2

Please sign in to comment.