diff --git a/README.md b/README.md index a725163..5c38a8f 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ The Relayer example for Stakewise v3-operator service Relayer-Operator api communication is described in [Operator docs](https://docs.stakewise.io/for-operators/operator-service/running-as-api-service). -In this example keystores and deposit-data file were not created in advance. -Relayer generates validator credentials on the fly. +In this example, keystores are stored in a local folder. ## Running with Docker @@ -34,20 +33,165 @@ europe-west4-docker.pkg.dev/stakewiselabs/public/relayer-example Relayer-example is Python app made with FastAPI. +## API Endpoints + +### Register New Validators + +**POST** `/validators` +**Request Body**: + +```json +{ + "vault": "0x1234...", + "validators_start_index": 20551, + "amounts": [32000000000], + "validator_type": "0x02" +} +``` + +- `vault` - Address of the vault contract to which the validators will be registered. +- `validators_start_index` - Validator index for the first validator in the batch. +- `amounts` - List of deposit amounts for each validator. Value provided in Gwei. +- `validator_type` - Type of validator to create. Possible values: `V1` or `V2`. + +**Response:** + +```json +{ + "validators": [ + { + "public_key": "0xPubKey1", + "deposit_signature": "0xDepositSig1", + "amount": 32000000000, + "exit_signature": "0xExitSig1" + } + ], + "validators_manager_signature": "0xManagerSig" +} +``` + +--- + +### Fund Compounding Validators + +**POST** `/fund` +**Request Body:** + +```json +{ + "vault": "0x1234...", + "public_keys": ["0xPubKey1"], + "amounts": [2000000000] +} +``` + +- `vault` - Address of the vault contract to which the validators will be funded. +- `public_keys` - List of public keys of validators to fund. +- `amounts` - List of amounts to fund into each validator. Value provided in Gwei. + +**Response:** + +```json +{ + "validators": [ + { + "public_key": "0xPubKey1", + "deposit_signature": "0xDepositSig1", + "amount": 2000000000 + } + ], + "validators_manager_signature": "0xManagerSig" +} +``` + +--- + +### Get Signature for Withdraw Funds from Validators Transaction + +**POST** `/withdraw` +**Request Body:** + +```json +{ + "vault": "0x1234...", + "public_keys": ["0xPubKey1", "0xPubKey2"], + "amounts": [55000000000, 0] +} +``` + +- `vault` - Address of the vault contract to which the validators will be withdrawn. +- `public_keys` - List of public keys of validators to withdraw from. +- `amounts` - List of amounts to withdraw from each validator. Value provided in Gwei. + +**Response:** + +```json +{ + "validators_manager_signature": "0xManagerSig" +} +``` + +--- + +### Get Signature for Consolidate Validators Transaction + +**POST** `/consolidate` +**Request Body:** + +```json +{ + "vault": "0x1234...", + "source_public_keys": ["0xPubKey1", "0xPubKey2"], + "target_public_keys": ["0xPubKey3", "0xPubKey3"] +} +``` + +- `vault` - Address of the vault contract to which the validators will be consolidated. +- `source_public_keys` - List of public keys of validators to consolidate from. +- `target_public_keys` - List of public keys of validators to consolidate to. + +**Response:** + +```json +{ + "validators_manager_signature": "0xManagerSig" +} +``` + +--- + +### Fetch info about relayer + +**Get** `/info` + +**Response:** + +```json +{ + "network": "mainnet" +} +``` + ### Folders structure ```text src/ # sources root |-- common/ # | |-- abi/ # contracts ABI +| |-- app_state/ # store app state | |-- clients.py # execution client | |-- contracts.py # validators registry contract +| |-- endpoints.py # info api endpoint +| |-- schema.py # api request/response schema +| |-- setup_logging.py # logging scheme setup +| |-- typings.py # comon types |-- config/ | |-- networks.py # network configs | |-- settings.py # app settings |-- validators/ # | |-- credentials.py # Credential and CredentialManager used to generate keystores | |-- endpoints.py # api endpoints +| |-- keystore.py # local keystore storage | |-- schema.py # api request/response schema | |-- typings.py # dataclasses | |-- validators.py # functions for creating validators and exit signatures