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

Mev Prevention: Allow protocol owner to set delay #50

Open
wants to merge 1 commit 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 @@ -117,7 +117,7 @@ contract LenderCommitmentGroup_Smart is

mapping(address => uint256) public poolSharesPreparedToWithdrawForLender;
mapping(address => uint256) public poolSharesPreparedTimestamp;
uint256 immutable public WITHDRAW_DELAY_TIME_SECONDS = 300;
uint256 immutable public DEFAULT_WITHDRAWL_DELAY_TIME_SECONDS = 300;


//mapping(address => uint256) public principalTokensCommittedByLender;
Expand All @@ -128,6 +128,7 @@ contract LenderCommitmentGroup_Smart is
int256 tokenDifferenceFromLiquidations;

bool public firstDepositMade;
uint256 public withdrawlDelayTimeSeconds;



Expand Down Expand Up @@ -204,6 +205,15 @@ contract LenderCommitmentGroup_Smart is
_;
}


modifier onlyProtocolOwner() {
require(
msg.sender == Ownable(address(TELLER_V2)).owner(),
"Can only be called by TellerV2"
);
_;
}

modifier bidIsActiveForGroup(uint256 _bidId) {
require(activeBids[_bidId] == true, "Bid is not active for group");

Expand All @@ -219,6 +229,7 @@ contract LenderCommitmentGroup_Smart is
TELLER_V2 = _tellerV2;
SMART_COMMITMENT_FORWARDER = _smartCommitmentForwarder;
UNISWAP_V3_FACTORY = _uniswapV3Factory;

}

/*
Expand Down Expand Up @@ -257,6 +268,8 @@ contract LenderCommitmentGroup_Smart is

marketId = _marketId;

withdrawlDelayTimeSeconds = DEFAULT_WITHDRAWL_DELAY_TIME_SECONDS;

//in order for this to succeed, first, that SmartCommitmentForwarder needs to be THE trusted forwarder for the market


Expand Down Expand Up @@ -299,6 +312,12 @@ contract LenderCommitmentGroup_Smart is
);
}


function setWithdrawlDelayTime(uint256 _seconds) onlyProtocolOwner {

withdrawlDelayTimeSeconds = _seconds;
}

function _deployPoolSharesToken()
internal
onlyInitializing
Expand Down Expand Up @@ -526,7 +545,7 @@ contract LenderCommitmentGroup_Smart is
) external returns (uint256) {

require(poolSharesPreparedToWithdrawForLender[msg.sender] >= _amountPoolSharesTokens,"Shares not prepared for withdraw");
require(poolSharesPreparedTimestamp[msg.sender] <= block.timestamp - WITHDRAW_DELAY_TIME_SECONDS,"Shares not prepared for withdraw");
require(poolSharesPreparedTimestamp[msg.sender] <= block.timestamp - withdrawlDelayTimeSeconds,"Shares not prepared for withdraw");


poolSharesPreparedToWithdrawForLender[msg.sender] = 0;
Expand Down
Loading