Skip to main content

Streaming Payments / Salaries (StreamingPayments)

This expenditure enables ongoing "streaming" payments, useful for implementing salaries. Users with the Administration and Funding permissions can create streaming payments, indicating the tokens and amounts to be transferred over a given interval of time. Users can then claim tokens continually, at whatever frequency they choose.

This is a Colony Extension which conforms to the extension interface found here.

Interface Methods

authority():DSAuthority authority

Get the authority of the contract

Return Parameters

NameTypeDescription
authorityDSAuthorityThe authority of the contract

cancel(uint256 _adminPermissionDomainId, uint256 _adminChildSkillIndex, uint256 _id)

Cancel the streaming payment, specifically by setting endTime to block.timestamp

Parameters

NameTypeDescription
_adminPermissionDomainIduint256The domain in which the caller holds the admin permission
_adminChildSkillIndexuint256The index linking the adminPermissionDomainId to the domainId
_iduint256The id of the streaming payment

cancelAndWaive(uint256 _id)

Cancel the streaming payment, specifically by setting endTime to block.timestamp, and waive claim to tokens already earned. Only callable by the recipient.

Parameters

NameTypeDescription
_iduint256The id of the streaming payment

claim(uint256 _permissionDomainId, uint256 _childSkillIndex, uint256 _fromChildSkillIndex, uint256 _toChildSkillIndex, uint256 _id)

Claim a streaming payment

Parameters

NameTypeDescription
_permissionDomainIduint256The domain in which the extension holds the funding & admin permissions
_childSkillIndexuint256The index linking the permissionDomainId to the domainId the payment is in
_fromChildSkillIndexuint256The linking the domainId to the fromPot domain
_toChildSkillIndexuint256The linking the domainId to the toPot domain
_iduint256The id of the streaming payment

create(uint256 _fundingPermissionDomainId, uint256 _fundingChildSkillIndex, uint256 _adminPermissionDomainId, uint256 _adminChildSkillIndex, uint256 _domainId, uint256 _startTime, uint256 _endTimeOrDuration, uint256 _interval, address _recipient, address _token, uint256 _amount)

Creates a new streaming payment

Parameters

NameTypeDescription
_fundingPermissionDomainIduint256The domain in which the caller holds the funding permission
_fundingChildSkillIndexuint256The index linking the fundingPermissionDomainId to the domainId
_adminPermissionDomainIduint256The domain in which the caller holds the admin permission
_adminChildSkillIndexuint256The index linking the adminPermissionDomainId to the domainId
_domainIduint256The domain out of which the streaming payment will be paid
_startTimeuint256The time at which the payment begins paying out
_endTimeOrDurationuint256The time at which the payment ends paying out. If _startTime is 0, then this is the duration of the payment from the current time
_intervaluint256The period of time over which _amounts are paid out
_recipientaddressThe recipient of the streaming payment
_tokenaddressThe token to be paid out
_amountuint256The amount to be paid out (per _interval of time)

deprecate(bool _deprecated)

Called when deprecating (or undeprecating) the extension

Parameters

NameTypeDescription
_deprecatedboolIndicates whether the extension should be deprecated or undeprecated

executeMetaTransaction(address _user, bytes memory _payload, bytes32 _sigR, bytes32 _sigS, uint8 _sigV):bytes returnData

Main function to be called when user wants to execute meta transaction. The actual function to be called should be passed as param with name functionSignature Here the basic signature recovery is being used. Signature is expected to be generated using personal_sign method.

Parameters

NameTypeDescription
_useraddressAddress of user trying to do meta transaction
_payloadbytesFunction call to make via meta transaction
_sigRbytes32R part of the signature
_sigSbytes32S part of the signature
_sigVuint8V part of the signature

Return Parameters

NameTypeDescription
returnDatabytesReturn data returned by the actual function called

finishUpgrade()

A function to be called after an upgrade has been done from v2 to v3.

Note: Can only be called by the colony itself, and only expected to be called as part of the upgrade() call. Required to be external so it can be an external call.

getAmountClaimableLifetime(uint256 _id):uint256 amount

Get the amount claimable in the lifetime of the stream

Parameters

NameTypeDescription
_iduint256The id of the streaming payment

Return Parameters

NameTypeDescription
amountuint256The amount claimable

getAmountEntitledFromStart(uint256 _id):uint256 amount

Get the amount entitled to claim from the start of the stream

Parameters

NameTypeDescription
_iduint256The id of the streaming payment

Return Parameters

NameTypeDescription
amountuint256The amount entitled

getCapabilityRoles(bytes4 _sig):bytes32 roles

Gets the bytes32 representation of the roles authorized to call a function

Parameters

NameTypeDescription
_sigbytes4The function signature

Return Parameters

NameTypeDescription
rolesbytes32bytes32 representation of the authorized roles

getColony():address colony

Gets the address of the extension's colony

Return Parameters

NameTypeDescription
colonyaddressThe address of the colony

getDeprecated():bool deprecated

Gets the boolean indicating whether or not the extension is deprecated

Return Parameters

NameTypeDescription
deprecatedboolBoolean indicating whether or not the extension is deprecated

getMetatransactionNonce(address userAddress):uint256 nonce

Gets the next metatransaction nonce for user that should be used targeting this contract

Parameters

NameTypeDescription
userAddressaddressThe address of the user that will sign the metatransaction

Return Parameters

NameTypeDescription
nonceuint256The nonce that should be used for the next metatransaction

getNUnresolvedStreamingPayments():uint256 nUnresolvedPayments

Get the number of unresolved streaming payments

Return Parameters

NameTypeDescription
nUnresolvedPaymentsuint256The number of unresolved streaming payments

getNumStreamingPayments():uint256 numPayments

Get the total number of streaming payments

Return Parameters

NameTypeDescription
numPaymentsuint256The total number of streaming payments

getStreamingPayment(uint256 _id):StreamingPayment streamingPayment

Get the streaming payment struct by Id

Parameters

NameTypeDescription
_iduint256The id of the streaming payment

Return Parameters

NameTypeDescription
streamingPaymentStreamingPaymentThe streaming payment struct

identifier():bytes32 _identifier

Returns the identifier of the extension

Return Parameters

NameTypeDescription
_identifierbytes32The extension's identifier

install(address _colony)

Configures the extension

Parameters

NameTypeDescription
_colonyaddressThe colony in which the extension holds permissions

multicall(bytes[] calldata _data):bytes[] results

Call multiple functions in the current contract and return the data from all of them if they all succeed

Note: The msg.value should not be trusted for any method callable from multicall.

Parameters

NameTypeDescription
_databytes[]The encoded function data for each of the calls to make to this contract

Return Parameters

NameTypeDescription
resultsbytes[]The results from each of the calls passed in via data

owner():address owner

Get the owner of the contract

Return Parameters

NameTypeDescription
owneraddressThe owner of the contract

setEndTime(uint256 _adminPermissionDomainId, uint256 _adminChildSkillIndex, uint256 _id, uint256 _endTime)

Update the endTime, only if the new endTime is in the future

Parameters

NameTypeDescription
_adminPermissionDomainIduint256The domain in which the caller holds the admin permission
_adminChildSkillIndexuint256The index linking the adminPermissionDomainId to the domainId
_iduint256The id of the streaming payment
_endTimeuint256The new endTime to set

setOwner(address owner_)

Set the owner of the contract

Parameters

NameTypeDescription
owner_addressThe new owner of the contract

setStartTime(uint256 _adminPermissionDomainId, uint256 _adminChildSkillIndex, uint256 _id, uint256 _startTime)

Update the startTime, only if the current startTime is in the future

Parameters

NameTypeDescription
_adminPermissionDomainIduint256The domain in which the caller holds the admin permission
_adminChildSkillIndexuint256The index linking the adminPermissionDomainId to the domainId
_iduint256The id of the streaming payment
_startTimeuint256The new startTime to set

setTokenAmount(uint256 _fundingPermissionDomainId, uint256 _fundingChildSkillIndex, uint256 _permissionDomainId, uint256 _childSkillIndex, uint256 _fromChildSkillIndex, uint256 _toChildSkillIndex, uint256 _id, uint256 _amount, uint256 _interval)

Update the token amount to be paid out. Claims existing payout prior to the change

Parameters

NameTypeDescription
_fundingPermissionDomainIduint256The domain in which the caller holds the funding permission
_fundingChildSkillIndexuint256The index linking the fundingPermissionDomainId to the domainId
_permissionDomainIduint256The domain in which the extension holds the funding & admin permissions
_childSkillIndexuint256The index linking the permissionDomainId to the domainId
_fromChildSkillIndexuint256The linking the domainId to the fromPot domain
_toChildSkillIndexuint256The linking the domainId to the toPot domain
_iduint256The id of the streaming payment
_amountuint256The new amount to pay out
_intervaluint256The new interval over which _amount is paid out

uninstall()

Called when uninstalling the extension

verify(address _user, uint256 _nonce, uint256 _chainId, bytes memory _payload, bytes32 _sigR, bytes32 _sigS, uint8 _sigV):bool bool

Verifies the signature for the metatransaction

Parameters

NameTypeDescription
_useraddressAddress of user trying to do meta transaction
_nonceuint256Nonce of the user
_chainIduint256Chain id where the signature is valid for
_payloadbytesFunction call to make via meta transaction
_sigRbytes32R part of the signature
_sigSbytes32S part of the signature
_sigVuint8V part of the signature

Return Parameters

NameTypeDescription
boolboolindicating if the signature is valid or not

version():uint256 colonyVersion

Get the Colony contract version. Starts from 1 and is incremented with every deployed contract change.

Return Parameters

NameTypeDescription
colonyVersionuint256Version number