Commit Graph

803 Commits

Author SHA1 Message Date
Kevin Davis
3d6e730368
address issues from audit (#793) 2021-02-04 11:35:24 -07:00
Denali Marsh
be498c72f5
sync supply interest before ValidateBorrow (#798) 2021-02-04 17:54:13 +01:00
Denali Marsh
9fa83f0a1e
remove GetPreviousBlockTime/SetPreviousBlockTime (#797) 2021-02-04 17:54:01 +01:00
Denali Marsh
facb357fe9
return err in ValidateBorrow (#799) 2021-02-04 17:53:50 +01:00
Denali Marsh
754c018f04
Incentive module multiple reward denom tests (#788)
* types: multiple rewards

* supply-side reward keeper methods

* remove legacy comments

* update hard claim reward to coins type

* borrow-side reward keeper methods

* update claim payout to sdk.Coins

* make tests compile

* fix genesis validation for compile

* comment out failing tests

* fix ! found logic

* accumulate hard supply rewards (single)

* sync hard supply rewards (single)

* update hard borrow/supply index denoms

* accumulate hard borrow rewards (single)

* sync hard borrow rewards (single)

* sync hard delegator rewards

* payout hard claim (single)

* accumulate hard supply rewards (multiple)

* sync hard supply rewards (multiple)

* update hard supply index denoms (multiple)

* update hard borrow index denoms (multiple)

* accumulate hard borrow rewards (multiple)

* sync hard borrow rewards (multiple)

* fix denom

* remove comment

* fix merge

* payout hard reward (multiple)

Co-authored-by: karzak <kjydavis3@gmail.com>
2021-02-03 23:23:53 +01:00
Denali Marsh
0c1fa5d27b
emit hard liquidation event (#790) 2021-02-03 23:23:17 +01:00
Denali Marsh
7be0c8b48e
decrement supplied coins (#791) 2021-02-03 23:23:03 +01:00
Denali Marsh
cfb9e0cb76
add liquidate msg to codec (#792) 2021-02-03 23:22:51 +01:00
Kevin Davis
dd3470260d
add v0.13 legacy types for kava-5 (#784) 2021-02-02 15:10:57 -07:00
Kevin Davis
6118876074
[R4R] fix: match reward payouts to current harvest v1 payouts (#786)
* fix: payout rewards on 1st or 15th of month

* backport payout test

* fix: add default case
2021-02-02 15:10:32 -07:00
Kevin Davis
37be34b4d6
fix: replace is zero time check (#787) 2021-02-02 14:42:51 -07:00
Kevin Davis
71f60ec4d9
fix: update synchronize claim method (#789) 2021-02-02 14:42:01 -07:00
Denali Marsh
9b52154409
Accrue Hard module rewards in multiple coin denoms (#785)
* types: multiple rewards

* supply-side reward keeper methods

* remove legacy comments

* update hard claim reward to coins type

* borrow-side reward keeper methods

* update claim payout to sdk.Coins

* make tests compile

* fix genesis validation for compile

* comment out failing tests

* fix ! found logic
2021-02-02 09:17:46 -07:00
Denali Marsh
58494fe357
Hard: fix liquidation engine (#771)
* 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>
2021-02-01 14:13:17 -07:00
Denali Marsh
b5e02fde35
Hard incentive reward querier updates for acceptance (#782)
* simulate hard reward sync for querier

* test hard sync simulations

* simulate usdx minting sync for querier

* test usdx minting reward simulation
2021-01-29 13:32:07 -07:00
Denali Marsh
92a2425668
Query rewards via incentive module (#781)
* query rewards types

* query rewards keeper

* query rewards cli/rest

* query rewards alias

* implement branched query

* mirror changes in rest querier

* clean up rest querier
2021-01-27 14:33:36 +01:00
Denali Marsh
3a08fc582b
Incentive PR 4: claim Hard rewards via the Incentive module (#780)
* 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
2021-01-26 12:52:34 +01:00
Denali Marsh
72a6df17fd
Hard: Kava delegators earn HARD rewards via the Incentive module (#776)
* add staking keeper to incentive module

* update hard with delegator methods

* add delegator methods to incentive

* implement delegator hook scaffolds

* implement hard delegator reward accumulation

* update claim names to delegator

* stakingKeeper expected keeper methods

* accumulate delegator rewards

* initialize delegator reward

* synchronize delegator reward

* add TODO comments to rewards

* implement staking hooks interface

* initial revisions

* remove outdated TODO

* update methods for test compatibility

* update method names for test compatibility

* implement initial accumulate delegator reward test

* attempt validator set up in staking module

* initial synchronize delegator reward test

* delegator accumulation test passing

* synchronize delegator rewards test (not passing)

* synchronize delegator rewards passing

* revisions
2021-01-25 13:58:12 +01:00
Kevin Davis
dc330d02bf
Update hard genesis state (#777)
* feat: update hard genesis state and init/export methods

* address review comments
2021-01-22 22:17:40 -07:00
Denali Marsh
f89b8797ed
Clean up leftover Hard module claim types/queries (#775)
* clean up types

* clean up client/rest

* clean up alias

* remove LP/Gov schedule errors

* clean up claim multipliers
2021-01-21 18:38:52 +01:00
Kevin Davis
4eef80b47f
[R4R] CDP module migrations from v0.11 -> v0.13 (#769)
* remove references to savings rate

* removing savings rate module account in auth migration

* use compact json

* fix non-determinism is cdp migration
2021-01-21 10:37:35 -07:00
Kevin Davis
92afaf6ca0
add query for all current prices (#768) 2021-01-21 10:36:51 -07:00
Ruaridh
1ffe763f90
Minor docs updates (#774)
* remove link to old migration docs

* update readmes to latest version
2021-01-21 17:14:24 +00:00
Denali Marsh
4e6f6d1e9c
Incentive/Hard rebase to master (#773)
* spike: incentive/types

* spike: incentive/types tests

* spike: incentive/types/expected_keepers.go

* spike: incentive/keeper

* spike: incentive/keeper tests

* spike: incentive/sims and incentive/sims tests

* spike: incentive/module

* spike: incentive/module tests

* spike: hard/types

* spike: hard/types hooks

* spike: hard/types

* spike: hard/keeper basics

* spike: hard/keeper hooks

* integrate hard/keeper/borrow.go

* integrate hard/keeper/deposit.go

* integrate hard/keeper/liquidation.go

* integrate hard/keeper/withdraw.go

* integrate hard/keeper/repay.go

* spike: hard/sims

* spike: hard/sims tests

* spike: hard/client

* spike: hard/module

* integrate app.go

* spike: x/hard/keeper compile tests

* incentive/keeper test clean up

* validate usdx incentive types in genesis

* refactoring & fix deposit test

* fix liquidaton tests

* fix incentive tests for hard supply rewards

* fix hard genesis tests

* update incentive genesis state and params

* update cdp rewards accumulation

* update app init order and begin blocker order

Co-authored-by: karzak <kjydavis3@gmail.com>
2021-01-21 14:52:09 +01:00
Kevin Davis
67b58f555b
[R4R] fix: validate usdx minting collaterals in incentive genesis (#770)
* fix: validate that usdx incentive collateral types are found in cdp params

* update app initialization and tests
2021-01-19 22:42:50 -07:00
Kevin Davis
c63ecf908a
Cdp accumulators (#751)
* 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>
2021-01-18 12:12:37 -07:00
Denali Marsh
fba6b8c4f2
Hard: delete borrow/deposit from store on 0 amount (#766)
* delete borrow/deposit on 0 balance

* add/update tests to ensure deletion

* delete from LTV index
2021-01-18 10:43:20 +01:00
Ruaridh
293bfd6f1a
point the swagger link at the correct address (#767) 2021-01-15 11:26:25 -07:00
Denali Marsh
34a7172581
Hard: refactor borrow/borrows and deposit/deposits query (#761)
* refactor cli borrows query

* rest api feature parity for borrows query

* refactor deposits cli query

* remove deposit/borrow query names from types

* add named deposit/borrow queries back into types

* rest api feature parity for deposits query

* load synced deposit instead of synced balance

* deposits query returns synced deposits

* borrows query returns synced borrows

* refactor querier types

* update comment for accuracy

* add deposit/borrow slice types

* refactor 'borrowed' query

* implement 'deposited' query types

* implement 'deposited' query keeper function

* implement 'deposited' query CLI

* implement 'deposited' query rest endpoint

* update naming conventions to 'total'
2021-01-13 19:14:58 +01:00
Denali Marsh
d05516bbe0
Hard: sync supply interest on attempted liquidation (#763)
* sync supply interest on attempted liquidation

* update tests with supply interest accrual
2021-01-13 12:59:39 +01:00
Denali Marsh
f6efc2597b
Hard: investigate sdk.RelativePow runtime panic (#762)
* interest rate practical test

* add clarification comment
2021-01-12 10:03:09 +01:00
Denali Marsh
a0d70e1c81
fix example cli liquidate cmd (#760) 2021-01-11 13:50:00 -07:00
Denali Marsh
bc110ce609
Hard: LTV index refactor (#758)
* add set/delete/update ltv methods

* refactor borrow logic

* basic updates to keeper logic for compile

* Add deposit index set/delete/update keeper methods

* refactor deposit logic

* refactor repay logic

* update withdraw logic

* introduce DeleteDepositBorrowAndLtvIndex

* remove unused bool from AttemptKeeperLiquidation

* remove comments (transitioned to asana cards)

* catch multiple error types in liquidation loop
2021-01-07 22:40:25 +01:00
Denali Marsh
38306e5465
add deposit balance query (#759) 2021-01-07 17:22:00 +01:00
Denali Marsh
f7a73c9245
Hard: suppliers earn interest (#749)
* 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>
2021-01-07 11:23:05 +01:00
Denali Marsh
e9f5043c84
Hard: update REST API (#748)
* borrows, borrow, borrowed queries

* update deposit, withdraw, claim rest txs

* add borrow, repay, liquidate rest tx

* update liquidate on handler
2020-12-22 17:08:27 +01:00
Denali Marsh
477b937039
Hard: withdraws limited by ltv (#747)
* liquidations refactor

* validate withdraws above ltv

* set mm in initgenesis

* add ltv limited withdraw test

* address revisions

* resolve diff
2020-12-21 18:28:41 +01:00
Denali Marsh
a4bbea1ec4
update 'harvest' -> 'hard' (#746) 2020-12-21 18:18:55 +01:00
Denali Marsh
f140d7aff6
update naming conventions (#745) 2020-12-21 18:07:02 +01:00
Kevin Davis
06fd215de1
[hard] Update deposit type to use sdk.Coins (#744)
* update deposits to use sdk.Coins

* update tests

* update liquidation tests
2020-12-18 09:05:21 -07:00
Denali Marsh
83a5f51c11
Hard: automatic liquidation by LTV index (#743)
* hotfix

* update params, keys

* liquidation by keeper

* refactor GetPendingBorrowBalance

* fix app build

* elegant handling of denom arrays

* auction deposit in lots

* add error msg

* update tests with new params

* happy path liquidation test

* update liquidator macc name

* refactor reward % to money market params

* refactor tests for updated params

* compile: harvest liquidator module account

* add liquidate msg

* liquidation approach

* update liquidations

* return remaining deposit coins to original borrowr

* check keeper reward before sending

* introduce ValuationMap

* convert Ints <> Decs

* implement double-loop

* ModuleAccountName

* sort keys for deterministic auctions

* test: correct auctions created

* test: preset keeper coins

* ensure deterministic iteration

* test cases

* update repay test

* auction fixes, tests

* LTV index

* user actions sync interest and update ltv index

* tests: all deposits must have money markets

* reorder borrow logic

* ltv index liquidation logic

* test specific items in ltv index

* index liquidation tests

* update repay to spendable coins

* revisions

* remove address sort method

* merge master test package
2020-12-18 02:12:48 +01:00
Denali Marsh
6c0890d5ff
Hard: introduce LTV index (#742)
* hotfix

* update params, keys

* liquidation by keeper

* refactor GetPendingBorrowBalance

* fix app build

* elegant handling of denom arrays

* auction deposit in lots

* add error msg

* update tests with new params

* happy path liquidation test

* update liquidator macc name

* refactor reward % to money market params

* refactor tests for updated params

* compile: harvest liquidator module account

* add liquidate msg

* liquidation approach

* update liquidations

* return remaining deposit coins to original borrowr

* check keeper reward before sending

* introduce ValuationMap

* convert Ints <> Decs

* implement double-loop

* ModuleAccountName

* sort keys for deterministic auctions

* test: correct auctions created

* test: preset keeper coins

* ensure deterministic iteration

* test cases

* update repay test

* auction fixes, tests

* LTV index

* user actions sync interest and update ltv index

* tests: all deposits must have money markets

* reorder borrow logic

* check mm before setting borrow index

* insert into LTV index even when LTV is 0
2020-12-16 22:08:29 +01:00
Denali Marsh
89f07e92b4
Hard: liquidation by keeper (#731)
* hotfix

* update params, keys

* liquidation by keeper

* refactor GetPendingBorrowBalance

* fix app build

* elegant handling of denom arrays

* auction deposit in lots

* add error msg

* update tests with new params

* happy path liquidation test

* update liquidator macc name

* refactor reward % to money market params

* refactor tests for updated params

* compile: harvest liquidator module account

* add liquidate msg

* liquidation approach

* update liquidations

* return remaining deposit coins to original borrowr

* check keeper reward before sending

* introduce ValuationMap

* convert Ints <> Decs

* implement double-loop

* ModuleAccountName

* sort keys for deterministic auctions

* test: correct auctions created

* test: preset keeper coins

* ensure deterministic iteration

* test cases

* update repay test

* auction fixes, tests
2020-12-15 18:38:14 +01:00
Denali Marsh
2442d281ab
update ltv error msg (#733) 2020-12-08 14:28:01 +01:00
Kevin Davis
068e12380e
Update README.md 2020-12-07 17:53:52 -07:00
Denali Marsh
4e641c5212
Hard: repay borrowed coins (#725)
* add msg borrow test

* repay types

* register msg repay on codec

* repay keeper functionality

* repay cli

* repay keeper test

* Hard: repay insufficient balance error (#726)

* repay error: insufficient balance

* isolate coin type in error msg

* add multi-coin repay example

* CalculatePaymentAmount, repay > SyncBorrowInterest

* remove todo: index updated by sync

* update tests

* add back in test
2020-12-07 22:51:35 +01:00
Denali Marsh
4dd174ea85
query borrow balance (#732) 2020-12-04 20:04:05 +01:00
Denali Marsh
6aa97a8f75
hotfix (#730) 2020-12-04 15:35:26 +01:00
Kevin Davis
4c95227c1d
fix go 1.15 build warning (#729) 2020-12-03 16:07:47 -07:00
Kevin Davis
01311e77f6
Kd fix interest test (#728)
* fix: fix go 1.15 build

* fix: correct highest apy test
2020-12-03 16:05:56 -07:00