Keeper contract architecture

MarginlyKeeper

Contract helper for Marginly position liquidators.

It makes liquidations utilizing AAVE flashloans

Profit

event Profit(address liquidatedPosition, address token, uint256 amount)

Emitted when liquidation occurs

Parameters

NameTypeDescription

liquidatedPosition

address

liquidated position

token

address

profit token

amount

uint256

profit amount

LiquidationParams

struct LiquidationParams {
  address marginlyPool;
  address positionToLiquidate;
  address liquidator;
  uint256 minProfit;
}

ADDRESSES_PROVIDER

contract IPoolAddressesProvider ADDRESSES_PROVIDER

POOL

contract IPool POOL

constructor

constructor(address addressesProvider) public

flashLoan

function flashLoan(address asset, uint256 amount, uint16 referralCode, address marginlyPool, address positionToLiquidate, uint256 minProfit) external

Takes a simple flashloan in AAVE v3 protocol to liquidate a position in Marginly

Parameters

NameTypeDescription

asset

address

borrow asset

amount

uint256

borrow amount

referralCode

uint16

referral code to get rewards in AAVE

marginlyPool

address

address of marginly pool

positionToLiquidate

address

address of liquidatable position in Marginly pool

minProfit

uint256

amount of minimum profit worth in borrow asset

executeOperation

function executeOperation(address asset, uint256 amount, uint256 premium, address initiator, bytes data) external returns (bool)

Executes an operation after receiving the flash-borrowed asset

Ensure that the contract can return the debt + premium, e.g., has enough funds to repay and has approved the Pool to pull the total amount

Parameters

NameTypeDescription

asset

address

The address of the flash-borrowed asset

amount

uint256

The amount of the flash-borrowed asset

premium

uint256

The fee of the flash-borrowed asset

initiator

address

The address of the flashloan initiator

data

bytes

Return Values

NameTypeDescription

[0]

bool

True if the execution of the operation succeeds, false otherwise

Last updated