cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.24k stars 3.61k forks source link

Proportional Delegation #12281

Open alexanderbez opened 2 years ago

alexanderbez commented 2 years ago

Summary

Currently, when a delegator wants to delegate to a validator, they specify the validator address and the amount they want to delegate.

Problem Definition

Proposed by @hxrts:

It would make it so someone could specify the distribution of all delegations in 1 transaction. So you’d say: 0.25 Chorus One, 0.25 Iqlusion, 0.5 Figment

Right now to do the ICF re-delegation is going to be like 50 transactions, may need to unstake everything to do it, in the meantime the whole chain would be slightly less secure.

Proposal

Introduce a new message type that allows proportional delegations. Something like the following:

type ProportionalDelegation struct {
  Validator sdk.ValAddress
  Amount sdk.AccAddress
}

type MsgDelegateProportional struct {
  Delegator sdk.AccAddress
  Delegations []ProportionalDelegation
}

Alternatively, MsgDelegateProportional can also specify the total amount and ProportionalDelegation can specify the % of that total.

type ProportionalDelegation struct {
  Validator sdk.ValAddress
  Fraction sdk.Dec
}

type MsgDelegateProportional struct {
  Delegator sdk.AccAddress
  Amount sdk.Int
  Delegations []ProportionalDelegation
}

cc @hxrts @marbar3778 @okwme


For Admin Use

hxrts commented 2 years ago

from slack discussion with dev & sunny

dev:

thats the reverse flow I'd like to see happen. I'd instead like us to do https://github.com/osmosis-labs/osmosis/issues/408#issuecomment-1025070771 You define a validator set preference list on chain, and then do a delegate message to your preference list

sunny:

Basically, the preferences should be in state, so you don’t specify the preferences in each one. That way, a module can also auto delegate to your preference list (i.e. such as OSMO rewards get auto-staked)

sam:

I like your approach but I think the user behaviour I'm thinking about is still very helpful to rebalance a delegation portfolio. We would ideally have both. You can set an initial portfolio using fractional weights as I described, then the compounding rewards could use a preference list. As a delegator the current UX is terrible and encourages users to pick single validators and forget about it rather than constructing a risk adjusted portfolio.

hxrts commented 2 years ago

so a potential synthesis of these two proposals could look something like the following:

use the second of bez's proposed options

type ProportionalDelegation struct {
  Validator sdk.ValAddress
  Fraction sdk.Dec
}

the user could then specify whether action should be taken on current delegations, future delegations, or both. so the amount and autostake_rate would be moved into these secondary messages. you lose some granularity from dev's ValidatorPreference message in that you can't specify an autostake_rate per delegator, but that also maybe seems unnecessary?

hxrts commented 1 year ago

would be good to pull this into the sdk https://github.com/osmosis-labs/osmosis/issues/2579

cc @tac0turtle