Solidity API
ExecutionEnvironment
An Execution Environment contract is deployed for each unique combination of User address x DAppControl address that interacts with the Atlas protocol via a metacall transaction. IMPORTANT: The contract is not meant to be used as a smart contract wallet with any other protocols other than Atlas
constructor
constructor(address atlas) public
validUser
modifier validUser(struct UserOperation userOp)
preOpsWrapper
function preOpsWrapper(struct UserOperation userOp) external returns (bytes)
The preOpsWrapper function may be called by Atlas before the UserOperation is executed.
This contract is called by the Atlas contract, and delegatecalls the DAppControl contract via the
corresponding preOpsCall
function.
Parameters
Name | Type | Description |
---|---|---|
userOp | struct UserOperation | The UserOperation struct. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bytes | preOpsData Data to be passed to the next call phase. |
userWrapper
function userWrapper(struct UserOperation userOp) external payable returns (bytes returnData)
The userWrapper function is called by Atlas to execute the UserOperation.
This contract is called by the Atlas contract, and either delegatecalls or calls the DAppControl contract
with userOp.data
as calldata, depending on the the needsDelegateUser flag.
Parameters
Name | Type | Description |
---|---|---|
userOp | struct UserOperation | The UserOperation struct. |
Return Values
Name | Type | Description |
---|---|---|
returnData | bytes | Data to be passed to the next call phase. |
postOpsWrapper
function postOpsWrapper(bool solved, bytes returnData) external
The postOpsWrapper function may be called by Atlas as the last phase of a metacall
transaction.
This contract is called by the Atlas contract, and delegatecalls the DAppControl contract via the
corresponding postOpsCall
function.
Parameters
Name | Type | Description |
---|---|---|
solved | bool | Boolean indicating whether a winning SolverOperation was executed successfully. |
returnData | bytes | Data returned from the previous call phase. |
solverPreTryCatch
function solverPreTryCatch(uint256 bidAmount, struct SolverOperation solverOp, bytes returnData) external payable returns (struct SolverTracker solverTracker)
The solverPreTryCatch function is called by Atlas to execute the preSolverCall part of each SolverOperation. A SolverTracker struct is also returned, containing bid info needed to handle the difference in logic between inverted and non-inverted bids.
Note that the DAppControl always has the option for custom logic in a hook between the measurement of solver bids (preSolverCall for invertsBid mode, postSolverCall for normal bid mode) which could potentially affect the solvers' net bid. These hooks should be used with caution and the behaviour should be clearly documented for participating solvers.
Parameters
Name | Type | Description |
---|---|---|
bidAmount | uint256 | The Solver's bid amount. |
solverOp | struct SolverOperation | The SolverOperation struct. |
returnData | bytes | Data returned from the previous call phase. |
Return Values
Name | Type | Description |
---|---|---|
solverTracker | struct SolverTracker | Bid tracking information for the current solver. |
solverPostTryCatch
function solverPostTryCatch(struct SolverOperation solverOp, bytes returnData, struct SolverTracker solverTracker) external payable returns (struct SolverTracker)
The solverPostTryCatch function is called by Atlas to execute the postSolverCall part of each SolverOperation. The different logic scenarios depending on the value of invertsBidValue are also handled, and the SolverTracker struct is updated accordingly.
Note that the DAppControl always has the option for custom logic in a hook between the measurement of solver bids (preSolverCall for invertsBid mode, postSolverCall for normal bid mode) which could potentially affect the solvers' net bid. These hooks should be used with caution and the behaviour should be clearly documented for participating solvers.
Parameters
Name | Type | Description |
---|---|---|
solverOp | struct SolverOperation | The SolverOperation struct. |
returnData | bytes | Data returned from the previous call phase. |
solverTracker | struct SolverTracker | Bid tracking information for the current solver. |
Return Values
Name | Type | Description |
---|---|---|
[0] | struct SolverTracker | solverTracker Updated bid tracking information for the current solver. |
allocateValue
function allocateValue(address bidToken, uint256 bidAmount, bytes allocateData) external returns (bool allocateValueSucceeded)
The allocateValue function is called by Atlas after a successful SolverOperation.
This contract is called by the Atlas contract, and delegatecalls the DAppControl contract via the
corresponding allocateValueCall
function.
Parameters
Name | Type | Description |
---|---|---|
bidToken | address | The address of the token used for the winning SolverOperation's bid. |
bidAmount | uint256 | The winning bid amount. |
allocateData | bytes | Data returned from the previous call phase. |
Return Values
Name | Type | Description |
---|---|---|
allocateValueSucceeded | bool | Boolean indicating whether the allocateValue delegatecall succeeded (true) or reverted (false). This is useful when allowAllocateValueFailure is set to true, the failure is caught here, but we still need to communicate to Atlas that the hook did not succeed. |
withdrawERC20
function withdrawERC20(address token, uint256 amount) external
The withdrawERC20 function allows the environment owner to withdraw ERC20 tokens from this Execution Environment.
This function is only callable by the environment owner and only when Atlas is in an unlocked state.
Parameters
Name | Type | Description |
---|---|---|
token | address | The address of the ERC20 token to withdraw. |
amount | uint256 | The amount of the ERC20 token to withdraw. |
withdrawEther
function withdrawEther(uint256 amount) external
The withdrawEther function allows the environment owner to withdraw Ether from this Execution Environment.
This function is only callable by the environment owner and only when Atlas is in an unlocked state.
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of Ether to withdraw. |
getUser
function getUser() external pure returns (address user)
The getUser function returns the address of the user of this Execution Environment.
Return Values
Name | Type | Description |
---|---|---|
user | address | The address of the user of this Execution Environment. |
getControl
function getControl() external pure returns (address control)
The getControl function returns the address of the DAppControl contract of the current metacall transaction.
Return Values
Name | Type | Description |
---|---|---|
control | address | The address of the DAppControl contract of the current metacall transaction. |
getConfig
function getConfig() external pure returns (uint32 config)
The getConfig function returns the CallConfig of the current metacall transaction.
Return Values
Name | Type | Description |
---|---|---|
config | uint32 | The CallConfig in uint32 form of the current metacall transaction. |
getEscrow
function getEscrow() external view returns (address)
The getEscrow function returns the address of the Atlas/Escrow contract.
Return Values
Name | Type | Description |
---|---|---|
[0] | address | address The address of the Atlas/Escrow contract. |
_tryBalanceOf
function _tryBalanceOf(address token, bool inPreSolver) internal view returns (uint256)
Calls balanceOf of an arbitrary ERC20 token, and reverts with either a PreSolverFailed or PostSolverFailed, depending on the context in which this function is called, if any error occurs.
This stops malicious errors from bubbling up to the Atlas contract, and triggering unexpected behavior.
receive
receive() external payable
fallback
fallback() external payable