* 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
* move file to query.go (we are adding functionality so specific name
doesn't fit anymore)
* Add tx search for proposals in cli query proposal
* add rest support, height support for rest api, and add go doc string
* add in deadline calculation
* update changelog
Co-authored-by: Kevin Davis <kjydavis3@gmail.com>
* add initial augmented swaps to bring cli & rest api's under same schema
* use an array type
* update to not cause breaking changes in REST API -- don't embed swap
fields
* add module accounts command
* update get accounts query to return array of
module accounts instead of map of addresses
* update tests and add update swagger
Co-authored-by: Kevin Davis <kjydavis3@gmail.com>
* refactor price generation to use determistic sequence up to each block
height and reset for each simulation
* remove extra whitespace
* improve comment
* move PriceGenerator to simulation/types to keep logic clean
* fix exhibit 30 - remove redunant conversions in adding principle to fee
amount, and store debt denom in local var to avoid calling getter
several times
* add deleted comment back
* resolve exhibit 41 - move redundant assignment into if block and only
assign if value is false. No need to assign true to already true value.
* fix exhibit 43 - use existing auctionID variable instead of GetID
* use improved name for auction type in case statemnt
* rename a to auction in PlaceBidSurplus for legibility (part of exhibit 44)
* rename a to auctions in PlaceForwardBidCollateral (part of exhibit 44)
* rename a to auction in PlaceReverseBigCollateral for legibility (part of exhibit 44)
* rename a to auction in PlaceBidDebt for legibility (part of exhibit 44)
* renmae rest of a to auction variables for legibility and resolve exhibit
44
* one missed rename and a typo fix
* update GetTotalSurplus and GetTotalDebt code blocks to be consistent and
resolve feedback in exhibit 13
* spelling fix
* remove uneeded temp variables
* address PR feedback - use suite.Require() instead of default assertions
* initial sketch
* add module migrations
* add migrations for all accout types
* test account migration
* add tendermint migration and migrate cmd
* remove need for errors pkg dependency
* add bech32 decoding fork
* add suggested params and cmd to write them
* add basic upgrade instructions
* fix tests
* address some migration todos
* tidy contrib folder
* finalize params values
* align cdp init genesis with other modules
* add tendermint and distribution test
add custom distribution migration to patch bug
* add staking migration test
* add slashing, evidence tests, refactor auth tests
* add full migration test
* remove go-amino dependency from go.mod
also tidy up unused indirect dependencies
* address remaining TODOs
* remove commented out code from legacy types
* add spot/liquidation markets ids to kava-3 params
* Apply suggestions from code review
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
* address code review suggestions
* add validate genesis to migrate test
* refactor add params func
* remove commented out code from old types
* fix add params
* add deputy address
* add tests using exported kava-2 state
* incorporate new cdp params from master
* update params from review
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* add deputy account
* add committee permissions for new params
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>