Skip to content

Commit

Permalink
get the allEVMSpells test working
Browse files Browse the repository at this point in the history
  • Loading branch information
AStox committed Aug 1, 2024
1 parent e030960 commit 6d5636c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 71 deletions.
16 changes: 12 additions & 4 deletions src/spell/MigrationSpellBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {InvestmentManager} from "src/InvestmentManager.sol";
import {CastLib} from "src/libraries/CastLib.sol";
import {IAuth} from "src/interfaces/IAuth.sol";

interface IPoolManagerNew is IPoolManager {
function isPoolActive(uint64 poolId) external view returns (bool);
}

interface ITrancheOld {
function authTransferFrom(address from, address to, uint256 value) external returns (bool);
}
Expand Down Expand Up @@ -36,7 +40,7 @@ contract MigrationSpellBase {
address public POOLMANAGER_NEW;
address public RESTRICTIONMANAGER_NEW;
ITranche public trancheTokenNew;
IPoolManager poolManager;
IPoolManagerNew poolManager;

address public ROOT_OLD;
IRoot public rootOld;
Expand Down Expand Up @@ -83,7 +87,7 @@ contract MigrationSpellBase {
vaultOld = IVaultOld(VAULT_OLD);
POOL_ID = vaultOld.poolId();
TRANCHE_ID = vaultOld.trancheId();
poolManager = IPoolManager(address(POOLMANAGER_NEW));
poolManager = IPoolManagerNew(address(POOLMANAGER_NEW));
trancheTokenOld = ITranche(vaultOld.share());
DECIMALS = trancheTokenOld.decimals();
investmentManagerOld = InvestmentManager(vaultOld.manager());
Expand All @@ -94,9 +98,13 @@ contract MigrationSpellBase {

// deploy new tranche token
rootNew.relyContract(address(POOLMANAGER_NEW), self);
poolManager.addPool(POOL_ID);
if (!poolManager.isPoolActive(POOL_ID)) {
poolManager.addPool(POOL_ID);
}
poolManager.addTranche(POOL_ID, TRANCHE_ID, NAME, SYMBOL, DECIMALS, RESTRICTIONMANAGER_NEW);
poolManager.addAsset(CURRENCY_ID, vaultOld.asset());
if (poolManager.assetToId(vaultOld.asset()) == 0) {
poolManager.addAsset(CURRENCY_ID, vaultOld.asset());
}
poolManager.allowAsset(POOL_ID, CURRENCY_ID);
trancheTokenNew = ITranche(poolManager.deployTranche(POOL_ID, TRANCHE_ID));
rootNew.relyContract(address(trancheTokenNew), self);
Expand Down
134 changes: 67 additions & 67 deletions test/fork/ShareMigration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ contract ForkTest is Deployer, Test {
using stdJson for string;

address self;
mapping(address => uint256) balancesOld;
mapping(address => mapping(address => uint256)) balancesOld; // member => token => balance
string[] deployments;

struct MigrationContext {
Expand Down Expand Up @@ -293,70 +293,70 @@ contract ForkTest is Deployer, Test {
migrateSharesPartTwo(ctx, address(root), address(poolManager), address(restrictionManager));
}

// function testAllEVMMigrationsAgainstRealDeployment() public {
// TestableSpell spellLTF = new TestableSpell(new LTF_EVM());
// _loadDeployment("mainnet", spellLTF.NETWORK());
// _loadFork(0);
// MigrationContext memory ctxLTF = migrateSharesPartOne(
// spellLTF,
// spellLTF.ROOT_NEW(),
// spellLTF.POOLMANAGER_NEW(),
// spellLTF.RESTRICTIONMANAGER_NEW(),
// spellLTF.ADMIN_MULTISIG(),
// spellLTF.GUARDIAN_NEW()
// );
// TestableSpell spellDYF = new TestableSpell(new DYF_EVM());
// MigrationContext memory ctxDYF = migrateSharesPartOne(
// spellDYF,
// spellDYF.ROOT_NEW(),
// spellDYF.POOLMANAGER_NEW(),
// spellDYF.RESTRICTIONMANAGER_NEW(),
// spellDYF.ADMIN_MULTISIG(),
// spellDYF.GUARDIAN_NEW()
// );
// TestableSpell spellNS3SR = new TestableSpell(new NS3SR_EVM());
// MigrationContext memory ctxNS3SR = migrateSharesPartOne(
// spellNS3SR,
// spellNS3SR.ROOT_NEW(),
// spellNS3SR.POOLMANAGER_NEW(),
// spellNS3SR.RESTRICTIONMANAGER_NEW(),
// spellNS3SR.ADMIN_MULTISIG(),
// spellNS3SR.GUARDIAN_NEW()
// );
// TestableSpell spellNS3JR = new TestableSpell(new NS3JR_EVM());
// MigrationContext memory ctxNS3JR = migrateSharesPartOne(
// spellNS3JR,
// spellNS3JR.ROOT_NEW(),
// spellNS3JR.POOLMANAGER_NEW(),
// spellNS3JR.RESTRICTIONMANAGER_NEW(),
// spellNS3JR.ADMIN_MULTISIG(),
// spellNS3JR.GUARDIAN_NEW()
// );
// migrateSharesPartTwo(
// ctxLTF,
// spellLTF.ROOT_NEW(),
// spellLTF.POOLMANAGER_NEW(),
// spellLTF.RESTRICTIONMANAGER_NEW()
// );
// migrateSharesPartTwo(
// ctxDYF,
// spellDYF.ROOT_NEW(),
// spellDYF.POOLMANAGER_NEW(),
// spellDYF.RESTRICTIONMANAGER_NEW()
// );
// migrateSharesPartTwo(
// ctxNS3SR,
// spellNS3SR.ROOT_NEW(),
// spellNS3SR.POOLMANAGER_NEW(),
// spellNS3SR.RESTRICTIONMANAGER_NEW()
// );
// migrateSharesPartTwo(
// ctxNS3JR,
// spellNS3JR.ROOT_NEW(),
// spellNS3JR.POOLMANAGER_NEW(),
// spellNS3JR.RESTRICTIONMANAGER_NEW()
// );
// }
function testAllEVMMigrationsAgainstRealDeployment() public {
TestableSpell spellLTF = new TestableSpell(new LTF_EVM());
_loadDeployment("mainnet", spellLTF.NETWORK());
_loadFork(0);
MigrationContext memory ctxLTF = migrateSharesPartOne(
spellLTF,
spellLTF.ROOT_NEW(),
spellLTF.POOLMANAGER_NEW(),
spellLTF.RESTRICTIONMANAGER_NEW(),
spellLTF.ADMIN_MULTISIG(),
spellLTF.GUARDIAN_NEW()
);
TestableSpell spellDYF = new TestableSpell(new DYF_EVM());
MigrationContext memory ctxDYF = migrateSharesPartOne(
spellDYF,
spellDYF.ROOT_NEW(),
spellDYF.POOLMANAGER_NEW(),
spellDYF.RESTRICTIONMANAGER_NEW(),
spellDYF.ADMIN_MULTISIG(),
spellDYF.GUARDIAN_NEW()
);
TestableSpell spellNS3SR = new TestableSpell(new NS3SR_EVM());
MigrationContext memory ctxNS3SR = migrateSharesPartOne(
spellNS3SR,
spellNS3SR.ROOT_NEW(),
spellNS3SR.POOLMANAGER_NEW(),
spellNS3SR.RESTRICTIONMANAGER_NEW(),
spellNS3SR.ADMIN_MULTISIG(),
spellNS3SR.GUARDIAN_NEW()
);
TestableSpell spellNS3JR = new TestableSpell(new NS3JR_EVM());
MigrationContext memory ctxNS3JR = migrateSharesPartOne(
spellNS3JR,
spellNS3JR.ROOT_NEW(),
spellNS3JR.POOLMANAGER_NEW(),
spellNS3JR.RESTRICTIONMANAGER_NEW(),
spellNS3JR.ADMIN_MULTISIG(),
spellNS3JR.GUARDIAN_NEW()
);
migrateSharesPartTwo(
ctxLTF,
spellLTF.ROOT_NEW(),
spellLTF.POOLMANAGER_NEW(),
spellLTF.RESTRICTIONMANAGER_NEW()
);
migrateSharesPartTwo(
ctxDYF,
spellDYF.ROOT_NEW(),
spellDYF.POOLMANAGER_NEW(),
spellDYF.RESTRICTIONMANAGER_NEW()
);
migrateSharesPartTwo(
ctxNS3SR,
spellNS3SR.ROOT_NEW(),
spellNS3SR.POOLMANAGER_NEW(),
spellNS3SR.RESTRICTIONMANAGER_NEW()
);
migrateSharesPartTwo(
ctxNS3JR,
spellNS3JR.ROOT_NEW(),
spellNS3JR.POOLMANAGER_NEW(),
spellNS3JR.RESTRICTIONMANAGER_NEW()
);
}

function migrateSharesPartOne(
TestableSpell spell,
Expand Down Expand Up @@ -429,7 +429,7 @@ contract ForkTest is Deployer, Test {
uint256 maxMint = IInvestmentManager(ctx.vaultOld.manager()).maxMint(
ctx.spell.VAULT_OLD(), ctx.spell.memberlistMembers(i)
);
balancesOld[ctx.spell.memberlistMembers(i)] =
balancesOld[ctx.spell.memberlistMembers(i)][address(ctx.trancheTokenToMigrate)] =
ctx.trancheTokenToMigrate.balanceOf(ctx.spell.memberlistMembers(i)) + maxMint;
}
}
Expand All @@ -442,7 +442,7 @@ contract ForkTest is Deployer, Test {
ctx.totalSupplyNew += balanceNew;
assertApproxEqAbs(ctx.trancheTokenToMigrate.balanceOf(ctx.spell.memberlistMembers(i)), 0, 1);
if (ctx.spell.memberlistMembers(i) != ctx.vaultOld.escrow()) {
assertApproxEqAbs(balanceNew, balancesOld[ctx.spell.memberlistMembers(i)], 1);
assertApproxEqAbs(balanceNew, balancesOld[ctx.spell.memberlistMembers(i)][address(ctx.trancheTokenToMigrate)], 1);
}
}
assertApproxEqAbs(ctx.trancheTokenToMigrate.balanceOf(ctx.vaultOld.escrow()), 0, 1);
Expand Down

0 comments on commit 6d5636c

Please sign in to comment.