Skip to main content

FuroStream

FuroStream allows you to create and update token streams, complete with full deposit / withdraw functionality - all on BentoBox!

The full contract can be found here.

Functions

tokenURI

function tokenURI(uint256 id)
public
view
override
returns (string memory)

View function that returns the token URI.

Parameters

NameTypeDescription
iduint256token ID to return the URI from

setBentoBoxApproval

function setBentoBoxApproval(
address user,
bool approved,
uint8 v,
bytes32 r,
bytes32 s
) external override

Approves this contract for BentoBox.

Parameters

NameTypeDescription
useraddressuser address to set as owner in BentoBox
approvedboolboolean if approved or not by BentoBox
vuint8recovery byte of the signature
rbytes32half of the ECDSA signature pair
sbytes32half of the ECDSA signature pair

createStream

function createStream(
address recipient,
address token,
uint64 startTime,
uint64 endTime,
uint256 amount,
bool fromBentoBox
)
external
payable
override
returns (uint256 streamId, uint256 depositedShares)

Creates a new token stream.

Parameters

NameTypeDescription
recipientaddressrecipient address
tokenaddressaddress of token to create stream for
startTimeuint64when stream starts
endTimeuint64when stream will end
amountuint256amount of token to stream (in token amount, not shares)
fromBentoBoxboolboolean for if stream is coming from BentoBox or not

Returns

NameTypeDescription
streamIduint256new stream's ID
depositedSharesuint256amount of shares deposited in stream

withdrawFromStream

function withdrawFromStream(
uint256 streamId,
uint256 sharesToWithdraw,
address withdrawTo,
bool toBentoBox,
bytes calldata taskData
) external override returns (uint256 recipientBalance, address to)

Withdraws token shares from the stream.

Parameters

NameTypeDescription
streamIduint256stream ID to withdraw from
sharesToWithdrawuint256amount of tokens (in shares) to withdraw
withdrawToaddressaddress to push withdrawn shares into
toBentoBoxboolboolean of whether its from BentoBox or not
taskDatabytesthe task data

Returns

NameTypeDescription
recipientBalanceuint256user's new balance after withdrawal
toaddressaddress that shares were withdrawn to

cancelStream

function cancelStream(uint256 streamId, bool toBentoBox)
external
override
returns (uint256 senderBalance, uint256 recipientBalance)

Cancels a token stream with the given ID and returns the sender and recipient balances.

Parameters

NameTypeDescription
streamIduint256stream ID of stream to delete
toBentoBoxboolboolean of if funds will be sent to BentoBox after or not

Returns

NameTypeDescription
senderBalanceuint256new balance of user after cancelling stream
recipientBalanceuint256new balance of recipient of funds after cancelling stream

getStream

function getStream(uint256 streamId)
external
view
override
returns (Stream memory)

View function that returns a stream given its ID.

Parameters

NameTypeDescription
streamIduint256stream ID of stream to return

streamBalanceOf

function streamBalanceOf(uint256 streamId)
external
view
override
returns (uint256 senderBalance, uint256 recipientBalance)

View function that calls _balanceOf, which returns the balances (sender and recipient) of a stream given its ID.

Parameters

NameTypeDescription
streamIduint256stream ID of stream to return

Returns

NameTypeDescription
senderBalanceuint256balance of user
recipientBalanceuint256balance of recipient

_balanceOf

function _balanceOf(Stream memory stream)
internal
view
returns (uint256 senderBalance, uint256 recipientBalance)

Internal function called by balanceOf, it returns the balances (sender and recipient) of a stream given the Stream object itself.

Parameters

NameTypeDescription
streamStreamspecific stream object to find the balance of

Returns

NameTypeDescription
senderBalanceuint256balance of user
recipientBalanceuint256balance of recipient

updateSender

function updateSender(uint256 streamId, address sender) external override

Updates the sender of a stream. Must be the current sender to update.

Parameters

NameTypeDescription
streamIduint256stream ID of stream to update sender of
senderaddressaddress of new sender to update to

updateStream

function updateStream(
uint256 streamId,
uint128 topUpAmount,
uint64 extendTime,
bool fromBentoBox
) external returns (uint256 depositedShares)

Updates an entire stream and returns the total amount of shares currently deposited in the stream. Must be sender to update.

Parameters

NameTypeDescription
streamIduint256stream ID of stream to update
topUpAmountuint128amount of tokens to top stream off with
extendTimeuint64amount of time to extend stream by
fromBentoBoxboolboolean of whether update is coming from BentoBox or not

Returns

NameTypeDescription
depositedSharesuint256amount of shares deposited in stream

_depositToken

function _depositToken(
address token,
address from,
address to,
uint256 amount,
bool fromBentoBox
) internal returns (uint256 depositedShares)

Internal function that deposits a token into a stream.

Parameters

NameTypeDescription
tokenaddressaddress of token to deposit
fromaddressaddress of user depositing tokens
toaddressaddress of token recipient
amountuint256amount of tokens to deposit
fromBentoBoxboolboolean of whether update is coming from BentoBox or not

Returns

NameTypeDescription
depositedSharesuint256amount of shares deposited in stream

_transferToken

function _transferToken(
address token,
address from,
address to,
uint256 amount,
bool toBentoBox
) internal

Internal function used by others in the contract, it safely transfers tokens.

Parameters

NameTypeDescription
tokenaddressaddress of token to send
fromaddressaddress of user sending the tokens
toaddressaddress of token recipient
amountuint256amount of tokens to send
toBentoBoxboolboolean of whether the transfer is going to BentoBox or not