* add test for validate multi reward periods
* tidy up: combine files
* don't accumulate global indexes containing zeros
Previously if the time since last block was 0,
indexes were added containing 0s.
Now leave them out. Missing is assumed to be 0.
* move state independent test to types folder
* clarify reward source concept to "source shares"
- rename variables and update doc comments
- extract method from swap accumulation
* tidy up and expand swap accumulation unit tests
* rename swap test file to match others
* update swap pool id format in tests
* refactor borrow accumulation, use new accumulator
* refactor supply accumulation, use new accumulator
* refactor delegator accumulation, use accumulator
* refactor usdx accumulation, use new accumulator
* fix types const
* remove unsed methods
* more usdx minting param validation.
Protect against the rewards per second denom changing.
It should always be "ukava".
* add safety check in InitGenesis
It prevents huge accumulations on the first block by limiting all
previous accumulation times to be within one year of genesis
* add todo for adding swp token distirbution info
* update state store key separator and extract pool key sep
* update state key separater and pool id seperator to not conflict with
'/' in ibc vouchers
* fix pool ids for updated sep
* add regression test for hooks; refactor deposit to commit pool and
shares in one place with commit after validation checks; panic on pool
and share set methods if the record is invalid
* use correct hook ordering; add regression test for order - fails if
hooks are not called before or after share record set
* wip: add swap state persistent to genesis
* separate pool record constructors; add tests for json and yaml encoding
of record structs
* beef up validation checks for state records
* fix integration with master - renamed method
* add test coverage for basic state array validations
* extra test around pool record reserve and id ordering to ensure no
regressions in the future
* add validations to ensure pool records and share records are unique
within the collection types
* test genesis json and yaml encoding
* validate in genesis that the total shares owned for each pool is equal
to the total shares of each pool
* update alias
* nit lint
* test genesis init and export
* add migration todo
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
* move defualt values to file where they're used
* add type to hold RewardIndexes in genesis state
* add reward indexes state to genesis
* fix genesis state importers
* add iterator keeper methods for accrual times
* remove syncing from export/init genesis
* separate incentive migration to new file
* refactor out common funcs from incentive migration
* update legacy genesis state to v0.14.3
* add test and example migrated json
* fully initialize rewards in genesis builder
* add kava-7-mainnet incentive state
* run aliasgen
* add missing type to incentive/legacy
Co-authored-by: karzak <kjydavis3@gmail.com>
* add message types for swaps
* add tx client commands
* add test coverage for swap message deadlines
* start handler swap tests, export handler result message event into
private method, add stubbed keeper methods
* add initial swap implementation to get handler tests passing; adds event
specific for trades
* add handler acceptance test for slippage in exact input and exact output
swaps
* implement slippage limit for swap keeper methods
* add tests to ensure a user can only swap spendable coins
* test pool not found, panic on invalid pool, and panic when module
account does not have enough funds
* validate that the exact output when using for exact swaps is less than
the pool liquidity
* nit: long line
* add validation that swap output is greater than zero
* add rest txs for swap messages
* nit: lints
* dry up swap keeper methods
* from pr feedback - spelling and increase clairty around the output
amount of a swap rounding to zero
* add swap claim type
* add store methods for swap claims
* add swap claims to genesis state
* tidy up cdp and hard hook doc comments
* add uncalled hooks to the swap keeper
* add swap rewards sync method
* add swap rewards init method
* connect swap rewards via swap hooks
* Update querier and client for swap claims (#951)
* refactor querier to dedupe code
* add swap claims querier endpoint
* add swap claim querying to rest
* add swap claim querying to cli
* add keeper method to iterate swap reward indexes
* simplify reward-factors query endpoint, add swap
* update swap hook to match latest swap branch
* rename func to not collide with latest swap branch
* Squash merge swap-acceptance branch (#956)
* add failing acceptance test for a user depositing into a pool
* implement GetAccount test helper
* implement swap.MsgDeposit for creating and adding liquidity to a pool
* update aliases, add event types, and fix typo/compiler errors in handler
test
* use only aliases names in handler test (don't use swap types -- ensures
we have run aliasgen), add assertion for even type message
* implement account and module account balance checks in handler test
* fill out handler assertions for testing keeper state and events
* update signed json representation and register swap/MsgDeposit for
proper encoding
* fill out boilerplate to get handler test to compile
* alias gen for pool
* add handling of message type; fill in deposit keeper method for
succesful compile; noop but test assertions now run up to module acc not
nil check
* add module account permissions for swap module -- fixes module account
creation; pass account keeper and supply keeper into swap keeper to
allow the ability to work with user and module accounts
* implement create pool logic for msg deposit; allows creation of a of new
pool, checking params to see if it is allowed. Initi shares are set,
and senders number of shares are stored
* Swap migrations scaffolding (#925)
* swap module scaffolding
* global swap fee
* can't think of a reason for begin blocker; removing for abci.go for now;
* test pair types; refactor pair name logic; simplify pairs validation and
fix stack overflow error
* check comparison
* use test package
* init swap module genesis
* add basic marshall tests
* remove reward apy from pairs
* fix integration helpers
* use max swap fee constant; fix validation of swap fee; add tests to
cover param validation and param set setup
* use noerror over nil
* start genesis tests
* test param set validation mirrors param validation
* add genesis tests
* remove print statement
* add subtests for genesis test cases; add extra querier test for unknown
route; add keeper params testing
* add spec
* update swagger
* find replace hard -> swap in comments
* remove unused method
* rename pairs to allowed pools; pool is more commonly used, and
allowedPool makes it more clear what swap parameter is for. In
addition, we won't conflict with Pool data structure for storing a
created pool in the store.
* remove generated link
* missed spec rename
* validate token order for allowed pools
* fix swagger
* json should be snakecase; change allowedPools to allowed_pools
* add legacy types
* add swap genesis to v0_15 migration
* add legacy types
* add swap genesis to v0_15 migration
* migration revisions
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
* keeper todos
* update keeper tests
* type todos
* update types tests
* tx deposit cli cmd
* tx deposit rest
* Swap module simulation scaffolding (#924)
* sims scaffolding
* add noop operation
* genesis revisions
* add param changes
* mvoe persistance methods to main keeper file, consolidate tests
* make helper methods private. they are tested via deposit method, and
unit testing them would make test suite brittle and refactoring
difficult
* use more clear coin variables
* code 1 is reserved, use code 2 and sequence all errors
* remove todo
* Implement deadline for swap module module message. This is implemented in
handler with a interface to easily apply to it to all messages, and
separate msg validation concerns from the keeper
* move allowed pools to params -- let pool and pool_test focus on pool domain logic, not
parameter & governance concerns
* update alias
* add unitless implementatin of constant product liquidity pool to
isolate and enapsulate liquidity logic. Swap methods interfaces are
added, but implementation not yet added
* nits and todos
* add ErrInvalidPool
* add tests for edge cases around pool depletion; add explicit panic for
edge case that results in a pool reserve being zero; handle pool
reinitialization if it is empty
* touch up comments and flush out the rest of assertions
* add data structures for keeper state storage separate from pool domain
objects, and improve structure for easier querying
* rename pool name to pool key for events
* add support for a denominated pool that uses sdk.Coins and sdk.Coin
arguments, keeping tracking of the units in the base pool. This gives
nice separation between pool logic, and coin/denom logic
* refactor keeper to use new records for storage, and implement pool
deposit using the denominated pool
* address previous PR comment - reminder for migration if changing
account permissions
* msg deposit should validate that denoms are not equal
* add godoc comments
* golint and some poolName -> poolID cleanup
* implement adding liquidity to an existing pool
* hardcode pools in sims
* touch up comment
* withdraw keeper logic
* withdraw type updates
* add withdraw msg tx handler
* initial withdraw test
* fix panic
* use new denominated pool with existing shares
* fix: check args on deposit cmd
* add slippage limit check for depositing to an existing pool
* send coins just before event emission
* check liquidity returned is greater than zero for both coins; ensure
returned number of shares are greater than zero
* add deadline to msgwithdraw
* register msgwithdraw
* scaffold msgwithdraw types test
* register the correct msg
* modify swap functions to also return the amount paid for the pool swap
fee. This will be used to calculate slippage and for event tracking
* add slippage types
* add expected withdrawal coins
* calculate slippage against expected coins
* update withdraw keeper tests
* spelling, improve comments on add liquidity math
* typo
* typo
* grammer
* typo / grammer
* remove pool_id from withdraw msg
* add slippage to tx cmd
* TestWithdraw_Partial
* nit
* add withdraw no pool, no deposit record tests
* drop event check on partial withdraw test
* fix broken link
* fix broken link
* resolve merge conflicts
* ensure swap fee can not be equal to 1; add full implementation of swap
pool methods; these implementation ensure that the pool invariant is
always greater or equal to the previous invariant
* refactor duplicated code into private swap methods
* add runtime assertion to always ensure invariant is greater or equal
to the previous invariant sub fee on swaps
* improve comments for base pool swap functions
* add swap exact input and output methods to denominated pool that wrap
the base pool interface for swapping
* comment touch ups
* more comment touchups
* fix msg deposit struct tag (#943)
* use better name for swap calculation private methods
* nits: golint
* fix misspelling in method name
* Add HARD token governance committee for Hard module (#941)
* add hard gov token committee
* revisions: update migration
* revisions: update test/data file
* initial revisions
* add TokenCommittee JSONMarshal test
* fix SetPermissions method
* remove BaseCommittee Type field
* add incentive params to allowed params
* Add SWP token governance committee for Swap module (#946)
* add swp token commitee to migration
* update test, add gen export utility method
* final revisions: add TODO
* remove slippage from withdraw to use min values for coins; add
additional validation test cases
* update alias for swap module
* add withdraw tests to handler for increased coverage; note: first pass,
improvements still yet to be made here
* refact withdraw keeper to use min amounts; panic for cases that do not
happen in normal situations
* lint fixes
* use total shares to track if pool should be deleted; add more in depth
withdraw comment
* add exact args for withdraw cmd
* extract record update methods
* update depositor share record if it exists -- do not overwrite an
existing record; ensures no loss of shares if the same address deposits
more than once
* Swap queries: deposit, pool, pools (#949)
* query deposits types
* implement deposit querier keeper methods
* query deposits CLI
* query deposits REST
* query types for pool/pools
* pool/pools querier keeper methods
* pool/pools CLI
* pool/pools REST
* basic pool/pools query tests
* basic deposit querier test
* iterate share records via owner bytes
* nit: add example for querying deposits by owner only
Co-authored-by: karzak <kjydavis3@gmail.com>
* feat: add REST tx handler for swap LP withdrawals
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
Co-authored-by: Denali Marsh <denali@kava.io>
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
Co-authored-by: karzak <kjydavis3@gmail.com>
* expand incentive cli query docs
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
Co-authored-by: Denali Marsh <denali@kava.io>
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
Co-authored-by: karzak <kjydavis3@gmail.com>
* minor update to godoc comment
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
Co-authored-by: Denali Marsh <denali@kava.io>
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
Co-authored-by: karzak <kjydavis3@gmail.com>
* add failing acceptance test for a user depositing into a pool
* implement GetAccount test helper
* implement swap.MsgDeposit for creating and adding liquidity to a pool
* update aliases, add event types, and fix typo/compiler errors in handler
test
* use only aliases names in handler test (don't use swap types -- ensures
we have run aliasgen), add assertion for even type message
* implement account and module account balance checks in handler test
* fill out handler assertions for testing keeper state and events
* update signed json representation and register swap/MsgDeposit for
proper encoding
* fill out boilerplate to get handler test to compile
* alias gen for pool
* add handling of message type; fill in deposit keeper method for
succesful compile; noop but test assertions now run up to module acc not
nil check
* add module account permissions for swap module -- fixes module account
creation; pass account keeper and supply keeper into swap keeper to
allow the ability to work with user and module accounts
* implement create pool logic for msg deposit; allows creation of a of new
pool, checking params to see if it is allowed. Initi shares are set,
and senders number of shares are stored
* Swap migrations scaffolding (#925)
* swap module scaffolding
* global swap fee
* can't think of a reason for begin blocker; removing for abci.go for now;
* test pair types; refactor pair name logic; simplify pairs validation and
fix stack overflow error
* check comparison
* use test package
* init swap module genesis
* add basic marshall tests
* remove reward apy from pairs
* fix integration helpers
* use max swap fee constant; fix validation of swap fee; add tests to
cover param validation and param set setup
* use noerror over nil
* start genesis tests
* test param set validation mirrors param validation
* add genesis tests
* remove print statement
* add subtests for genesis test cases; add extra querier test for unknown
route; add keeper params testing
* add spec
* update swagger
* find replace hard -> swap in comments
* remove unused method
* rename pairs to allowed pools; pool is more commonly used, and
allowedPool makes it more clear what swap parameter is for. In
addition, we won't conflict with Pool data structure for storing a
created pool in the store.
* remove generated link
* missed spec rename
* validate token order for allowed pools
* fix swagger
* json should be snakecase; change allowedPools to allowed_pools
* add legacy types
* add swap genesis to v0_15 migration
* add legacy types
* add swap genesis to v0_15 migration
* migration revisions
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
* keeper todos
* update keeper tests
* type todos
* update types tests
* tx deposit cli cmd
* tx deposit rest
* Swap module simulation scaffolding (#924)
* sims scaffolding
* add noop operation
* genesis revisions
* add param changes
* mvoe persistance methods to main keeper file, consolidate tests
* make helper methods private. they are tested via deposit method, and
unit testing them would make test suite brittle and refactoring
difficult
* use more clear coin variables
* code 1 is reserved, use code 2 and sequence all errors
* remove todo
* Implement deadline for swap module module message. This is implemented in
handler with a interface to easily apply to it to all messages, and
separate msg validation concerns from the keeper
* move allowed pools to params -- let pool and pool_test focus on pool domain logic, not
parameter & governance concerns
* update alias
* add unitless implementatin of constant product liquidity pool to
isolate and enapsulate liquidity logic. Swap methods interfaces are
added, but implementation not yet added
* nits and todos
* add ErrInvalidPool
* add tests for edge cases around pool depletion; add explicit panic for
edge case that results in a pool reserve being zero; handle pool
reinitialization if it is empty
* touch up comments and flush out the rest of assertions
* add data structures for keeper state storage separate from pool domain
objects, and improve structure for easier querying
* rename pool name to pool key for events
* add support for a denominated pool that uses sdk.Coins and sdk.Coin
arguments, keeping tracking of the units in the base pool. This gives
nice separation between pool logic, and coin/denom logic
* refactor keeper to use new records for storage, and implement pool
deposit using the denominated pool
* address previous PR comment - reminder for migration if changing
account permissions
* msg deposit should validate that denoms are not equal
* add godoc comments
* golint and some poolName -> poolID cleanup
* implement adding liquidity to an existing pool
* hardcode pools in sims
* touch up comment
* withdraw keeper logic
* withdraw type updates
* add withdraw msg tx handler
* initial withdraw test
* fix panic
* use new denominated pool with existing shares
* fix: check args on deposit cmd
* add slippage limit check for depositing to an existing pool
* send coins just before event emission
* check liquidity returned is greater than zero for both coins; ensure
returned number of shares are greater than zero
* add deadline to msgwithdraw
* register msgwithdraw
* scaffold msgwithdraw types test
* register the correct msg
* modify swap functions to also return the amount paid for the pool swap
fee. This will be used to calculate slippage and for event tracking
* add slippage types
* add expected withdrawal coins
* calculate slippage against expected coins
* update withdraw keeper tests
* spelling, improve comments on add liquidity math
* typo
* typo
* grammer
* typo / grammer
* remove pool_id from withdraw msg
* add slippage to tx cmd
* TestWithdraw_Partial
* nit
* add withdraw no pool, no deposit record tests
* drop event check on partial withdraw test
* fix broken link
* fix broken link
* resolve merge conflicts
* ensure swap fee can not be equal to 1; add full implementation of swap
pool methods; these implementation ensure that the pool invariant is
always greater or equal to the previous invariant
* refactor duplicated code into private swap methods
* add runtime assertion to always ensure invariant is greater or equal
to the previous invariant sub fee on swaps
* improve comments for base pool swap functions
* add swap exact input and output methods to denominated pool that wrap
the base pool interface for swapping
* comment touch ups
* more comment touchups
* fix msg deposit struct tag (#943)
* use better name for swap calculation private methods
* nits: golint
* fix misspelling in method name
* Add HARD token governance committee for Hard module (#941)
* add hard gov token committee
* revisions: update migration
* revisions: update test/data file
* initial revisions
* add TokenCommittee JSONMarshal test
* fix SetPermissions method
* remove BaseCommittee Type field
* add incentive params to allowed params
* Add SWP token governance committee for Swap module (#946)
* add swp token commitee to migration
* update test, add gen export utility method
* final revisions: add TODO
* remove slippage from withdraw to use min values for coins; add
additional validation test cases
* update alias for swap module
* add withdraw tests to handler for increased coverage; note: first pass,
improvements still yet to be made here
* refact withdraw keeper to use min amounts; panic for cases that do not
happen in normal situations
* lint fixes
* use total shares to track if pool should be deleted; add more in depth
withdraw comment
* add exact args for withdraw cmd
* extract record update methods
* update depositor share record if it exists -- do not overwrite an
existing record; ensures no loss of shares if the same address deposits
more than once
* Swap queries: deposit, pool, pools (#949)
* query deposits types
* implement deposit querier keeper methods
* query deposits CLI
* query deposits REST
* query types for pool/pools
* pool/pools querier keeper methods
* pool/pools CLI
* pool/pools REST
* basic pool/pools query tests
* basic deposit querier test
* iterate share records via owner bytes
* nit: add example for querying deposits by owner only
Co-authored-by: karzak <kjydavis3@gmail.com>
* feat: add REST tx handler for swap LP withdrawals
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
Co-authored-by: Denali Marsh <denali@kava.io>
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
Co-authored-by: karzak <kjydavis3@gmail.com>
* add get set methods for swap reward indexes
* add get set methods for swap accrual time
* tidy up location of multi periods
* add swap reward periods to params
* add initial legacy types for incentive
* minor refactor of migration code
* add incentive migration for swap params
* minor incentive test refactors
* add math methods to RewardIndexes
* add keeper method to increment global indexes
* add swap keeper to incentive keeper
* indicate if pool shares were found or not
* add accumulator to compute new rewards each block
* accumulate swap rewards globally
* remove unecessary keeper method
* expand doc comments on accumulator methods
* test precision not lost in accumulation
* minor fixes from merge
* rename storeGlobalDelegatorFactor to match others
* fix migration from merge
* fix bug in app setup
* fix accumulation bug when starting with no state
* rename swap files to match others
* add swap accumulation times to genesis
* remove old migration refactor
* minor updates to spec
* add high level description of how rewards work
* organise testing committee gen state
* remove repeated test app initialization
* minor fixes from linter in tests
* move more setup to SetupApp
* split up KeeperTestSuite for each reward type
* simplify KeeperTestSuite
* simplify PayoutKeeperSuite
* simplify DelegatorRewardSuite
* simplify SupplyRewardsSuite
* simplify BorrowRewardsSuite
* simplify USDXRewardsSuite
* add auth genesis builder for easier test setup
* migrate all incentive tests to auth builder
* add incentive genesis builder for easier setup
migrate hard incentive tests
* migrate all tests to incentive builder
* add hard genesis builder
* small tidy ups
* deduplicate initialTime from borrow tests
* deduplicate initialtTime from supply tests
* deduplicate initialTime from usdx and keeper tests
* deduplicate initialTime in delgator tests
* deduplicate genesis time in payout test
* deduplicate test app initialization
* make authGenesisBuilder available for all modules
* remove unused pricefeed setup
* export incentive genesis builder
* remove commented out test cases
* migrate cdp test to new test state builders
* migrate vv payout tests to use new builders
* add SynchronizeHardBorrowReward unit test
* extract calculatReward method
* tidy up unit test for borrow rewards
* add helper method to RewardIndexes
* user helper to extract logic from SyncBorrowReward
* add Get methods to (Multi)RewardIndexes
* replace params.Subspace in keeper to test easier
* add unit tests for usdx minting
* refactor InitializeUSDXMintingClaim
* add unit tests for InitializeHardBorrowRewards
* refactor SynchronizeUSDXMintingReward
* add unit tests for UpdateHardBorrowIndexDenoms
* change rewardSource type to Dec
needed by delegation rewards
* fix typo in test names
* refactor UpdateHardBorrowIndexDenoms
* update genesis test TODO to use auth builder
* add skipped test for bug in usdx sync
* extract common method for calculating rewards
* doc comment tidy
* add unit tests for delegator rewards
* tidy up test files
* remove old TODOs
* reaarrange InitializeHardDelegatorReward
to fit with other init reward functions
* duplicate borrow unit tests to create supply tests
* add tests for syncing with zero rewards per second
* refactor SynchronizeHardDelegatorRewards
* refactor supply rewards in same way as borrow
* fix total delegation calculation bug
* fix new usdx reward bug
* fix new supply/borrow reward bug
* remove working comment
* standardize behaviour when global factors missing
* improve documentation for CalculateRewards
* standardize variable names
* remove panic from calculateSingleReward
* wip
* Tidy up comments
* remove wip comment
* organise testing committee gen state
* remove repeated test app initialization
* minor fixes from linter in tests
* move more setup to SetupApp
* split up KeeperTestSuite for each reward type
* simplify KeeperTestSuite
* simplify PayoutKeeperSuite
* simplify DelegatorRewardSuite
* simplify SupplyRewardsSuite
* simplify BorrowRewardsSuite
* simplify USDXRewardsSuite
* add auth genesis builder for easier test setup
* migrate all incentive tests to auth builder
* add incentive genesis builder for easier setup
migrate hard incentive tests
* migrate all tests to incentive builder
* add hard genesis builder
* small tidy ups
* deduplicate initialTime from borrow tests
* deduplicate initialtTime from supply tests
* deduplicate initialTime from usdx and keeper tests
* deduplicate initialTime in delgator tests
* deduplicate genesis time in payout test
* deduplicate test app initialization
* make authGenesisBuilder available for all modules
* remove unused pricefeed setup
* export incentive genesis builder
* remove commented out test cases
* migrate cdp test to new test state builders
* migrate vv payout tests to use new builders
* swap module scaffolding
* global swap fee
* can't think of a reason for begin blocker; removing for abci.go for now;
* test pair types; refactor pair name logic; simplify pairs validation and
fix stack overflow error
* check comparison
* use test package
* init swap module genesis
* add basic marshall tests
* remove reward apy from pairs
* fix integration helpers
* use max swap fee constant; fix validation of swap fee; add tests to
cover param validation and param set setup
* use noerror over nil
* start genesis tests
* test param set validation mirrors param validation
* add genesis tests
* remove print statement
* add subtests for genesis test cases; add extra querier test for unknown
route; add keeper params testing
* add spec
* update swagger
* find replace hard -> swap in comments
* remove unused method
* rename pairs to allowed pools; pool is more commonly used, and
allowedPool makes it more clear what swap parameter is for. In
addition, we won't conflict with Pool data structure for storing a
created pool in the store.
* remove generated link
* missed spec rename
* validate token order for allowed pools
* fix swagger
* json should be snakecase; change allowedPools to allowed_pools
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
* feat: add community multi-spend proposal type
* feat: add handler for community multi-spend proposals
* chore: register new community multi-spend proposal
* feat: define client for community multi-spend proposal
* fix typos in example cli json
* fix: register now proposal type with module codec
* fix: register community multi-spend proposal with gov router, not committee
* fix: define kavadist keeper before referencing it
* nit: include deposit in example proposal
* nit: update comment
* nit: fix error codes
* nit: update comments
* group reward code by type
* split out usdx reward tests into own file
* split out delegator reward tests into own file
* split supply borrow reward tests into own files
* sync order of test functions in files
* sync claims on validator state changes and slashes
* add test notes
* update missed sync delegator calls
* tidy up suite addresses initialization
* test claim synced when validator bonds/unbonds
* test validator slashed
* check reward factor increased
* test redelegation sync claim
* revert mistake
* resolve trailing TODOs
* call incentive hooks after hard liquidation
* check global index in tests after delegator reward sync
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
Co-authored-by: karzak <kjydavis3@gmail.com>
* delete incentive reward index on repay/withdraw
* call hook on borrow in all cases
* additional types functionality
* extend tests to cover fix
* update naming convention in tests
* update test comment
* feat: add set difference unit tests
* clarify test names
Co-authored-by: karzak <kjydavis3@gmail.com>
* sync indexes when deposit is small
* add test for borrow index sync when zero rewards
* update test for borrow index updates
* fix synchronize hard supply reward
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
* prevent cdp liquidation ratio being 0.0
* fix linter warning
* prevent hard conversin factor being < 1
* add liquidation tests for different keeper rewards
* switch hard and committee begin blocker order
* udpate money market deprecation steps
* move committee begin blocker in front of cdp
Co-authored-by: karzak <kjydavis3@gmail.com>
* panic on export if prev accrual time not set
* on export if interest factor not set, set to 1.0
* fix prev accrual time in cdp export
* panic on export if prev accrual time not set
* export hard reward denom accumulation times
* init genesis starts usdx reward indexes at 0.0
* update incentive migration
* update incentive tests
* initialize hard supply reward for empty rewards
* add god committee to integration test
* organize claim types, add helper methods
* reorder integration test's god committee
* legacy suppliers earn rewards + tests
* update InitializeHardBorrowReward + test
* remove formatting comments from tests
* allocate rewards to legacy borrowers + test
* apply change to update index denom methods
* Update querier to show synced rewards for legacy deposits/borrows (#834)
* update simulated sync method to show rewards for legacy deposits/borrows
* more explicity debuging logs
* revisions
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* decrement total borrow on liquidation
* copy kevin's decrement changes
* check error in liquidation
* extend decrement borrowed changes
* mimic negative check on the supplied coins side
* update liquidation test
* add module param MinimumBorrowUSDValue
* borrow/repay min limit restrictions
* add borrow/repay test cases
* update tests with new module params
* update timelock test with param
* update withdraw LTV test
* remove unused GetCurrentBorrowUSDValue method
* commit to prompt CircleCI run
* initial
* liquidation debugging
* max lot == macc coin balance
* add print statements
* add test for pricefeed liquidation scenarios
* skip zero lot
* add insolvency liquidation test scenario
* remove debugging statements
* fix tests after rebase
Co-authored-by: karzak <kjydavis3@gmail.com>
* claim hard reward keeper methods
* test hard claim payout
* claim hard rewards via cli
* query hard claims via cli
* rest txs and queries
* add handler test
* add claim type event field
* Add 'InterestFactor' to CDP type (#734)
* update cdp type to include interest factor
* fix build
* Add cdp accumulator methods (#735)
* remame fees to interest
* add accumulate interest method
* add basic test
* add note
* address review comments
* update tests
* Add sync cdp interest method (#737)
* remame fees to interest
* add accumulate interest method
* add basic test
* add note
* address review comments
* update tests
* remove old fee functions
* add method to synchronize cdp interest
* add multi-cdp tests
* add test with many blocks
* add test for interest getter
* address review comments
* calculate time difference then convert to seconds
* fix: update collateral index when syncing interest
* fix: differentiate between case when apy is zero and all fees are being rounded to zero
* fix: round time difference properly
* update cdp genesis state and migrations (#738)
* remame fees to interest
* add accumulate interest method
* add basic test
* add note
* address review comments
* update tests
* remove old fee functions
* add method to synchronize cdp interest
* add multi-cdp tests
* add test with many blocks
* add test for interest getter
* update cdp genesis state and migrations
* address review comments
* calculate time difference then convert to seconds
* fix: update collateral index when syncing interest
* fix: differentiate between case when apy is zero and all fees are being rounded to zero
* fix: simplify add/remove/update collateral index
* update genesis state to include total principal amounts
* update migration
* Delete kava-4-cdp-state-block-500000.json
* Add cdp liquidations by external keeper (#750)
* feat: split liquidations between external keepers and automated begin blocker
* address review comments
* USDX incentive accumulators (#752)
* feat: split liquidations between external keepers and automated begin blocker
* wip: refactor usdx minting incentives to use accumulators/hooks
* wip: refactor usdx minting claim object
* feat: use accumulators/hooks for usdx minting rewards
* fix: get tests passing
* fix: don't create claim objects unless that cdp type is eligable for rewards
* add begin blocker
* update client
* cleanup comments/tests
* update querier
* address review comments
* fix: check for division by zero
* address review comments
* run hook before interest is synced
* Remove savings rate (#764)
* remove savings rate
* remove savings rate from debt param
* update migrations
* address review comments
* Add usdx incentives calculation test (#765)
* add usdx incentive calculation test
* update reward calculation
* add allowable error to test criteria
* Update x/incentive/keeper/rewards_test.go
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* fix: remove old fields from test genesis state
Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com>
Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com>
* update to borrow interest factor
* add supply interest factor to accrue interest
* supply interest factor keeper methods
* fix potential bug with user borrow indexing
* sync supply interest on deposit/withdraw
* separate withdraw/deposit
* relocate interest sync methods
* update comment
* simplify supply interest statement
* check truncated int not zero
* add .sub(storedAmount) back
* add store key suppliedcoins
* increment/decrement supplied coins
* update withdraw with new accounting
* update withdraw test
* catch repay edge case
* unit tests
* TestSupplyInterest scaffolding
* test notes
* temp: interest test
* example test
* changes, test checks more state
* fix: calculate supply interest directly
* fix: catch divide by zero
* add state checks back into interest test
* add snapshot test cases
* test owed supplied interest paid at correct ratio
* test user supply syncs user's borrow interest
* remove print statements and clean up
* refactor indented logic
* test supply/borrow multiple coins
* update decoder test
Co-authored-by: karzak <kjydavis3@gmail.com>
* initial feature scaffolding
* implement interest keeper logic
* basic AccrueInterest
* accrue interest on borrow
* update borrow index formula
* update sample reserve factor
* move AccrueInterest to begin blocker
* refactor interest rate updates for accrue interest
* use interest rate model from store
* refactor begin blocker state machine
* add reserve factor to interest model params
* update comment
* store money market instead of interest rate models
* update test suite
* use BorrowedCoins store key
* update public functions and alias
* unit tests, keeper test scaffolding
* demo panic
* address revisions
* add 'normal no jump' test case
* spy = 1 + borrow rate
* update comment
* APYToSPY unit test
* per user borrow index list
* interest keeper test
* test: interest applied on successive borrows
* varied snapshot times
* test: multiple, varied snapshots
* address revisions
* add pending interest before validating new borrow
* update makefile
* address revisions
* fix test
* use kava antehandler
* add authenticated mempool decorator
* add get authorised address methods
* hook antehandler into app
* refactor address fetcher interface
* tidy up args to NewApp
* remove unused function
* tidy up after removing address fetcher interface
* read authorized addresses from config
* fix error message, and minor tidy
* update cosmos-sdk and tendermint
* clarify function name
* add flags for mempool options
* update MaximumLimit param to MaximumLimitUSD
* track total borrowed coins in the store
* implement total borrowed coins querier
* add maximum value usd check
* update test suite, add zero coins check
* add test case, update error msg
* max limit in native amount
* remove debug logging
* prepare for master rebase
* master rebase
* fix build
* fix: check for any status other than bonded
* Add harvest staking tests (#680)
* refactor config initialization
* refactor delegator rewards test, add tests
* fix share to token calculation, add unbonding test
* remove dead link
Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com>
* fix: don't allow denoms other than hard for harvest rewards
* fix: parse cli flags correctly
* fix: convert duration to seconds before calculating time elapsed
* fix: don't distribute rewards before they start or after they end
* fix: return correct message type
* wip: and types and keeper methods
* add keeper tests
* add client
* add spec and events
* respond to review comments
* apply suggestions from review
* feat: add test for validator vesting case
* use int64 for multiplier type
* remove incentive changes
* feat: query old blocks for auctions
* fix: add next auction id to querier
* fix: set boolean when found
* fix: use correct query route and params
* apply suggestions from review comments
* fix go version in dockerfile
* mix frequently occuring errors
* add missed import
* fix minor validator vesting sim bug
* fix auction sim bug
* fix docker build
* add todo from sim failure
* tidy up dockerfile
* update docs, add dockerignore to speed up builds
* Update simulations/README.md
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* add stack traces to logs for easier debugging
* replace root func with sdk version
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
Co-authored-by: karzak <kjydavis3@gmail.com>
* use remaining length when sending coins to vesting account
* query claims that have corresponding claim periods
* cleanup comments
* remove debugging statements
* fix bug with inserting period in middle of vesting schedule
* apply review suggestion
* add collateral type field to cdp and collateral param
* fix upstream tests
* fix simulations
* fix validation logic
* update incentive to use collateral type instead of denom
* use collateral type instead of denom in cdp
* remove unused code
* address review comments