Verified contractExactMIT
CooldownSlot
Address0x2e4bed1d90ab76274ebb68a38ab805196c4f9b9e
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- No
- EVM version
- paris
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,477,058
- Creation transaction
- 0x3adb98d64d…cc95db48f6
contracts/CooldownSlots.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
}
interface IStakedPendle is IERC20 {
function cooldown(uint256 amount) external;
function cancelCooldown() external;
function finalizeCooldown() external returns (uint256);
}
/**
* sPENDLE allows one open cooldown per address. A slot is one more address that can hold a cooldown
* for the same owner, so several cooldowns can run side by side without a second wallet or key.
*
* This is the logic every slot runs through its SlotProxy. It keeps no storage, and everything a
* slot holds can leave to exactly one place: OWNER. No function takes a recipient.
*/
contract CooldownSlot {
address public immutable OWNER;
IERC20 public immutable PENDLE;
IStakedPendle public immutable SPENDLE;
modifier onlyOwner() {
require(msg.sender == OWNER, "CooldownSlot: not owner");
_;
}
constructor(address owner, IERC20 pendle, IStakedPendle spendle) {
OWNER = owner;
PENDLE = pendle;
SPENDLE = spendle;
}
/// Starts a cooldown of all sPENDLE this slot holds. The owner transfers it in first, in the same batch.
function start() external onlyOwner {
SPENDLE.cooldown(SPENDLE.balanceOf(address(this)));
}
/// Claims the matured cooldown and sends all PENDLE here to the owner. Anyone may call it.
function finalize() external {
SPENDLE.finalizeCooldown();
_send(PENDLE);
}
/// Abandons the open cooldown and returns the sPENDLE to the owner.
function cancel() external onlyOwner {
SPENDLE.cancelCooldown();
_send(SPENDLE);
}
/// Returns this slot's whole balance of a token to the owner.
function sweep(IERC20 token) external onlyOwner {
_send(token);
}
function _send(IERC20 token) private {
require(token.transfer(OWNER, token.balanceOf(address(this))), "CooldownSlot: transfer failed");
}
}
/// A slot's address. Forwards every call to the logic its deployer, the registry, currently names.
contract SlotProxy {
CooldownSlots private immutable REGISTRY;
constructor() {
REGISTRY = CooldownSlots(msg.sender);
}
fallback() external {
address target = REGISTRY.implementation();
assembly {
calldatacopy(0, 0, calldatasize())
let ok := delegatecall(gas(), target, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if iszero(ok) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/**
* Creates the slot logic, deploys slots at predictable addresses and lets OWNER, and only OWNER,
* replace the logic of every slot at once. The owner can never change.
*/
contract CooldownSlots {
address public immutable OWNER;
address public implementation;
event Upgraded(address indexed implementation);
constructor(address owner, IERC20 pendle, IStakedPendle spendle) {
OWNER = owner;
implementation = address(new CooldownSlot(owner, pendle, spendle));
}
function upgradeTo(address newImplementation) external {
require(msg.sender == OWNER, "CooldownSlots: not owner");
require(newImplementation.code.length > 0, "CooldownSlots: not a contract");
implementation = newImplementation;
emit Upgraded(newImplementation);
}
/// The address of slot `index`, whether or not it exists yet.
function slot(uint256 index) public view returns (address) {
bytes32 digest = keccak256(
abi.encodePacked(bytes1(0xff), address(this), bytes32(index), keccak256(type(SlotProxy).creationCode))
);
return address(uint160(uint256(digest)));
}
/// Makes sure slot `index` exists. Anyone may call it, any number of times.
function deploy(uint256 index) external {
if (slot(index).code.length == 0) new SlotProxy{salt: bytes32(index)}();
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.