Skip to content

Commit 1c30b52

Browse files
committed
docs: add resign and withdraw utility scripts for liquidity management
1 parent 5b25038 commit 1c30b52

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ define utils_build
1010
CGO_ENABLED=0 go build -v -o ./utils/register_pegin ./cmd/utils/register_pegin/register_pegin.go
1111
CGO_ENABLED=0 go build -v -o ./utils/refund_user_pegout ./cmd/utils/refund_user_pegout/refund_user_pegout.go
1212
CGO_ENABLED=0 go build -v -o ./utils/key_conversion ./cmd/utils/key_conversion/key_conversion.go
13+
CGO_ENABLED=0 go build -v -o ./utils/resign_utils ./cmd/utils/resign_utils/resign_utils.go
14+
CGO_ENABLED=0 go build -v -o ./utils/withdraw ./cmd/utils/withdraw/withdraw.go
1315
endef
1416

1517
tools: download

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ The LPS provides several utility scripts that can be helpful for liquidity provi
165165
- **register_pegin**: Register a PegIn transaction within the Liquidity Bridge Contract. Most times, this script is only required to execute refunds on special cases. This script requires an input file whose structure can be found in the [input-example.json](https://github.com/rsksmart/liquidity-provider-server/blob/master/cmd/utils/register_pegin/input-example.json) file.
166166
- **refund_user_pegout**: Executes a refund for a user's peg-out operation through the Liquidity Bridge Contract. This is used when a peg-out operation needs to be refunded back to the user's RSK address. The script requires the quote hash of the operation to refund.
167167
- **key_conversion**: Shows the corresponding BTC and RSK address for a given private key and encrypts it into a keystore, accepts the key either in WIF or hex format. The key can be provided through the terminal, a file or an existing keystore.
168+
- **resign_utils**: Resigns a liquidity provider and withdraws collateral from the Collateral Management contract.
169+
- **withdraw**: Withdraws liquidity locked in the PegIn contract (full balance or specific amount).
170+
171+
For migration-specific examples, see [docs/LP-Migration-Utils.md](./docs/LP-Migration-Utils.md).
168172

169173
## Monitoring Service
170174

docs/LP-Migration-Utils.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: LP Migration Utilities
3+
---
4+
5+
# LP Migration Utilities
6+
7+
This document describes the utility scripts that help Liquidity Providers migrate liquidity to the new contract set.
8+
9+
## Prerequisites
10+
11+
- Access to the Rootstock RPC endpoint for the target network.
12+
- Wallet secrets configured via the same mechanisms used by the LPS (`--secret-src env|aws`).
13+
14+
## Build the utilities
15+
16+
```bash
17+
make utils
18+
```
19+
20+
The binaries will be placed in the `./utils` directory.
21+
22+
## Common options
23+
24+
Both scripts reuse the base input flags from `cmd/utils/scripts`:
25+
26+
- `--network` (required): `regtest`, `testnet`, or `mainnet`
27+
- `--rsk-endpoint` (required): RPC URL (e.g. `http://localhost:4444`)
28+
- `--secret-src` (required): `env` or `aws`
29+
- `--keystore-file`: required when `--secret-src=env`
30+
- `--keystore-secret` and `--password-secret`: required when `--secret-src=aws`
31+
- `--custom-pegin-address`, `--custom-collateral-address`, `--custom-pegout-address`, `--custom-discovery-address`: optional overrides
32+
33+
### Default regtest env file
34+
35+
If you want to run the utilities with minimal flags (for example `./utils/resign_utils --resign`), you can provide defaults via an env file:
36+
37+
- Set `LPS_UTILS_ENV_FILE` to a file containing `LPS_STAGE`, `RSK_ENDPOINT`, `SECRET_SRC`, `AWS_LOCAL_ENDPOINT`, and wallet keys such as `WALLET_FILE`, `WALLET_SECRET`, and `PASSWORD_SECRET`.
38+
- If `LPS_UTILS_ENV_FILE` is not set, the utilities will try `docker-compose/local/.env.regtest`, then `regtest.env` at the repo root.
39+
- A minimal `regtest.env` is included for local regtest defaults; adjust it to match your environment.
40+
41+
## Resign utility
42+
43+
### Resign
44+
45+
```bash
46+
./utils/resign_utils \
47+
--network testnet \
48+
--rsk-endpoint http://localhost:4444 \
49+
--secret-src env \
50+
--keystore-file /path/to/keystore.json \
51+
--resign
52+
```
53+
54+
### Withdraw collateral
55+
56+
```bash
57+
./utils/resign_utils \
58+
--network testnet \
59+
--rsk-endpoint http://localhost:4444 \
60+
--secret-src env \
61+
--keystore-file /path/to/keystore.json \
62+
--withdraw-collateral
63+
```
64+
65+
Note: `--withdraw-collateral` requires the resignation delay to have elapsed after calling `--resign`.
66+
67+
## Withdraw utility
68+
69+
### Withdraw full balance
70+
71+
```bash
72+
./utils/withdraw \
73+
--network testnet \
74+
--rsk-endpoint http://localhost:4444 \
75+
--secret-src env \
76+
--keystore-file /path/to/keystore.json \
77+
--all
78+
```
79+
80+
### Withdraw a specific amount
81+
82+
```bash
83+
./utils/withdraw \
84+
--network testnet \
85+
--rsk-endpoint http://localhost:4444 \
86+
--secret-src env \
87+
--keystore-file /path/to/keystore.json \
88+
--amount 1000000000000000000
89+
```
90+
91+
The `--amount` value is expressed in wei.

0 commit comments

Comments
 (0)