-
Notifications
You must be signed in to change notification settings - Fork 8
BaseLocker
Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for)
uint256 WEEKuint256 MAXTIMEuint256 supplystring versionuint8 decimalsuint256 tokenIdCurrent count of token
contract IOmnichainStaking stakingcontract IERC20 _underlyingmapping(uint256 => struct ILocker.LockedBalance) _lockedfunction __BaseLocker_init(string _name, string _symbol, address _token, address _staking, uint256 _maxTime) internalfunction supportsInterface(bytes4 _interfaceID) public view returns (bool)Interface identification is specified in ERC-165.
| Name | Type | Description |
|---|---|---|
| _interfaceID | bytes4 | Id of the interface |
function lockedEnd(uint256 _tokenId) external view returns (uint256)Get timestamp when _tokenId's lock finishes
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | User NFT |
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | Epoch time of the lock end |
function underlying() external view returns (contract IERC20)Get the underlying ERC20 token
| Name | Type | Description |
|---|---|---|
| [0] | contract IERC20 | The ERC20 token contract |
function locked(uint256 _tokenId) external view returns (struct ILocker.LockedBalance)Get the locked balance details of an NFT
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | The NFT ID |
| Name | Type | Description |
|---|---|---|
| [0] | struct ILocker.LockedBalance | The LockedBalance struct containing lock details |
function votingPowerOf(address _owner) external view returns (uint256 _power)Returns the voting power of the _owner.
Throws if _owner is the zero address. NFTs assigned to the zero address are considered invalid.
| Name | Type | Description |
|---|---|---|
| _owner | address | Address for whom to query the voting power of. |
function _calculatePower(struct ILocker.LockedBalance lock) internal view returns (uint256 power)function _depositFor(uint256 _tokenId, uint256 _value, uint256 _unlockTime, struct ILocker.LockedBalance _lock, enum ILocker.DepositType _type) internal virtualDeposit and lock tokens for a user
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | NFT that holds lock |
| _value | uint256 | Amount to deposit |
| _unlockTime | uint256 | New time when to unlock the tokens, or 0 if unchanged |
| _lock | struct ILocker.LockedBalance | Previous locked amount / timestamp |
| _type | enum ILocker.DepositType | The type of deposit |
function merge(uint256 _from, uint256 _to) externalMerge two NFTs into one
| Name | Type | Description |
|---|---|---|
| _from | uint256 | The ID of the NFT to merge from |
| _to | uint256 | The ID of the NFT to merge into |
function depositFor(uint256 _tokenId, uint256 _value) externalDeposit _value tokens for _tokenId and add to the lock
Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | lock NFT |
| _value | uint256 | Amount to add to user's lock |
function createLockFor(uint256 _value, uint256 _lockDuration, address _to, bool _stakeNFT) external returns (uint256)Deposit _value tokens for _to and lock for _lockDuration
| Name | Type | Description |
|---|---|---|
| _value | uint256 | Amount to deposit |
| _lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
| _to | address | Address to deposit |
| _stakeNFT | bool |
function createLock(uint256 _value, uint256 _lockDuration, bool _stakeNFT) external returns (uint256)Deposit _value tokens for msg.sender and lock for _lockDuration
| Name | Type | Description |
|---|---|---|
| _value | uint256 | Amount to deposit |
| _lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
| _stakeNFT | bool | Should we also stake the NFT as well? |
function increaseAmount(uint256 _tokenId, uint256 _value) externalDeposit _value additional tokens for _tokenId without modifying the unlock time
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | |
| _value | uint256 | Amount of tokens to deposit and add to the lock |
function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) externalExtend the unlock time for _tokenId
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | |
| _lockDuration | uint256 | New number of seconds until tokens unlock |
function withdraw(uint256 _tokenId) public virtualWithdraw all tokens for _tokenId
Only possible if the lock has expired
function withdraw(uint256[] _tokenIds) externalWithdraw tokens from multiple NFTs
| Name | Type | Description |
|---|---|---|
| _tokenIds | uint256[] | An array of NFT IDs |
function withdraw(address _user) externalWithdraw tokens for a specific user
| Name | Type | Description |
|---|---|---|
| _user | address | The address of the user |
function _createLock(uint256 _value, uint256 _lockDuration, address _to, bool _stakeNFT) internal returns (uint256)Deposit _value tokens for _to and lock for _lockDuration
| Name | Type | Description |
|---|---|---|
| _value | uint256 | Amount to deposit |
| _lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
| _to | address | Address to deposit |
| _stakeNFT | bool | should we stake into the staking contract |
function balanceOfNFT(uint256 _tokenId) public view returns (uint256)Get the balance associated with an NFT
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | The NFT ID |
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | The balance of the NFT |
function tokenURI(uint256) public view virtual returns (string)