* 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
* 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>
* 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>
* 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
* 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>
* 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
* Incentive module simulations (#439)
Co-authored-by: John Maheswaran <jmaheswaran@users.noreply.github.com>
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
Co-authored-by: Kevin Davis <kjydavis3@gmail.com>
Co-authored-by: John Maheswaran <john@kava.io>