diff --git a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py index 6098d6786..dd2108f56 100644 --- a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py +++ b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py @@ -23,25 +23,25 @@ class WowBuyTokenInput(BaseModel): description="The WOW token contract address, such as `0x036CbD53842c5426634e7929541eC2318f3dCF7e`", ) - amount_eth: str = Field( + amount_eth_in_wei: str = Field( ..., description="Amount of ETH to spend (in wei), meaning 1 is 1 wei or 0.000000000000000001 of ETH", ) -def wow_buy_token(wallet: Wallet, contract_address: str, amount_eth: str) -> str: +def wow_buy_token(wallet: Wallet, contract_address: str, amount_eth_in_wei: str) -> str: """Buy a Zora Wow ERC20 memecoin with ETH. Args: wallet (Wallet): The wallet to create the token from. contract_address (str): The WOW token contract address, such as `0x036CbD53842c5426634e7929541eC2318f3dCF7e` - amount_eth (str): Amount of ETH to spend (in wei), meaning 1 is 1 wei or 0.000000000000000001 of ETH + amount_eth_in_wei (str): Amount of ETH to spend (in wei), meaning 1 is 1 wei or 0.000000000000000001 of ETH Returns: str: A message containing the token purchase details. """ - token_quote = get_buy_quote(wallet.network_id, contract_address, amount_eth) + token_quote = get_buy_quote(wallet.network_id, contract_address, amount_eth_in_wei) # Multiply by 99/100 and floor to get 99% of quote as minimum min_tokens = str(int((token_quote * 99) // 100)) # Using integer division to floor the result @@ -60,7 +60,7 @@ def wow_buy_token(wallet: Wallet, contract_address: str, amount_eth: str) -> str "sqrtPriceLimitX96": "0", # TODO "comment": "", }, - amount=amount_eth, + amount=amount_eth_in_wei, asset_id="wei", ).wait() diff --git a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/quotes.py b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/quotes.py index 68c500d59..1b82a5eaf 100644 --- a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/quotes.py +++ b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/quotes.py @@ -21,49 +21,49 @@ def get_current_supply(token_address): return test -def get_buy_quote(network_id: str, token_address: str, amount_eth: str): +def get_buy_quote(network_id: str, token_address: str, amount_eth_in_wei: str): """Get quote for buying tokens. Args: network_id: Network ID, which is either `base-sepolia` or `base-mainnet` token_address: Address of the token contract, such as `0x036CbD53842c5426634e7929541eC2318f3dCF7e` - amount_eth: Amount of ETH to buy (in wei), meaning 1 is 1 wei or 0.000000000000000001 of ETH + amount_eth_in_wei: Amount of ETH to buy (in wei), meaning 1 is 1 wei or 0.000000000000000001 of ETH """ has_graduated = get_has_graduated(network_id, token_address) token_quote = ( has_graduated - and (get_uniswap_quote(network_id, token_address, amount_eth, "buy")).amount_out + and (get_uniswap_quote(network_id, token_address, amount_eth_in_wei, "buy")).amount_out or SmartContract.read( network_id, token_address, "getEthBuyQuote", abi=WOW_ABI, - args={"ethOrderSize": str(amount_eth)}, + args={"ethOrderSize": str(amount_eth_in_wei)}, ) ) return token_quote -def get_sell_quote(network_id: str, token_address: str, amount_tokens: str): +def get_sell_quote(network_id: str, token_address: str, amount_tokens_in_wei: str): """Get quote for selling tokens. Args: network_id: Network ID, which is either `base-sepolia` or `base-mainnet` token_address: Address of the token contract, such as `0x036CbD53842c5426634e7929541eC2318f3dCF7e` - amount_tokens (str): Amount of tokens to sell (in wei), meaning 1 is 1 wei or 0.000000000000000001 of the token + amount_tokens_in_wei (str): Amount of tokens to sell (in wei), meaning 1 is 1 wei or 0.000000000000000001 of the token """ has_graduated = get_has_graduated(network_id, token_address) token_quote = ( has_graduated - and (get_uniswap_quote(network_id, token_address, amount_tokens, "sell")).amount_out + and (get_uniswap_quote(network_id, token_address, amount_tokens_in_wei, "sell")).amount_out or SmartContract.read( network_id, token_address, "getTokenSellQuote", WOW_ABI, - args={"tokenOrderSize": str(amount_tokens)}, + args={"tokenOrderSize": str(amount_tokens_in_wei)}, ) ) return token_quote diff --git a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py index 72205c558..dc4d0cb77 100644 --- a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py +++ b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py @@ -23,25 +23,25 @@ class WowSellTokenInput(BaseModel): description="The WOW token contract address, such as `0x036CbD53842c5426634e7929541eC2318f3dCF7e`", ) - amount_tokens: str = Field( + amount_tokens_in_wei: str = Field( ..., description="Amount of tokens to sell (in wei), meaning 1 is 1 wei or 0.000000000000000001 of the token", ) -def wow_sell_token(wallet: Wallet, contract_address: str, amount_tokens: str): +def wow_sell_token(wallet: Wallet, contract_address: str, amount_tokens_in_wei: str): """Sell WOW tokens for ETH. Args: wallet (Wallet): The wallet to sell the tokens from. contract_address (str): The WOW token contract address, such as `0x036CbD53842c5426634e7929541eC2318f3dCF7e` - amount_tokens (str): Amount of tokens to sell (in wei), meaning 1 is 1 wei or 0.000000000000000001 of the token + amount_tokens_in_wei (str): Amount of tokens to sell (in wei), meaning 1 is 1 wei or 0.000000000000000001 of the token Returns: str: A message confirming the sale with the transaction hash """ - eth_quote = get_sell_quote(wallet.network_id, contract_address, amount_tokens) + eth_quote = get_sell_quote(wallet.network_id, contract_address, amount_tokens_in_wei) has_graduated = get_has_graduated(wallet.network_id, contract_address) # Multiply by 98/100 and floor to get 98% of quote as minimum (slippage protection) @@ -52,7 +52,7 @@ def wow_sell_token(wallet: Wallet, contract_address: str, amount_tokens: str): method="sell", abi=WOW_ABI, args={ - "tokensToSell": str(amount_tokens), + "tokensToSell": str(amount_tokens_in_wei), "recipient": wallet.default_address.address_id, "orderReferrer": "0x0000000000000000000000000000000000000000", "comment": "",