Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/migrate user token #16

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

sujine2
Copy link
Contributor

@sujine2 sujine2 commented Apr 15, 2022

User Can migrate staking token

  • When the staking pool is updated, the current pool is closed.
  • If user calls migrate function, the user receives reward and the entire amount of staked token is transferred to the new staking pool contract.
  • Only admin can set contract address to transfer the user's staking token.

@@ -48,6 +50,21 @@ const setStakingPool = async (
return stakingPool;
};

const migrateSetStakingPool = async (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setMigrageStaking would be the better choice for a unified name convention.

return migrateTestEnv;
}

// export const setMigrateTestEnv = async (): Promise<MigrateTestEnv> => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those codes depreciated?

@@ -36,3 +36,38 @@ export const getPoolData = async (testEnv: TestEnv) => {

return poolData;
};

export const newGetUserData = async (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new keyword is not clear. Can't this function be merged with above getPoolData and getUserData? What is the difference? I think they are same.


/// @dev Allow a user to migrate underlying tokens to next new contract
/// @notice This function is based on the openzeppelin ERC20Wrapper
function _migrateTo(address toContractAddr, uint256 amount) internal virtual returns (bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think _migrate is enough for the name of this function.

// Migrate next contract of user, total principal
nextContract.setPreviousPoolData(msg.sender, amount);

emit Migrate(msg.sender);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For making this event to be more practical, I'd recommend adding other parameters to the Migrate event

@@ -8,6 +8,7 @@ interface TestEnv {

interface MigrateTestEnv extends TestEnv {
newStakingPool: StakingPoolV3;
isNew: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this field for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants