Skip to content

feat: add inspector queries#2085

Merged
toteki merged 34 commits intomainfrom
adam/inspector2
Jun 21, 2023
Merged

feat: add inspector queries#2085
toteki merged 34 commits intomainfrom
adam/inspector2

Conversation

@toteki
Copy link
Copy Markdown
Contributor

@toteki toteki commented Jun 6, 2023

Contains a query that combines the risk data query as specified by risk team, and the inspector query which allows a user to filter all active borrower accounts.

umeed query leverage inspect [symbol] [borrowed] [collateral [danger] [ltv]

Example of web usage:

http://localhost:1317/umee/leverage/v1/inspect?symbol=ALL&borrowed=100000&ltv=0.7

Example of new CLI usage:

(show all borroweds with >$100k USD borrowed value and >0.7 LTV

umeed q leverage inspect all 100000 0 0 0.7

borrowers:
- address: umee1rphd0j66lpnzchpw956ejyhg237rffy9k9zvph
  analysis:
    Borrowed: 1007000
    Liquidation: 1065000
    Value: 1365000
  position:
    borrowed:
    - amount: "1008946.943914000000000000"
      denom: USDC
    collateral:
    - amount: "3032261.017830785773337404"
      denom: OSMO
- address: umee1pjuufs7jk6sa5avs36uec8u8spf2hqq02xdyyy
  analysis:
    Borrowed: 375791
    Liquidation: 388241
    Value: 507004
  position:
    borrowed:
    - amount: "376496.493107000000000000"
      denom: USDC
    collateral:
    - amount: "23432.816342540682021296"
      denom: ATOM
    - amount: "0.000000000100017791"
      denom: DOT
    - amount: "192246.705675326605412238"
      denom: OSMO
    - amount: "5185.135472357015580737"
      denom: STOSMO
    - amount: "0.000000010010631796"
      denom: WBTC
    - amount: "22473.172598202930492651"
      denom: stATOM

@toteki toteki marked this pull request as ready for review June 6, 2023 14:26
@toteki toteki requested a review from a team as a code owner June 6, 2023 14:26
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 6, 2023

Codecov Report

Merging #2085 (9935dbf) into main (7f05ad4) will decrease coverage by 0.49%.
The diff coverage is 78.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2085      +/-   ##
==========================================
- Coverage   75.38%   74.89%   -0.49%     
==========================================
  Files         100      127      +27     
  Lines        8025     9745    +1720     
==========================================
+ Hits         6050     7299    +1249     
- Misses       1589     1963     +374     
- Partials      386      483      +97     
Impacted Files Coverage Δ
ante/spam_prevention.go 75.92% <ø> (ø)
util/store/unmarshal.go 0.00% <0.00%> (ø)
x/incentive/codec.go 47.82% <ø> (+9.89%) ⬆️
x/incentive/keeper/invariants.go 0.00% <0.00%> (ø)
x/incentive/keeper/keeper.go 64.28% <ø> (ø)
x/leverage/keeper/errors.go 100.00% <ø> (ø)
x/leverage/keeper/exchange_rate.go 72.72% <ø> (ø)
x/leverage/keeper/genesis.go 87.23% <ø> (ø)
x/leverage/keeper/grpc_query.go 67.21% <ø> (ø)
x/leverage/keeper/incentive.go 0.00% <0.00%> (ø)
... and 67 more

... and 24 files with indirect coverage changes

@toteki toteki requested a review from a team as a code owner June 6, 2023 14:32
Copy link
Copy Markdown
Contributor

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proto review only

Copy link
Copy Markdown
Contributor

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few more comments. Would be good to add a bit more tests.

@toteki
Copy link
Copy Markdown
Contributor Author

toteki commented Jun 15, 2023

See updated PR description for examples of new CLI and web usage

for _, account := range borrowers {
ok := account.Analysis.Borrowed > req.Borrowed
ok = ok && account.Analysis.Value > req.Collateral
ok = ok && account.Analysis.Borrowed/account.Analysis.Liquidation > req.Danger

Check notice

Code scanning / CodeQL

Floating point arithmetic

Floating point arithmetic operations are not associative and a possible source of non-determinism
@toteki toteki requested a review from a team as a code owner June 15, 2023 15:42
ok := account.Analysis.Borrowed > req.Borrowed
ok = ok && account.Analysis.Value > req.Collateral
ok = ok && account.Analysis.Borrowed/account.Analysis.Liquidation > req.Danger
ok = ok && account.Analysis.Borrowed/account.Analysis.Value > req.Ltv

Check notice

Code scanning / CodeQL

Floating point arithmetic

Floating point arithmetic operations are not associative and a possible source of non-determinism
}
// Truncate the float at a certain precision (can be negative)
x := math.Pow(10, float64(precision))
return float64(int(n*x)) / x

Check notice

Code scanning / CodeQL

Floating point arithmetic

Floating point arithmetic operations are not associative and a possible source of non-determinism
}
// Truncate the float at a certain precision (can be negative)
x := math.Pow(10, float64(precision))
return float64(int(n*x)) / x

Check notice

Code scanning / CodeQL

Floating point arithmetic

Floating point arithmetic operations are not associative and a possible source of non-determinism
Copy link
Copy Markdown
Contributor

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per-approving given the 2 remaining comments.

@toteki toteki enabled auto-merge June 21, 2023 12:12
@toteki toteki added this pull request to the merge queue Jun 21, 2023
Merged via the queue into main with commit 3d6be4a Jun 21, 2023
@toteki toteki deleted the adam/inspector2 branch June 21, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants