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/cover v2 #128

Merged
merged 104 commits into from
Oct 4, 2021
Merged

Feature/cover v2 #128

merged 104 commits into from
Oct 4, 2021

Conversation

danoctavian
Copy link
Contributor

No description provided.

}

struct Product {
uint16 productType;
address productAddress;
uint16 capacityFactor;
uint24 productId;
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need a productId here. The id is the index itself. Also bring back productAddress since there is plenty of space in this slot and there's no need to make another read from a different slot when redeeming incident payouts.

uint maxPrice,
StakingPool[] calldata stakingPools
uint maxPremiumInAsset,
CoverChunkRequest[] calldata coverChunkRequests
Copy link
Contributor

Choose a reason for hiding this comment

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

The Cover prefix is a bit redundant given that we're in the context of cover anyway. Is using a struct for calldata helpful? I'd rather see it as two arrays (pool ids and amounts) since it's only used once here.


Cover[] public override covers;
mapping(uint => StakingPool[]) stakingPoolsForCover;
CoverData[] public override covers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just Cover?

));
}

function addProduct(
uint16 productType,
address productAddress,
uint24 productId,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed here, but the productAddress is.


/* === MUTATIVE FUNCTIONS ==== */

function buyCover(
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

{
IPool pool = pool();
// convert to NXM amount
tokenPrice = pool.getTokenPrice(payoutAsset);
Copy link
Contributor

Choose a reason for hiding this comment

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

pool.getTokenPrice -> pool().getTokenPrice
This means you can remove the lone above.


contract CoverNFT is ERC721 {

ICover cover;
Copy link
Contributor

Choose a reason for hiding this comment

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

cover is a state variable and no visibility is specified. There's no way to modify it so there's no point in having it in storage - let's make it immutable (cover is a proxy anyway) and let's make it public.

Comment on lines 14 to 16
uint public capacityFactor;
uint public coverCount;

Copy link
Contributor

Choose a reason for hiding this comment

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

Make capacityFactor and coverCount uint32 and move them near coverNFT address so they can use the same slot (32+32+160 = 224).

uint24 productId;
uint8 payoutAsset;
uint96 amount;
uint32 start;
uint32 period; // seconds
uint96 price;
uint96 premium;
}

struct Product {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's pack initialPrice and activeCoverAmountInNXM in here as well.

@horodnicdragos horodnicdragos merged commit 4a65e2e into nexus-v2 Oct 4, 2021
@roxdanila roxdanila deleted the feature/cover-v2 branch July 26, 2022 13:52
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