Skip to content

Follow a contract that names others ​

Ask stETH where the rest of Lido lives, then read the contract it names.

stETH holds one address it calls the locator, and the locator holds the addresses of everything else: the withdrawal queue, the treasury, the oracles. Two queries follow the trail. The one-query form is after them.

cql
let stETH = ethereum:0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84;

from stETH as s
| project { locator: s.getLidoLocator(), treasury: s.getTreasury() }

Open in workbench →

locatortreasury
ethereum:0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Ebethereum:0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c

Two addresses: the locator, and the treasury stETH names directly. Write the first as a let and ask it the same kind of question:

cql
let locator = ethereum:0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb;

from locator as l
| project { queue: l.withdrawalQueue(), treasury: l.treasury() }

Open in workbench →

queuetreasury
ethereum:0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1ethereum:0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c

The withdrawal queue, and the same treasury stETH gave — the two agree, which is the check.

How it reads ​

s.getLidoLocator() is a call that returns an address. An address in the grid carries a ⓘ. Press it, and the Contract tab shows what the contract is and what it offers. The second query is the first's answer written as a let. Neither query carries with { abi }, because both contracts are verified and CQL finds each ABI on its own.

In one query ​

The locator's address comes from s.getLidoLocator() while the query runs, so CQL has no ABI for it. Attach one where the address starts, and every call through the column uses it:

cql
let locatorAbi = abi ['function withdrawalQueue() view returns (address)',
                      'function treasury() view returns (address)'];
let stETH = ethereum:0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84;

from stETH as s
| project { locator: (s.getLidoLocator()) with { abi: locatorAbi } }
| project { locator, queue: locator.withdrawalQueue(), treasury: locator.treasury() }

Open in workbench →

This query makes the same calls as the two queries above, in one run. The parentheses are necessary. Without them, with applies to getLidoLocator() itself, and the calls through locator have no ABI (CQL2063). with options has the other places to attach one.

Variations ​

  • Keep going. The withdrawal queue is a contract too: let queue = ethereum:0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1; and q.unfinalizedStETH() is the stETH waiting to leave.
  • Many at once. A call can return a list rather than one value, such as the staking router's module ids. Then expand gives a row per element before the calls that use it: Unfold an array into rows. For a list of addresses, attach the ABI to the alias: expand … as d with { abi: v }.

See also ​