FlowERC20
Inherits: ICloneableV2, IFlowERC20V4, FlowCommon, ERC20
State Variables
sEvalHandleTransfer
True if we need to eval handleTransfer
on every transfer. For many
tokens this will be false, so we don't want to invoke the external
interpreter call just to cause a noop.
bool private sEvalHandleTransfer;
sEvaluable
The evaluable that will be used to evaluate handleTransfer
on
every transfer. This is only set if sEvalHandleTransfer
is true.
Evaluable internal sEvaluable;
Functions
constructor
Forwards the FlowCommon
constructor arguments to the FlowCommon
.
constructor(DeployerDiscoverableMetaV2ConstructionConfig memory config) FlowCommon(CALLER_META_HASH, config);
initialize
Overloaded typed initialize function MUST revert with this error.
As per ICloneableV2
interface.
function initialize(FlowERC20ConfigV2 memory) external pure;
initialize
function initialize(bytes calldata data) external initializer returns (bytes32);
stackToFlow
As per IFlowV4
but returns a FlowERC20IOV1
instead of a
FlowTransferV1
.
function stackToFlow(uint256[] memory stack) external pure virtual override returns (FlowERC20IOV1 memory);
Parameters
Name | Type | Description |
---|---|---|
stack | uint256[] | The stack to convert to a FlowERC20IOV1 . |
Returns
Name | Type | Description |
---|---|---|
<none> | FlowERC20IOV1 | flowERC20IO The FlowERC20IOV1 representation of the stack. |
flow
As per IFlowV4
but returns a FlowERC20IOV1
instead of a
FlowTransferV1
and mints/burns itself as an ERC20 accordingly.
function flow(Evaluable memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts)
external
virtual
returns (FlowERC20IOV1 memory);
Parameters
Name | Type | Description |
---|---|---|
evaluable | Evaluable | The Evaluable to use to evaluate the flow. |
callerContext | uint256[] | The caller context to use to evaluate the flow. |
signedContexts | SignedContextV1[] | The signed contexts to use to evaluate the flow. |
Returns
Name | Type | Description |
---|---|---|
<none> | FlowERC20IOV1 | flowERC20IO The FlowERC20IOV1 representing all token mint/burns and transfers that occurred during the flow. |
_afterTokenTransfer
Exposes the Open Zeppelin _afterTokenTransfer
hook as an evaluable
entrypoint so that the deployer of the token can use it to implement
custom transfer logic. The stack is ignored, so if the expression author
wants to prevent some kind of transfer, they can just revert within the
expression evaluation.
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual override;
_stackToFlow
Wraps the standard LibFlow.stackToFlow
with the additional logic to
convert the stack to a FlowERC20IOV1
struct. This involves consuming
the mints and burns from the stack as additional sentinel separated
tuples. The mints are consumed first, then the burns, then the remaining
stack is converted to a flow as normal.
function _stackToFlow(Pointer stackBottom, Pointer stackTop) internal pure virtual returns (FlowERC20IOV1 memory);
Parameters
Name | Type | Description |
---|---|---|
stackBottom | Pointer | The bottom of the stack. |
stackTop | Pointer | The top of the stack. |
Returns
Name | Type | Description |
---|---|---|
<none> | FlowERC20IOV1 | flowERC20IO The resulting FlowERC20IOV1 struct. |
_flow
Wraps the standard LibFlow.flow
with the additional logic to handle
the mints and burns from the FlowERC20IOV1
struct. The mints are
processed first, then the burns, then the remaining flow is processed
as normal.
function _flow(Evaluable memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts)
internal
virtual
nonReentrant
returns (FlowERC20IOV1 memory);