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

WIP Royalty #72

Closed
wants to merge 1 commit into from
Closed

Conversation

sebsadface
Copy link
Member

Description

Example:
This pr adds user login function, includes:

    1. add user login page.
    1. ...

Test Plan

Example:

    1. Use different test accounts for login tests, including correct user names and passwords, and incorrect user names and passwords.
    1. ...

Related Issue

Example: Issue #123

Notes

  • Example: Links and navigation need to be added to the front-end interface

@@ -0,0 +1,70 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
Copy link

@Spablob Spablob Sep 20, 2024

Choose a reason for hiding this comment

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

Would suggest not using "^" in pragma for security reasons. This applies to all contracts in SPG repo.

You may also bump the version to the same version as protocol core

Copy link
Member Author

Choose a reason for hiding this comment

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

Will create a ticket for updating all contracts to use 0.8.26 :)

/// @param nftContractBeacon The address of the NFT contract beacon.
/// @custom:storage-location erc7201:story-protocol-periphery.RoyaltyWorkflows
struct RoyaltyWorkflowsStorage {
address nftContractBeacon;
Copy link

Choose a reason for hiding this comment

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

what is the nftContractBeacon variable used for?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch! We don’t actually need it in this contract. Will remove it :)

) external returns (uint256 snapshotId, uint256[] memory amountsClaimed) {
// Claims revenue for each specified currency token from the latest snapshot
IIpRoyaltyVault ancestorIpRoyaltyVault;
(snapshotId, amountsClaimed, ancestorIpRoyaltyVault) = _transferToVaultAndSnapshotAndClaimByTokenBatch(
Copy link

@Spablob Spablob Sep 20, 2024

Choose a reason for hiding this comment

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

_transferToVaultAndSnapshotAndClaimByTokenBatch - is this function claiming by token batch inside an larger function which is by snapshot batch?

Perhaps for simplicity - given these internal functions are a bit too big - can we make the sequence of elementary functions transferToVault, snapshot, claimByTokenBatch / claimBySnapshotBatch without any internal functions first? Just to make sure we don't miss anything and it's easier to follow.

Then at the end we can think of making internal functions to reduce code duplication.

Copy link

@Spablob Spablob Sep 20, 2024

Choose a reason for hiding this comment

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

For example the function transferToVaultAndSnapshotAndClaimBySnapshotBatch could be:

transferToVault()
snapshot()
claimBySnapshotBatch()

using more elementary building blocks sequence. then at the end we think about internal functions.

Same thinking applies for the remaining functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

_transferToVaultAndSnapshotAndClaimByTokenBatch - is this function claiming by token batch inside an larger function which is by snapshot batch?

Good question! All the SPG functions let you claim multiple tokens at the same time. For the ones using claimBySnapshotBatch, we first take the latest snapshot and claim all tokens, then handle any additional unclaimed snapshots user provide. We set it up this way so that if user don't need to bundle the calls, they can use the core protocol to claim your snapshots directly.

One improvement we could add is making snapshotting optional in transferToVaultAndSnapshotAndClaimBySnapshotBatch and snapshotAndClaimBySnapshotBatch. That way, if taking the latest snapshot fails, users can still claim their unclaimed snapshots.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps for simplicity - given these internal functions are a bit too big - can we make the sequence of elementary functions transferToVault, snapshot, claimByTokenBatch / claimBySnapshotBatch without any internal functions first? Just to make sure we don't miss anything and it's easier to follow.

Agreed, that would make the code a lot more readable

amountsClaimed[i] += ancestorIpRoyaltyVault.claimRevenueOnBehalfBySnapshotBatch({
snapshotIds: unclaimedSnapshotIds,
token: royaltyClaimDetails[i].currencyToken,
claimer: address(ancestorIpRoyaltyVault)
Copy link

@Spablob Spablob Sep 20, 2024

Choose a reason for hiding this comment

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

When doing the final call that will take the money from a vault to a royalty token holder the claimer can be any address in the world that holds royalty tokens. So claimer that we added in last protocol PR on the functions claimRevenueOnBehalfBySnapshotBatch and claimRevenueOnBehalfByTokenBatch are input from the app/outside and should be passed in to the SPG functions as the SPG has no way to know what this address is

Applies whenever these two functions above are called throughout SPG the RoyaltyWorkflows.sol

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, will add an extra claimer param to these functions 🫡

@sebsadface sebsadface closed this Sep 20, 2024
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