Skip to content

Commit

Permalink
Updated Lido integration (#159)
Browse files Browse the repository at this point in the history
* Update widgets.yaml

* feat: reth

* tested

* Update README.md

* Update display_widgets.py

* update for reth

* Update constants.py

* chore: update widget idx

* fix: use items

---------

Co-authored-by: marcomariscal <[email protected]>
  • Loading branch information
iamsahu and marcomariscal authored Sep 21, 2023
1 parent 7ee1d25 commit 2c34b57
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The usage guide for the Cacti chatbot is available [here](./usage_guide.md)

## Steps to add new widget command
- Update `widgets.yaml` with the widget command details
- If no value has to be returned please specify an empty string '' for `return_value_description`
- Increment the numeric version in `WIDGET_INDEX_NAME` constant in `utils/constants.py`
- For local env, the widget index name would use your OS login name to create an isolated index. For dev/prod, the widget index would be the numeric version mentioned above. (more info in `scripts/check_update_widget_index.py`)
- Run this Python command to update your widget index with the new widget `python -m scripts.check_update_widget_index`
Expand Down
14 changes: 13 additions & 1 deletion chat/display_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,25 @@ def _widgetize_inner(command: str, params: str, depth: int = 0) -> str:
lines.append(f"yield protocol borrow action for borrow token: {items[0]}, borrow amount: {items[1]}, collateral token: {items[2]}, collateral amount: {items[3]}.")
elif command == 'yield-protocol-borrow-close':
items = params.split(",")
lines.append(f"yield protocol borrow close action: {items[0]}")
lines.append(f"yield protocol borrow close action: {items[0]}")
elif command == 'hop-protocol-bridge':
items = params.split(",")
lines.append(f"hop protocol bridge action for amount: {items[0]}, token symbol: {items[1]}, from chain: {items[2]}, to chain: {items[3]}.")
elif command == 'tx-replay':
items = params.split(",")
lines.append(f"replay transaction with tx hash: {items[0]}")
elif command == "deposit-eth-lido":
items = params.split(",")
lines.append(f"deposit eth to lido action for amount: {items[0]}.")
elif command == "withdraw-eth-lido":
items = params.split(",")
lines.append(f"withdraw eth from lido action for amount: {items[0]}.")
elif command == "deposit-eth-reth":
items = params.split(",")
lines.append(f"deposit eth to reth action for amount: {items[0]}.")
elif command == "withdraw-eth-reth":
items = params.split(",")
lines.append(f"withdraw eth from reth action for amount: {items[0]}.")
else:
# assert 0, f'unrecognized command: {command}({params})'
lines.append(f"An unrecognized command: {command}({params})")
Expand Down
46 changes: 45 additions & 1 deletion knowledge_base/widgets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -731,4 +731,48 @@
required:
- txHash
type: object
return_value_description: ""
return_value_description: ""
- _name_: display_deposit_eth_lido
description: This widget is only used when the user wants to deposit/stake ETH into the Lido protocol to get steth
parameters:
properties:
amount:
description: Amount of ETH to deposit/stake into Lido (and obtain stETH)
type: string
required:
- amount
type: object
return_value_description: ''
- _name_: display_withdraw_eth_lido
description: This widget is only used when the user wants to withdraw ETH from Lido (convert stETH to ETH)
parameters:
properties:
amount:
description: Amount of ETH to withdraw from Lido
type: string
required:
- amount
type: object
return_value_description: ''
- _name_: deposit_eth_reth
description: This widget is only used when the user wants to deposit ETH into the rocket pool protocol to get rETH
parameters:
properties:
amount:
description: Amount of ETH to deposit into rocket pool (and obtain rETH)
type: string
required:
- amount
type: object
return_value_description: ''
- _name_: display_withdraw_eth_reth
description: This widget is only used when the user wants to withdraw ETH from rETH (convert rETH to ETH)
parameters:
properties:
amount:
description: Amount of ETH to withdraw from rocket pool
type: string
required:
- amount
type: object
return_value_description: ''
2 changes: 1 addition & 1 deletion utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
WIDGET_INFO_TOKEN_LIMIT = 4000

# Widget Index
WIDGET_INDEX_NAME = "WidgetV22"
WIDGET_INDEX_NAME = "WidgetV23"

def get_widget_index_name():
if env.is_local():
Expand Down

0 comments on commit 2c34b57

Please sign in to comment.