Skip to content

Commit

Permalink
chore(AGENT-68): Superfluid Python Core Changelog (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
John-peterson-coinbase authored Jan 23, 2025
1 parent b60d98b commit 231042d
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 95 deletions.
6 changes: 6 additions & 0 deletions cdp-agentkit-core/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### Added

- Add action `superfluid_create_flow` to create a flow using Superfluid
- Add action `superfluid_update_flow` to update a flow using Superfluid
- Add action `superfluid_delete_flow` to delete a flow using Superfluid

## [0.0.10] - 2025-01-22

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,15 @@
class MorphoDepositInput(BaseModel):
"""Input schema for Morpho Vault deposit action."""

assets: str = Field(
...,
description="The quantity of assets to deposit, in whole units"
)
assets: str = Field(..., description="The quantity of assets to deposit, in whole units")
receiver: str = Field(
...,
description="The address that will own the position on the vault which will receive the shares"
description="The address that will own the position on the vault which will receive the shares",
)
token_address: str = Field(
...,
description="The address of the assets token to approve for deposit"
)
vault_address: str = Field(
...,
description="The address of the Morpho Vault to deposit to"
..., description="The address of the assets token to approve for deposit"
)
vault_address: str = Field(..., description="The address of the Morpho Vault to deposit to")


DEPOSIT_PROMPT = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,9 @@
class MorphoWithdrawInput(BaseModel):
"""Input schema for Morpho Vault withdraw action."""

vault_address: str = Field(
...,
description="The address of the Morpho Vault to withdraw from"
)
assets: str = Field(
...,
description="The amount of assets to withdraw in atomic units"
)
receiver: str = Field(
...,
description="The address to receive the withdrawn assets"
)
vault_address: str = Field(..., description="The address of the Morpho Vault to withdraw from")
assets: str = Field(..., description="The amount of assets to withdraw in atomic units")
receiver: str = Field(..., description="The address to receive the withdrawn assets")


WITHDRAW_PROMPT = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,22 @@
- The flowrate cannot have any decimal points, since the unit of measurement is wei per second.
- Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action.
- 1 wei = 0.000000000000000001 ETH
- This is supported on the following networks:
- Base Sepolia (ie, 'base-sepolia')
- Base Mainnet (ie, 'base', 'base-mainnet')
- Ethereum Mainnet (ie, 'ethereum', 'ethereum-mainnet')
- Polygon Mainnet (ie, 'polygon', 'polygon-mainnet')
- Arbitrum Mainnet (ie, 'arbitrum', 'arbitrum-mainnet')
- Optimism, Celo, Scroll, Avalanche, Gnosis, BNB Smart Chain, Degen Chain, Avalance Fuji, Optimism Sepolia and Scroll Sepolia
"""


class SuperfluidCreateFlowInput(BaseModel):
"""Input argument schema for creating a flow."""

recipient: str = Field(
...,
description="The wallet address of the recipient"
)
recipient: str = Field(..., description="The wallet address of the recipient")

token_address: str = Field(..., description="The address of the token that will be streamed")

token_address: str = Field(
...,
description="The address of the token that will be streamed"
)
flow_rate: str = Field(..., description="The flow rate of tokens in wei per second")

flow_rate: str = Field(
...,
description="The flow rate of tokens in wei per second"
)

def superfluid_create_flow(wallet: Wallet, recipient: str, token_address: str, flow_rate: str) -> str:
def superfluid_create_flow(
wallet: Wallet, recipient: str, token_address: str, flow_rate: str
) -> str:
"""Create a money flow using Superfluid.
Args:
Expand All @@ -70,8 +58,9 @@ def superfluid_create_flow(wallet: Wallet, recipient: str, token_address: str, f
"sender": wallet.default_address.address_id,
"receiver": recipient,
"flowrate": flow_rate,
"userData": "0x"
})
"userData": "0x",
},
)

invocation.wait()

Expand All @@ -80,6 +69,7 @@ def superfluid_create_flow(wallet: Wallet, recipient: str, token_address: str, f
except Exception as e:
return f"Error creating flow: {e!s}"


class SuperfluidCreateFlowAction(CdpAction):
"""Create flow action."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,16 @@
Inputs:
- Wallet address that the tokens are being streamed to or being streamed from
- Super token contract address
Important Notes:
- This is supported on the following networks:
- Base Sepolia (ie, 'base-sepolia')
- Base Mainnet (ie, 'base', 'base-mainnet')
- Ethereum Mainnet (ie, 'ethereum', 'ethereum-mainnet')
- Polygon Mainnet (ie, 'polygon', 'polygon-mainnet')
- Arbitrum Mainnet (ie, 'arbitrum', 'arbitrum-mainnet')
- Optimism, Celo, Scroll, Avalanche, Gnosis, BNB Smart Chain, Degen Chain, Avalance Fuji, Optimism Sepolia and Scroll Sepolia
"""


class SuperfluidDeleteFlowInput(BaseModel):
"""Input argument schema for deleting a flow."""

recipient: str = Field(
...,
description="The wallet address of the recipient"
)
recipient: str = Field(..., description="The wallet address of the recipient")

token_address: str = Field(..., description="The address of the token being flowed")

token_address: str = Field(
...,
description="The address of the token being flowed"
)

def superfluid_delete_flow(wallet: Wallet, recipient: str, token_address: str) -> str:
"""Delete an existing money flow using Superfluid.
Expand All @@ -59,15 +46,17 @@ def superfluid_delete_flow(wallet: Wallet, recipient: str, token_address: str) -
"token": token_address,
"sender": wallet.default_address.address_id,
"receiver": recipient,
"userData": "0x"
})
"userData": "0x",
},
)

invocation.wait()

return f"Flow deleted successfully. Result: {invocation}"
except Exception as e:
return f"Error deleting flow: {e!s}"


class SuperfluidDeleteFlowAction(CdpAction):
"""Delete flow action."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,22 @@
- The flowrate cannot have any decimal points, since the unit of measurement is wei per second.
- Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action.
- 1 wei = 0.000000000000000001 ETH
- This is supported on the following networks:
- Base Sepolia (ie, 'base-sepolia')
- Base Mainnet (ie, 'base', 'base-mainnet')
- Ethereum Mainnet (ie, 'ethereum', 'ethereum-mainnet')
- Polygon Mainnet (ie, 'polygon', 'polygon-mainnet')
- Arbitrum Mainnet (ie, 'arbitrum', 'arbitrum-mainnet')
- Optimism, Celo, Scroll, Avalanche, Gnosis, BNB Smart Chain, Degen Chain, Avalance Fuji, Optimism Sepolia and Scroll Sepolia
"""


class SuperfluidUpdateFlowInput(BaseModel):
"""Input argument schema for updating a flow."""

recipient: str = Field(
...,
description="The wallet address of the recipient"
)
recipient: str = Field(..., description="The wallet address of the recipient")

token_address: str = Field(..., description="The address of the token that is being streamed")

token_address: str = Field(
...,
description="The address of the token that is being streamed"
)
new_flow_rate: str = Field(..., description="The new flow rate of tokens in wei per second")

new_flow_rate: str = Field(
...,
description="The new flow rate of tokens in wei per second"
)

def superfluid_update_flow(wallet: Wallet, recipient: str, token_address: str, new_flow_rate: str) -> str:
def superfluid_update_flow(
wallet: Wallet, recipient: str, token_address: str, new_flow_rate: str
) -> str:
"""Update an existing money flow using Superfluid.
Args:
Expand All @@ -70,8 +58,9 @@ def superfluid_update_flow(wallet: Wallet, recipient: str, token_address: str, n
"sender": wallet.default_address.address_id,
"receiver": recipient,
"flowrate": new_flow_rate,
"userData": "0x"
})
"userData": "0x",
},
)

invocation.wait()

Expand All @@ -80,6 +69,7 @@ def superfluid_update_flow(wallet: Wallet, recipient: str, token_address: str, n
except Exception as e:
return f"Error updating flow: {e!s}"


class SuperfluidUpdateFlowAction(CdpAction):
"""Update flow action."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def test_create_flow_api_error(wallet_factory):
"""Test flow creation when API error occurs."""
mock_wallet = wallet_factory()

with patch.object(mock_wallet, "invoke_contract", side_effect=Exception("API error")) as mock_invoke_contract:
with patch.object(
mock_wallet, "invoke_contract", side_effect=Exception("API error")
) as mock_invoke_contract:
action_response = superfluid_create_flow(
mock_wallet, MOCK_RECIPIENT, MOCK_TOKEN_ADDRESS, MOCK_FLOW_RATE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def test_delete_flow_success(wallet_factory, contract_invocation_factory):
mock_contract_invocation, "wait", return_value=mock_contract_invocation
) as mock_contract_invocation_wait,
):
action_response = superfluid_delete_flow(
mock_wallet, MOCK_RECIPIENT, MOCK_TOKEN_ADDRESS
)
action_response = superfluid_delete_flow(mock_wallet, MOCK_RECIPIENT, MOCK_TOKEN_ADDRESS)

expected_response = f"Flow deleted successfully. Result: {mock_contract_invocation}"
assert action_response == expected_response
Expand All @@ -66,10 +64,10 @@ def test_delete_flow_api_error(wallet_factory):
"""Test flow deletion when API error occurs."""
mock_wallet = wallet_factory()

with patch.object(mock_wallet, "invoke_contract", side_effect=Exception("API error")) as mock_invoke_contract:
action_response = superfluid_delete_flow(
mock_wallet, MOCK_RECIPIENT, MOCK_TOKEN_ADDRESS
)
with patch.object(
mock_wallet, "invoke_contract", side_effect=Exception("API error")
) as mock_invoke_contract:
action_response = superfluid_delete_flow(mock_wallet, MOCK_RECIPIENT, MOCK_TOKEN_ADDRESS)

expected_response = "Error deleting flow: API error"
assert action_response == expected_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def test_update_flow_api_error(wallet_factory):
"""Test flow update when API error occurs."""
mock_wallet = wallet_factory()

with patch.object(mock_wallet, "invoke_contract", side_effect=Exception("API error")) as mock_invoke_contract:
with patch.object(
mock_wallet, "invoke_contract", side_effect=Exception("API error")
) as mock_invoke_contract:
action_response = superfluid_update_flow(
mock_wallet, MOCK_RECIPIENT, MOCK_TOKEN_ADDRESS, MOCK_NEW_FLOW_RATE
)
Expand Down

0 comments on commit 231042d

Please sign in to comment.