Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.0.4 Core|0.0.6 CDP Langchain|0.0.4 Twitter Langchain #47

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cdp-agentkit-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## [0.0.4] - 2024-11-15

### Added

- Added `wow_buy_token` and `wow_sell_token`.
- Added `token_uri` to `wow_create_token` action for custom token metadata.
- Refactor twitter actions to conform to extendable `twitter-langchain` updates.
Expand Down
36 changes: 20 additions & 16 deletions cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,26 @@ def wow_buy_token(wallet: Wallet, contract_address: str, amount_eth_in_wei: str)
min_tokens = str(int((token_quote * 99) // 100)) # Using integer division to floor the result

has_graduated = get_has_graduated(wallet.network_id, contract_address)
invocation = wallet.invoke_contract(
contract_address=contract_address,
method="buy",
abi=WOW_ABI,
args={
"recipient": wallet.default_address.address_id,
"refundRecipient": wallet.default_address.address_id,
"orderReferrer": "0x0000000000000000000000000000000000000000",
"expectedMarketType": has_graduated and "1" or "0",
"minOrderSize": min_tokens,
"sqrtPriceLimitX96": "0",
"comment": "",
},
amount=amount_eth_in_wei,
asset_id="wei",
).wait()

try:
invocation = wallet.invoke_contract(
contract_address=contract_address,
method="buy",
abi=WOW_ABI,
args={
"recipient": wallet.default_address.address_id,
"refundRecipient": wallet.default_address.address_id,
"orderReferrer": "0x0000000000000000000000000000000000000000",
"expectedMarketType": has_graduated and "1" or "0",
"minOrderSize": min_tokens,
"sqrtPriceLimitX96": "0",
"comment": "",
},
amount=amount_eth_in_wei,
asset_id="wei",
).wait()
except Exception as e:
return f"Error buying Zora Wow ERC20 memecoin {e!s}"

return f"Purchased WoW ERC20 memecoin with transaction hash: {invocation.transaction.transaction_hash}"

Expand Down
31 changes: 17 additions & 14 deletions cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,23 @@ def wow_sell_token(wallet: Wallet, contract_address: str, amount_tokens_in_wei:
# Multiply by 98/100 and floor to get 98% of quote as minimum (slippage protection)
min_eth = str(int((eth_quote * 98) // 100))

invocation = wallet.invoke_contract(
contract_address=contract_address,
method="sell",
abi=WOW_ABI,
args={
"tokensToSell": str(amount_tokens_in_wei),
"recipient": wallet.default_address.address_id,
"orderReferrer": "0x0000000000000000000000000000000000000000",
"comment": "",
"expectedMarketType": "1" if has_graduated else "0",
"minPayoutSize": min_eth,
"sqrtPriceLimitX96": "0",
},
).wait()
try:
invocation = wallet.invoke_contract(
contract_address=contract_address,
method="sell",
abi=WOW_ABI,
args={
"tokensToSell": str(amount_tokens_in_wei),
"recipient": wallet.default_address.address_id,
"orderReferrer": "0x0000000000000000000000000000000000000000",
"comment": "",
"expectedMarketType": "1" if has_graduated else "0",
"minPayoutSize": min_eth,
"sqrtPriceLimitX96": "0",
},
).wait()
except Exception as e:
return f"Error selling Zora Wow ERC20 memecoin {e!s}"

return (
f"Sold WoW ERC20 memecoin with transaction hash: {invocation.transaction.transaction_hash}"
Expand Down
2 changes: 1 addition & 1 deletion cdp-agentkit-core/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

project = 'CDP Agentkit - Core'
author = 'Coinbase Developer Platform'
release = '0.0.3'
release = '0.0.4'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
180 changes: 90 additions & 90 deletions cdp-agentkit-core/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cdp-agentkit-core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cdp-agentkit-core"
version = "0.0.3"
version = "0.0.4"
description = "CDP Agentkit core primitives"
authors = ["John Peterson <john.peterson@coinbase.com>"]
readme = "README.md"
Expand Down
14 changes: 8 additions & 6 deletions cdp-agentkit-core/tests/actions/wow/test_buy_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ def test_buy_token_api_error(wallet_factory):
mock_wallet, "invoke_contract", side_effect=Exception("API error")
) as mock_invoke,
):
with pytest.raises(Exception, match="API error"):
wow_buy_token(
mock_wallet,
MOCK_CONTRACT_ADDRESS,
MOCK_AMOUNT_ETH,
)
action_response = wow_buy_token(
mock_wallet,
MOCK_CONTRACT_ADDRESS,
MOCK_AMOUNT_ETH,
)

expected_response = "Error buying Zora Wow ERC20 memecoin API error"

assert action_response == expected_response
mock_invoke.assert_called_once()
14 changes: 8 additions & 6 deletions cdp-agentkit-core/tests/actions/wow/test_sell_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ def test_sell_token_api_error(wallet_factory):
mock_wallet, "invoke_contract", side_effect=Exception("API error")
) as mock_invoke,
):
with pytest.raises(Exception, match="API error"):
wow_sell_token(
mock_wallet,
MOCK_CONTRACT_ADDRESS,
MOCK_AMOUNT_TOKENS,
)
action_response = wow_sell_token(
mock_wallet,
MOCK_CONTRACT_ADDRESS,
MOCK_AMOUNT_TOKENS,
)

expected_response = "Error selling Zora Wow ERC20 memecoin API error"

assert action_response == expected_response
mock_invoke.assert_called_once()
12 changes: 12 additions & 0 deletions cdp-langchain/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## Unreleased

## [0.0.6] - 2024-11-15

### Fixed

- Bump correlation header data package version.

## [0.0.5] - 2024-11-15

### Added

- Bump dependency `cdp-agentkit-core` to version `0.0.4`.

## [0.0.4] - 2024-11-10

### Added
Expand Down
2 changes: 1 addition & 1 deletion cdp-langchain/cdp_langchain/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.4"
__version__ = "0.0.6"
2 changes: 1 addition & 1 deletion cdp-langchain/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

project = 'CDP Agentkit - LangChain'
author = 'Coinbase Developer Platform'
release = '0.0.4'
release = '0.0.6'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
Loading
Loading