Skip to content

Conversation

0xdewy
Copy link
Contributor

@0xdewy 0xdewy commented Dec 13, 2022

Context

closes #473

Changes proposed in this pull request

This PR changes the capital pool so when it is deployed, it copies over coverAssets, investmentAssets and swapDetails from the previous pool. It also also adds the option to add additional assets when deploying a new Pool.

Test plan

A test was added to unit/Pool/upgradeCapitalPool.js. I was going to create a new unit test file constructor.js and add more tests, but the tests are still using truffle/web3 and I was having issues testing the reverts in the constructor.

Checklist

  • Rebased the base branch
  • Attached corresponding Github issue
  • Prefixed the name with the type of change (i.e. feat, chore, test)
  • Performed a self-review of my own code
  • Followed the style guidelines of this project
  • Made corresponding changes to the documentation
  • Didn't generate new warnings
  • Didn't generate failures on existing tests
  • Added tests that prove my fix is effective or that my feature works

Review

When reviewing a PR, please indicate intention in comments using the following emojis:

  • 🍰 = Nice to have but not essential.
  • 💡 = Suggestion or a comment based on personal opinion
  • 🔨 = I believe this should be changed.
  • 🤔 = I don’t understand something, do you mind giving me more context?
  • 🚀 = Feedback

@danoctavian
Copy link
Contributor

At a feature spec level, this implementation makes things a little bit less flexible.

With the constructor variables we can rebuild the arrays everytime and add new things in on a need basis or deprecate etc.

Here we need to upgrade the pool and the run another governance update to add or deprecate an asset.

I'm not convinced it's ideal to have it, it does heavily reduce the probability of error so that's the big upside.

Putting this out there.

@0xdewy 0xdewy force-pushed the feature/upgrade-capital-pool-assets branch from 5bc1216 to 9bc6980 Compare December 17, 2022 00:21
assert.strictEqual(maxAmount.toString(), ether('32500').toString());
assert.strictEqual(maxSlippageRatio.toString(), '0');
// TODO: does this need to be exactly this timestamp?
assert.strictEqual(lastSwapTime.toString(), '1633425218');
Copy link
Contributor Author

@0xdewy 0xdewy Dec 19, 2022

Choose a reason for hiding this comment

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

The lastSwapTime is no longer manually set in the constructor, but instead goes through _addAsset(), which sets lastSwapTIme to 0. I didn't make any changes for this as I wanted to ask if this exact timestamp is still required?

@0xdewy 0xdewy requested a review from danoctavian December 19, 2022 20:43
return swapDetails[assetAddress];
}

function getAssetsAndSwapDetails() external view returns (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we exclude abandoned assets from being copied over? I could change this function so it only returns active assets.

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you mean by abandoned what do you check for that?

@0xdewy 0xdewy requested a review from shark0der December 19, 2022 20:58
@0xdewy 0xdewy changed the title Remove assets from constructor of new pool. Update test setup scripts Feature: Make upgradeCapitalPool copy over investmentAssets and coverAssets when pool is upgraded Dec 19, 2022
@0xdewy 0xdewy added the feature label Dec 19, 2022
@0xdewy 0xdewy marked this pull request as ready for review December 20, 2022 16:05
@roxdanila roxdanila force-pushed the feature/upgrade-capital-pool-assets branch from 98c88af to f165501 Compare January 3, 2023 12:24

// Transfer cover assets. Start from 1 (0 is ETH)
uint coverAssetsCount = coverAssets.length;
uint coverAssetsCount = coverAssets.length; // substract 1 as ETH is skiped
Copy link
Contributor

Choose a reason for hiding this comment

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

there's no substraction here the comment is not relevant imo, it's just ETH skipped at the start

@danoctavian
Copy link
Contributor

we can use some unit tests for the constructor itself for Pool.sol now since it's relatively complex.

Copy link
Contributor

@danoctavian danoctavian left a comment

Choose a reason for hiding this comment

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

Small changes, and a request for unit testing the constructor

@roxdanila roxdanila force-pushed the feature/upgrade-capital-pool-assets branch from c0fafb1 to 3c69709 Compare January 5, 2023 10:17
@shark0der shark0der force-pushed the feature/upgrade-capital-pool-assets branch from 3c69709 to a88063f Compare January 5, 2023 13:39
@shark0der shark0der force-pushed the feature/upgrade-capital-pool-assets branch from a88063f to 0c30bde Compare January 5, 2023 14:21
@shark0der
Copy link
Contributor

As per discussion, the current implementation will fail to upgrade because the previousPool.getAssetsAndSwapDetails() call will fail. Will close this task and we'll get back to it post V2 launch.

@shark0der shark0der closed this Jan 5, 2023
@roxdanila roxdanila deleted the feature/upgrade-capital-pool-assets branch May 16, 2023 14:03
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.

Tokenomics: Change the Pool.upgradeCapitalPool to copy over investmentAssets and coverAssets when pool is upgraded
4 participants