Event signature · Lending

Borrow (Aave V2) event signature and topic0

The topic0 of the Borrow (Aave V2) event is 0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b, the keccak-256 hash of Borrow(address,address,address,uint256,uint256,uint256,uint16); 3 of its 7 arguments are indexed. Borrow taken on an Aave V2-style money market.

Anatomy of a Borrow (Aave V2) log

Topics

  • topic00xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9bkeccak256("Borrow(address,address,address,uint256,uint256,uint256,uint16)")
  • topic1reserve (address)indexed: filterable
  • topic2onBehalfOf (address)indexed: filterable
  • topic3referral (uint16)indexed: filterable

Data

  • datauser (address), amount (uint256), borrowRateMode (uint256), borrowRate (uint256)ABI-encoded, decoded with the ABI
Parameters

Arguments and where they sit in the log

Indexed arguments travel as topics and can be filtered cheaply; the others are ABI-encoded together in the data.

NameTypeIn the log
reserveaddresstopic1
useraddressdata
onBehalfOfaddresstopic2
amountuint256data
borrowRateModeuint256data
borrowRateuint256data
referraluint16topic3

Solidity declaration

event Borrow(address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral);

Canonical signature

Borrow(address,address,address,uint256,uint256,uint256,uint16)

topic0

0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b

Ready-made alerts

Get an alert on Borrow

Each rule opens with the contract and the conditions filled in. Sign in, pick your chat and click Create.

Code

Read Borrow logs in code

The same filter in viem, ethers and plain JSON-RPC, and the Solidity that emits it. Put in the address of the contract you read.

viem
import { createPublicClient, http, parseAbiItem } from "viem"
import { mainnet } from "viem/chains"

const client = createPublicClient({ chain: mainnet, transport: http() })

const logs = await client.getLogs({
  address: "0xYourContractAddress",
  event: parseAbiItem("event Borrow(address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral)"),
  fromBlock: "latest",
})

for (const log of logs) console.log(log.args) // { reserve, user, onBehalfOf, amount, borrowRateMode, borrowRate, referral }
ethers v6
import { Interface, JsonRpcProvider } from "ethers"

const provider = new JsonRpcProvider(process.env.RPC_URL)
const iface = new Interface(["event Borrow(address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral)"])

const logs = await provider.getLogs({
  address: "0xYourContractAddress",
  topics: [iface.getEvent("Borrow")!.topicHash],
})

for (const log of logs) console.log(iface.parseLog(log)?.args)
JSON-RPC (eth_getLogs)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getLogs",
  "params": [
    {
      "address": "0xYourContractAddress",
      "topics": [
        "0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b"
      ],
      "fromBlock": "latest"
    }
  ]
}
Solidity
event Borrow(address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral);

// inside a function:
emit Borrow(reserve, user, onBehalfOf, amount, borrowRateMode, borrowRate, referral);
Example

An example Borrow log, encoded and decoded

Placeholder values, not a real transaction: how each argument is stored in the topics and the data, and what decoding gives back.

Encoded (as the node returns it)
  • topic0keccak256("Borrow(address,address,address,uint256,uint256,uint256,uint16)")0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b
  • topic1reserve0x0000000000000000000000001111111111111111111111111111111111111111
  • topic2onBehalfOf0x0000000000000000000000003333333333333333333333333333333333333333
  • topic3referral0x0000000000000000000000000000000000000000000000000000000000000007
  • data0x00000000000000000000000022222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000fa000000000000000000000000000000000000000000000000000000000000013880000000000000000000000000000000000000000000000000000000000001770
Decoded with the ABI
  • reserveaddress · indexed0x1111111111111111111111111111111111111111
  • useraddress0x2222222222222222222222222222222222222222
  • onBehalfOfaddress · indexed0x3333333333333333333333333333333333333333
  • amountuint2564000
  • borrowRateModeuint2565000
  • borrowRateuint2566000
  • referraluint16 · indexed7
FAQ

Frequently asked questions

What is the topic0 of the Borrow (Aave V2) event?

0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b: the keccak-256 hash of Borrow(address,address,address,uint256,uint256,uint256,uint16).

Which Borrow (Aave V2) arguments are indexed?

reserve, onBehalfOf, referral are indexed and sit in the log's topics; user, amount, borrowRateMode, borrowRate are in the data.

How do I get an alert when a contract emits Borrow (Aave V2)?

Open one of the ready-made rules on this page, or add any contract and pick Borrow (Aave V2) from the event list. Conditions can be set on indexed and non-indexed arguments, and each alert names the contract and links to the transaction.

Keep exploring

More event signatures and tools

Know the moment a contract emits it

The Beta plan is free: one wallet and one contract, no credit card.