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

Onsen Allocator update #278

Open
wants to merge 8 commits into
base: allocators
Choose a base branch
from
Open

Onsen Allocator update #278

wants to merge 8 commits into from

Conversation

calusaca
Copy link

Added Onsen allocator based on the latest allocators branch.

@calusaca calusaca requested review from ind-igo, a user and Paul4912 March 28, 2022 16:47
/// Call the poolLength function from sushi masterchef v2 and compare against the LP token passed as parameter
uint256 poolsLength = IMasterChef(masterChef).poolLength();

for (uint256 i; i < poolsLength; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Poollength of masterchef is 355 i think unless im looking at wrong contract. i think this can be done offchain. We can figure out the id mappings offchain using view functions on masterchef and insert them in with a setter function. This would work but im worried it will use alot more gas than we need to.

Copy link
Author

Choose a reason for hiding this comment

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

Added the following 2 functions:

function setLPTokenOnsenPoolId(address lpToken, uint256 onsenPoolId) external onlyGuardian
function getLPTokenOnsenPoolId(address lpToken) external view returns (bool, uint256)

So we can add the Onsen Pool Id for the LP Tokens ahead of time and also check if the LP token was already added, worst-case scenario would be that the token is not added and it will go search for it based on the Onsen Pool Length.

@Paul4912 Please let me know if this is fine or if we need to be able to add all Onsen Pool Ids at once?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea that's how id imagine we'd do it.

Idk how many onsen farms there are to need a batch add.

Copy link
Author

Choose a reason for hiding this comment

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

@PARABRAHMAN0 @ind-igo Do you have any idea about how many Onsen Pools are used? Or do you know where I can check this?
We would like to know if a batch function to add Onsen pools is needed or not?

contracts/allocators/OnsenAllocatorV2.sol Show resolved Hide resolved
contracts/allocators/OnsenAllocatorV2.sol Outdated Show resolved Hide resolved
address _sushi,
address _xSushi,
address _treasury,
AllocatorInitData memory data
Copy link

Choose a reason for hiding this comment

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

What if we want to add more tokens? Add a setter for more LP tokens, should be easy.

Copy link
Author

Choose a reason for hiding this comment

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

@PARABRAHMAN0 Sorry but not sure about what this means, or maybe is already added based on a previous comment with the following 2 functions?
function setLPTokenOnsenPoolId(address lpToken, uint256 onsenPoolId) external onlyGuardian
function getLPTokenOnsenPoolId(address lpToken) external view returns (bool, uint256)

@Paul4912
Copy link
Contributor

r u planning on adding tests in this pr or seperate pr

@calusaca
Copy link
Author

r u planning on adding tests in this pr or seperate pr

Yes, I am working on testing and I will create a new PR for it

@ghost
Copy link

ghost commented Mar 31, 2022

r u planning on adding tests in this pr or seperate pr

Yes, I am working on testing and I will create a new PR for it

Can you just do this in this PR? I mean when you push to your branch it will automatically add it to the PR.

Then you can also re-request a review.

@calusaca
Copy link
Author

calusaca commented Apr 1, 2022

Sure, I thought I needed to add it as new PR, but sure I will push the testing to the branch and re-request review

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.

3 participants