diff --git a/pyproject.toml b/pyproject.toml index e9df25e..e89f2c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "vertex-protocol" -version = "1.1.19" +version = "1.1.20" description = "Vertex Protocol SDK" authors = ["Jeury Mejia "] homepage = "https://vertexprotocol.com/" diff --git a/tests/vertex_client/test_create_vertex_client.py b/tests/vertex_client/test_create_vertex_client.py index 3a7eb98..7efb00c 100644 --- a/tests/vertex_client/test_create_vertex_client.py +++ b/tests/vertex_client/test_create_vertex_client.py @@ -132,22 +132,45 @@ def test_create_vertex_client( assert mainnet_vertex_client.context.indexer_client.url == VertexBackendURL.MAINNET assert mainnet_vertex_client.context.engine_client.signer == signer - testnet_vertex_client = create_vertex_client( + sepolia_testnet_vertex_client = create_vertex_client( VertexClientMode.SEPOLIA_TESTNET, signer ) - assert testnet_vertex_client.context.engine_client.chain_id == chain_id - assert testnet_vertex_client.context.engine_client.endpoint_addr == endpoint_addr - assert testnet_vertex_client.context.engine_client.book_addrs == book_addrs + assert sepolia_testnet_vertex_client.context.engine_client.chain_id == chain_id assert ( - testnet_vertex_client.context.engine_client.url + sepolia_testnet_vertex_client.context.engine_client.endpoint_addr + == endpoint_addr + ) + assert sepolia_testnet_vertex_client.context.engine_client.book_addrs == book_addrs + assert ( + sepolia_testnet_vertex_client.context.engine_client.url == VertexBackendURL.SEPOLIA_TESTNET ) assert ( - testnet_vertex_client.context.indexer_client.url + sepolia_testnet_vertex_client.context.indexer_client.url == VertexBackendURL.SEPOLIA_TESTNET ) - assert testnet_vertex_client.context.engine_client.signer == signer + assert sepolia_testnet_vertex_client.context.engine_client.signer == signer + + mantle_testnet_vertex_client = create_vertex_client( + VertexClientMode.MANTLE_TESTNET, signer + ) + + assert mantle_testnet_vertex_client.context.engine_client.chain_id == chain_id + assert ( + mantle_testnet_vertex_client.context.engine_client.endpoint_addr + == endpoint_addr + ) + assert mantle_testnet_vertex_client.context.engine_client.book_addrs == book_addrs + assert ( + mantle_testnet_vertex_client.context.engine_client.url + == VertexBackendURL.MANTLET_TESTNET + ) + assert ( + mantle_testnet_vertex_client.context.indexer_client.url + == VertexBackendURL.MANTLET_TESTNET + ) + assert mantle_testnet_vertex_client.context.engine_client.signer == signer devnet_vertex_client = create_vertex_client(VertexClientMode.TESTING, signer) diff --git a/vertex_protocol/client/__init__.py b/vertex_protocol/client/__init__.py index 9da9ed3..8c76501 100644 --- a/vertex_protocol/client/__init__.py +++ b/vertex_protocol/client/__init__.py @@ -28,6 +28,8 @@ class VertexClientMode(StrEnum): SEPOLIA_TESTNET: For operating in Vertex's testnet environment deployed on Arbitrum Sepolia. + MANTLE_TESTNET: For operating in Vertex's testnet environment deployed on Mantle Goerli. + DEVNET: For local development. TESTING: For running tests. @@ -35,6 +37,7 @@ class VertexClientMode(StrEnum): MAINNET = "mainnet" SEPOLIA_TESTNET = "sepolia-testnet" + MANTLE_TESTNET = "mantle-testnet" DEVNET = "devnet" TESTING = "testing" @@ -101,6 +104,7 @@ def create_vertex_client( mode (VertexClientMode): The mode in which to operate the client. Can be one of the following: VertexClientMode.MAINNET: For operating in Vertex's mainnet environment deployed on Arbitrum One. VertexClientMode.SEPOLIA_TESTNET: For operating in Vertex's testnet environment deployed on Arbitrum Sepolia. + VertexClientMode.MANTLE_TESTNET: For operating in Vertex's testnet environment deployed on Mantle Goerli. VertexClientMode.DEVNET: For local development. signer (Signer, optional): An instance of LocalAccount or a private key string for signing transactions. @@ -114,9 +118,11 @@ def create_vertex_client( logging.info(f"Initializing default {mode} context") engine_endpoint_url, indexer_endpoint_url, network_name = client_mode_to_setup(mode) try: - deployment = load_deployment(VertexNetwork(network_name)) + network = VertexNetwork(network_name) + deployment = load_deployment(network) rpc_node_url = deployment.node_url contracts_context = VertexContractsContext( + network=network, endpoint_addr=deployment.endpoint_addr, querier_addr=deployment.querier_addr, perp_engine_addr=deployment.perp_engine_addr, @@ -168,6 +174,11 @@ def client_mode_to_setup( VertexBackendURL.MAINNET.value, VertexNetwork.ARBITRUM_ONE.value, ), + VertexClientMode.MANTLE_TESTNET: ( + VertexBackendURL.MANTLET_TESTNET.value, + VertexBackendURL.MANTLET_TESTNET.value, + VertexNetwork.MANTLE_GOERLI.value, + ), VertexClientMode.SEPOLIA_TESTNET: ( VertexBackendURL.SEPOLIA_TESTNET.value, VertexBackendURL.SEPOLIA_TESTNET.value, diff --git a/vertex_protocol/contracts/__init__.py b/vertex_protocol/contracts/__init__.py index 3cf2439..0b33f34 100644 --- a/vertex_protocol/contracts/__init__.py +++ b/vertex_protocol/contracts/__init__.py @@ -34,6 +34,7 @@ class VertexContractsContext(BaseModel): clearinghouse_addr (Optional[str]): The clearinghouse address. This may be None. """ + network: Optional[VertexNetwork] endpoint_addr: str querier_addr: str spot_engine_addr: Optional[str] @@ -47,6 +48,7 @@ class VertexContracts: """ w3: Web3 + network: Optional[VertexNetwork] contracts_context: VertexContractsContext querier: Contract endpoint: Contract @@ -66,6 +68,7 @@ def __init__(self, node_url: str, contracts_context: VertexContractsContext): contracts_context (VertexContractsContext): The Vertex contracts context, holding the relevant addresses. """ + self.network = contracts_context.network self.w3 = Web3(Web3.HTTPProvider(node_url)) self.contracts_context = VertexContractsContext.parse_obj(contracts_context) @@ -223,7 +226,11 @@ def _build_tx_params(self, signer: LocalAccount) -> TxParams: "from": signer.address, "nonce": self.w3.eth.get_transaction_count(signer.address), } - if os.getenv("CLIENT_MODE") == "devnet": + needs_gas_price = self.network is not None and self.network.value in [ + VertexNetwork.HARDHAT.value, + VertexNetwork.MANTLE_GOERLI.value, + ] + if needs_gas_price or os.getenv("CLIENT_MODE") in ["devnet"]: tx_params["gasPrice"] = self.w3.eth.gas_price return tx_params diff --git a/vertex_protocol/contracts/deployments/deployment.mantleGoerli.json b/vertex_protocol/contracts/deployments/deployment.mantleGoerli.json new file mode 100644 index 0000000..36c0658 --- /dev/null +++ b/vertex_protocol/contracts/deployments/deployment.mantleGoerli.json @@ -0,0 +1,14 @@ +{ + "publicNodeUrl": "https://mantle-goerli.public.blastapi.io", + "explorerUrl": "https://explorer.testnet.mantle.xyz/", + "startBlock": 26921136, + "deployer": "0x3c06e307BA6Ab81E8Ff6661c1559ce8027744AE5", + "quote": "0xA7Fcb606611358afa388b6bd23b3B2F2c6abEd82", + "querier": "0x6f5F5d9Cb93062dd1d684c6694Fee7bbBE94eD6B", + "feeCalculator": "0xA1DbC395Cbaa8c7b74456697C42ADa8F2b08CAbb", + "clearinghouse": "0x1a77cB939B7C4fA5Cc90b09787260DABf5f05c41", + "endpoint": "0xB61B069d741C98DA3302986BF107aA9083b64133", + "spotEngine": "0xEC1149dF1559eaDB0Af4cf6d9BeAc7a08Aa9f694", + "perpEngine": "0x19a4B178654F42Ea994347D514ED9E4f99221Ba2", + "arbAirdrop": "0x0000000000000000000000000000000000000000" +} diff --git a/vertex_protocol/contracts/types.py b/vertex_protocol/contracts/types.py index b42d9ef..c2316fe 100644 --- a/vertex_protocol/contracts/types.py +++ b/vertex_protocol/contracts/types.py @@ -12,6 +12,7 @@ class VertexNetwork(StrEnum): ARBITRUM_ONE = "arbitrumOne" ARBITRUM_SEPOLIA = "arbitrumSepolia" + MANTLE_GOERLI = "mantleGoerli" HARDHAT = "localhost" TESTING = "test" diff --git a/vertex_protocol/utils/backend.py b/vertex_protocol/utils/backend.py index c99e103..4f1448c 100644 --- a/vertex_protocol/utils/backend.py +++ b/vertex_protocol/utils/backend.py @@ -4,6 +4,7 @@ class VertexBackendURL(StrEnum): """Enum representing different Vertex backend URLs.""" + MANTLET_TESTNET = "https://api.mantle-test.vertexprotocol.com" SEPOLIA_TESTNET = "https://api.sepolia-test.vertexprotocol.com" MAINNET = "https://api.prod.vertexprotocol.com" DEVNET_ENGINE = "http://localhost:80"