Skip to main content

StrategyController

Overview

Strategy Controller acts as an intermediary between the Strategy and the PrePO Collateral contract.

The Collateral contract should never interact with the Strategy directly and only perform operations via the Strategy Controller.

Functions

deposit

  function deposit(
uint256 amount
) external

Deposits the specified amount of Base Token into the Strategy.

Only the vault (Collateral contract) may call this function.

Assumes approval to transfer amount from the Collateral contract has been given.

Parameters:

NameTypeDescription
amountuint256Amount of Base Token to deposit

withdraw

  function withdraw(
address amount,
uint256 recipient
) external

Withdraws the requested amount of Base Token from the Strategy to the recipient.

Only the vault (Collateral contract) may call this function.

This withdrawal is optimistic, returned amount might be less than the amount specified.

Parameters:

NameTypeDescription
amountaddressAmount of Base Token to withdraw
recipientuint256Address to receive the Base Token

migrate

  function migrate(
contract IStrategy newStrategy
) external

Migrates funds from currently configured Strategy to a new Strategy and replaces it.

If a Strategy is not already set, it sets the Controller's Strategy to the new value with no funds being exchanged.

Gives infinite Base Token approval to the new strategy and sets it to zero for the old one.

Only callable by owner().

Parameters:

NameTypeDescription
newStrategycontract IStrategyAddress of the new Strategy

setVault

  function setVault(
address newVault
) external

Sets the vault that is allowed to deposit/withdraw through this StrategyController.

Only callable by owner().

Parameters:

NameTypeDescription
newVaultaddressAddress of the new vault

totalValue

  function totalValue(
) external returns (uint256)

Returns the Base Token balance of this contract and the totalValue() returned by the Strategy.

getVault

  function getVault(
) external returns (address)

Returns the vault that is allowed to deposit/withdraw through this Strategy Controller.

getBaseToken

  function getBaseToken(
) external returns (contract IERC20)

Returns the ERC20 asset that this Strategy Controller supports handling funds with.

getStrategy

  function getStrategy(
) external returns (contract IStrategy)

Events

VaultChanged

  event VaultChanged(
address vault
)

Emitted via setVault().

Parameters:

NameTypeDescription
vaultaddressThe new vault address

StrategyMigrated

  event StrategyMigrated(
address oldStrategy,
address newStrategy,
uint256 amount
)

Emitted via migrate().

Parameters:

NameTypeDescription
oldStrategyaddressThe old strategy address
newStrategyaddressThe new strategy address
amountuint256The amount migrated