Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ contract LenderCommitmentGroup_Pool_V2 is



uint256 immutable public DEFAULT_WITHDRAW_DELAY_TIME_SECONDS = 300;
uint256 immutable public MAX_WITHDRAW_DELAY_TIME = 86400;
// uint256 immutable public DEFAULT_WITHDRAW_DELAY_TIME_SECONDS = 300;
// uint256 immutable public MAX_WITHDRAW_DELAY_TIME = 86400;

mapping(uint256 => bool) public activeBids;
mapping(uint256 => uint256) public activeBidsAmountDueRemaining;

int256 tokenDifferenceFromLiquidations;

bool private firstDepositMade_deprecated; // no longer used
uint256 public withdrawDelayTimeSeconds;
uint256 public withdrawDelayTimeSeconds; // immutable for now - use withdrawDelayBypassForAccount

IUniswapPricingLibrary.PoolRouteConfig[] public poolOracleRoutes;

Expand All @@ -162,7 +162,8 @@ contract LenderCommitmentGroup_Pool_V2 is
bool public paused;
bool public borrowingPaused;
bool public liquidationAuctionPaused;


mapping(address => bool) public withdrawDelayBypassForAccount;

event PoolInitialized(
address indexed principalTokenAddress,
Expand Down Expand Up @@ -302,7 +303,7 @@ contract LenderCommitmentGroup_Pool_V2 is

marketId = _commitmentGroupConfig.marketId;

withdrawDelayTimeSeconds = DEFAULT_WITHDRAW_DELAY_TIME_SECONDS;
withdrawDelayTimeSeconds = 300;

//in order for this to succeed, first, the SmartCommitmentForwarder needs to be a trusted forwarder for the market
ITellerV2Context(TELLER_V2).approveMarketForwarder(
Expand Down Expand Up @@ -1136,17 +1137,19 @@ contract LenderCommitmentGroup_Pool_V2 is


/**
* @notice Sets the delay time for withdrawing shares. Only Protocol Owner.
* @param _seconds Delay time in seconds.
* @notice Allows accounts such as Yearn Vaults to bypass withdraw delay.
* @dev This should ONLY be enabled for smart contracts that separately implement MEV/spam protection.
* @param _addr The account that will have the bypass.
* @param _bypass Whether or not bypass is enabled
*/
function setWithdrawDelayTime(uint256 _seconds)
function setWithdrawDelayBypassForAccount(address _addr, bool _bypass )
external
onlyProtocolOwner {
require( _seconds < MAX_WITHDRAW_DELAY_TIME , "WD");

withdrawDelayTimeSeconds = _seconds;

withdrawDelayBypassForAccount[_addr] = _bypass;

}



// ------------------------ Pausing functions ------------
Expand Down Expand Up @@ -1391,7 +1394,12 @@ contract LenderCommitmentGroup_Pool_V2 is

// Check withdrawal delay
uint256 sharesLastTransferredAt = getSharesLastTransferredAt(owner);
require(block.timestamp >= sharesLastTransferredAt + withdrawDelayTimeSeconds, "SW");


require(
withdrawDelayBypassForAccount[msg.sender] ||
block.timestamp >= sharesLastTransferredAt + withdrawDelayTimeSeconds, "SW"
);

require(msg.sender == owner, "UA");

Expand Down Expand Up @@ -1436,7 +1444,10 @@ contract LenderCommitmentGroup_Pool_V2 is

// Check withdrawal delay
uint256 sharesLastTransferredAt = getSharesLastTransferredAt(owner);
require(block.timestamp >= sharesLastTransferredAt + withdrawDelayTimeSeconds, "SR");
require(
withdrawDelayBypassForAccount[msg.sender] ||
block.timestamp >= sharesLastTransferredAt + withdrawDelayTimeSeconds, "SR"
);

// Burn shares from owner
burnShares(owner, shares);
Expand Down Expand Up @@ -1557,7 +1568,7 @@ contract LenderCommitmentGroup_Pool_V2 is
uint256 availableShares = balanceOf(owner);
uint256 sharesLastTransferredAt = getSharesLastTransferredAt(owner);

if (block.timestamp <= sharesLastTransferredAt + withdrawDelayTimeSeconds) {
if ( !withdrawDelayBypassForAccount[msg.sender] && block.timestamp <= sharesLastTransferredAt + withdrawDelayTimeSeconds) {
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { DeployFunction } from 'hardhat-deploy/dist/types'

import { get_ecosystem_contract_address } from "../../helpers/ecosystem-contracts-lookup"


const deployFn: DeployFunction = async (hre) => {
hre.log('----------')
hre.log('')
hre.log('Lender pools V2: Proposing upgrade...')



const lenderCommitmentGroupV2BeaconProxy = await hre.contracts.get('LenderCommitmentGroupBeaconV2')

const tellerV2 = await hre.contracts.get('TellerV2')
const SmartCommitmentForwarder = await hre.contracts.get(
'SmartCommitmentForwarder'
)
const tellerV2Address = await tellerV2.getAddress()


const smartCommitmentForwarderAddress =
await SmartCommitmentForwarder.getAddress()


let uniswapV3FactoryAddress: string = get_ecosystem_contract_address( hre.network.name, "uniswapV3Factory" ) ;


const uniswapPricingHelper = await hre.contracts.get('UniswapPricingHelper')
const uniswapPricingHelperAddress = await uniswapPricingHelper.getAddress()




//this is why the owner of the beacon should be timelock controller !
// so we can upgrade it like this . Using a proposal. This actually goes AROUND the proxy admin, interestingly.
await hre.upgrades.proposeBatchTimelock({
title: 'Lender Pools V2: Upgrade Rollover Fns',
description: `
# Lender Pools V2

* A patch to use withdraw allowlist.
`,
_steps: [
{
beacon: lenderCommitmentGroupV2BeaconProxy,
implFactory: await hre.ethers.getContractFactory('LenderCommitmentGroup_Pool_V2', {

}),

opts: {
unsafeSkipStorageCheck: true,
unsafeAllow: [
'constructor',
'state-variable-immutable',
'external-library-linking',
],
constructorArgs: [
tellerV2Address,
smartCommitmentForwarderAddress,
uniswapV3FactoryAddress,
uniswapPricingHelperAddress
],
},
},
],
})

hre.log('done.')
hre.log('')
hre.log('----------')

return true
}

// tags and deployment
deployFn.id = 'lender-commitment-group-beacon-v2:withdraw-allowlist'
deployFn.tags = ['lender-commitment-group-beacon-v2']
deployFn.dependencies = [
'teller-v2:deploy',
'smart-commitment-forwarder:deploy',
'teller-v2:uniswap-pricing-library-v2',

'lender-commitment-group-beacon-v2:deploy',
'uniswap-pricing-helper:deploy'
]

deployFn.skip = async (hre) => {
return !hre.network.live || !['sepolia','polygon','base','mainnet','arbitrum','katana','optimism'].includes(hre.network.name)
}
export default deployFn
3 changes: 2 additions & 1 deletion packages/contracts/deployments/polygon/.migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
"smart-commitment-forwarder:upgrade-oracle": 1753816748,
"lender-commitment-group-beacon-v2:upgrade-first-deposit": 1754323999,
"lender-commitment-group-beacon-v2:pricing-helper": 1755271511,
"lender-commitment-forwarder:extensions:flash-swap-rollover:g2-upgrade": 1755275678
"lender-commitment-forwarder:extensions:flash-swap-rollover:g2-upgrade": 1755275678,
"lender-commitment-group-beacon-v2:withdraw-allowlist": 1755275678,
}
Loading