Developer Docs
Smart Contracts
Account

DCAAccount

Methods

Execute

function Execute(uint256 strategyId_, uint16 feeAmount_) external nonpayable returns (bool)

Executes the given strategy with the given fee amount. Can only be done by the executor.

Parameters

NameTypeDescription
strategyId_uint256the id of the strategy to execute
feeAmount_uint16the amount of fee to pay to the executor

Returns

NameTypeDescription
_0boolundefined

ExecutorDeactivate

function ExecutorDeactivate(uint256 strategyId_) external nonpayable

used by the Executor to remove failing strategies/out of funds strategies.

Force unsubscribe the strategy from the executor

Parameters

NameTypeDescription
strategyId_uint256Strategy Id of the strategy to unsubscribe

FundAccount

function FundAccount(address token_, uint256 amount_) external nonpayable

Fund the account with a base currency

Parameters

NameTypeDescription
token_address{address} The ERC20 token address
amount_uint256{uint256} Amount of the token to deposit

SWAP_ROUTER

function SWAP_ROUTER() external view returns (contract ISwapRouter)

Returns

NameTypeDescription
_0contract ISwapRouterundefined

SetupStrategy

function SetupStrategy(IDCADataStructures.Strategy newStrategy_, uint256 seedFunds_, bool subscribeToExecutor_) external nonpayable

Parameters

NameTypeDescription
newStrategy_IDCADataStructures.Strategyundefined
seedFunds_uint256undefined
subscribeToExecutor_boolundefined

SubscribeStrategy

function SubscribeStrategy(uint256 strategyId_) external nonpayable

Subscribes an already created strategy to an executor

Parameters

NameTypeDescription
strategyId_uint256{uint256} Id of the strategy to subscribe to an executor

UnFundAccount

function UnFundAccount(address token_, uint256 amount_) external nonpayable

Unfund account of a base token

Parameters

NameTypeDescription
token_address{address} The ERC20 token address
amount_uint256{uint256} Amount of the token to withdraw

UnWindReinvest

function UnWindReinvest(uint256 strategyId_) external nonpayable

Unwinds the reinvestment for the given strategy

Parameters

NameTypeDescription
strategyId_uint256The id of the strategy to unwind

UnsubscribeStrategy

function UnsubscribeStrategy(uint256 strategyId_) external nonpayable

Unsubscribes the given strategy from its executor

Parameters

NameTypeDescription
strategyId_uint256Strategy Id of the strategy to unsubscribe

WithdrawSavings

function WithdrawSavings(address token_, uint256 amount_) external nonpayable

Withdraws the given amount of the target token balance

Parameters

NameTypeDescription
token_address{address} The ERC20 token address
amount_uint256{uint256} Amount of the target token to withdraw

changeExecutor

function changeExecutor(address executorAddress_) external nonpayable

Parameters

NameTypeDescription
executorAddress_addressundefined

changeReinvestLibrary

function changeReinvestLibrary(address newLibraryAddress_) external nonpayable

Updates the contract holding the reinvest logic

Parameters

NameTypeDescription
newLibraryAddress_addressaddress of the library contract to use

getAttachedReinvestLibraryAddress

function getAttachedReinvestLibraryAddress() external view returns (address)

Returns the address of the attached reinvest library

Returns

NameTypeDescription
_0addressThe address of the attached reinvest library

getAttachedReinvestLibraryVersion

function getAttachedReinvestLibraryVersion() external view returns (string)

Returns the version of the attached reinvest library

Returns

NameTypeDescription
_0stringThe version of the attached reinvest library

getBaseBalance

function getBaseBalance(address token_) external view returns (uint256)

get account balance of base token

Parameters

NameTypeDescription
token_address{address} Base token address

Returns

NameTypeDescription
_0uint256{uint256} account balance of Base token

getExecutorAddress

function getExecutorAddress() external view returns (address)

Returns the executor address

Returns

NameTypeDescription
_0addressThe executor address

getStrategyData

function getStrategyData(uint256 strategyId_) external view returns (struct IDCADataStructures.Strategy)

Get the full data for the given strategy

Parameters

NameTypeDescription
strategyId_uint256Strategy Id of the strategy data to get

Returns

NameTypeDescription
_0IDCADataStructures.Strategy{Strategy} the given strategy's full data struct

getTargetBalance

function getTargetBalance(address token_) external view returns (uint256)

get account balance of target token

Parameters

NameTypeDescription
token_address{address} Base token address

Returns

NameTypeDescription
_0uint256{uint256} account balance of Base token

getTimeTillWindow

function getTimeTillWindow(uint256 strategyId_) external view returns (uint256 lastEx, uint256 secondsLeft, bool checkReturn)

returns UI data for strategy interval timing

Parameters

NameTypeDescription
strategyId_uint256Strategy Id of the strategy data to get

Returns

NameTypeDescription
lastExuint256{uint256} time of last execution (seconds)
secondsLeftuint256{uint256} seconds left till strategy is in window
checkReturnbool{bool} if the strategy is in the window

owner

function owner() external view returns (address)

Returns the address of the current owner.

Returns

NameTypeDescription
_0addressundefined

removeExecutor

function removeExecutor() external nonpayable

Removes the executor address

renounceOwnership

function renounceOwnership() external nonpayable

Leaves the contract without owner. It will not be possible to call onlyOwner functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.

setStrategyReinvest

function setStrategyReinvest(uint256 strategyId_, IDCADataStructures.Reinvest reinvest_) external nonpayable

Parameters

NameTypeDescription
strategyId_uint256undefined
reinvest_IDCADataStructures.Reinvestundefined

transferOwnership

function transferOwnership(address newOwner) external nonpayable

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

Parameters

NameTypeDescription
newOwneraddressundefined

updateSwapAddress

function updateSwapAddress(address swapRouter_) external nonpayable

Updates the Uniswap SwapRouter Address

Parameters

NameTypeDescription
swapRouter_addressNew address for the Uniswap router

Events

ExecutorAddressChange

event ExecutorAddressChange(address indexed newAddress_)

Emitted when the executor address is changed

Parameters

NameTypeDescription
newAddress_ indexedaddressThe new executor address

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)

Parameters

NameTypeDescription
previousOwner indexedaddressundefined
newOwner indexedaddressundefined

ReinvestExecuted

event ReinvestExecuted(uint256 indexed strategyId_, bool indexed success, uint256 amountReturned)

Emits when a Reinvest modula has been executed

Parameters

NameTypeDescription
strategyId_ indexeduint256the ID of the strategy executed
success indexedboolWether the reinvest was successful
amountReturneduint256The amount returned by the Reinvest

ReinvestLibraryChanged

event ReinvestLibraryChanged(address indexed newLibraryAddress)

Emits when the reinvest address has been changed

Parameters

NameTypeDescription
newLibraryAddress indexedaddressThe address for the Library contract

ReinvestUnwound

event ReinvestUnwound(uint256 indexed strategyId, uint256 amount, bool indexed success)

Emited when a Reinvest is unwound

Parameters

NameTypeDescription
strategyId indexeduint256The ID of the strategy
amountuint256The amount unwond and returned to the account
success indexedboolIf the unwind was successful

StrategyCreated

event StrategyCreated(uint256 indexed strategyId_)

Emitted when a new strategy has been created

Parameters

NameTypeDescription
strategyId_ indexeduint256Id of the newly created strategy

StrategyExecuted

event StrategyExecuted(uint256 indexed strategyId_, uint256 indexed amountIn_, bool reInvested_)

Emitted when a strategy has been executed

Parameters

NameTypeDescription
strategyId_ indexeduint256the id for the executed strategy
amountIn_ indexeduint256amount received from the swap
reInvested_boolwether the strategy reinvested or not

StrategySubscribed

event StrategySubscribed(uint256 indexed strategyId_, address indexed executor_)

Emitted when the Strategy is confirmed to be subscribed to an Executor

Parameters

NameTypeDescription
strategyId_ indexeduint256ID of the strategy that has been subscribed
executor_ indexedaddressAddress of the Executor contract subscribed to

StrategyUnsubscribed

event StrategyUnsubscribed(uint256 indexed strategyId_)

Emitted when a strategy has been unsubscribed from an Executor

Parameters

NameTypeDescription
strategyId_ indexeduint256Id of the strategy being unsubscribed

Errors

AddressEmptyCode

error AddressEmptyCode(address target)

There's no code at target (it is not a contract).

Parameters

NameTypeDescription
targetaddressundefined

AddressInsufficientBalance

error AddressInsufficientBalance(address account)

The ETH balance of the account is not enough to perform the operation.

Parameters

NameTypeDescription
accountaddressundefined

FailedInnerCall

error FailedInnerCall()

A call to an address target failed. The target may have reverted.

OwnableInvalidOwner

error OwnableInvalidOwner(address owner)

The owner is not a valid owner account. (eg. address(0))

Parameters

NameTypeDescription
owneraddressundefined

OwnableUnauthorizedAccount

error OwnableUnauthorizedAccount(address account)

The caller account is not authorized to perform an operation.

Parameters

NameTypeDescription
accountaddressundefined

SafeERC20FailedOperation

error SafeERC20FailedOperation(address token)

An operation with an ERC20 token failed.

Parameters

NameTypeDescription
tokenaddressundefined