* 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
* 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
* 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>
* 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 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
* 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
* 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>
* bump SDK version to v0.38.3
Co-authored-by: Denali Marsh <denali@kava.io>
Co-authored-by: Kevin Davis <kjydavis3@gmail.com>
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
Co-authored-by: denalimarsh <denalimarsh@gmail.com>
Co-authored-by: rhuairahrighairigh <ruaridh.odonnell@gmail.com>
* R4R: BEP3 module (#370)
* bep3 module scaffold from cosmos/scaffold
* Populated types, keeper with HTLT msgs, module params, and scaffolding for keys, and genesis
* added KavaHTLT struct, UpdateHTLT struct, resolved compilation errors
* refactored kavaHTLT struct <-> msgs
* Implemented params, refactored UpdateKavaHTLT to UpdateKHTLT interface
* Updated keeper with byTimeIndex methods
* HTLT creation flow
* adjustments in prep for repo config updates
* App moudle updated for bep3, MsgCreateHTLT tested, HTLT keeper methods tested
* Updated bep3 params to match spec
* tests for MsgRefundHTLT, MsgDepositHTLT, MsgClaimHTLT
* AddHtlt cli cmd, queryHtlts cmd, added conversion funcs for binance -> cosmos types, refactored MsgCreateHTLT from binance.AccAddress to sdk.AccAddress
* working edits related to bep3-deputy compatibility
* removed binance-chain go sdk dependency
* updated msg ValidateBasic() return to sdk.Error type
* implement MsgCalculateSwapID
* added MsgCalculateSwapID test, updated randomNumberHash type to []byte
* removed binance type conversions
* msg codec registration
* clean /types directory
* CLI cmds:create htlt, query htlt
* update keeper logic
* handle MsgCreateHTLT
* implement htlt type, msg types
* implement global chain types
* update querier
* added go-ethereum to go mod
* refactor QuerySwap to QueryHTLT
* update HTLTMsg to MsgCreateHTLT
* implemented htlt deposit
* add token transfer to MsgCreateHTLT
* implement refund, claim client txs
* add refund/claim cmds to tx cmd
* commiting go.sum for build
* implemented keeper claim logic
* add RandomNumberHash to create-htlt event
* implement refund keeper logic
* AddHTLT updated to CreateHTLT
* added params keeper
* updated params to single chain, added sample genesis file
* implemented htlt keeper param checks
* removed go-ethereum dependency
* updated go.sum
* housekeeping on keeper tests
* updated cli tx cmds
* ran go.tidy
* remove links from module readme
* updated coin construction in tests
* added expectedIncome checks in ValidateBasic()
* made ValidateAsset() more robust
* update param format for tests
* added basic HTLTByTime index
* implement abci, fix expectedIncome validation
* byTime index updated to blocks, added swap ID & expiration block to htlt
* added not-expired check to HTLT claims
* cross-chain mint/burn logic, htlt string type refactored to []byte
* fix bnb_deputy_address param
* remove abci panic
* cmn.HexBytes, byTime index iteration update, claim-mint logic update
* update genesis example
* general codebase cleaning
* renamed HTLT to AtomicSwap
* staging for PR
* updated naming conventions
* refactor + revisions
* removed code related to deposits & swap block index
* added timestamp validation comment
* post-refactor housekeeping
* post refactor housekeeping (keeper)
* remove GenesisAtomicSwap type
* refactor asset supply logic
* BeginBlocker expires swaps automatically
* param asset.limit type updated to sdk.Int
* remove claimed swaps from block index
* fix DefaultDeputyAddress
* removed BaseSwap
* revisions
* total genesis coins
* updated tx examples
* Automatically update fees for risky cdps (#381)
* wip: sketch implementation
* adding initial function to calcuate risky fees for cdps
* adding todo comment to fix the function arguments
* changing the function arguments
* adding multiplication, print error, change types
* get the number of periods, add comments and questios for code review
* adding specification notes
* removing old comment
* replace collateral with collateral denom
* remove todo and clarify comment
* Update x/cdp/keeper/fees.go
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update x/cdp/keeper/fees.go
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update go.sum
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update x/cdp/keeper/fees.go
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update x/cdp/keeper/fees.go
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update x/cdp/keeper/fees.go
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update x/cdp/abci.go
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* updating fees
* error handling and propogation
* fix collat denom variable
* fix build issues, error, variable names, parameter type
* Update x/cdp/abci.go
Use `err` as name instead of `e`
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update x/cdp/keeper/fees.go
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* fixing error variable name
* changing call to method to compute risky cdps fees
* changing the calcualation to select risky cdps to be based on normalized ratio
* adding skeleton for test methods, adding skeleton helper function for creating cdps for use in tests
* fixing function call to helper method
* fix assignment, calling function that returns two variables instead of one
* adding comment and fixing call to create cdps
* adding create cdps function and updating / fixing the test. one of the expected tests is failing, need to figure out why that is. added a todo question to note it
* logging the cdp object before and after updating. it seems that the fees are not set / written before or after
* adding interim changed
* updated
* fixing normalized ratio
* code cleanup
* changing print of accumulated fees
* removing debug code
* remove completed todo
* remove old variable
* remove spewing print statement
* remove dead todo
* adding note about prices for future
* remove dead code
* try to fix test
* fix types
* fix types
* fix context in call
* changing back as new version breaks a test
* fix
* cleanup, removing logging and old code
* remove dead code
* removing changes to cdp test
* Update x/cdp/keeper/fees.go
Remove old comment as suggested
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update x/cdp/spec/04_begin_block.md
Fix typo as suggested
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* Add Savings Rate (#365)
* fix: ensure cdp module accounts created at gensis
* feat: add savings rate
* chore: update alias
* fix: update default test param values
* chore: update spec for savings rate
* fix: add distribution time to genesis state
* fix: iterate over accounts using callback function
* feat: use seprate mod account for savings rate
* fix: remove mod account coins from total supply
* address review comments
* fix: genesis function initialization
* fix: update alias
* add comment about maintaining module account list
* feat: add genesis example
* R4R: bep3 module upgrades (#388)
* bep3 module scaffold from cosmos/scaffold
* Populated types, keeper with HTLT msgs, module params, and scaffolding for keys, and genesis
* added KavaHTLT struct, UpdateHTLT struct, resolved compilation errors
* refactored kavaHTLT struct <-> msgs
* Implemented params, refactored UpdateKavaHTLT to UpdateKHTLT interface
* Updated keeper with byTimeIndex methods
* HTLT creation flow
* adjustments in prep for repo config updates
* App moudle updated for bep3, MsgCreateHTLT tested, HTLT keeper methods tested
* Updated bep3 params to match spec
* tests for MsgRefundHTLT, MsgDepositHTLT, MsgClaimHTLT
* AddHtlt cli cmd, queryHtlts cmd, added conversion funcs for binance -> cosmos types, refactored MsgCreateHTLT from binance.AccAddress to sdk.AccAddress
* working edits related to bep3-deputy compatibility
* removed binance-chain go sdk dependency
* updated msg ValidateBasic() return to sdk.Error type
* implement MsgCalculateSwapID
* added MsgCalculateSwapID test, updated randomNumberHash type to []byte
* removed binance type conversions
* msg codec registration
* clean /types directory
* CLI cmds:create htlt, query htlt
* update keeper logic
* handle MsgCreateHTLT
* implement htlt type, msg types
* implement global chain types
* update querier
* added go-ethereum to go mod
* refactor QuerySwap to QueryHTLT
* update HTLTMsg to MsgCreateHTLT
* implemented htlt deposit
* add token transfer to MsgCreateHTLT
* implement refund, claim client txs
* add refund/claim cmds to tx cmd
* commiting go.sum for build
* implemented keeper claim logic
* add RandomNumberHash to create-htlt event
* implement refund keeper logic
* AddHTLT updated to CreateHTLT
* added params keeper
* updated params to single chain, added sample genesis file
* implemented htlt keeper param checks
* removed go-ethereum dependency
* updated go.sum
* housekeeping on keeper tests
* updated cli tx cmds
* ran go.tidy
* remove links from module readme
* updated coin construction in tests
* added expectedIncome checks in ValidateBasic()
* made ValidateAsset() more robust
* update param format for tests
* added basic HTLTByTime index
* implement abci, fix expectedIncome validation
* byTime index updated to blocks, added swap ID & expiration block to htlt
* added not-expired check to HTLT claims
* cross-chain mint/burn logic, htlt string type refactored to []byte
* fix bnb_deputy_address param
* remove abci panic
* cmn.HexBytes, byTime index iteration update, claim-mint logic update
* update genesis example
* general codebase cleaning
* renamed HTLT to AtomicSwap
* staging for PR
* updated naming conventions
* refactor + revisions
* removed code related to deposits & swap block index
* added timestamp validation comment
* post-refactor housekeeping
* post refactor housekeeping (keeper)
* remove GenesisAtomicSwap type
* refactor asset supply logic
* BeginBlocker expires swaps automatically
* param asset.limit type updated to sdk.Int
* remove claimed swaps from block index
* fix DefaultDeputyAddress
* removed BaseSwap
* revisions
* total genesis coins
* updated tx examples
* timestamp to unix
* add past timestamp limit
* update random number byte encoding
* add recipient_other_chain to AtomicSwap
* add TODO for timestamp arg parsing
* generate secure random numbers
* update tx cli
* keeper tests
* add bnb token
* bep3 params test set up, test CreateAtomicSwap
* swap table tests
* Revert "bep3 params test set up, test CreateAtomicSwap"
This reverts commits containing tests.
* use tmtime.Now()
* Kava distribution module (#387)
* wip: kavadist module structure
* feat: implement minting logic
* wip: sketch module
* wip: module level code
* wip: bug fixes
* wip: add tests
* wip: resolve todos and tidy
* fix: remove unused file
* address review comments
* fix: update genesis for guide (#394)
* add kava_dist to sample genesis file (#396)
* R4R: BEP3 module test suite (#395)
* refactor secure rng
* refactor common tests, implement keeper tests
* implement asset tests
* implement params, querier tests
* implement keeper swap tests
* refactor import naming conventions
* implement core types tests
* improve keeper swap tests
* implement genesis types test
* implement params test + revisions
* implement duplicate swap test
* implement duplicate swap ID test
* R4R: BEP3 additional features + module test suite (#397)
* update and reorder errors
* implement swap deletion block delay
* add swap deletion block delay, set up tests
* add secure random number gen
* implement AtomicSwapLongtermStorage index
* fix syntax error
* abci test updates
* implement handler test
* implement core genesis tests
* update asset supply logic
* implement functional asset supply
* pretty print atomic swaps
* requested revisions
* fix test suite post merge
* implement and integrate asset supply tests
* update import genesis, add storage duration param
* implement swap deletion ABCI test
* go mod tidy
* remove duplicated interface assertion
* add new bep3 param to contrib genesis file
* remove btc from supported assets
* revisions: LongtermStorageDuration param
* revisions: suite ctx, fix genesis, update contrib
* implement AssetSupply type, store key, keeper
* integrate supply and swaps; genesis, tests
* remove legacy comments
* requested revisions
* update alias
* Swagger Rest Automating Testing With Dredd (#390)
* swagger testing and mods
* fixed a test
* fixed withdraw address
* adding script to start the chain
* fixed val rewards test
* fix outstanding rewards test
* fixed rewards
* hooks skeleton
* adding test file and hooks
* updates on the hooks working
* now creates a transaction and sends to the chain via rest api successfully
* small fix - now works
* 34 tests now passing successfully
* fix print statement error
* instructions on how to run the tests
* changing function names when to run the hooks
* adding instructions on how to setup and run the dredd tests
* removing large error output file
* removing binary file
* removing more output logging files
* creating a vote on a proposal to send to the blockchain
* adding instructions on how to setup chain
* adding function to get account number and sequence number
* adding send msg to blockchain method
* posting vote tx to blockchain - successfully prepares and sends vote to endpoint but endpoint returns 'inactive proposal with id'
* successfully depositing 600 stake to a proposal
* successfully depositing onto a proposal and then voting on it
* got another governance test working now after submitting a vote to the blockchain
* updating instructions on how to run
* fixed another voting test
* fixed deposits test
* fixed another gov test
* fix print line
* fix circle ci build issue with println
* improving instructions on how to build and run the hooks and dredd tests
* improving instructions on how to build and run the hooks and dredd tests
* finally fixed param change governance proposal test
* trying to unskip tests wip
* fixed gov/proposals test
* fixed another test
* fixed a slashing test
* fixed another redelegation test
* fixed another unbonding delegation test
* fixed more staking tests
* fixed another staking test
* fixed another test
* fixed more tests. 50 now passing, 15 failing
* fixed mislabeled variable
* managed to fix unjail test
* fixed bank acct transfers test
* change certain types from number to string to match the output, typo fix
* another typo fix
* fixed delegation test
* finally figured out and fixed the latest blocks types mismatch - fixed the test
* fixed staking delegators validators test
* removed and noted unimplemented tests from yaml file. fixed blocks height test
* fixed transcations test
* adding functionality to send transfer of coins to blockchain, and to send delegations
* updating the yaml to line up with a valid message format
* added delegation method
* adding test results showing 57 are now passing and only 5 failing
* remove test yaml file from pull req
* testing file updates
* adding test memo
* added undelegation hook method - fixed unbonding delegation test
* fixed the get tx from hash test
* adding not if you encounter validator set is different errors how to fix. 59 tests now passsing, 3 failing
* adding test results showing 59 passing, 3 failing
* finally fixed encode test - 60 tests now passing only 2 failing
* adding test results 60 passing 1 failing
* more test updates
* finally fixed decode test - 61 tests now passing only 1 failing
* test results 61 tests passing 1 failing
* remove dead code
* all 62 tests are now passingga swagger.yaml 0 failing
* used for testing and generating transactions and testing hooks
* updating run instructions
* more instructions updates
* updating the test file
* adding note on reading from a file
* refactoring code and cleanup
* refactoring getting the keybase
* code cleanup for address, keyname methods, remove unused code
* more code cleanup around addresses
* updating the instructions on how to run the dredd tests
* adding comment
* adding additional requirements to the go.mod dependency file
* remove hardcoded home directory, read using os golang library
* increase timeout in example run script
* remove hardcoded home directory
* reordering commands to get rid of errors if key directory is deleted
* changing to use temporary directory
* updating dredd timeout time
* finally managed to get the script wroking using a temporary directory instead of the default
* adding notes and comments
* changing to use a temp directory instead of default directory
* remove un-needed file
* rename debugging tools folder
* adding instructions to install dredd and npm
* Update swagger-ui/startchain.sh
Send output to dev null not to console
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* Update swagger-ui/startchain.sh
Send output to dev null not to console
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
* adding new version of test.go to setup the chain
* adding todo to update instructions for new workflow
* updating script to start and setup the chain
* updating the transaction hash test
* update the start chain script to setup the chain correctly
* add the script to stop the chain and the rest server
* updated the instructions for the new workflow so that all the tests pass the first time
* updated the instructions on how to run the tests
* update instructions for printing logs or not
* updating the startchain script to add messages when starting the rest server and preparing transactions
* adding print messages when stop chain is completed
* updating test results to just include test output and not the debug log statements
* cleaning up the messages that are printed to the user
* moving files to their own directory
* build go test file and remove previous binary
* move instructions
* updating instructions now that test file is auto built
* building, running dredd tests, propagating error code, shut down blockchain all in one script
* fix object type to array type for block latests
* cleaning up the script
* rename script as it now does all the setup, test running, shutdown, and cleanup
* update instructions for new workflow
* adding a shell script to call from the makefile
* adding a make command to build and run all the dredd tests
* update instructions to run using make
* updated code review comment
* minor update to instructions
* update remove file command so doesn't print an error if the file has already been deleted
* renaming folder and test
* adjust code comment
* removing example test results
* updating instructions to remove reference to the test results
* remove old hooks file
* remove obsolete code comment
* remove swagger file, will change references to the other one
* remove shell script, will now use the one called from make instead
* renaming as underscore messes up go build
* clean up script, fix return code issues
* cleanup output file
* fix object to array issue
* add comments to explain functionality
* use variables for kvd home and kvcli home, check for errors
* change the kvcli home directory. need to take this from command line
* take kvcli from command line parameter to golang file
* take kvcli directory from command line parameter
Co-authored-by: John Maheswaran <john@kava.io>
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* R4R: Update BEP3 rest endpoints + format example requests (#402)
* update and reorder errors
* implement swap deletion block delay
* add swap deletion block delay, set up tests
* add secure random number gen
* implement AtomicSwapLongtermStorage index
* fix syntax error
* abci test updates
* implement handler test
* implement core genesis tests
* update asset supply logic
* implement functional asset supply
* pretty print atomic swaps
* requested revisions
* fix test suite post merge
* implement and integrate asset supply tests
* update import genesis, add storage duration param
* implement swap deletion ABCI test
* go mod tidy
* remove duplicated interface assertion
* add new bep3 param to contrib genesis file
* remove btc from supported assets
* revisions: LongtermStorageDuration param
* revisions: suite ctx, fix genesis, update contrib
* implement AssetSupply type, store key, keeper
* integrate supply and swaps; genesis, tests
* remove legacy comments
* requested revisions
* update alias
* rest queries
* implement BEP3 REST txs
* draft rest server readme + example json files
* tested all swap rest examples
* implement query swaps rest endpoint
* feat: update genesis examples
* fix: use post instead of put (#405)
Co-authored-by: Denali Marsh <denali@kava.io>
Co-authored-by: John Maheswaran <jmaheswaran@users.noreply.github.com>
Co-authored-by: John Maheswaran <john@kava.io>
* refactor bidding test
* add some more bid test cases
* add balance checks to bid tests
* add more checks to bid tests
* add min bid increments
* protect against negative lot amounts
* fix params tests
* change endblocker to beginblocker
* update spec
* fix params tests
* fix: update alias
Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
* stub out simulation integration for cdp, pricefeed
* stub out simulation integration for auction
* fix cdp export
* update pricefeed to match
* update validator-vesting to match