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/pool v2 #832

Merged
merged 11 commits into from
Nov 17, 2023
Merged

Feature/pool v2 #832

merged 11 commits into from
Nov 17, 2023

Conversation

rndquu
Copy link
Member

@rndquu rndquu commented Nov 14, 2023

We have the old UbiquityPool contract which is a stripped down version of FraxPool (v1).

The old UbiquityPool has some drawbacks:

  • some state variables are unused (one, two)
  • some slippage protection checks are missed (like this one)
  • it incorrectly calculates the collateral USD price (related issue)
  • it doesn't allow AMO minter contracts to borrow collateral from the pool to make yield in 3rd party protocols (like Compound, Curve, etc...)
  • it uses the old Frax pool version 1 while there is version 3 available (FraxPoolV3)

This PR introduces a new UbiquityPool contract which is an (almost) exact copy of FraxPoolV3 where most of the above issues are solved.

With the new UbiquityPool contract users are able to mint/redeem Dollar tokens for collateral tokens (we start with the LUSD token).

The only catch is the collateral price in USD. The original FraxPoolV3 by default uses only USD-pegged stablecoins as collateral. Hence the collateral price is set to $1.00 on adding a new collateral token. While the FraxPoolV3 contract has the method for setting the collateral price in USD the original contract has never called this method because underlying USD-collateral tokens have never depegged + Frax protocol simply paused the pool when they got enough of collateral liquidity.

While it seems to be ok to use hardcoded $1.00 price for collateral tokens it is better to rely on oracles (can't say why Frax didn't implement them for getting collateral token prices) hence this issue was created. I think we can deploy with hardcoded $1.00 collateral prices (unless somebody has reasons of why it might be bad) and when #830 is ready update the UbiquityPool to use oracles for collateral prices.

P.S. The "check storage layout" workflow fails because the new pool modifies the order of state variables (compared to the old pool) but since the Diamond has never been deployed we can neglect this failing CI run.

@gitcoindev
Copy link
Contributor

Hi @rndquu I see still tests failing in the set up stage, please ping once the pull request will be ready for review.

@rndquu
Copy link
Member Author

rndquu commented Nov 15, 2023

Hi @rndquu I see still tests failing in the set up stage, please ping once the pull request will be ready for review.

The PR is draft so it is not ready yet

Copy link

ubiquibot bot commented Nov 15, 2023

@rndquu rndquu marked this pull request as ready for review November 15, 2023 11:00
@rndquu
Copy link
Member Author

rndquu commented Nov 15, 2023

@gitcoindev I can't request a review from you because you're not a member of the ubiquity organization. Anyway pls take a look at the current PR.

@pavlovcik Should we add @gitcoindev to the Software Development team?

@0x4007
Copy link
Member

0x4007 commented Nov 15, 2023

Yes

@molecula451
Copy link
Member

@rndquu can we have some testing to this, or is it planned on a future PR?

@rndquu
Copy link
Member Author

rndquu commented Nov 15, 2023

Copy link
Member

@molecula451 molecula451 left a comment

Choose a reason for hiding this comment

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

The "check storage layout" is safe since this is a new storage induction, looks good to me, we need testing on the subsequently issue about the either the dollar peg or new oracle manipulation, probably the decision was internal business, we could or we could not the same according to our purpose

@molecula451
Copy link
Member

@gitcoindev let us hear your thoughts on this one

Copy link
Contributor

@gitcoindev gitcoindev left a comment

Choose a reason for hiding this comment

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

I tried to carefully go through the changes as it is not a small pr. I have a few questions/remarks, but overall good job! I also verified the LUSD token address is correct. I went through https://docs.frax.finance/ to check internals. With the tests passing and "check storage layout" workflow failing I would approve since the Diamond deployment was not done yet.

@0x4007
Copy link
Member

0x4007 commented Nov 16, 2023

I really think it's prudent to use an oracle instead of assuming $1.00. LUSD historically has been between ~0.99-1.05. ~6% is a pretty significant potential deficit.

It comes down to how long that would take to implement (I would imagine not longer than a couple weeks)

@rndquu
Copy link
Member Author

rndquu commented Nov 17, 2023

I really think it's prudent to use an oracle instead of assuming $1.00. LUSD historically has been between ~0.99-1.05. ~6% is a pretty significant potential deficit.

It comes down to how long that would take to implement (I would imagine not longer than a couple weeks)

Ok, #830 (where collateral oracle should be implemented) will be part of the production deploy

Copy link
Contributor

@gitcoindev gitcoindev left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the review comments. I did another review round and approving from my side.

@rndquu rndquu mentioned this pull request Nov 17, 2023
4 tasks
@molecula451
Copy link
Member

@rndquu we are having styling issues, we should decide whether to allow

function setRndnuu() private {
    // code
}

or

function setRndnuu() private
{

}

this can be seen here as well as many other parts of the code

@molecula451 molecula451 merged commit 10739ec into ubiquity:development Nov 17, 2023
31 of 36 checks passed
@rndquu rndquu deleted the feature/pool-v2 branch November 17, 2023 14:39
@rndquu
Copy link
Member Author

rndquu commented Nov 17, 2023

@rndquu we are having styling issues, we should decide whether to allow

function setRndnuu() private {
    // code
}

or

function setRndnuu() private
{

}

this can be seen here as well as many other parts of the code

I guess the linter decides how to format code

@0x4007
Copy link
Member

0x4007 commented Nov 20, 2023

@rndquu we are having styling issues, we should decide whether to allow

function setRndnuu() private {
    // code
}

or

function setRndnuu() private
{

}

this can be seen here as well as many other parts of the code

I guess the linter decides how to format code

I looked into this and we would have to make a custom tool to enforce this with lint-staged I believe.

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.

4 participants