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 Referral #76

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions contracts/StMATIC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ contract StMATIC is
AccessControlUpgradeable,
PausableUpgradeable
{
event SubmitEvent(address indexed _from, uint256 indexed _amount);
event RequestWithdrawEvent(address indexed _from, uint256 indexed _amount);
event SubmitEvent(address indexed _from, uint256 indexed _amount, address indexed _referral);
event RequestWithdrawEvent(address indexed _from, uint256 indexed _amount, address indexed _partner);
event DistributeRewardsEvent(uint256 indexed _amount);
event WithdrawTotalDelegatedEvent(
address indexed _from,
Expand Down Expand Up @@ -114,9 +114,10 @@ contract StMATIC is
* @dev Send funds to StMATIC contract and mints StMATIC to msg.sender
* @notice Requires that msg.sender has approved _amount of MATIC to this contract
* @param _amount - Amount of MATIC sent from msg.sender to this contract
* @param _referral - Referral address.
* @return Amount of StMATIC shares generated
*/
function submit(uint256 _amount)
function submit(uint256 _amount, address _referral)
external
override
whenNotPaused
Expand Down Expand Up @@ -151,16 +152,17 @@ contract StMATIC is
abi.encode(totalShares + amountToMint, totalPooledMatic + _amount)
);

emit SubmitEvent(msg.sender, _amount);
emit SubmitEvent(msg.sender, _amount, _referral);

return amountToMint;
}

/**
* @dev Stores users request to withdraw into a RequestWithdraw struct
* @param _amount - Amount of StMATIC that is requested to withdraw
* @param _referral - referral address.
*/
function requestWithdraw(uint256 _amount) external override whenNotPaused {
function requestWithdraw(uint256 _amount, address _referral) external override whenNotPaused {
require(_amount > 0, "Invalid amount");

Operator.OperatorInfo[] memory operatorInfos = nodeOperatorRegistry
Expand Down Expand Up @@ -265,7 +267,7 @@ contract StMATIC is
)
);

emit RequestWithdrawEvent(msg.sender, _amount);
emit RequestWithdrawEvent(msg.sender, _amount, _referral);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IStMATIC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ interface IStMATIC is IERC20Upgradeable {
uint256 _submitThreshold
) external;

function submit(uint256 _amount) external returns (uint256);
function submit(uint256 _amount, address _referral) external returns (uint256);

function requestWithdraw(uint256 _amount) external;
function requestWithdraw(uint256 _amount, address _referral) external;

function delegate() external;

Expand Down
Loading