* Add methods for reward accrual time
* Add accrual time methods
* Add claim type to IterateAllRewardAccrualTimes callback method
* Use new AccrualTime proto type for state methods, add to genesis
* Add GetAllRewardAccrualTimes doc
* Add accrual times to genesis methods
* Remove DecodeKeyPrefix
* Update acrual time iterate method naming
* Update Iterate claims naming
* Use method for sourceID key conversion
* Update incentive test to use beginblocker instead manual accumulation
* Update integration test suite
* Add base integration test, wip staking reward calculation
* Get actual staking reward amounts from BeginBlocker events, calculate expected indexes
* Simplify event parsing
* Add initial earn accum test with real keepers
* Add the rest of the accum integration tests with real keepers
* Check if delegation rewards are zero before transferring
* Update staking integration test to use updated methods
* Call earn hooks with correct share values
User's shares instead of total vault shares
* Use different amounts for different accounts
* Add claim test with staking claims
* Remove logging statements
* Remove log
* Pass suite.T() to mock earn hooks
* Use begin blocker for staking reward distribution
* Remove unused beginblocker
* Remove log
* wip Add claim
* Add distr keeper and claiming
* Add claim test
* Update claim test with failures
* wip Add staking rewards
* -S
Fix savings to earn incentive methods
* Use a single accural time for all earn incentives
* Add additional required liquid methods
* Update genesis to only include 1 accrual time for earn
* Revert "Update genesis to only include 1 accrual time for earn"
This reverts commit cc7e35347298681c0c8a4a0b9bf9b9b296c25531.
* Revert "Use a single accural time for all earn incentives"
This reverts commit aeb49c4622d4e3d99dc6421c8830932b1b546be9.
* Update tests with incentive distribution
* Add earn to incentive rewards query
* add earn cli tx
* Update claim example to use ukava large
* Use underlying ukava to determine proportional reward amount
* Rename liquid methods to reflect derivative value
* Add tests for derivative values
* Return error to panic in BeginBlocker
Co-authored-by: karzak <kjydavis3@gmail.com>
* Add module name to multiplier
* Add claim test to use correct multiplier
* Add separate test for GetMultiplierByDenom
* Add 0 length lockup for earn to params test
* Add additional tests for genesis and params
* Add bkava handler for earn incentives
* Add bkava accum tests
* Add bkava denoms in index state
* Set storeTimeEquals to default value
* Add supply expected keepers
* Add tests for proportional adjustment
* Add liquid keeper to incentive keeper
* Use weighted reward periods for bkava
* Add liquid keeper to tests
* Add Accumulate override rewards period with deccoins
* Adjust test to handle sub unit coins
* Add liquid keeper to test
* Fix div by zero for proportional rewards
* Update test for actual expected values
* Update expected indexes to be same for different vaults
* Allow no stored time for vaults that have no indexes or state
* Add test for partial bkava deposit
* Add math check to test
* Deterministically iterate over bkava denoms
* Remove unused expected liquid method GetAllDerivativeDenoms
* Add incentive types
* Add earn state methods
* Update earn incentives
* Update unit test NewKeeper to include earn keeper
* Fix sharesOwned typo
* Shares not used for AfterVaultDepositCreated
* Add earn to init genesis
* Pass earn keeper to incentive keeper
* Add sdk.Msg impl, disable legacy migrations
* Disable migrations
* Update incentive earn sync test
* Add earn to client and querier
* Add accum and init tests
* Add additional earn tests
* Fill in fakeEarnKeeper methods to fix tests
* Add earn reward periods to params, begin blocker earn reward
* Add earn to query
* Update genesis_test with missing DefaultMultiRewardPeriods parameter
* Remove disable of migration package
* Fix proto type comments
* Remove unused migration state
* Add legacytx.LegacyMsg compile time interface check
* add earn state validation to genesis validation
Co-authored-by: rhuairahrighairigh <ruaridh.odonnell@gmail.com>
* ibc v3 upgrade
* ibc no longer uses confio
* add proofs proto for ibc/v3
* wip add ethermint module
* update cosmos to 0.45.0
* add ethermint proto & bug fixes
* remove todo
* update docs
* fix a number of bugs
* minor comments update
* fix breaking tests
* Wrap bank keeper for EVM to convert decimals (#1154)
* Add bankkeeper wrapper for evm
* Remove agas from init-new-chain.sh, use ukava for evm_denom
* Fix sdk.Coins conversion, require min 1 coin amount
* Remove gas from init script
idk how this happened lol
* Remove debug logging stmt
* Restore original init ukava amounts
* Fix inplace coins conversion
* Use evmtypes.BankKeeper interface insteadof banktypes
* Add TestGetBalance
* Add doc comments, remove temp actualAmt vars
actualAmt vars replaced with inline calls to make it more clear that the
converted value is being used, as opposed to accidentally reusing the
raw EVM amt.
* Add TestSetBalance
* Add TestIdempotentConversion
* Panic if converted coin from EVM is 0
This happens if a value is less than 1ukava
* Deep copy coins instead of in place modification
* Update test coins amount
* Add panic tests for small EVM amounts
* Use evmtypes.BankKeeper as NewEVMBankKeeper param
* Tidy test setup
* ensure sdk config is set when creating new apps
* Respond EVM bank keeper GetBalance with SpendableCoins
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
* further speed up docker builds
* feat: restore previous keys add defaults, add eth flag (#1172)
* feat: restore previous keys add defaults, add eth flag
* remove outdated comment
* fix: remove redundant flag default
* evm bank keeper with akava handling
* fix issues
* add remaining tests
* add emv module to app
* add missing imports
* clean up comments
* wip akava keeper
* evm keeper
* fix genesis import
* reduce module permissions
* add bank keeper tests
* cleanup tests
* genesis tests
* change defaults
* add eth faucet key & fix issues
* switch to kava ethermint
* add a lot of tests
* add balances invariant
* add evm tests
* Remove panic if Swagger disabled in config (#1155) (#1183)
Co-authored-by: Derrick Lee <derrick@dlee.dev>
* add invariant to catch any akava balance > 1 ukava
* clarify name of balances invariant
* connect invariants to app
* fix evmbankkeeper akava issues
* add spec for evmutil
* remove zero balance accounts from state
* minor adustments
* update to ethermint 0.10.0
* fix eth ante
* add missing godoc comment
* Update x/evmutil/spec/01_concepts.md
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* Update x/evmutil/spec/01_concepts.md
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* Update ethermint to v0.12 (#1203)
* update to ethermint v0.12.2
* use app.Options for new evm options
* fix missed references to app.Options
* use ethermint branch while waiting on upstream fix
* evm migrations for tesnet alpha 2 (#1206)
* update to ethermint v0.12.2
* use app.Options for new evm options
* fix missed references to app.Options
* use ethermint branch while waiting on upstream fix
* add upgrade handler for evm-alpha testnet 2
* v17 migration setup + evm modules
* refactor migrate states
* x/feemarket migration
* v17 migrations setup + evm modules migration (#1210)
* v17 migration setup + evm modules
* refactor migrate states
* update gen time
* fix: update genesis time in test output
Co-authored-by: karzak <kjydavis3@gmail.com>
* add savings module to app blockers
Co-authored-by: Derrick Lee <derrick@dlee.dev>
Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
Co-authored-by: rhuairahrighairigh <ruaridh.odonnell@gmail.com>
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com>
Co-authored-by: karzak <kjydavis3@gmail.com>
* move multipliers to their own file
* add multipliers per denom to MsgClaimHardReward
* claim with multipliers per denom for hard claims
* remove unused error
* add multipliers per denom to params
connect to to hard claiming
* temporary fix migration
* update usdx claiming for new multiplier params
* claim with multipliers per denom for delegator
* claim with multipliers per denom for swap rewards
* tidy up multiplier name validation
* rename new multipliers field in params
* remove old multpliers from params
* clear up various TODOs
* add tags to new structs
* remove dead code
* extract borrow sync logic into separate func
* fix borrow reward calculations
Use the normalized borrow as the source shares in reward calculations.
* extract supply sync logic into separate func
* prepare to fix supply reward calculations
* fix deposit reward calculations
Use the normalized deposit as the source shares in reward calculations.
* extract usdx sync logic into separate func
* prepare to fix usdx reward calculations
* fix cdp reward calculations
Use the normalized cdp debt as the source shares in reward calculations.
* fix compile error from messed up partial stage
* Fix incentive usdx reward bug (#976)
* minor test refactors
* fix overpayment bug
Init methods should not read params.
Add test to cover bug
* fix typos
* 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
* 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 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 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>
* 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