Skip to content

Commit

Permalink
Fix amount require
Browse files Browse the repository at this point in the history
  • Loading branch information
davidliudev committed Sep 25, 2023
1 parent 7ad70fa commit cf28692
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/v2/crossspace_content_v2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract CrossSpaceShareContentV2 is Ownable {

uint256 supply = sharesSupply[author][subject];
require(supply >= amount, "Cannot sell more than the shares supply");
require(supply > amount, "Cannot sell the last share");
uint256 price = getPrice(supply - amount, amount);
uint256 protocolFee = price * protocolFeePercent / PERCENT_BASE;
uint256 subjectFee = price * subjectFeePercent / PERCENT_BASE;
Expand Down
2 changes: 2 additions & 0 deletions contracts/v2/crossspace_user_v2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ contract CrossSpaceShareUserV2 is Ownable {
require(msg.sender == parentProtocolAddress, "Caller is not the parent protocol");

uint256 supplyInWei = sharesSupplyInWei[author];
require(supplyInWei > 0 || author == sender, "Only the shares' subject owner can buy the first share");
uint256 price = getPrice(supplyInWei, amountInWei);
uint256 protocolFee = price * protocolFeePercent / PERCENT_BASE;
uint256 subjectFee = price * subjectFeePercent / PERCENT_BASE;
Expand All @@ -108,6 +109,7 @@ contract CrossSpaceShareUserV2 is Ownable {

uint256 supplyInWei = sharesSupplyInWei[author];
require(supplyInWei >= amountInWei, "Cannot sell exceeding shares supply");
require(supplyInWei > amountInWei, "Cannot sell the last share");
uint256 price = getPrice(supplyInWei - amountInWei, amountInWei);
uint256 protocolFee = price * protocolFeePercent / PERCENT_BASE;
uint256 subjectFee = price * subjectFeePercent / PERCENT_BASE;
Expand Down

0 comments on commit cf28692

Please sign in to comment.