harmony-one / onebtc

Trustless Bitcoin on Harmony
Apache License 2.0
33 stars 13 forks source link

Locked collateral staking for yield generation to reward the vault providers #106

Open gupadhyaya opened 2 years ago

gupadhyaya commented 2 years ago

Currently, the vaults lock their collateral over the period of 3-12 months, which is sitting idle in the 1BTC contract. Design and implement a feature that will stake the locked collateral by utilizing the smart contract staking facility. This could help us generate some yield (up to 10% APR) which we can use to reward the vault providers for their service. Analyze the risk involved in not keeping the collateral in the liquid form and the downside to staking it. Note that, the collateral locked for different periods when staked should account for 7 days cool-off period before unstaking. Discuss the design of this feature along with risk and concerns before implementing it.

hashmesan commented 2 years ago

The collateral is held by the vaults OneBTC contract. We can have the contract stake the collateral and forward the rewards to the VaultReserve for theVaultReward to distribute it. For accounting purposes, we can add a functionality in VaultReserve to track the stake rewards deposits.

We can leverage contract staking work done by onewallet contract

One wrinkle to the process is we have to consider how locked collateral impacts remove, replace tx, and liquidation..

Design questions

Staking locks up collateral for 7 days which impacts when vault owner receives their collateral back

Design 1: We could have them stake individually as their preference? Doing so, we need to reward vault owner who staked MORE THAN the vault owner who did not stake. [MORE COMPLEX]

Design 2: We could have all of them staked automatically, and declare that any vault collateralization requires a 7 day cooling period. Doing so, we can provide uniform rewards. [LESS COMPLEX]

Security

Secure since this is all done on the contract.

gupadhyaya commented 2 years ago

why do we need to worry about 7 days unstaking locking period? we are only going to stake the collateral that is locked by the vault in the reward program (3-12 months) and we just need to unstake 7 days prior to the reward program end date to make it immediately available for the vault. the collateral that is not enrolled into the reward program won't be considered for staking. @hashmesan

hashmesan commented 2 years ago

@gupadhyaya I missed that part. Then that simplifies our design. I propose in the withdrawCollateral, we implement a two stage withdrawal process.

If the block timestamp is GREATER lock expiration MINUS 7 days, it will trigger the unstaking process. If the block timestamp is GREATER than the lock expiration && collateral is unstaked -- Continue with release Collateral.

The UI can check on public functions for the stake status, lock period, and unstaking lock period to inform the user what stage of the withdrawal they're on.