keep-network / keep-core

The smart contracts and reference client behind the Keep network
https://keep.network
MIT License
122 stars 75 forks source link

Automate Deposits Sweeps CLI #3626

Closed nkuba closed 1 year ago

nkuba commented 1 year ago

The changes here are a step on the road to the fully automated sweeps (https://github.com/keep-network/keep-core/issues/3614).

We update the propose-deposits-sweep command initially implemented in https://github.com/keep-network/keep-core/pull/3549.

The main change to the command is that if deposits are not provided as arguments, they will be automatically fetched from the chain.

The command will find the oldest unswept deposits for the oldest unswept wallet and construct a sweep proposal for them.

Number of deposits for the proposal is based on the depositSweepMaxSize defined in the WalletCoordinator contract. The value can be overwritten with --deposit-sweep-max-size <number>.

If --wallet <wallet-public-key-hash> is provided the command will find unswept deposits for the particular wallet.

If --fee <number> is not provided the command will estimate a fee for the sweep transaction.

Sample Command

To execute the command in dry-run mode:

# Sweep deposits from the oldest unswept wallet:
LOG_LEVEL=debug go run . coordinator --testnet propose-deposits-sweep --dry-run

# Sweep deposits from a specific wallet:
LOG_LEVEL=debug go run . coordinator --testnet propose-deposits-sweep --wallet 0x7670343fc00ccc2d0cd65360e6ad400697ea0fed --dry-run
nkuba commented 1 year ago

Thanks for the review @pdyraga. I consider the work for this PR completed. It's ready for the next round.

pdyraga commented 1 year ago

To summarize, there are three code changes I'd like to see in this PR:

Everything else is tracked in separate issues.

nkuba commented 1 year ago

@pdyraga its' ready.