Skip to main content

Token Locking (ITokenLocking)

This contract supports secure token voting for the Colony Network, allowing for on-chain token votes to occur without the risk of "double-voting". Unlike Snapshot, which uses state snapshots to allow for secure voting off-chain, this contract allows for secure voting on-chain by preventing users from transferring their tokens until their votes have been cast. Only tokens which have been deposited in this contract can be used to vote.

Interface Methods

approveStake(address _user, uint256 _amount, address _token)

Allow the colony to obligate some amount of tokens as a stake.

Note: Can only be called by a colony or colonyNetwork

Parameters

NameTypeDescription
_useraddressAddress of the user that is allowing their holdings to be staked by the caller
_amountuint256Amount of that colony's internal token up to which we are willing to be obligated.
_tokenaddressThe colony's internal token address

deobligateStake(address _user, uint256 _amount, address _token)

Deobligate the user some amount of tokens, releasing the stake. Can only be called by a colony or colonyNetwork.

Parameters

NameTypeDescription
_useraddressAddress of the account we are deobligating.
_amountuint256Amount of colony's internal token we are deobligating.
_tokenaddressThe colony's internal token address

deposit(address _token, uint256 _amount)

Deposit _amount of deposited tokens. Can only be called if user tokens are not locked. Before calling this function user has to allow that their tokens can be transferred by token locking contract.

Parameters

NameTypeDescription
_tokenaddressAddress of the token to deposit
_amountuint256Amount to deposit

deposit(address _token, uint256 _amount, bool _force)

Deposit _amount of colony tokens. Before calling this function user has to allow that their tokens can be transferred by token locking contract.

Parameters

NameTypeDescription
_tokenaddressAddress of the token to deposit
_amountuint256Amount to deposit
_forceboolPass true to forcibly unlock the token

depositFor(address _token, uint256 _amount, address _recipient)

Deposit _amount of colony tokens in the recipient's account. Goes into pendingBalance if token is locked.

Parameters

NameTypeDescription
_tokenaddressAddress of the token to deposit
_amountuint256Amount to deposit
_recipientaddressUser to receive the tokens

getApproval(address _user, address _token, address _obligator):uint256 approval

See how much an address has approved another address to obligate on their behalf.

Parameters

NameTypeDescription
_useraddressAddress of the account that has approved _approvee to obligate their funds.
_tokenaddressThe token for which the user has provided the approval.
_obligatoraddressThe address that has been approved to obligate the funds.

Return Parameters

NameTypeDescription
approvaluint256The total amount for this obligation

getColonyNetwork():address networkAddress

Get ColonyNetwork address.

Return Parameters

NameTypeDescription
networkAddressaddressColonyNetwork address

getObligation(address _user, address _token, address _obligator):uint256 approval

See how much a user is currently obligated by another.

Parameters

NameTypeDescription
_useraddressAddress of the account that has had their funds obligated.
_tokenaddressThe token for which the user has provided the approval.
_obligatoraddressThe address that obligated the funds (and therefore can slash or return them).

Return Parameters

NameTypeDescription
approvaluint256The total amount for this obligation

getTotalLockCount(address _token):uint256 lockCount

Get global lock count for a specific token.

Parameters

NameTypeDescription
_tokenaddressAddress of the token

Return Parameters

NameTypeDescription
lockCountuint256Global token lock count

getTotalObligation(address _user, address _token):uint256 obligation

See the total amount of a user's obligation.

Parameters

NameTypeDescription
_useraddressAddress of the obligated account.
_tokenaddressThe token for which the user is obligated.

Return Parameters

NameTypeDescription
obligationuint256The total amount this user is obligated

getUserLock(address _token, address _user):Lock lock

Get user token lock info (lock count and deposited amount).

Parameters

NameTypeDescription
_tokenaddressAddress of the token
_useraddressAddress of the user

Return Parameters

NameTypeDescription
lockLockLock object containing: lockCount User's token lock count, balance User's deposited amount, DEPRECATED_timestamp Timestamp of deposit (deprecated) pendingBalance Tokens that have been sent to them, but are inaccessible until all locks are cleared and then these tokens are claimed

incrementLockCounterTo(address _token, uint256 _lockId)

Increments sender's lock count to _lockId.

Parameters

NameTypeDescription
_tokenaddressAddress of the token we want to increment lock count for
_lockIduint256Id of the lock user wants to increment to

lockToken(address _token):uint256 lockCount

Locks everyones' tokens on _token address.

Parameters

NameTypeDescription
_tokenaddressAddress of the token we want to lock

Return Parameters

NameTypeDescription
lockCountuint256Updated total token lock count

obligateStake(address _user, uint256 _amount, address _token)

Obligate the user some amount of tokens as a stake. Can only be called by a colony or colonyNetwork.

Parameters

NameTypeDescription
_useraddressAddress of the account we are obligating.
_amountuint256Amount of the colony's internal token we are obligating.
_tokenaddressThe colony's internal token address

reward(address _recipient, uint256 _amount)

This function is deprecated and only exists to aid upgrades.

Note: It's a NOOP. You don't need to call this, and if you write a contract that does it will break in the future.

Parameters

NameTypeDescription
_recipientaddressThe address to receive the reward
_amountuint256The amount to reward

setColonyNetwork(address _colonyNetwork)

Set the ColonyNetwork contract address.

Note: ColonyNetwork is used for checking if sender is a colony created on colony network.

Parameters

NameTypeDescription
_colonyNetworkaddressAddress of the ColonyNetwork

transfer(address _token, uint256 _amount, address _recipient, bool _force)

Transfer tokens to a recipient's pending balance. Can only be called if user tokens are not locked.

Parameters

NameTypeDescription
_tokenaddressAddress of the token to transfer
_amountuint256Amount to transfer
_recipientaddressUser to receive the tokens
_forceboolPass true to forcibly unlock the token

transferStake(address _user, uint256 _amount, address _token, address _recipient)

Transfer some amount of staked tokens. Can only be called by a colony or colonyNetwork.

Parameters

NameTypeDescription
_useraddressAddress of the account we are taking.
_amountuint256Amount of colony's internal token we are taking.
_tokenaddressThe colony's internal token address
_recipientaddressRecipient of the slashed tokens

unlockTokenForUser(address _token, address _user, uint256 _lockId)

Increments the lock counter to _lockId for the _user if user's lock count is less than _lockId by 1. Can only be called by a colony.

Parameters

NameTypeDescription
_tokenaddressAddress of the token we want to unlock
_useraddressAddress of the user
_lockIduint256Id of the lock we want to increment to

withdraw(address _token, uint256 _amount)

Withdraw _amount of deposited tokens. Can only be called if user tokens are not locked.

Parameters

NameTypeDescription
_tokenaddressAddress of the token to withdraw from
_amountuint256Amount to withdraw

withdraw(address _token, uint256 _amount, bool _force)

Withdraw _amount of deposited tokens. Set _force to true to forcibly unlock the token before the withdrawal.

Parameters

NameTypeDescription
_tokenaddressAddress of the token to withdraw from
_amountuint256Amount to withdraw
_forceboolPass true to forcibly unlock the token