UNPKG

@dydxfoundation/governance

Version:
30 lines (29 loc) 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.simulateAffectedStakers = void 0; const deploy_config_1 = require("../../src/deploy-config"); const affected_stakers_1 = require("../../src/lib/affected-stakers"); const constants_1 = require("../../src/lib/constants"); const util_1 = require("../../src/lib/util"); const impersonate_account_1 = require("../../src/migrations/helpers/impersonate-account"); const types_1 = require("../../types"); const get_affected_stakers_for_test_1 = require("../helpers/get-affected-stakers-for-test"); async function simulateAffectedStakers({ dydxTokenAddress, safetyModuleAddress, }) { const deployConfig = (0, deploy_config_1.getDeployConfig)(); const dydxToken = new types_1.DydxToken__factory().attach(dydxTokenAddress); const safetyModule = new types_1.SafetyModuleV2__factory().attach(safetyModuleAddress); const dydxFoundation = await (0, impersonate_account_1.impersonateAndFundAccount)(deployConfig.TOKEN_ALLOCATIONS.DYDX_FOUNDATION.ADDRESS); const testStakers = (0, get_affected_stakers_for_test_1.getAffectedStakersForTest)(); for (const stakerAddress of testStakers) { const stakedAmount = (0, affected_stakers_1.getStakedAmount)(stakerAddress); await (0, util_1.waitForTx)(await dydxToken.connect(dydxFoundation).transfer(stakerAddress, stakedAmount)); const staker = await (0, impersonate_account_1.impersonateAndFundAccount)(stakerAddress); await (0, util_1.waitForTx)(await dydxToken.connect(staker).approve(safetyModuleAddress, constants_1.MAX_UINT_AMOUNT)); await (0, util_1.waitForTx)(await safetyModule.connect(staker).stake(stakedAmount)); // TODO: Debugging on hardhat for events.spec.ts. // Seems like this is possibly a bug in the hardhat node itself? // const myval = (await safetyModule.connect(staker).queryFilter(safetyModule.filters.Staked('0xb97d9350F32C1366016e2C0a55E4A210D1158b22'))).length > 0; // console.log('Staked from', staker.address, myval); } } exports.simulateAffectedStakers = simulateAffectedStakers;