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

feat: operator rollapps #50

Merged
merged 21 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
da24d0c
WIP
zale144 Oct 2, 2024
005d2b4
Refactor, add tests, fix bugs
zale144 Oct 5, 2024
06cdbba
Test the whole client with necessary abstractions
zale144 Oct 6, 2024
b9c91af
Various improvements, add p2p mode test, feed orders through events, …
zale144 Oct 6, 2024
cb3e594
Bug fixes, manual finalization, update tests
zale144 Oct 8, 2024
82a2e26
Add packet key to demand order, finalize by packet key
zale144 Oct 8, 2024
eb15527
Merge remote-tracking branch 'origin/main' into zale144/fulfillment-m…
zale144 Oct 8, 2024
26ab6b0
Query status for finalizing check, listen to status update event, add…
zale144 Oct 10, 2024
48d8889
Add get bot and list bots endpoints, refactor everything to move clie…
zale144 Oct 15, 2024
c4fb8e4
Rely on authorizations instead of topping up balances for bots, remov…
zale144 Oct 19, 2024
dcb958f
Optimize creating bot accounts and granting fees to them
zale144 Oct 19, 2024
3228083
Implement LP, improve error handling and balance tracking, client uni…
zale144 Oct 24, 2024
e6b3d85
Update readme file
zale144 Oct 24, 2024
1fb9fb9
Update readme file
zale144 Oct 24, 2024
2e5f202
Config rollapps individually
zale144 Oct 27, 2024
750cb33
Update readme
zale144 Oct 29, 2024
998a4d8
Update cosmos client
zale144 Oct 30, 2024
84c6713
Update structure: per rollapp criteria
zale144 Nov 1, 2024
8b34bf5
fulfill order authorization spend limit per rollapp
zale144 Nov 10, 2024
687b2d4
shuffle LPs before selecting the best one for the order
zale144 Nov 11, 2024
5411746
fixes
zale144 Nov 11, 2024
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
82 changes: 59 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,69 @@ eibc-client is a bot designed to continuously scan for eIBC demand orders and fu

## Features

- **Account Setup**: The bot is configured with a Dymension account that can be found in the local keyring. The account is used to fulfill demand orders.
- **Order Scanning**: The bot scans the hub for demand orders that are unfulfilled and have not expired.
- Gets unfulfilled demand orders from the indexer by polling periodically
- Gets orders from events emitted by the Hub for new demand orders.
- **Order Fulfillment Criteria**:
- An order needs to provide the minimum amount of fee earnings to the operator and the LP
- The Rollapp where the order comes needs to be supported by at least one LP
- The Denom of the order needs to be supported by at least one LP
- The order needs to be within the max price of the LP
- The order needs to be within the spend limit of the LP
- **LP Grants Refresh**: The bot periodically refreshes its list of LP grants to ensure it has the most up-to-date LP information.
- **Order Fulfillment**: The bot fulfills unfulfilled pending demand orders it finds on the hub, by sourcing the funds from LPs.
- **Fee/Gas Payment**: The operator grants all the running bot accounts the permission to pay for fees on their behalf.
- **Concurrency**: Run multiple bots concurrently to fulfill orders faster. Also, fulfill multiple orders per transaction.

- **Order Refresh**: The bot periodically refreshes its demand order list to ensure it has the most up-to-date information.
Apart from refreshing the order list, the bot also checks for new orders by subscribing to eIBC events.

- **Order Fulfillment**: The bot fulfills unfulfilled pending demand orders it finds on the hub.
## Setup

- **Balance Checks**: Every time the bot attempts to fulfill orders it will first check its balances for the denominations it needs to fulfill them.
If it lacks funds for a particular denomination as specified in the order price, it will send an alert by posting a message on Slack,
and will skip trying to fulfill that order until its account is topped up.
To set up the bot, you need to have Go installed on your machine. Once Go is installed, you can clone this repository and run the bot.

- **Gas Payment**: The bot uses DYM coins to pay for gas. If it runs out of DYM coins, it will send an alert by posting a message on Slack,
and will pause all order fulfillments until it is topped up.
- **Operator Setup**: The eibc client will expect certain environment to be set up before it can run.
1. The operator account needs to be set up with some adym coins to pay for gas/fees.
dymd keys add operator
2. A group needs to be created where the operator account is the admin:

dymd tx group create-group operator --keyring-backend test "==A" members.json --fees 1dym -y

members.json
```
{
"members": [
{
"address": "<operator_address>",
"weight": "1", "metadata": "president"
}
]
}
```
3. The group needs a policy that can be granted by LPs in order to source funds from them and sign order fulfillment messages on their behalf:

dymd tx group create-group-policy operator 1 "==A" policy.json --fees 1dym -y

policy.json
```
{
"@type": "/cosmos.group.v1.PercentageDecisionPolicy",
"percentage": "0.0001",
"windows": {
"voting_period": "1s",
"min_execution_period": "0s"
}
}
```

- **Order Cleanup**: The bot periodically checks and flushes fulfilled demand orders.
4. At least one LP needs to grant authorization to the group to fulfill orders:

## Setup

To set up the bot, you need to have Go installed on your machine. Once Go is installed, you can clone this repository and run the bot.
dymd tx eibc grant <POLICY_ADDRESS> \
--from lp_key --keyring-backend test \
--spend-limit 10000adym \
--rollapp rollapp1 \
--denoms "adym,uatom" \
--min-lp-fee-percentage "0.1" \
--max-price 10000adym \
--operator-fee-share 0.1 \
--settlement-validated --fees 1dym -y

## Usage

Expand All @@ -33,13 +77,5 @@ To run the bot, use the following command:
```bash
make install

eibc-client --config <path-to-config-file>
```

### Docker

```bash
make docker-build

docker run -v <path-to-config-file>:/.eibc-client.yaml eibc-client --config /.eibc-client.yaml
eibc-client start --config <path-to-config-file>
```
Loading
Loading