SmarterContract
SmarterContract.sol is designed to be used as inheritence. It stores a callbreaker, and can make some assertions about callbreaker state. It be used with or without importing CallBreaker.
Key Features:
- Interaction with CallBreaker: Stores an instance of CallBreaker and interacts with its functions.
- Transaction Order Management: Prevents frontrunning and backrunning through modifiers.
- Conditional Execution: Allows assertions about future calls.
How to Use in a Contract
To use the CallBreaker contract, inherit from it:
import "path-to/SmarterContract.sol";
contract YourContract is SmarterContract {
constructor(address _callbreaker) SmarterContract(_callbreaker) {
}
}
Functions
getCurrentExecutingPair
Returns the call index, CallObject, and ReturnObject of the currently executing call.
Returns
| Name | Type |
|---|---|
| CallObject | CallObject (memory) |
| ReturnObject | ReturnObject (memory) |
frontrunBlocker
Prevents frontrunning by ensuring the currently executing call is the first in the list.
Custom Reverts
IllegalFrontrun(): If there is a frontrunning call.
backrunBlocker
Prevents backrunning by ensuring the currently executing call is the first in the reverse list.
Custom Reverts
IllegalBackrun(): If there is a backrunning call.
soloExecuteBlocker
Prevents both frontrunning and backrunning.
assertFutureCallTo
Ensures that there is a future call after the current call.
Parameters
| Name | Type |
|---|---|
callObj | CallObject (memory) |
hintdex (optional) | uint256 |
Custom Reverts
FutureCallExpected(): If no future call is found.
CallMismatch(): If the CallObject at the hintdex does not match.
assertNextCallTo
Ensures that the next call is to the specified CallObject.
Parameters
| Name | Type |
|---|---|
callObj | CallObject (memory) |
Custom Reverts
CallMismatch(): If the CallObject at the next index does not match.
Events
EnterPortal
Emitted when the enterPortal function is called.
Parameters
| Name | Type |
|---|---|
callObj | CallObject |
returnvalue | ReturnObject |
index | uint256 |
Tip
Emitted when a tip is received.
Parameters
| Name | Type |
|---|---|
from | address (indexed) |
to | address (indexed) |
amount | uint256 |
VerifyStxn
Emitted when the verifyStxn function is called, indicating the completion of the verification process.
Modifiers
ensureTurnerOpen
This checks if the portal is open at the CallBreaker contract.
noFrontrun
Prevents frontrunning by using frontrunBlocker.
noBackrun
Prevents backrunning by using backrunBlocker.