Skip to content

Commit f63dcc1

Browse files
committed
docs: update README
1 parent 25c2552 commit f63dcc1

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

README.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,51 @@ WBTC-WETH (V3, 0.30%)
159159
}
160160
```
161161

162+
## Uniswap V4 Liquidity Pools
163+
Uniswap V4 introduces hooks and a new pool manager architecture. The `UniswapV4Pool` class provides access to V4 pools with support for the new features.
164+
165+
```
166+
>>> lp = degenbot.UniswapV4Pool(
167+
... pool_id='0x96d4b53a38337a5733179751781178a2613306063c511b78cd02684739288c0a',
168+
... pool_manager_address='0x498581fF718922c3f8e6A244956aF099B2652b2b',
169+
... state_view_address='0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71',
170+
... tokens=[
171+
... '0x0000000000000000000000000000000000000000',
172+
... '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
173+
... ],
174+
... fee=500,
175+
... tick_spacing=10
176+
... )
177+
ETH-USDC (UniswapV4Pool, id=0x96d4b53a38337a5733179751781178a2613306063c511b78cd02684739288c0a)
178+
• ID: 0x96d4b53a38337a5733179751781178a2613306063c511b78cd02684739288c0a
179+
• Token 0: ETH
180+
• Token 1: USDC
181+
• Liquidity: 60429069420043934
182+
• SqrtPrice: 4220772448119892035402666
183+
• Tick: -196812
184+
185+
# Calculate output for a 1 ETH swap
186+
>>> lp.calculate_tokens_out_from_tokens_in(
187+
... token_in=lp.token0,
188+
... token_in_quantity=1*10**18,
189+
... )
190+
2834164215
191+
192+
# Inspect active hooks
193+
>>> lp.active_hooks
194+
frozenset()
195+
196+
# Get pool key information
197+
>>> lp.pool_key
198+
UniswapV4PoolKey(
199+
currency0='0x0000000000000000000000000000000000000000',
200+
currency1='0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
201+
fee=500,
202+
tick_spacing=10,
203+
hooks='0x0000000000000000000000000000000000000000'
204+
)
205+
```
206+
162207
## Forking With Anvil
163208
The `AnvilFork` class is used to launch a fork with `anvil` from the [Foundry](https://github.com/foundry-rs/foundry) toolkit. The object provides a `w3` attribute, connected to an IPC socket, which can be used to communicate with the fork like a typical RPC.
164209

@@ -233,7 +278,8 @@ Users wanting fine-grained control over **all** client options may pass them thr
233278
anvil_opts=['--optimism']
234279
)
235280
236-
# Launch with a non-default hardfork, which may be necessary for accurate simulation on a historical block.
281+
# Launch with a non-default hardfork, which may be necessary for accurate simulation on a
282+
# historical block.
237283
>>> fork = degenbot.AnvilFork(
238284
fork_url='http://localhost:8545',
239285
fork_block=12_980_000,
@@ -324,4 +370,31 @@ ArbitrageCalculationResult(
324370
),
325371
state_block=22676748
326372
)
373+
```
374+
375+
## Chainlink Price Feeds
376+
Chainlink price feeds provide reliable oracle data for various assets. The `ChainlinkPriceContract` class simplifies access to these feeds.
377+
378+
```
379+
# Load the price feed for ETH/USD
380+
>>> price_feed = degenbot.ChainlinkPriceContract(
381+
... '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
382+
... )
383+
384+
>>> price_feed.price
385+
2836.68731709
386+
387+
# Check the decimals used by the price feed
388+
>>> price_feed.decimals
389+
8
390+
391+
# Call an arbitrary function `latestRoundData` on the underlying contract
392+
>>> price_feed.w3_contract.functions.latestRoundData().call()
393+
[
394+
129127208515966883788,
395+
283668731709,
396+
1766031970,
397+
1766031983,
398+
129127208515966883788
399+
]
327400
```

0 commit comments

Comments
 (0)