gnosis.eth.oracles package
Subpackages
Submodules
gnosis.eth.oracles.oracles module
- class gnosis.eth.oracles.oracles.AaveOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
PriceOracle- get_price(token_address: str) float
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.oracles.BalancerOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
PricePoolOracleOracle for Balancer. More info on https://balancer.exchange
- get_pool_token_price(pool_token_address: ChecksumAddress) float
Estimate balancer pool token price based on its components
- Parameters:
pool_token_address – Balancer pool token address
- Returns:
Eth price for pool token
- Raises:
CannotGetPriceFromOracle
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.oracles.BaseOracle
Bases:
ABC- abstract classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.oracles.ComposedPriceOracle
Bases:
BaseOracle- abstract get_underlying_tokens(*args) List[Tuple[UnderlyingToken]]
- class gnosis.eth.oracles.oracles.CreamOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
PriceOracle- get_price(token_address: str) float
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.oracles.CurveOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ZerionComposedOracleCurve pool Oracle. More info on https://curve.fi/
- ZERION_ADAPTER_ADDRESS = '0x99b0bEadc3984eab9842AF81f9fad0C2219108cc'
- get_underlying_tokens(token_address: ChecksumAddress) List[UnderlyingToken]
Check if passed token address is a Curve gauge deposit token, if it’s a gauge we replace the address with the corresponding LP token address More info on https://resources.curve.fi/base-features/understanding-gauges
- class gnosis.eth.oracles.oracles.EnzymeOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ZerionComposedOracleEnzyme pool Oracle. More info on https://enzyme.finance/
- ZERION_ADAPTER_ADDRESS = '0x9e71455D748C23566b19493D09435574097C7D67'
- class gnosis.eth.oracles.oracles.MooniswapOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
BalancerOracle- get_pool_token_price(pool_token_address: ChecksumAddress) float
Estimate balancer pool token price based on its components
- Parameters:
pool_token_address – Moniswap pool token address
- Returns:
Eth price for pool token
- Raises:
CannotGetPriceFromOracle
- class gnosis.eth.oracles.oracles.PoolTogetherOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ZerionComposedOraclePoolTogether pool Oracle. More info on https://pooltogether.com/
- ZERION_ADAPTER_ADDRESS = '0xb4E0E1672fFd9b128784dB9f3BE9158fac3f1DFc'
- class gnosis.eth.oracles.oracles.PriceOracle
Bases:
BaseOracle- abstract get_price(*args) float
- class gnosis.eth.oracles.oracles.PricePoolOracle
Bases:
BaseOracle- abstract get_pool_token_price(pool_token_address: ChecksumAddress) float
- class gnosis.eth.oracles.oracles.UnderlyingToken(address: eth_typing.evm.ChecksumAddress, quantity: int)
Bases:
object- address: ChecksumAddress
- quantity: int
- class gnosis.eth.oracles.oracles.UniswapOracle(ethereum_client: EthereumClient, uniswap_factory_address: str | None = None)
Bases:
PriceOracleUniswap V1 Oracle
https://docs.uniswap.org/protocol/V1/guides/connect-to-uniswap
- ADDRESSES = {EthereumNetwork.GOERLI: '0x6Ce570d02D73d4c384b46135E87f8C592A8c86dA', EthereumNetwork.MAINNET: '0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95', EthereumNetwork.RINKEBY: '0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36', EthereumNetwork.ROPSTEN: '0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351'}
- get_price(token_address: str) float
- get_uniswap_exchange(token_address: str) str
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- property uniswap_factory
- property uniswap_factory_address
- class gnosis.eth.oracles.oracles.UniswapV2Oracle(ethereum_client: EthereumClient, router_address: str | None = None)
Bases:
PricePoolOracle,PriceOracle- PAIR_INIT_CODE = HexBytes('0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f')
- ROUTER_ADDRESSES = {EthereumNetwork.MAINNET: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'}
- calculate_pair_address(token_address: str, token_address_2: str)
Calculate pair address without querying blockchain. https://uniswap.org/docs/v2/smart-contract-integration/getting-pair-addresses/#docs-header
- Parameters:
token_address –
token_address_2 –
- Returns:
Checksummed address for token pair. It could be not created yet
- property factory
- property factory_address: str
- Returns:
Uniswap factory checksummed address
- Raises:
Web3Exception: If router contract is not deployed
- get_pair_address(token_address: str, token_address_2: str) str | None
Get uniswap pair address. token_address and token_address_2 are interchangeable. https://uniswap.org/docs/v2/smart-contracts/factory/
- Parameters:
token_address –
token_address_2 –
- Returns:
Address of the pair for token_address and token_address_2, if it has been created, else None.
- get_pool_token_price(pool_token_address: ChecksumAddress) float
Estimate pool token price based on its components
- Parameters:
pool_token_address –
- Returns:
Pool token eth price per unit (total pool token supply / 1e18)
- Raises:
CannotGetPriceFromOracle
- get_price(token_address: str, token_address_2: str | None = None) float
- get_price_without_exception(token_address: str, token_address_2: str | None = None) float
- Parameters:
token_address –
token_address_2 –
- Returns:
Call get_price, return 0. instead on an exception if there’s any issue
- get_reserves(pair_address: str) Tuple[int, int]
Returns the number of tokens in the pool. getReserves() also returns the block.timestamp (mod 2**32) of the last block during which an interaction occurred for the pair, but it’s ignored. https://uniswap.org/docs/v2/smart-contracts/pair/
- Returns:
Reserves of token_address and token_address_2 used to price trades and distribute liquidity.
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- property weth_address: str
- Returns:
Wrapped ether checksummed address
- Raises:
Web3Exception: If router contract is not deployed
- class gnosis.eth.oracles.oracles.YearnOracle(ethereum_client: EthereumClient, yearn_vault_token_adapter: str | None = '0xb460FcC1B6c1CBD7D03F47B6BD5F03994d286c75', iearn_token_adapter: str | None = '0x65B23774daE2a5be02dD275918DDF048d177a5B4')
Bases:
ComposedPriceOracleYearn oracle. More info on https://docs.yearn.finance
- get_underlying_tokens(token_address: ChecksumAddress) List[Tuple[float, ChecksumAddress]]
- Parameters:
token_address –
- Returns:
Price per share and underlying token
- Raises:
CannotGetPriceFromOracle
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.oracles.ZerionComposedOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ComposedPriceOracle- ZERION_ADAPTER_ADDRESS = None
- get_underlying_tokens(token_address: ChecksumAddress) List[UnderlyingToken]
Use Zerion Token adapter to return underlying components for pool
- Parameters:
token_address – Pool token address
- Returns:
Price per share and underlying token
- Raises:
CannotGetPriceFromOracle
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- property zerion_adapter_contract: Contract | None
Module contents
- class gnosis.eth.oracles.AaveOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
PriceOracle- get_price(token_address: str) float
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.BalancerOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
PricePoolOracleOracle for Balancer. More info on https://balancer.exchange
- get_pool_token_price(pool_token_address: ChecksumAddress) float
Estimate balancer pool token price based on its components
- Parameters:
pool_token_address – Balancer pool token address
- Returns:
Eth price for pool token
- Raises:
CannotGetPriceFromOracle
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.ComposedPriceOracle
Bases:
BaseOracle- abstract get_underlying_tokens(*args) List[Tuple[UnderlyingToken]]
- class gnosis.eth.oracles.CowswapOracle(ethereum_client: EthereumClient)
Bases:
PriceOracleCowSwap Oracle implementation
https://docs.cow.fi/off-chain-services/api
- get_price(token_address_1: str, token_address_2: str | None = None) float
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if CowSwap is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.CreamOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
PriceOracle- get_price(token_address: str) float
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.CurveOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ZerionComposedOracleCurve pool Oracle. More info on https://curve.fi/
- ZERION_ADAPTER_ADDRESS = '0x99b0bEadc3984eab9842AF81f9fad0C2219108cc'
- get_underlying_tokens(token_address: ChecksumAddress) List[UnderlyingToken]
Check if passed token address is a Curve gauge deposit token, if it’s a gauge we replace the address with the corresponding LP token address More info on https://resources.curve.fi/base-features/understanding-gauges
- class gnosis.eth.oracles.EnzymeOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ZerionComposedOracleEnzyme pool Oracle. More info on https://enzyme.finance/
- ZERION_ADAPTER_ADDRESS = '0x9e71455D748C23566b19493D09435574097C7D67'
- class gnosis.eth.oracles.KyberOracle(ethereum_client: EthereumClient, kyber_network_proxy_address: str | None = None)
Bases:
PriceOracleKyberSwap Legacy Oracle
https://docs.kyberswap.com/Legacy/addresses/addresses-mainnet
- ADDRESSES = {EthereumNetwork.MAINNET: '0x9AAb3f75489902f3a48495025729a0AF77d4b11e', EthereumNetwork.RINKEBY: '0x0d5371e5EE23dec7DF251A8957279629aa79E9C5', EthereumNetwork.ROPSTEN: '0xd719c34261e099Fdb33030ac8909d5788D3039C4'}
- ETH_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
- get_price(token_address_1: str, token_address_2: str = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE') float
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- property kyber_network_proxy_address
- property kyber_network_proxy_contract
- class gnosis.eth.oracles.MooniswapOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
BalancerOracle- get_pool_token_price(pool_token_address: ChecksumAddress) float
Estimate balancer pool token price based on its components
- Parameters:
pool_token_address – Moniswap pool token address
- Returns:
Eth price for pool token
- Raises:
CannotGetPriceFromOracle
- class gnosis.eth.oracles.PoolTogetherOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ZerionComposedOraclePoolTogether pool Oracle. More info on https://pooltogether.com/
- ZERION_ADAPTER_ADDRESS = '0xb4E0E1672fFd9b128784dB9f3BE9158fac3f1DFc'
- class gnosis.eth.oracles.PriceOracle
Bases:
BaseOracle- abstract get_price(*args) float
- class gnosis.eth.oracles.PricePoolOracle
Bases:
BaseOracle- abstract get_pool_token_price(pool_token_address: ChecksumAddress) float
- class gnosis.eth.oracles.SuperfluidOracle(ethereum_client: EthereumClient, price_oracle: PriceOracle)
Bases:
PriceOracle- get_price(token_address: str) float
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.SushiswapOracle(ethereum_client: EthereumClient, router_address: str | None = None)
Bases:
UniswapV2Oracle- PAIR_INIT_CODE = HexBytes('0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303')
- ROUTER_ADDRESSES = {EthereumNetwork.ARBITRUM_ONE: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.AVALANCHE_C_CHAIN: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.BNB_SMART_CHAIN_MAINNET: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.CELO_MAINNET: '0x1421bDe4B10e8dd459b3BCb598810B1337D56842', EthereumNetwork.FANTOM_OPERA: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.FUSE_MAINNET: '0xF4d73326C13a4Fc5FD7A064217e12780e9Bd62c3', EthereumNetwork.GNOSIS: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.HUOBI_ECO_CHAIN_MAINNET: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.MAINNET: '0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F', EthereumNetwork.MOONBEAM: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.MOONRIVER: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.OKXCHAIN_MAINNET: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.PALM: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', EthereumNetwork.POLYGON: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506'}
- class gnosis.eth.oracles.UnderlyingToken(address: eth_typing.evm.ChecksumAddress, quantity: int)
Bases:
object- address: ChecksumAddress
- quantity: int
- class gnosis.eth.oracles.UniswapOracle(ethereum_client: EthereumClient, uniswap_factory_address: str | None = None)
Bases:
PriceOracleUniswap V1 Oracle
https://docs.uniswap.org/protocol/V1/guides/connect-to-uniswap
- ADDRESSES = {EthereumNetwork.GOERLI: '0x6Ce570d02D73d4c384b46135E87f8C592A8c86dA', EthereumNetwork.MAINNET: '0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95', EthereumNetwork.RINKEBY: '0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36', EthereumNetwork.ROPSTEN: '0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351'}
- get_price(token_address: str) float
- get_uniswap_exchange(token_address: str) str
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- property uniswap_factory
- property uniswap_factory_address
- class gnosis.eth.oracles.UniswapV2Oracle(ethereum_client: EthereumClient, router_address: str | None = None)
Bases:
PricePoolOracle,PriceOracle- PAIR_INIT_CODE = HexBytes('0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f')
- ROUTER_ADDRESSES = {EthereumNetwork.MAINNET: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'}
- calculate_pair_address(token_address: str, token_address_2: str)
Calculate pair address without querying blockchain. https://uniswap.org/docs/v2/smart-contract-integration/getting-pair-addresses/#docs-header
- Parameters:
token_address –
token_address_2 –
- Returns:
Checksummed address for token pair. It could be not created yet
- property factory
- property factory_address: str
- Returns:
Uniswap factory checksummed address
- Raises:
Web3Exception: If router contract is not deployed
- get_pair_address(token_address: str, token_address_2: str) str | None
Get uniswap pair address. token_address and token_address_2 are interchangeable. https://uniswap.org/docs/v2/smart-contracts/factory/
- Parameters:
token_address –
token_address_2 –
- Returns:
Address of the pair for token_address and token_address_2, if it has been created, else None.
- get_pool_token_price(pool_token_address: ChecksumAddress) float
Estimate pool token price based on its components
- Parameters:
pool_token_address –
- Returns:
Pool token eth price per unit (total pool token supply / 1e18)
- Raises:
CannotGetPriceFromOracle
- get_price(token_address: str, token_address_2: str | None = None) float
- get_price_without_exception(token_address: str, token_address_2: str | None = None) float
- Parameters:
token_address –
token_address_2 –
- Returns:
Call get_price, return 0. instead on an exception if there’s any issue
- get_reserves(pair_address: str) Tuple[int, int]
Returns the number of tokens in the pool. getReserves() also returns the block.timestamp (mod 2**32) of the last block during which an interaction occurred for the pair, but it’s ignored. https://uniswap.org/docs/v2/smart-contracts/pair/
- Returns:
Reserves of token_address and token_address_2 used to price trades and distribute liquidity.
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- router_address: str
- property weth_address: str
- Returns:
Wrapped ether checksummed address
- Raises:
Web3Exception: If router contract is not deployed
- class gnosis.eth.oracles.UniswapV3Oracle(ethereum_client: EthereumClient, uniswap_v3_router_address: ChecksumAddress | None = None)
Bases:
PriceOracle- DEFAULT_ROUTER_ADDRESS = '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'
- PRICE_CONVERSION_CONSTANT = 6277101735386680763835789423207666416102355444464034512896
- ROUTER_ADDRESSES = {EthereumNetwork.CELO_MAINNET: '0x5615CDAb10dc425a742d643d949a7F474C01abc4', EthereumNetwork.MAINNET: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'}
- get_factory() Contract
Factory contract creates the pools for token pairs
- Returns:
Uniswap V3 Factory Contract
- get_pool_address(token_address: str, token_address_2: str, fee: int | None = 3000) ChecksumAddress | None
Get pool address for tokens with a given fee (by default, 0.3)
- Parameters:
token_address –
token_address_2 –
fee – Uniswap V3 uses 0.3 as the default fee
- Returns:
Pool address
- get_price(token_address: str, token_address_2: str | None = None) float
- Parameters:
token_address –
token_address_2 –
- Returns:
price for token_address related to token_address_2. If token_address_2 is not provided, Wrapped Eth address will be used
- classmethod is_available(ethereum_client: EthereumClient, uniswap_v3_router_address: ChecksumAddress | None = None) bool
- Parameters:
ethereum_client –
uniswap_v3_router_address – Provide a custom SwapRouter02 address
- Returns:
True if Uniswap V3 is available for the EthereumClient provided, False otherwise
- property router: Contract
Router knows about the Uniswap Factory and Wrapped Eth addresses for the network
- Returns:
Uniswap V3 Router Contract
- property weth_address: ChecksumAddress
- Returns:
Wrapped ether checksummed address
- class gnosis.eth.oracles.YearnOracle(ethereum_client: EthereumClient, yearn_vault_token_adapter: str | None = '0xb460FcC1B6c1CBD7D03F47B6BD5F03994d286c75', iearn_token_adapter: str | None = '0x65B23774daE2a5be02dD275918DDF048d177a5B4')
Bases:
ComposedPriceOracleYearn oracle. More info on https://docs.yearn.finance
- get_underlying_tokens(token_address: ChecksumAddress) List[Tuple[float, ChecksumAddress]]
- Parameters:
token_address –
- Returns:
Price per share and underlying token
- Raises:
CannotGetPriceFromOracle
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- class gnosis.eth.oracles.ZerionComposedOracle(ethereum_client: EthereumClient, zerion_adapter_address: str | None = None)
Bases:
ComposedPriceOracle- ZERION_ADAPTER_ADDRESS = None
- get_underlying_tokens(token_address: ChecksumAddress) List[UnderlyingToken]
Use Zerion Token adapter to return underlying components for pool
- Parameters:
token_address – Pool token address
- Returns:
Price per share and underlying token
- Raises:
CannotGetPriceFromOracle
- classmethod is_available(ethereum_client: EthereumClient) bool
- Parameters:
ethereum_client –
- Returns:
True if Oracle is available for the EthereumClient provided, False otherwise
- property zerion_adapter_contract: Contract | None