-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CL Incentives] Implement CreateIncentive
logic and message
#4519
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just have couple of questions
string incentive_denom = 3; | ||
string incentive_amount = 4 [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a thought, why not set this as Coin instead of denom and amount? so that later down the line we can create incentives record for many Coins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on making this a Coin, unless it was by design for a reason I am not seeing.
|
||
func (msg MsgCreateIncentive) Route() string { return RouterKey } | ||
func (msg MsgCreateIncentive) Type() string { return TypeMsgCollectIncentives } | ||
func (msg MsgCreateIncentive) ValidateBasic() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we check if min_uptime is valid here too? basically the same logic as https://github.com/osmosis-labs/osmosis/pull/4519/files#diff-8fb13ed7a62b35b89555bdc906798a4353c391186de40eacadac4045c1e4d7bdR526-R534
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also do we ever need to update Incentive Records? or are these also non fungible once created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done :) just a few non blocking comments
string incentive_denom = 3; | ||
string incentive_amount = 4 [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on making this a Coin, unless it was by design for a reason I am not seeing.
string incentive_denom = 1; | ||
string incentive_amount = 2 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.moretags) = "yaml:\"incentive_amount\"", | ||
(gogoproto.nullable) = false | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetJustPoolId()}}, | ||
}, &types.MsgCreateIncentive{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking, but we have been trying to move away from mandatory flags, would be nice if we could just make poolId be part of the create incentive message
"existing incentive records": { | ||
poolId: defaultPoolId, | ||
sender: s.TestAccs[0], | ||
senderBalance: sdk.NewCoins( | ||
sdk.NewCoin( | ||
incentiveRecordOne.IncentiveDenom, | ||
incentiveRecordOne.RemainingAmount.Ceil().RoundInt(), | ||
), | ||
), | ||
recordToSet: incentiveRecordOne, | ||
existingRecords: []types.IncentiveRecord{incentiveRecordTwo, incentiveRecordThree}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test case that tests what happens if someone creates the same incentive record twice? Does it add to the existing incentive record? I don't believe this tests that test case since I think incentiveRecordTwo and Three have different params.
|
||
func (msg MsgCreateIncentive) Route() string { return RouterKey } | ||
func (msg MsgCreateIncentive) Type() string { return TypeMsgCollectIncentives } | ||
func (msg MsgCreateIncentive) ValidateBasic() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
validUptime := false | ||
for _, supportedUptime := range types.SupportedUptimes { | ||
if minUptime == supportedUptime { | ||
validUptime = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validUptime = true | |
validUptime = true | |
break |
} | ||
|
||
// Ensure sender has balance for incentive denom | ||
incentiveCoin := sdk.NewCoin(incentiveDenom, incentiveAmount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to earlier comments - I think having it as Coin
from the start makes more sense to me as well
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), | ||
), | ||
sdk.NewEvent( | ||
types.TypeEvtCreateIncentive, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), | ||
sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(msg.PoolId, 10)), | ||
sdk.NewAttribute(types.AttributeIncentiveDenom, msg.IncentiveDenom), | ||
sdk.NewAttribute(types.AttributeIncentiveAmount, msg.IncentiveAmount.String()), | ||
sdk.NewAttribute(types.AttributeIncentiveEmissionRate, msg.EmissionRate.String()), | ||
sdk.NewAttribute(types.AttributeIncentiveStartTime, msg.StartTime.String()), | ||
sdk.NewAttribute(types.AttributeIncentiveMinUptime, msg.MinUptime.String()), | ||
), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we test these events being emitted?
|
* initial push * push * untracked files * add untracked files * merge branches * add changes required for fees * lint * fix test errors * clean up * remove print lines * feat: single fee accum (#4116) * single fee accum * lint * no longer need to get all positions for fee * incentive accum initialization * lint * Update x/concentrated-liquidity/store_test.go Co-authored-by: Sishir Giri <[email protected]> * add lower level tests and make uptime accum access private * lint * add gotests for helper fn * Update test to use existing variable Co-authored-by: Roman <[email protected]> * create or update records upon position creation/update * add tests and clean up * sync position-related changes * add support for negative liquidity delta * add and test helper & set up tick initialization logic * implement accumulator updates on tick crossing and clean up proto * clean up comments * minor test cleanup * ensure accum initalization follows conventions and clean up tests * update pool proto and CL pool extension for tracking liq changes * update new field at pool initialization and add tests * comment todos * clean up naming and move empty options to global var * add clarifying comments and lint * implement IncentiveRecord proto * add comments * lint * set up wiring for proto * implement updateUptimeAccumulatorsToNow * implement and test calcAccruedIncentivesForAccum * add tests for new helpers * minor comment updates Co-authored-by: Roman <[email protected]> * accum test updates * lint * clean up diff * lint * update go.mod for e2e * clean up proto and add error message * lint * sketch out testing approach * set up keys * clean up diff * clean up comments * lint * implement set and get for incentive records * comment cleanup * minor comment and test cleanup * clean up tests and comments * [CL Incentives] Implement `setIncentiveRecords` and `getIncentiveRecords` (#4283) * set up keys * implement set and get for incentive records * comment cleanup * minor comment and test cleanup * Revert "[CL Incentives] Implement `setIncentiveRecords` and `getIncentiveRecords` (#4283)" (#4294) This reverts commit de7c146. * set incentive records in new position tests * fix merge conflicts * add check for init position record values * fix and finalize uptime accum position tests * fix go mod for e2e * clean up diff * add err check to accum update * fix rounding error * implement tick init uptime tracker logic * fix test compatibility * implement fix for global accums falling out of sync before tick init * add tests to ensure uptime trackers are initialized properly * add comment for new helper * add core logic * go mod tidy * fix conflicts * fix e2e * update go mod * fix and further test tick init logic * remove redundant values from incentive record state * cleanup from review * comment cleanup * set up cross tick tests * add further tests * test and comment cleanup * implement core logic * update osmoutils go mod and remove curTick as fn param * thorough tests for new functionality * clean up new functions for readability * clean up test comments * fix test names * lint * add godoc and further comments * update go mod for e2e * update liq change logic * update uptime accums before gettings them for tick crossing * abstract uptime init and update logic to helper * add thorough tests for initOrUpdatePositionUptime * update liquidity update logic and tests to use new helper * add todo for frozenuntil issue * lint * lint * clean up logic and add tests for helper * go mod for osmoutils e2e * move position key computation outside loop * clean up imports and go sum * fix imports * [CL Incentives][bugfix]: Replace all uses of frozenUntil with joinTime and freezeDuration * e2e passing * implement message, proto, and core logic * convert freezeduration to uint64 * implement tests for collectIncentives * add msg level tests and clean up logic/tests * add codec, cli, and simulation * claim incentives upon position deletion to clear records * comment cleanup * lint * minor test comment updates Co-authored-by: Roman <[email protected]> * godoc update Co-authored-by: Roman <[email protected]> * expand withdraw tests to better include incentives logic * minor optimizations and cleanup from code review * [CL Incentives] Implement `CreateIncentive` logic and message (#4519) * draft implementation * begin testing * add more test cases * add error catching test cases * implement createIncentive message * cli and codec * add check and related tests * add further tests and lint * add test case for existing incentive records * Revert "[CL Incentives] Implement `CreateIncentive` logic and message (#4519)" (#4568) This reverts commit b07e763. * fix conflicts --------- Co-authored-by: Adam Tucker <[email protected]> Co-authored-by: Adam Tucker <[email protected]> Co-authored-by: Sishir Giri <[email protected]> Co-authored-by: Roman <[email protected]>
* initial push * push * untracked files * add untracked files * merge branches * add changes required for fees * lint * fix test errors * clean up * remove print lines * feat: single fee accum (#4116) * single fee accum * lint * no longer need to get all positions for fee * incentive accum initialization * lint * Update x/concentrated-liquidity/store_test.go Co-authored-by: Sishir Giri <[email protected]> * add lower level tests and make uptime accum access private * lint * add gotests for helper fn * Update test to use existing variable Co-authored-by: Roman <[email protected]> * create or update records upon position creation/update * add tests and clean up * sync position-related changes * add support for negative liquidity delta * add and test helper & set up tick initialization logic * implement accumulator updates on tick crossing and clean up proto * clean up comments * minor test cleanup * ensure accum initalization follows conventions and clean up tests * update pool proto and CL pool extension for tracking liq changes * update new field at pool initialization and add tests * comment todos * clean up naming and move empty options to global var * add clarifying comments and lint * implement IncentiveRecord proto * add comments * lint * set up wiring for proto * implement updateUptimeAccumulatorsToNow * implement and test calcAccruedIncentivesForAccum * add tests for new helpers * minor comment updates Co-authored-by: Roman <[email protected]> * accum test updates * lint * clean up diff * lint * update go.mod for e2e * clean up proto and add error message * lint * sketch out testing approach * set up keys * clean up diff * clean up comments * lint * implement set and get for incentive records * comment cleanup * minor comment and test cleanup * clean up tests and comments * [CL Incentives] Implement `setIncentiveRecords` and `getIncentiveRecords` (#4283) * set up keys * implement set and get for incentive records * comment cleanup * minor comment and test cleanup * Revert "[CL Incentives] Implement `setIncentiveRecords` and `getIncentiveRecords` (#4283)" (#4294) This reverts commit de7c146. * set incentive records in new position tests * fix merge conflicts * add check for init position record values * fix and finalize uptime accum position tests * fix go mod for e2e * clean up diff * add err check to accum update * fix rounding error * implement tick init uptime tracker logic * fix test compatibility * implement fix for global accums falling out of sync before tick init * add tests to ensure uptime trackers are initialized properly * add comment for new helper * add core logic * go mod tidy * fix conflicts * fix e2e * update go mod * fix and further test tick init logic * remove redundant values from incentive record state * cleanup from review * comment cleanup * set up cross tick tests * add further tests * test and comment cleanup * implement core logic * update osmoutils go mod and remove curTick as fn param * thorough tests for new functionality * clean up new functions for readability * clean up test comments * fix test names * lint * add godoc and further comments * update go mod for e2e * update liq change logic * update uptime accums before gettings them for tick crossing * abstract uptime init and update logic to helper * add thorough tests for initOrUpdatePositionUptime * update liquidity update logic and tests to use new helper * add todo for frozenuntil issue * lint * lint * clean up logic and add tests for helper * go mod for osmoutils e2e * move position key computation outside loop * clean up imports and go sum * fix imports * [CL Incentives][bugfix]: Replace all uses of frozenUntil with joinTime and freezeDuration * e2e passing * implement message, proto, and core logic * convert freezeduration to uint64 * implement tests for collectIncentives * add msg level tests and clean up logic/tests * draft implementation * begin testing * add codec, cli, and simulation * claim incentives upon position deletion to clear records * comment cleanup * add more test cases * lint * add error catching test cases * implement createIncentive message * cli and codec * add check and related tests * add further tests and lint * add test case for existing incentive records * minor test comment updates Co-authored-by: Roman <[email protected]> * godoc update Co-authored-by: Roman <[email protected]> * expand withdraw tests to better include incentives logic * minor optimizations and cleanup from code review * [CL Incentives] Implement `CreateIncentive` logic and message (#4519) * draft implementation * begin testing * add more test cases * add error catching test cases * implement createIncentive message * cli and codec * add check and related tests * add further tests and lint * add test case for existing incentive records * Revert "[CL Incentives] Implement `CreateIncentive` logic and message (#4519)" (#4568) This reverts commit b07e763. * fix conflicts --------- Co-authored-by: Adam Tucker <[email protected]> Co-authored-by: Adam Tucker <[email protected]> Co-authored-by: Sishir Giri <[email protected]> Co-authored-by: Roman <[email protected]>
* initial push * push * untracked files * add untracked files * merge branches * add changes required for fees * lint * fix test errors * clean up * remove print lines * feat: single fee accum (#4116) * single fee accum * lint * no longer need to get all positions for fee * incentive accum initialization * lint * Update x/concentrated-liquidity/store_test.go Co-authored-by: Sishir Giri <[email protected]> * add lower level tests and make uptime accum access private * lint * add gotests for helper fn * Update test to use existing variable Co-authored-by: Roman <[email protected]> * create or update records upon position creation/update * add tests and clean up * sync position-related changes * add support for negative liquidity delta * add and test helper & set up tick initialization logic * implement accumulator updates on tick crossing and clean up proto * clean up comments * minor test cleanup * ensure accum initalization follows conventions and clean up tests * update pool proto and CL pool extension for tracking liq changes * update new field at pool initialization and add tests * comment todos * clean up naming and move empty options to global var * add clarifying comments and lint * implement IncentiveRecord proto * add comments * lint * set up wiring for proto * implement updateUptimeAccumulatorsToNow * implement and test calcAccruedIncentivesForAccum * add tests for new helpers * minor comment updates Co-authored-by: Roman <[email protected]> * accum test updates * lint * clean up diff * lint * update go.mod for e2e * clean up proto and add error message * lint * sketch out testing approach * set up keys * clean up diff * clean up comments * lint * implement set and get for incentive records * comment cleanup * minor comment and test cleanup * clean up tests and comments * [CL Incentives] Implement `setIncentiveRecords` and `getIncentiveRecords` (#4283) * set up keys * implement set and get for incentive records * comment cleanup * minor comment and test cleanup * Revert "[CL Incentives] Implement `setIncentiveRecords` and `getIncentiveRecords` (#4283)" (#4294) This reverts commit de7c146. * set incentive records in new position tests * fix merge conflicts * add check for init position record values * fix and finalize uptime accum position tests * fix go mod for e2e * clean up diff * add err check to accum update * fix rounding error * implement tick init uptime tracker logic * fix test compatibility * implement fix for global accums falling out of sync before tick init * add tests to ensure uptime trackers are initialized properly * add comment for new helper * add core logic * go mod tidy * fix conflicts * fix e2e * update go mod * fix and further test tick init logic * remove redundant values from incentive record state * cleanup from review * comment cleanup * set up cross tick tests * add further tests * test and comment cleanup * implement core logic * update osmoutils go mod and remove curTick as fn param * thorough tests for new functionality * clean up new functions for readability * clean up test comments * fix test names * lint * add godoc and further comments * update go mod for e2e * update liq change logic * update uptime accums before gettings them for tick crossing * abstract uptime init and update logic to helper * add thorough tests for initOrUpdatePositionUptime * update liquidity update logic and tests to use new helper * add todo for frozenuntil issue * lint * lint * clean up logic and add tests for helper * go mod for osmoutils e2e * move position key computation outside loop * clean up imports and go sum * fix imports * [CL Incentives][bugfix]: Replace all uses of frozenUntil with joinTime and freezeDuration * e2e passing * implement message, proto, and core logic * convert freezeduration to uint64 * implement tests for collectIncentives * add msg level tests and clean up logic/tests * draft implementation * begin testing * add codec, cli, and simulation * claim incentives upon position deletion to clear records * comment cleanup * add more test cases * lint * add error catching test cases * implement createIncentive message * cli and codec * add check and related tests * add further tests and lint * add test case for existing incentive records * pull relevant changes into new branch * lint * minor test comment updates Co-authored-by: Roman <[email protected]> * godoc update Co-authored-by: Roman <[email protected]> * expand withdraw tests to better include incentives logic * minor optimizations and cleanup from code review * [CL Incentives] Implement `CreateIncentive` logic and message (#4519) * draft implementation * begin testing * add more test cases * add error catching test cases * implement createIncentive message * cli and codec * add check and related tests * add further tests and lint * add test case for existing incentive records * Revert "[CL Incentives] Implement `CreateIncentive` logic and message (#4519)" (#4568) This reverts commit b07e763. * make unit tests more robust * minor comment cleanup * fix conflicts --------- Co-authored-by: Adam Tucker <[email protected]> Co-authored-by: Adam Tucker <[email protected]> Co-authored-by: Sishir Giri <[email protected]> Co-authored-by: Roman <[email protected]>
Closes: #4400, #4183
What is the purpose of the change
This PR implements incentive creation logic and its respective message.
Brief Changelog
createIncentive
MsgCreateIncentive
& related wiringTesting and Verifying
incentives_test.go
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (no)