Skip to content

Commit 2ef7e25

Browse files
authored
Add Gate liquidity provider (#3)
* Add Gate liquidity provider
1 parent b4e73a7 commit 2ef7e25

File tree

41 files changed

+1224
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1224
-311
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12-
- name: Setup Golang with cache
13-
uses: magnetikonline/action-golang-cache@v4
14-
with:
15-
go-version-file: go.mod
1612
- name: golangci-lint
1713
uses: golangci/golangci-lint-action@v3
1814
with:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.vscode
33
local
44
.run
5-
*.yaml
5+
./*.yaml
66
omni-balance.db
77
start.sh
88
*.json

README.md

Lines changed: 171 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -54,192 +54,191 @@ Omni Balance is an intelligent liquidity management tool designed to achieve sea
5454
#### Supported Commands
5555

5656
```sh
57+
USAGE:
58+
omni-balance [global options] command [command options]
59+
5760
COMMANDS:
58-
version, v show version
59-
list list supported providers and docs
60-
tasks list supported tasks
61-
example create a example config file
62-
help, h Shows a list of commands or help for one command
61+
gate_liquidity Create an order for the liquidity of Gate.
62+
del_order delete order by id
63+
version, v show version
64+
list list supported providers and docs
65+
tasks list supported tasks
66+
example create a example config file
67+
help, h Shows a list of commands or help for one command
6368

6469
GLOBAL OPTIONS:
65-
66-
--conf value, -c value (default: "./config.yaml")
70+
71+
--conf value, -c value (default: "./config.yaml")
6772
config file path
68-
69-
--placeholder, -p (default: false)
70-
enable placeholder, you can use placeholder to replace private key, Example: Fill '{{privateKey}}' in config.yaml. Run with -p to enable placeholder: SERVER_PORT=:8080 omni-balance -c ./config.yaml -p. Waiting for 'waiting for placeholder...' log, send placeholder
71-
data according to the prompt.
72-
73-
--port value (default: ":8080")
73+
74+
--placeholder, -p (default: false)
75+
enable placeholder, you can use placeholder to replace private key, Example:
76+
Fill '{{privateKey}}' in config.yaml.Run with -p to enable placeholder, Example:
77+
SERVER_PORT=:8080
78+
/var/folders/b9/kgdbsh096b76234g3nhxg2qh0000gn/T/go-build3443181796/b001/exe/cmd
79+
-c ./config.yaml -pWaiting for 'waiting for placeholder...' log, send
80+
placeholder data according to the prompt.
81+
82+
--port value (default: ":8080")
7483
When the placeholder parameter is set to true, you can specify and set the
7584
listening address of the HTTP server that receives the placeholder.
7685

7786
MISC
78-
--help, -h show help
87+
88+
89+
--help, -h (default: false)
90+
show help
7991
```
8092
#### Configuration
93+
94+
##### Example
95+
96+
* [global_config.yaml](./example/global_config.yaml): A generic example configuration for global settings.
97+
* [gate_liquidity_config.yaml](./example/gate_liquidity_config.yaml): An example configuration for providing liquidity to the Gate.io exchange.
98+
* [general_config.yaml](./example/general_config.yaml): An example configuration for standard addresses swapping liquidity between two chains.
99+
* [helix_liquidity_config.yaml](./example/helix_liquidity_config.yaml): An example configuration that, when checking address balances, includes both on-chain balances and unclaimed HelixBridge balances for evaluation.
100+
* [operator_safe_config.yaml](./example/operator_safe_config.yaml): An example configuration for scenarios where the operator address utilizes a multi-signature setup.
101+
102+
##### Configuration Reference
81103
```
82-
# Debug mode
83104
debug: true
84-
# Chains
105+
apiKey: "999999999999"
106+
# All utilized blockchain networks along with their corresponding tokens must be defined here.
85107
chains:
86-
- # Chain id
87-
id: 1
88-
# Chain name
89-
name: etnereum
90-
# Native token name, if not set, use the 0x0000000000000000000000000000000000000000
91-
nativetoken: "ETH"
92-
# RPC endpoints
93-
rpc_endpoints:
94-
- https://api.tatum.io/v3/blockchain/node/ethereum-mainnet
95-
- https://ethereum-rpc.publicnode.com
96-
# Tokens
97-
tokens:
98-
- # Token name
99-
name: ETH
100-
# Token contract address
101-
contract_address: "0x0000000000000000000000000000000000000000"
102-
# Token decimals
103-
decimals: 18
104-
- # Token name
105-
name: RING
106-
# Token contract address
107-
contract_address: 0x9469D013805bFfB7D3DEBe5E7839237e535ec483
108-
# Token decimals
109-
decimals: 18
110-
- # Token name
111-
name: USDT
112-
# Token contract address
113-
contract_address: 0xdAC17F958D2ee523a2206206994597C13D831ec7
114-
# Token decimals
115-
decimals: 6
116-
- # Chain id
117-
id: 42161
118-
# Chain name
119-
name: arbitrum
120-
# Native token name, if not set, use the 0x0000000000000000000000000000000000000000
121-
nativetoken: "ETH"
122-
# RPC endpoints
123-
rpc_endpoints:
124-
- https://1rpc.io/arb
125-
- https://arbitrum.llamarpc.com
126-
# Tokens
127-
tokens:
128-
- # Token name
129-
name: ETH
130-
# Token contract address
131-
contract_address: "0x0000000000000000000000000000000000000000"
132-
# Token decimals
133-
decimals: 18
134-
- # Token name
135-
name: USDT
136-
# Token contract address
137-
contract_address: 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9
138-
# Token decimals
139-
decimals: 6
140-
- # Token name
141-
name: RING
142-
# Token contract address
143-
contract_address: 0x9e523234D36973f9e38642886197D023C88e307e
144-
# Token decimals
145-
decimals: 18
146-
# Source token used to buy other tokens
147-
source_token:
148-
- # Token name
149-
name: USDT
150-
# Chain name
151-
chains:
152-
- etnereum
153-
- arbitrum
154-
- # Token name
155-
name: ETH
156-
# Chain name
157-
chains:
158-
- etnereum
159-
- arbitrum
160-
# Liquidity providers
161-
liquidity_providers:
162-
- # Type liquidity provider type
163-
type: CEX
164-
# LiquidityName liquidity provider name
165-
liquidity_name: gate.io
166-
# Config liquidity provider config, depend on the type
167-
config:
168-
key: <gate_api_key>
169-
secret: <gate_api_secret>
170-
- # Type liquidity provider type
171-
type: DEX
172-
# LiquidityName liquidity provider name
173-
liquidity_name: uniswap
174-
- # Type liquidity provider type
175-
type: Bridge
176-
# LiquidityName liquidity provider name
177-
liquidity_name: helixbridge
178-
- # Type liquidity provider type
179-
type: Bridge
180-
# LiquidityName liquidity provider name
181-
liquidity_name: darwinia-bridge
182-
# Wallets need to rebalance
183-
wallets:
184-
- # Wallet address
185-
address: 0x43Ef13E84D9992d1461a1f90CAc4653658CEA4FD
186-
# If set, when the 'address' balance is insufficient, the operator address will be used to rebalance
187-
operator: ""
188-
# Tokens to be monitored
189-
tokens:
190-
- # Token name
191-
name: ETH
192-
# The number of each rebalance
193-
amount: "1"
194-
# Threshold when the token balance is less than the threshold, the rebalance will be triggered
195-
threshold: "2"
196-
# The chains need to be monitored
197-
chains:
198-
- ethereum
199-
# Wallet private key. If operator is not empty, private_key is the operator's private key
200-
private_key: <wallet1_private_key>
201-
- # Wallet address
202-
address: 0x43Ef13E84D9992d1461a1f90CAc4653658CEA4FD
203-
# If set, when the 'address' balance is insufficient, the operator address will be used to rebalance
204-
operator: "0x178D8546C5f78e01133858958355B06EC3406A1A"
205-
# Tokens to be monitored
206-
tokens:
207-
- # Token name
208-
name: RING
209-
# The number of each rebalance
210-
amount: "20000"
211-
# Threshold when the token balance is less than the threshold, the rebalance will be triggered
212-
threshold: "10000"
213-
# The chains need to be monitored
214-
chains:
215-
- ethereum
216-
- arbitrum
217-
# Wallet private key. If operator is not empty, private_key is the operator's private key
218-
private_key: <wallet2_private_key>
219-
# Database config, must set one of them
108+
- id: 42161 # Chain ID
109+
name: arbitrum # Chain name
110+
nativeToken: "ETH" # Native token of the chain; if not provided, defaults to the token with contract address set to zero.
111+
rpcEndpoints: # List of RPC endpoints; multiple entries can be specified, and requests will cycle through these.
112+
- https://arb1.arbitrum.io/rpc
113+
- https://arbitrum.llamarpc.com
114+
- https://arb-mainnet-public.unifra.io
115+
- https://arbitrum.rpc.subquery.network/public
116+
- https://1rpc.io/arb
117+
tokens: # All required tokens must be configured.
118+
- name: ETH # Token name
119+
contractAddress: "0x0000000000000000000000000000000000000000" # Token contract address
120+
decimals: 18 # Token decimal places; must be specified.
121+
- name: USDT
122+
contractAddress: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
123+
decimals: 6
124+
- name: RING
125+
contractAddress: "0x9e523234D36973f9e38642886197D023C88e307e"
126+
decimals: 18
127+
- id: 137
128+
name: polygon
129+
nativeToken: "MATIC"
130+
rpcEndpoints:
131+
- https://polygon-rpc.com
132+
tokens:
133+
- name: MATIC
134+
contractAddress: "0x0000000000000000000000000000000000000000"
135+
decimals: 18
136+
- name: USDT
137+
contractAddress: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
138+
decimals: 6
139+
- id: 1
140+
name: ethereum
141+
nativeToken: "ETH"
142+
rpcEndpoints:
143+
- https://eth.llamarpc.com
144+
- https://rpc.ankr.com/eth
145+
- https://1rpc.io/eth
146+
- https://ethereum-rpc.publicnode.com
147+
tokens:
148+
- name: ETH
149+
contractAddress: "0x0000000000000000000000000000000000000000"
150+
decimals: 18
151+
- name: RING
152+
contractAddress: 0x9469D013805bFfB7D3DEBe5E7839237e535ec483
153+
decimals: 18
154+
- id: 534352
155+
name: scroll
156+
nativeToken: "ETH"
157+
rpcEndpoints:
158+
- https://rpc.scroll.io
159+
- https://scroll.drpc.org
160+
- https://1rpc.io/scroll
161+
tokens:
162+
- name: ETH
163+
contractAddress: "0x0000000000000000000000000000000000000000"
164+
decimals: 18
165+
- name: USDT
166+
contractAddress: 0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df
167+
decimals: 6
168+
169+
# During rebalancing, tokens from the following configuration will be selected to determine the optimal route for swaps.
170+
sourceTokens:
171+
- name: ETH # Token name, must match the token name in the 'chains' section.
172+
chains: # On which chains this token can be used as a source token.
173+
- arbitrum
174+
- scroll
175+
- ethereum
176+
- name: USDT
177+
chains:
178+
- arbitrum
179+
- scroll
180+
- ethereum
181+
- name: RING
182+
chains:
183+
- arbitrum
184+
- ethereum
185+
186+
# Providers that need to be enabled.
187+
providers:
188+
- type: CEX
189+
name: gate.io
190+
config:
191+
key: <gate_api_key>
192+
secret: <gate_api_secret>
193+
- type: DEX
194+
name: uniswap
195+
- type: Bridge
196+
name: helixbridge
197+
config: {}
198+
- type: Bridge
199+
name: darwinia-bridge
200+
- type: Bridge
201+
liquidityName: router_nitro
202+
config: {}
203+
- type: Bridge
204+
liquidityName: okx
205+
config:
206+
apiKey: "xxxx"
207+
secretKey: "xxxx"
208+
passphrase: "xxxxx"
209+
project: "xxxxx"
210+
211+
# Database storage settings.
220212
db:
221-
# MYSQL config
222-
MYSQL:
223-
host: ""
224-
port: ""
225-
user: ""
226-
password: ""
227-
database: ""
228-
# POSTGRESQL config
229-
POSTGRESQL:
230-
host: ""
231-
port: ""
232-
user: ""
233-
password: ""
234-
database: ""
235-
# SQLITE config
236-
SQLITE:
237-
path: /data/omni-balance.db
238-
task_interval:
239-
cross_chain: 1m
240-
get_token_price_in_usdt: 1m
241-
monitor_wallet_balance: 1m
242-
rebalance: 1m
213+
type: SQLite # Database type; options include: MySQL, PostgreSQL, SQLite.
214+
SQLITE: # SQLite configuration.
215+
path: ./omni-balance.db
216+
217+
# Task execution intervals.
218+
taskInterval:
219+
crossChain: 30m # Interval for processing cross-chain order tasks.
220+
getTokenPriceInUsdt: 30m # Interval for fetching token price tasks.
221+
bot: 2m # Interval for running bot tasks, primarily for creating orders.
222+
market: 2m # Interval for executing order tasks.
223+
224+
225+
# Wallets configuration for monitoring purposes where direct operations on these addresses are not allowed.
226+
# All token operations like withdrawals or deposits will be executed through the associated operator address.
227+
wallets:
228+
- address: 0x888888c278443CFC4D6E60b1964c2F1BAc3Ef257
229+
# Private key for the wallet associated with the operator address for transaction signing.
230+
privateKey: <0x9273283412f0A26C2cB99BBD874D54AD18540101_privateKey>
231+
tokens:
232+
# Configuration for triggering the gate_liquidity bot when the balance of a specific token at this address meets certain conditions.
233+
- name: USDT
234+
# Current amount of the token at the address.
235+
amount: "1.5"
236+
# Threshold amount; when the balance is less than or equal to this value, the gate_liquidity bot is activated.
237+
threshold: "1"
238+
# List of chains where the token balance is to be monitored.
239+
chains:
240+
- arbitrum
241+
- polygon
243242
```
244243

245244
#### Run

0 commit comments

Comments
 (0)