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

safe-global / safe-eth-py / 18643788944

20 Oct 2025 06:10AM UTC coverage: 89.949% (-4.0%) from 93.927%
18643788944

Pull #2055

github

web-flow
Merge bca00d803 into 8eac6367d
Pull Request #2055: Bump psycopg[binary] from 3.2.9 to 3.2.11

9227 of 10258 relevant lines covered (89.95%)

1.8 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
2✔
2
from eth_utils import to_checksum_address
2✔
3
from web3.exceptions import Web3Exception
2✔
4

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

10

11
class SuperfluidOracle(PriceOracle):
2✔
12
    def __init__(self, ethereum_client: EthereumClient, price_oracle: PriceOracle):
2✔
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
2✔
22
    def is_available(
2✔
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:
2✔
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