* extract hard claim migration function
* tidy up claim delegator index migration
* fix invalid hard claims
* fix comment missed in merge conflict reolution
* fix tests
* minor migration refactor
* overwrite usdx claims with latest reward indexes
* add missing usdx claims in migration
* add script to calculate missing usdx rewards
* generate missing rewards using preliminary data
* add missing usdx rewards in migration
* update missing rewards data to use correct genesis
* test rewards were not decreased
* add tests for missing reward calculations
* clarify function names
* test to assert total new rewards are as expected
* remove unecessary todo item
* implement swp airdrop to usdx depositors to hard
* verify swp airdrop amount, total supply, affected users
* remove unused test code
* add map as go file
* update tests to use stored variable
* re-add snapshot test
* update snapshot testdata
* remove unused code for generating swp airdrop map
* remove snapshot test
* add swp token distribution
* bump test timeouts
* address review comments
* use global variables to simplify testing assertions on swp supply
* optional: swp migration test and small refactor (#1005)
* add test to ensure balances are not decreased
* simplify slice manipulation
* bump context deadline in circleci
Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com>
* implement swp airdrop to usdx depositors to hard
* verify swp airdrop amount, total supply, affected users
* remove unused test code
* add map as go file
* update tests to use stored variable
* re-add snapshot test
* update snapshot testdata
* remove unused code for generating swp airdrop map
* remove snapshot test
* update acceptance test to fail
* update periodic vesting reset to reflect additive period lengths, not
absolute lengths
* simplify end time logic
* remove log
* test inclusion of v0_15 migration tests
* add auth test data
* add periodic vesting account migration
* assert owned coins are equal and unchanged during migration
* add script for generating test data from a genesis file
* remove commented import
* touch ups
* don't pretty print test data for auth module; update generate script to
use jq -c option
* fix typo in comment, improve clarity of assertions
* add context to migrate auth assertions
* add 180 days check for spendable coins
* asssertion context
* pr feedback - add assertions, touch up assertion msgs, and fix migration test to correctly
type assert pointer
* 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
* 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>