From b4fa25f4f519b12394f3cb631da48b70f3f0e444 Mon Sep 17 00:00:00 2001 From: setup Date: Sat, 8 Feb 2025 02:19:49 +0000 Subject: [PATCH 1/4] Change != to == in basic agent example The docs say it must be ==, but the code was != --- examples/basic_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic_agent.py b/examples/basic_agent.py index d8c21cd1..c9e26382 100644 --- a/examples/basic_agent.py +++ b/examples/basic_agent.py @@ -23,7 +23,7 @@ def main(): # Ensure that the wallet address and agent address are not the same # This prevents the risk of accidentally creating an agent using the wallet itself. - if exchange.account_address != exchange.wallet.address: + if exchange.account_address == exchange.wallet.address: raise Exception("You should not create an agent using an agent") approve_result, agent_key = exchange.approve_agent() From 1b61b9fc673e51cb09b5f8e8f4f2f4f7fbd314b9 Mon Sep 17 00:00:00 2001 From: setup Date: Sat, 8 Feb 2025 02:43:50 +0000 Subject: [PATCH 2/4] Fix bug: use extra_agent_exchange instead of agent_exchange --- examples/basic_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic_agent.py b/examples/basic_agent.py index c9e26382..c0252c4d 100644 --- a/examples/basic_agent.py +++ b/examples/basic_agent.py @@ -74,7 +74,7 @@ def main(): # Place an order with the extra agent using the same process as the original agent. print("Placing order with original agent") - order_result = agent_exchange.order("ETH", True, 0.2, 1000, {"limit": {"tif": "Gtc"}}) + order_result = extra_agent_exchange.order("ETH", True, 0.2, 1000, {"limit": {"tif": "Gtc"}}) print(order_result) # If the extra agent's order is placed successfully, attempt to cancel it. From 6c5277c27563b395547d89a0cca84f2d01c467df Mon Sep 17 00:00:00 2001 From: setup Date: Sat, 8 Feb 2025 02:48:59 +0000 Subject: [PATCH 3/4] Change docs & variable name to make more clear --- examples/basic_agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/basic_agent.py b/examples/basic_agent.py index c0252c4d..ec765f54 100644 --- a/examples/basic_agent.py +++ b/examples/basic_agent.py @@ -21,9 +21,9 @@ def main(): # Set up the environment (exchange, account info, etc.) for testing purposes. address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True) - # Ensure that the wallet address and agent address are not the same + # Ensure that the wallet address and agent address are the same # This prevents the risk of accidentally creating an agent using the wallet itself. - if exchange.account_address == exchange.wallet.address: + if address != exchange.wallet.address: raise Exception("You should not create an agent using an agent") approve_result, agent_key = exchange.approve_agent() From c7113aedb12ddf6a8c8ed273a6df090b06753ccb Mon Sep 17 00:00:00 2001 From: setup Date: Sat, 8 Feb 2025 03:35:52 +0000 Subject: [PATCH 4/4] Another attempt at better docs --- examples/basic_agent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/basic_agent.py b/examples/basic_agent.py index ec765f54..7e7a5719 100644 --- a/examples/basic_agent.py +++ b/examples/basic_agent.py @@ -21,8 +21,8 @@ def main(): # Set up the environment (exchange, account info, etc.) for testing purposes. address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True) - # Ensure that the wallet address and agent address are the same - # This prevents the risk of accidentally creating an agent using the wallet itself. + # Ensure that the wallet address and account address are the same. + # If these are not the same then an agent will be approved for the wallet address instead of the account address, and the order will fail. if address != exchange.wallet.address: raise Exception("You should not create an agent using an agent") @@ -73,7 +73,7 @@ def main(): print("Running with extra agent address:", extra_agent_account.address) # Place an order with the extra agent using the same process as the original agent. - print("Placing order with original agent") + print("Placing order with extra agent") order_result = extra_agent_exchange.order("ETH", True, 0.2, 1000, {"limit": {"tif": "Gtc"}}) print(order_result)