Skip to content

Commit

Permalink
[Adapter] feat: add Adapter::unlockTime and Adapter::currentTime func…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
kyriediculous committed Nov 30, 2023
1 parent 9c29cb6 commit 5bcf0b0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/adapters/Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ interface Adapter is IERC165 {

function unlockMaturity(uint256 unlockID) external view returns (uint256);

function unlockTime() external view returns (uint256);

function currentTime() external view returns (uint256);

function stake(address validator, uint256 amount) external;

function unstake(address validator, uint256 amount) external returns (uint256 unlockID);
Expand Down
8 changes: 8 additions & 0 deletions src/adapters/GraphAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ contract GraphAdapter is Adapter {
}
}

function unlockTime() external view override returns (uint256) {
return GRAPH.thawingPeriod();
}

function currentTime() external view override returns (uint256) {
return block.number;
}

function stake(address validator, uint256 amount) external override {
GRT.safeApprove(address(GRAPH), amount);
GRAPH.delegate(validator, amount);
Expand Down
8 changes: 8 additions & 0 deletions src/adapters/LivepeerAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ contract LivepeerAdapter is Adapter {
}
}

function unlockTime() external view override returns (uint256) {
return LIVEPEER_ROUNDS.roundLength() * LIVEPEER.unbondingPeriod();
}

function currentTime() external view override returns (uint256) {
return block.number;
}

function stake(address validator, uint256 amount) public {
LPT.approve(address(LIVEPEER), amount);
LIVEPEER.bond(amount, validator);
Expand Down
8 changes: 8 additions & 0 deletions src/adapters/PolygonAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ contract PolygonAdapter is Adapter {
return u.withdrawEpoch + WITHDRAW_DELAY;
}

function unlockTime() external pure override returns (uint256) {
return WITHDRAW_DELAY;
}

function currentTime() external view override returns (uint256) {
return MATIC_STAKE_MANAGER.epoch();
}

function stake(address validator, uint256 amount) external override {
// approve tokens
POLY.safeApprove(address(MATIC_STAKE_MANAGER), amount);
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/interfaces/ILivepeer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ interface ILivepeerBondingManager {
returns (uint256 amount, uint256 withdrawRound);

function isRegisteredTranscoder(address _transcoder) external view returns (bool);

function unbondingPeriod() external view returns (uint256);
}

interface ILivepeerRoundsManager {
Expand Down
1 change: 1 addition & 0 deletions src/adapters/interfaces/IPolygon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct DelegatorUnbond {
interface IMaticStakeManager {
function getValidatorId(address user) external view returns (uint256);
function getValidatorContract(uint256 validatorId) external view returns (address);
function epoch() external view returns (uint256);
}

interface IValidatorShares {
Expand Down

0 comments on commit 5bcf0b0

Please sign in to comment.