Compound
Examples
Note
These examples are crafted as a Jupyter notebook. You can download the original notebook file here.
Also note that inside Jupyter notebooks, await
can be used freely outside of asyncio.run()
.
In [1]:
from ctc.protocols import compound_utils
In [2]:
ctoken = '0x35a18000230da775cac24873d00ff85bccded550'
Get supply APY¶
In [3]:
await compound_utils.async_get_supply_apy(ctoken)
Out[3]:
0.003777415895703129
Get borrow APY¶
In [4]:
await compound_utils.async_get_borrow_apy(ctoken)
Out[4]:
0.05932247119699485
Get supply APY by block¶
In [5]:
blocks = [14000000, 14100000, 14200000]
await compound_utils.async_get_supply_apy_by_block(ctoken, blocks=blocks)
Out[5]:
[0.0015700051686593497, 0.002428224167829729, 0.0017380529006516543]
Get borrow APY by block¶
In [6]:
blocks = [14000000, 14100000, 14200000]
await compound_utils.async_get_borrow_apy_by_block(ctoken, blocks=blocks)
Out[6]:
[0.04338541891628256, 0.050325319640804, 0.04485273411875479]
Reference
- async ctc.protocols.compound_utils.async_get_borrow_apy(ctoken, block=None)
- async ctc.protocols.compound_utils.async_get_borrow_apy_by_block(ctoken, blocks)
- async ctc.protocols.compound_utils.async_get_supply_apy(ctoken, block=None)
- async ctc.protocols.compound_utils.async_get_supply_apy_by_block(ctoken, blocks)