Dolomite Margin - Events

Dolomite's Core smart contracts emit events that make tracking system changes easy.

These events are all emitted by instances of DolomiteMargin on each network Dolomite is deployed. See smart contract addresses to discover the address of DolomiteMargin on each network.

Account Operation Events

These events are logged right after they occur within each Action of an Operation

BalanceUpdate Struct

Description:

The BalanceUpdate struct represents an update to an account's balance, including changes to both token amounts and principal amounts.

Struct Members:

  • deltaWei (Types.Wei): The change in token balance (Wei) for the account. Can be positive or negative.

  • newPar (Types.Par): The new principal value for the account. Can be positive or negative.

Struct Signature:

library Types {
    struct Wei {
        bool sign; // true if positive
        uint128 value;
    }

    struct Par {
        bool sign; // true if positive
        uint128 value;
    }
}

struct BalanceUpdate {
    Types.Wei deltaWei;
    Types.Par newPar;
}

LogOperation Event

Description:

This event is emitted at the start of an operation.

Event Signature:

event LogOperation(
    address sender
);
  • sender (address): The address of the caller of DolomiteMargin who performed the operation.

LogDeposit Event

Description:

This event is emitted when tokens are deposited into an account via a Deposit Action.

Event Signature:

event LogDeposit(
    address indexed accountOwner,
    uint256 accountNumber,
    uint256 market,
    BalanceUpdate update,
    address from
);
  • accountOwner (address): The owner of the account where the deposit occurred.

  • accountNumber (uint256): The account number where the deposit occurred.

  • market (uint256): The market identifier where the deposit occurred.

  • update (BalanceUpdate): The balance update for the account as a result of the deposit.

  • from (address): The address from which the deposit was made.

LogWithdraw Event

Description:

This event is emitted when tokens are withdrawn from an account via a Withdraw Action.

Event Signature:

event LogWithdraw(
    address indexed accountOwner,
    uint256 accountNumber,
    uint256 market,
    BalanceUpdate update,
    address to
);
  • accountOwner (address): The owner of the account from which the withdrawal occurred.

  • accountNumber (uint256): The account number from which the withdrawal occurred.

  • market (uint256): The market identifier from which the withdrawal occurred.

  • update (BalanceUpdate): The balance update for the account as a result of the withdrawal.

  • to (address): The address to which the withdrawal was sent.

LogTransfer Event

Description:

This event is emitted when a transfer of tokens occurs between two accounts via a Transfer Action. Note this does not materialize an ERC20 transfer event since only virtual liquidity is transferred.

Event Signature:

event LogTransfer(
    address indexed accountOneOwner,
    uint256 accountOneNumber,
    address indexed accountTwoOwner,
    uint256 accountTwoNumber,
    uint256 market,
    BalanceUpdate updateOne,
    BalanceUpdate updateTwo
);
  • accountOneOwner (address): The owner of the first account involved in the transfer.

  • accountOneNumber (uint256): The account number of the first account involved in the transfer.

  • accountTwoOwner (address): The owner of the second account involved in the transfer.

  • accountTwoNumber (uint256): The account number of the second account involved in the transfer.

  • market (uint256): The market identifier where the transfer occurred.

  • updateOne (BalanceUpdate): The balance update for the first account as a result of the transfer.

  • updateTwo (BalanceUpdate): The balance update for the second account as a result of the transfer.

LogBuy Event

Description:

This event is emitted when a Buy Action occurs, representing a trade where one account purchases tokens via an exchange wrapper contract. Mechnically, this Action is similar to Uniswap's swapTokensForExactTokens.

Event Signature:

event LogBuy(
    address indexed accountOwner,
    uint256 accountNumber,
    uint256 takerMarket,
    uint256 makerMarket,
    BalanceUpdate takerUpdate,
    BalanceUpdate makerUpdate,
    address exchangeWrapper
);
  • accountOwner (address): The owner of the account that performed the buy operation.

  • accountNumber (uint256): The account number that performed the buy operation.

  • takerMarket (uint256): The market identifier for the taker's (buyer's) side of the trade (the inputMarket).

  • makerMarket (uint256): The market identifier for the maker's (seller's) side of the trade (the outputMarket).

  • takerUpdate (BalanceUpdate): The balance update for the taker's account as a result of the buy.

  • makerUpdate (BalanceUpdate): The balance update for the maker's account as a result of the buy.

  • exchangeWrapper (address): The address of the exchange wrapper contract involved in the buy action.

LogSell Event

Description:

This event is emitted when a Sell Action occurs, representing a trade where one account sells tokens via an exchange wrapper contract. Mechanically, this Action is similar to Uniswap's swapExactTokensForTokens.

Event Signature:

event LogSell(
    address indexed accountOwner,
    uint256 accountNumber,
    uint256 takerMarket,
    uint256 makerMarket,
    BalanceUpdate takerUpdate,
    BalanceUpdate makerUpdate,
    address exchangeWrapper
);
  • accountOwner (address): The owner of the account that performed the sell operation.

  • accountNumber (uint256): The account number that performed the sell operation.

  • takerMarket (uint256): The market identifier for the taker's (seller's) side of the trade (the inputMarket).

  • makerMarket (uint256): The market identifier for the maker's (buyer's) side of the trade (the outputMarket).

  • takerUpdate (BalanceUpdate): The balance update for the taker's account as a result of the sell.

  • makerUpdate (BalanceUpdate): The balance update for the maker's account as a result of the sell.

  • exchangeWrapper (address): The address of the exchange wrapper contract involved in the sell action.

LogTrade Event

Description:

This event is emitted when a Trade Action occurs between a taker and a maker account using an auto-trader contract.

Event Signature:

event LogTrade(
    address indexed takerAccountOwner,
    uint256 takerAccountNumber,
    address indexed makerAccountOwner,
    uint256 makerAccountNumber,
    uint256 inputMarket,
    uint256 outputMarket,
    BalanceUpdate takerInputUpdate,
    BalanceUpdate takerOutputUpdate,
    BalanceUpdate makerInputUpdate,
    BalanceUpdate makerOutputUpdate,
    address autoTrader
);
  • takerAccountOwner (address): The owner of the taker account involved in the trade.

  • takerAccountNumber (uint256): The account number of the taker account involved in the trade.

  • makerAccountOwner (address): The owner of the maker account involved in the trade. The makerAccountOwner is the address that approved the trade for the auto-trader contract.

  • makerAccountNumber (uint256): The account number of the maker account involved in the trade.

  • inputMarket (uint256): The market identifier for the input tokens of the trade.

  • outputMarket (uint256): The market identifier for the output tokens of the trade.

  • takerInputUpdate (BalanceUpdate): The balance update for the taker's input tokens as a result of the trade.

  • takerOutputUpdate (BalanceUpdate): The balance update for the taker's output tokens as a result of the trade.

  • makerInputUpdate (BalanceUpdate): The balance update for the maker's input tokens as a result of the trade.

  • makerOutputUpdate (BalanceUpdate): The balance update for the maker's output tokens as a result of the trade.

  • autoTrader (address): The address of the auto-trader contract used for the trade.

LogCall Event

Description:

This event is emitted when a Call Action occurs.

Event Signature:

event LogCall(
    address indexed accountOwner,
    uint256 accountNumber,
    address callee
);
  • accountOwner (address): The owner of the account that initiated the call.

  • accountNumber (uint256): The account number of the account owner that initiated the call.

  • callee (address): The address of the contract that was called.

LogLiquidate Event

Description:

This event is emitted when a Liquidate Action occurs, representing the process of one account liquidating another account's under-collateralized position.

Event Signature:

event LogLiquidate(
    address indexed solidAccountOwner,
    uint256 solidAccountNumber,
    address indexed liquidAccountOwner,
    uint256 liquidAccountNumber,
    uint256 heldMarket,
    uint256 owedMarket,
    BalanceUpdate solidHeldUpdate,
    BalanceUpdate solidOwedUpdate,
    BalanceUpdate liquidHeldUpdate,
    BalanceUpdate liquidOwedUpdate
);
  • solidAccountOwner (address): The owner of the account performing the liquidation.

  • solidAccountNumber (uint256): The account number of the account performing the liquidation.

  • liquidAccountOwner (address): The owner of the account being liquidated.

  • liquidAccountNumber (uint256): The account number of the account being liquidated.

  • heldMarket (uint256): The market identifier for the held (collateral) tokens.

  • owedMarket (uint256): The market identifier for the owed (borrowed) tokens.

  • solidHeldUpdate (BalanceUpdate): The balance update for the held tokens of the account performing the liquidation.

  • solidOwedUpdate (BalanceUpdate): The balance update for the owed tokens of the account performing the liquidation.

  • liquidHeldUpdate (BalanceUpdate): The balance update for the held tokens of the account being liquidated.

  • liquidOwedUpdate (BalanceUpdate): The balance update for the owed tokens of the account being liquidated.

LogVaporize Event

Description:

This event is emitted when a Vaporize Action occurs, representing the process of a solid account using the admin's excess tokens to cover a vapor account's bad debt. A position's debt is considered to be bad if there is no held value (balance == 0) but there is still debt held in the position.

Event Signature:

event LogVaporize(
    address indexed solidAccountOwner,
    uint256 solidAccountNumber,
    address indexed vaporAccountOwner,
    uint256 vaporAccountNumber,
    uint256 heldMarket,
    uint256 owedMarket,
    BalanceUpdate solidHeldUpdate,
    BalanceUpdate solidOwedUpdate,
    BalanceUpdate vaporOwedUpdate
);
  • solidAccountOwner (address): The owner of the solid account from which the vaporization occurred.

  • solidAccountNumber (uint256): The account number of the solid account from which the vaporization occurred.

  • vaporAccountOwner (address): The owner of the vapor account that has bad debt

  • vaporAccountNumber (uint256): The account number of the vapor account has bad debt

  • heldMarket (uint256): The market identifier for the held (collateral) tokens.

  • owedMarket (uint256): The market identifier for the owed (borrowed) tokens.

  • solidHeldUpdate (BalanceUpdate): The balance update for the held tokens of the solid account.

  • solidOwedUpdate (BalanceUpdate): The balance update for the owed tokens of the solid account.

  • vaporOwedUpdate (BalanceUpdate): The balance update for the owed tokens of the vaporized account.

LogOperatorSet Event

Description:

This event is emitted when an account adds or removes another contract (or account) as an operator for itself.

Event Signature:

event LogOperatorSet(
    address indexed owner,
    address operator,
    bool trusted
);
  • owner (address): The owner of the account for which the operator status was updated.

  • operator (address): The address of the operator whose status was updated.

  • trusted (bool): The new status of the operator. true indicates the operator is trusted, while false indicates the operator is untrusted.

Market Events

LogIndexUpdate Event

Description:

This event is emitted when an interest index is updated for a specific market, indicating a change in the accrued borrow and supply values, as well as possibly a change in the borrow and supply rates. The interest index is updated, at-most, once per block. This event is emitted at the start of an Operation, before the Actions are processed.

Event Signature:

library Interest {
    struct Index {
        uint96 borrow;
        uint96 supply;
        uint32 lastUpdate;
    }
}

event LogIndexUpdate(
    uint256 indexed market,
    Interest.Index index
);
  • market (uint256): The identifier of the market for which the interest index was updated.

  • index (Interest.Index): The updated interest index for the market, containing information about the updated borrowing and supplying values used to convert borrow or supply Par to borrow or supply Wei.

LogOraclePrice Event

Description:

This event is emitted when an oracle price is retrieved for a specific market at the start of an Operation, before the Actions are processed. It specifies to data indexers and block explorers what the USD value of a market was during an Operation.

Event Signature:

library Monetary {
    /*
     * The price of a base-unit of an asset. Has `36 - token.decimals` decimals
     */
    struct Price {
        uint256 value;
    }
}

event LogOraclePrice(
    uint256 indexed market,
    Monetary.Price price
);
  • market (uint256): The identifier of the market for which the oracle price was updated.

  • price (Monetary.Price): The oracle price for the market during an Operation. Prices have 36 - token.decimals decimals, meaning a value of 1000000000000000000000000000000 corresponds with $1.00 for USDC (USDC has 6 decimals of precision).

Last updated