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

Name
Type
Description

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

POOL

constructor

flashLoan

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

Parameters

Name
Type
Description

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

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

Name
Type
Description

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

Name
Type
Description

[0]

bool

True if the execution of the operation succeeds, false otherwise

Last updated