Skip to content

vault_module reads starknet_domain from EndpointsConfig, but it lives on SigningConfig. AttributeError on every vault deposit/withdraw. #99

@Gloom0x0

Description

@Gloom0x0

Version: x10-python-trading-starknet 1.4.0

Summary

Any call to trading_client.vault.deposit_to_vault(...) or withdraw_from_vault(...) raises
AttributeError: 'EndpointsConfig' object has no attribute 'starknet_domain'. The vault module is
unusable out of the box on 1.4.0.

Root cause

In x10/perpetual/trading_client/vault_module.py the module accesses starknet_domain through
_get_endpoint_config() (defined in BaseModule as return self.__config.endpoints):

# vault_module.py:91 (deposit_to_vault)
starknet_domain=self._get_endpoint_config().starknet_domain,
# vault_module.py:143 (withdraw_from_vault)
starknet_domain=self._get_endpoint_config().starknet_domain,                                              

But in x10/config.py the starknet_domain attribute is declared on SigningConfig, not
EndpointsConfig:

@dataclass(kw_only=True, frozen=True)
class SigningConfig:                                                                                      
    signing_domain: str
    starknet_domain: StarknetDomain   # <-- lives here                                                    
                                                                                                          
@dataclass(kw_only=True, frozen=True)
class EndpointsConfig:                                                                                    
    chain_rpc_url: str
    api_base_url: str
    ...
    vault_asset_name: str             # <-- no starknet_domain here

Config exposes both as separate fields (config.signing and config.endpoints), so reading
config.endpoints.starknet_domain always fails.

Reproduction

from decimal import Decimal
from x10.config import MAINNET_CONFIG
from x10.core.stark_account import StarkPerpetualAccount
from x10.perpetual.trading_client import PerpetualTradingClient                                           

account = StarkPerpetualAccount(vault=..., private_key=..., public_key=..., api_key=...)                  
client = PerpetualTradingClient(config=MAINNET_CONFIG, stark_account=account)                             

await client.vault.deposit_to_vault(collateral_amount=Decimal("5"))                                       
# AttributeError: 'EndpointsConfig' object has no attribute 'starknet_domain'                             

Suggested fix

Either:

  1. Add a _get_signing_config() helper to BaseModule and read from there in vault_module.py:

    # base_module.py
    def _get_signing_config(self):
        return self.__config.signing                                                                       
    
    # vault_module.py                                                                                      
    starknet_domain=self._get_signing_config().starknet_domain,
  2. Or read directly via self._BaseModule__config.signing.starknet_domain (less clean).

Option 1 is preferable, it keeps the access pattern symmetric with _get_endpoint_config() and avoids
touching the frozen dataclasses.

Current workaround

We patch starknet_domain onto EndpointsConfig at init time using object.__setattr__ (since it's a
frozen dataclass) so the existing vault_module code path works unchanged:

object.__setattr__(
    config.endpoints,
    "starknet_domain",
    config.signing.starknet_domain,
)                                                                                                         

Happy to open a PR if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions