Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate leverage simulations #657

Closed
wants to merge 13 commits into from
Closed

feat: integrate leverage simulations #657

wants to merge 13 commits into from

Conversation

toteki
Copy link
Member

@toteki toteki commented Mar 16, 2022

Description

closes: #644


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added appropriate labels to the PR
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov-commenter
Copy link

codecov-commenter commented Mar 16, 2022

Codecov Report

Merging #657 (97f8998) into main (2343d70) will increase coverage by 0.02%.
The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #657      +/-   ##
==========================================
+ Coverage   47.87%   47.90%   +0.02%     
==========================================
  Files          64       64              
  Lines        9426     9441      +15     
==========================================
+ Hits         4513     4523      +10     
- Misses       4646     4650       +4     
- Partials      267      268       +1     
Impacted Files Coverage Δ
x/leverage/module.go 52.77% <25.00%> (-3.48%) ⬇️
x/leverage/simulation/operations.go 91.89% <85.18%> (+0.19%) ⬆️
x/leverage/simulation/decoder.go 1.78% <0.00%> (+1.78%) ⬆️

@alexanderbez
Copy link
Contributor

My hero <3

@toteki
Copy link
Member Author

toteki commented Apr 8, 2022

Note: gotta finish this off by adding funds to your random accounts on startup. Currently all simulated operations are working with zero spendable coins, which makes them useless even if the test is passing.

Note sure if this will do it, but something to that effect is needed.

Comment on lines 117 to 126
// add some leverage supported assets to accounts that already have nonzero balances
for i, balance := range bankState.Balances {
fundedBalance := balance
for _, t := range leverageState.Registry {
fund := sdk.NewInt64Coin(t.BaseDenom, 100)
fundedBalance.Coins = fundedBalance.Coins.Add(fund)
bankState.Supply = bankState.Supply.Add(fund)
}
bankState.Balances[i] = fundedBalance
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this covers the nonzero initial balance issue

@toteki
Copy link
Member Author

toteki commented Apr 21, 2022

Note:

Now that nonzero amounts are being used, transactions are failing when asset USD values are needed for tokens that the (simulated) oracle module doesn't have at a given moment.

Need to check oracle sim's initial accept list, then either modify it to contain the three test tokens in leverage simulation or reduce leverage sim to just use uumee, then only run transactions that require oracle (borrow, withdraw, liquidate) when the price exists.

tests/simulation/state.go Outdated Show resolved Hide resolved
@adamewozniak
Copy link
Collaborator

@toteki should we close this for the time being?

@toteki
Copy link
Member Author

toteki commented Jun 17, 2022

Yeah, that'll help de-clutter.

@toteki toteki closed this Jun 17, 2022
@toteki toteki deleted the adam/sims branch July 21, 2023 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x/leverage: integrate simulations
4 participants