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/shares prepare improvement #52

Open
wants to merge 2 commits into
base: merge-train-r2
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,13 @@ contract LenderCommitmentGroup_Smart is

//mint shares equal to _amount and give them to the shares recipient !!!
poolSharesToken.mint(_sharesRecipient, sharesAmount_);



// prepare current balance
uint256 sharesBalance = poolSharesToken.balanceOf(address(this));
_prepareSharesForWithdraw(sharesBalance);

//reset prepared amount
poolSharesPreparedToWithdrawForLender[msg.sender] = 0;

emit LenderAddedPrincipal(

Expand Down Expand Up @@ -506,11 +509,16 @@ contract LenderCommitmentGroup_Smart is
function prepareSharesForWithdraw(
uint256 _amountPoolSharesTokens
) external returns (bool) {
return _prepareSharesForWithdraw(_amountPoolSharesTokens);
}

function _prepareSharesForWithdraw(
uint256 _amountPoolSharesTokens
) internal returns (bool) {
require( poolSharesToken.balanceOf(msg.sender) >= _amountPoolSharesTokens );

poolSharesPreparedToWithdrawForLender[msg.sender] = _amountPoolSharesTokens;
poolSharesPreparedTimestamp[msg.sender] = block.timestamp;

poolSharesPreparedTimestamp[msg.sender] = block.timestamp;

return true;
}
Expand All @@ -530,7 +538,7 @@ contract LenderCommitmentGroup_Smart is


poolSharesPreparedToWithdrawForLender[msg.sender] = 0;
poolSharesPreparedTimestamp[msg.sender] = 0;
poolSharesPreparedTimestamp[msg.sender] = block.timestamp;


//this should compute BEFORE shares burn
Expand Down
Loading