• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-eth-py / 17723951463

15 Sep 2025 06:20AM UTC coverage: 89.937% (-4.0%) from 93.974%
17723951463

Pull #1947

github

web-flow
Merge ad31bc77e into ee8dff1a4
Pull Request #1947: Bump mypy from 1.17.1 to 1.18.1

9223 of 10255 relevant lines covered (89.94%)

2.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.55
/safe_eth/eth/oracles/superfluid.py
1
from eth_abi.exceptions import DecodingError
3✔
2
from eth_utils import to_checksum_address
3✔
3
from web3.exceptions import Web3Exception
3✔
4

5
from .. import EthereumClient, EthereumNetwork
3✔
6
from .abis.superfluid_abis import super_token_abi
3✔
7
from .exceptions import CannotGetPriceFromOracle
3✔
8
from .oracles import PriceOracle
3✔
9

10

11
class SuperfluidOracle(PriceOracle):
3✔
12
    def __init__(self, ethereum_client: EthereumClient, price_oracle: PriceOracle):
3✔
13
        """
14
        :param ethereum_client:
15
        :param price_oracle: Price oracle to get the price for the components of Superfluid Tokens
16
        """
17
        self.ethereum_client = ethereum_client
×
18
        self.w3 = ethereum_client.w3
×
19
        self.price_oracle = price_oracle
×
20

21
    @classmethod
3✔
22
    def is_available(
3✔
23
        cls,
24
        ethereum_client: EthereumClient,
25
    ) -> bool:
26
        """
27
        :param ethereum_client:
28
        :return: `True` if Oracle is available for the EthereumClient provided, `False` otherwise
29
        """
30
        return ethereum_client.get_network() in (
×
31
            EthereumNetwork.POLYGON,
32
            EthereumNetwork.GNOSIS,
33
            EthereumNetwork.ARBITRUM_ONE,
34
            EthereumNetwork.OPTIMISM,
35
        )
36

37
    def get_price(self, token_address: str) -> float:
3✔
38
        try:
×
39
            token_address_checksum = to_checksum_address(token_address)
×
40
            underlying_token = (
×
41
                self.w3.eth.contract(
42
                    address=token_address_checksum, abi=super_token_abi
43
                )
44
                .functions.getUnderlyingToken()
45
                .call()
46
            )
47
            return self.price_oracle.get_price(underlying_token)
×
48
        except (Web3Exception, DecodingError, ValueError):
×
49
            raise CannotGetPriceFromOracle(
×
50
                f"Cannot get price for {token_address}. It is not a wrapper Super Token"
51
            )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc