All packages

ekubo_v3

moodysalem
v0.1.0/1 downloads/Repository

Package ref

ekubo-v3@v0.1.0

Run package

CLI

Run map_events from the command line.

substreams run ekubo-v3@v0.1.0 map_events -e mainnet --start-block -1
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

Ekubo v3 Substreams

A Substreams package that decodes every log emitted by the Ekubo v3 contracts on Ethereum and Arbitrum One, in chain order.

Unlike the subgraph in the parent directory, it reads every block's receipts directly, so it includes every swap, oracle snapshot, TWAMM virtual order execution and BoostedFees donation. Those are logged without topics, and a subgraph can only reach them through another event in the same transaction.

Output

map_events outputs ekubo.v3.Events (see proto/ekubo/v3/events.proto): one Event per log, with the block, transaction and log index, the emitting contract, and one decoded payload:

ContractPayloads
CorePoolInitialized, Swapped, PositionUpdated, PositionFeesCollected, FeesAccumulated, ExtensionRegistered
OracleOracleSnapshot
TWAMM (both)OrderUpdated, OrderProceedsWithdrawn, VirtualOrdersExecuted
BoostedFees (both)PoolBoosted, FeesDonated
Positions, OrdersNonfungibleTokenTransfer
AuctionsNonfungibleTokenTransfer, AuctionCompleted, AuctionFundsAdded, AuctionBoostStarted, CreatorProceedsCollected
IncentivesIncentivesFunded, IncentivesRefunded
TokenWrapperFactoryTokenWrapperDeployed

Integers that can exceed 64 bits are decimal strings. Square root prices are 64.128 fixed point numbers, decoded from the compact form the contracts emit. PositionUpdated also carries the pool's price, tick and active liquidity after the update. Blocks without a log from these contracts are skipped with the ethereum_common event index.

Build and run

Requires Rust with the wasm32-unknown-unknown target, protoc, and the substreams CLI.

cargo build --target wasm32-unknown-unknown --release
substreams pack
# Needs a Substreams API key from https://thegraph.market
substreams run ekubo-v3-v0.1.0.spkg map_events -s 26198900 -t +200
substreams run ekubo-v3-v0.1.0.spkg map_events --network arbitrum-one -s 416469410 -t +1000

Tests

cargo test

tests/mainnet.rs replays every log the contracts emitted on Ethereum in blocks 26198900 to 26199108 and checks the count of each event against an independent count of the same range on Dune, including the one transaction in that range that the subgraph cannot reach. Decoder tests compare against values from the parsers of the Ekubo indexer.

License

MIT. See LICENSE.

Modules

Execution graph

3 modules
Show 2 dependencies
map

ethereum_common:all_events

`all_events` gives you all the events in a block (from successful transactions), with basic block hash/number/timestamp and transaction hash

Output

sf.substreams.ethereum.v1.Events

blockIndex

ethereum_common:index_events

`index_events` sets the following keys on the block: * Event signatures evt_sig:0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (signature in hex, prefixed by 0x) * Event address evt_addr:0x0123456789abcdef0123456789abcdef01234567 (address in hex, prefixed by 0x)

Output

sf.substreams.index.v1.Keys