Skip to main content

GelatoLiquidator.sol

GelatoLiquidator

A contract that handles the liquidation and claiming of positions in Chromatic markets. It extends the AutomateReady contracts and implements the ILiquidator interface.

waitPositionClaim

uint256 waitPositionClaim

WaitPositionClaimUpdated

event WaitPositionClaimUpdated(uint256 waitingTime)

Emitted when the waiting time of the claim task is updated.

  • Parameters:

    NameTypeDescription
    waitingTimeuint256The new waiting time of the claim task.

constructor

constructor(contract IChromaticMarketFactory _factory, address _automate) public

Constructor function.

  • Parameters:

    NameTypeDescription
    _factorycontract IChromaticMarketFactoryThe address of the Chromatic Market Factory contract.
    _automateaddressThe address of the Gelato Automate contract.

updateWaitPositionClaim

function updateWaitPositionClaim(uint256 waitingTime) external

Updates the waiting time of the claim task.

  • Parameters:

    NameTypeDescription
    waitingTimeuint256The new waiting time of the claim task.

createLiquidationTask

function createLiquidationTask(uint256 positionId) external

Creates a liquidation task for a given position.

Can only be called by a registered market.

  • Parameters:

    NameTypeDescription
    positionIduint256The ID of the position to be liquidated.

cancelLiquidationTask

function cancelLiquidationTask(uint256 positionId) external

Cancels a liquidation task for a given position.

Can only be called by a registered market.

  • Parameters:

    NameTypeDescription
    positionIduint256The ID of the position for which to cancel the liquidation task.

resolveLiquidation

function resolveLiquidation(address _market, uint256 positionId, bytes) external view returns (bool canExec, bytes execPayload)

Resolves the liquidation of a position.

This function is called by the automation system.

  • Parameters:

    NameTypeDescription
    _marketaddress
    positionIduint256The ID of the position to be liquidated.
    bytes
  • Return Values:

    NameTypeDescription
    canExecboolWhether the liquidation can be executed.
    execPayloadbytesThe encoded function call to execute the liquidation.

createClaimPositionTask

function createClaimPositionTask(uint256 positionId) external

Creates a claim position task for a given position.

Can only be called by a registered market.

  • Parameters:

    NameTypeDescription
    positionIduint256The ID of the position to be claimed.

cancelClaimPositionTask

function cancelClaimPositionTask(uint256 positionId) external

Cancels a claim position task for a given position.

Can only be called by a registered market.

  • Parameters:

    NameTypeDescription
    positionIduint256The ID of the position for which to cancel the claim position task.

resolveClaimPosition

function resolveClaimPosition(address _market, uint256 positionId, bytes) external view returns (bool canExec, bytes execPayload)

Resolves the claim of a position.

This function is called by the automation system.

  • Parameters:

    NameTypeDescription
    _marketaddress
    positionIduint256The ID of the position to be claimed.
    bytes
  • Return Values:

    NameTypeDescription
    canExecboolWhether the claim can be executed.
    execPayloadbytesThe encoded function call to execute the claim.

cancelGelatoTask

function cancelGelatoTask(bytes32 taskId) external

_cancelTask

function _cancelTask(mapping(address => mapping(uint256 => bytes32)) registry, uint256 positionId) internal

Internal function to cancel a Gelato task.

  • Parameters:

    NameTypeDescription
    registrymapping(address => mapping(uint256 => bytes32))The mapping storing task IDs.
    positionIduint256The ID of the position.

getLiquidationTaskId

function getLiquidationTaskId(address market, uint256 positionId) external view returns (bytes32 taskId)

getClaimPositionTaskId

function getClaimPositionTaskId(address market, uint256 positionId) external view returns (bytes32 taskId)

_getFeeInfo

function _getFeeInfo() internal view returns (uint256 fee, address feePayee)