Locker
User-facing entry point. Atomic lock-and-issue: pulls DIEM, stakes it, mints DD, mints PT20 or PT721, all in one transaction.
contracts/src/platforms/venice/Locker.sol
Inherits
Ownable2Step, ReentrancyGuard, Pausable
Immutables
| Name | Type | Source |
|---|---|---|
diem | IDIEM | Read from vault.diem() in constructor |
vault | VeniceStakingVault | constructor arg |
kDiem | kDIEM | constructor arg |
pt721 | PT721 | constructor arg |
pt20Factory | PT20Factory | constructor arg |
Mutable state
| Name | Type | Mutability |
|---|---|---|
ddMinter | DDMinter | 7-day timelocked rotation |
pendingDdMinter | DDMinter | rotation buffer |
ddMinterEffectiveAt | uint64 | rotation effective-at |
User functions
solidity
function lock(uint256 amount, uint64 maturity, address recipient)
external nonReentrant whenNotPaused
returns (address pt, uint256 ptShares, uint256 ddMinted);
function lockPT721(uint256 amount, uint64 maturity, address recipient)
external nonReentrant whenNotPaused
returns (uint256 tokenId, uint256 ddMinted);Common requirements
amount > 0recipient != address(0)maturity > block.timestamp- DD constraints enforced by
DDMinter:amount ≥ minLockAmount,maturity ≤ now + maxLockHorizon.
lock extra
DateUtils.isFirstOfMonth(maturity)enforced.- Result
ptis thePT20Factory.getOrCreate(maturity)address.
lockPT721 extra
maturitycan be any future timestamp.
Admin functions
solidity
function proposeDdMinter(address ddMinter_) external onlyOwner;
function activateDdMinter() external; // permissionless after 7d
function cancelDdMinterChange() external onlyOwner;
function pause() external onlyOwner;
function unpause() external onlyOwner;proposeDdMinter cross-checks DDMinter(_).locker() == address(this) || == address(0).
Events
solidity
event PT20Locked(address indexed payer, address indexed recipient, uint64 indexed maturity,
uint256 amount, address pt, uint256 ptShares, uint256 ddMinted);
event PT721Locked(address indexed payer, address indexed recipient, uint64 indexed maturity,
uint256 amount, uint256 tokenId, uint256 ddMinted);
event DdMinterProposed(address indexed ddMinter, uint64 effectiveAt);
event DdMinterActivated(address indexed ddMinter);
event DdMinterChangeCancelled();Errors
ZeroAddress, ZeroAmount, MaturityInPast, MaturityNotFirstOfMonth,
NoPending, TooEarly, WiringMismatchAtomicity guarantees
A lock call either completes all of {DIEM transfer, vault stake, kDIEM mint, DD mint, PT20/PT721 deposit} or reverts the whole transaction. There is no partial state where, e.g., DIEM is staked but PT20 is not minted.
Gas
lock first time for a maturity (deploys PT20): ~750k gas. lock reuse of existing PT20: ~250k gas. lockPT721: ~250k gas.