Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
theethernaut committed Sep 20, 2024
2 parents 058b636 + 5be1867 commit 4883402
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ERCS/erc-5173.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@ Any realized profits (P) when an NFT is sold are distributed among the buyers/ow

We define a sliding window mechanism to decide which previous owners will be involved in the profit distribution. Let's imagine the owners as a queue starting from the first hand owner to the current owner. The profit distribution window starts from the previous owner immediately to the current owner and extends towards the first owner, and the size of the windows is fixed. Only previous owners located inside the window will join the profit distribution.

![Future Rewards calculation formula](../assets/eip-5173/nFR_distribution_formula.png?raw=true)
![Future Rewards calculation formula](../assets/eip-5173/nFR_distribution_formula.jpg?raw=true)

In this equation:

- P is the total profit, the difference between the selling price minus the buying price;
- r is buyer reward ratio of the total P;
- g is the common ratio of successive in the geometric sequence;
- n is the actual number of owners eligible and participating in the future rewards sharing. To calculate n, we have n = min(m, w), where m is the current number of owners for a token, and w is the window size of the profit distribution sliding window algorithm
- _R_ is buyer reward ratio of the total P;
- _g_ is the common ratio of successive in the geometric sequence;
- _n_ is the actual number of owners eligible and participating in the future rewards sharing. To calculate _n_, we have _n_ = min(_m_, _w_), where _m_ is the current number of owners for a token, and _w_ is the window size of the profit distribution sliding window algorithm

#### Converting into Code

Expand All @@ -334,7 +334,7 @@ pragma solidity ^0.8.0;
//...
/* Assumes usage of a Fixed Point Arithmetic library (prb-math) for both int256 and uint256, and OpenZeppelin Math utils for Math.min. */
function _calculateFR(uint256 P, uint256 r, uint256 g, uint256 m, uint256 w) pure internal virtual returns(uint256[] memory) {
function _calculateFR(uint256 p, uint256 r, uint256 g, uint256 m, uint256 w) pure internal virtual returns(uint256[] memory) {
uint256 n = Math.min(m, w);
uint256[] memory FR = new uint256[](n);
Expand All @@ -344,11 +344,11 @@ function _calculateFR(uint256 P, uint256 r, uint256 g, uint256 m, uint256 w) pur
if (successiveRatio != 1e18) {
int256 v1 = 1e18 - int256(g).powu(n);
int256 v2 = int256(g).powu(i - 1);
int256 v3 = int256(P).mul(int256(r));
int256 v3 = int256(p).mul(int256(r));
int256 v4 = v3.mul(1e18 - int256(g));
pi = uint256(v4 * v2 / v1);
} else {
pi = P.mul(r).div(n);
pi = p.mul(r).div(n);
}
FR[i - 1] = pi;
Expand Down
Binary file added assets/erc-5173/nFR_distribution_formula.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/erc-5173/nFR_distribution_formula.png
Binary file not shown.

0 comments on commit 4883402

Please sign in to comment.