Skip to content

BaseLocker

senamakel edited this page Jul 26, 2024 · 3 revisions

Solidity API

BaseLocker

Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for)

WEEK

uint256 WEEK

MAXTIME

uint256 MAXTIME

supply

uint256 supply

version

string version

decimals

uint8 decimals

tokenId

uint256 tokenId

Current count of token

staking

contract IOmnichainStaking staking

_underlying

contract IERC20 _underlying

_locked

mapping(uint256 => struct ILocker.LockedBalance) _locked

__BaseLocker_init

function __BaseLocker_init(string _name, string _symbol, address _token, address _staking, uint256 _maxTime) internal

supportsInterface

function supportsInterface(bytes4 _interfaceID) public view returns (bool)

Interface identification is specified in ERC-165.

Parameters

Name Type Description
_interfaceID bytes4 Id of the interface

lockedEnd

function lockedEnd(uint256 _tokenId) external view returns (uint256)

Get timestamp when _tokenId's lock finishes

Parameters

Name Type Description
_tokenId uint256 User NFT

Return Values

Name Type Description
[0] uint256 Epoch time of the lock end

underlying

function underlying() external view returns (contract IERC20)

Get the underlying ERC20 token

Return Values

Name Type Description
[0] contract IERC20 The ERC20 token contract

locked

function locked(uint256 _tokenId) external view returns (struct ILocker.LockedBalance)

Get the locked balance details of an NFT

Parameters

Name Type Description
_tokenId uint256 The NFT ID

Return Values

Name Type Description
[0] struct ILocker.LockedBalance The LockedBalance struct containing lock details

votingPowerOf

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.

Parameters

Name Type Description
_owner address Address for whom to query the voting power of.

_calculatePower

function _calculatePower(struct ILocker.LockedBalance lock) internal view returns (uint256 power)

_depositFor

function _depositFor(uint256 _tokenId, uint256 _value, uint256 _unlockTime, struct ILocker.LockedBalance _lock, enum ILocker.DepositType _type) internal virtual

Deposit and lock tokens for a user

Parameters

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

merge

function merge(uint256 _from, uint256 _to) external

Merge two NFTs into one

Parameters

Name Type Description
_from uint256 The ID of the NFT to merge from
_to uint256 The ID of the NFT to merge into

depositFor

function depositFor(uint256 _tokenId, uint256 _value) external

Deposit _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

Parameters

Name Type Description
_tokenId uint256 lock NFT
_value uint256 Amount to add to user's lock

createLockFor

function createLockFor(uint256 _value, uint256 _lockDuration, address _to, bool _stakeNFT) external returns (uint256)

Deposit _value tokens for _to and lock for _lockDuration

Parameters

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

createLock

function createLock(uint256 _value, uint256 _lockDuration, bool _stakeNFT) external returns (uint256)

Deposit _value tokens for msg.sender and lock for _lockDuration

Parameters

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?

increaseAmount

function increaseAmount(uint256 _tokenId, uint256 _value) external

Deposit _value additional tokens for _tokenId without modifying the unlock time

Parameters

Name Type Description
_tokenId uint256
_value uint256 Amount of tokens to deposit and add to the lock

increaseUnlockTime

function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external

Extend the unlock time for _tokenId

Parameters

Name Type Description
_tokenId uint256
_lockDuration uint256 New number of seconds until tokens unlock

withdraw

function withdraw(uint256 _tokenId) public virtual

Withdraw all tokens for _tokenId

Only possible if the lock has expired

withdraw

function withdraw(uint256[] _tokenIds) external

Withdraw tokens from multiple NFTs

Parameters

Name Type Description
_tokenIds uint256[] An array of NFT IDs

withdraw

function withdraw(address _user) external

Withdraw tokens for a specific user

Parameters

Name Type Description
_user address The address of the user

_createLock

function _createLock(uint256 _value, uint256 _lockDuration, address _to, bool _stakeNFT) internal returns (uint256)

Deposit _value tokens for _to and lock for _lockDuration

Parameters

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

balanceOfNFT

function balanceOfNFT(uint256 _tokenId) public view returns (uint256)

Get the balance associated with an NFT

Parameters

Name Type Description
_tokenId uint256 The NFT ID

Return Values

Name Type Description
[0] uint256 The balance of the NFT

tokenURI

function tokenURI(uint256) public view virtual returns (string)

Clone this wiki locally