diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 263155f2ca..10f2095f6e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,19 +32,24 @@ jobs: version: latest args: --timeout 8m - super-linter: - name: Run super-linter + markdown-lint: + name: markdown-lint runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v3 - - name: Run super-linter - uses: github/super-linter@v5 - env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_MARKDOWN: true - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + # lint only changed files + - uses: tj-actions/changed-files@v35 + id: changed-files + with: + files: "**/*.md" + separator: "," + - uses: DavidAnson/markdownlint-cli2-action@v9 + if: steps.changed-files.outputs.any_changed == 'true' + with: + globs: ${{ steps.changed-files.outputs.all_changed_files }} + separator: "," buf-lint: runs-on: ubuntu-latest diff --git a/.markdownlint.yml b/.markdownlint.yml index 918ea70436..2f42fc28d2 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -2,3 +2,4 @@ default: true # MD014/commands-show-output Dollar signs used before commands without showing output MD014: false +MD013: false diff --git a/CHANGELOG.md b/CHANGELOG.md index e646f2ec44..decb2dd26d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [1989](https://github.com/umee-network/umee/pull/1989) Leverage: fix the duplicate symbol denoms issue on adding new tokens to registry. - [1989](https://github.com/umee-network/umee/pull/1989) Updated go version from 1.19 to 1.20 +- [2009](https://github.com/umee-network/umee/pull/2009) Use DavidAnson/markdownlint action for Markdown linting. + ### Fixes - . diff --git a/docs/design_docs/002-deposit-assets.md b/docs/design_docs/002-deposit-assets.md index 5c44bd4453..e4f9151548 100644 --- a/docs/design_docs/002-deposit-assets.md +++ b/docs/design_docs/002-deposit-assets.md @@ -15,6 +15,7 @@ Implemented The `x/leverage` module allows users to supply and withdraw assets. The flow of events is as follows: + - Lender supplies a token to the module - Module mints and sends uTokens to the lender - Lender redeems uTokens for original tokens plus interest after some time @@ -48,15 +49,18 @@ If the full requested amount of tokens is not available for withdrawal, the tran ## Consequences ### Positive -- [x/bank module]([Cosmos Bank Keeper](https://github.com/cosmos/cosmos-sdk/blob/v0.44.0/x/bank/spec/02_keepers.md)) provides the underlying functionality. + +- [x/bank module]([Cosmos Bank Keeper](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/bank/spec/02_keepers.md)) provides the underlying functionality. ### Negative -- If tokens were to be sent unexpectedly to the `x/leverage` module account (see the warning on [this page](https://docs.cosmos.network/master/modules/bank/)), it would have the effect of donating said tokens to existing suppliers if the tokens were an accepted type. Otherwise, the tokens would remain inert. + +- If tokens were to be sent unexpectedly to the `x/leverage` module account (see the warning on [this page](https://docs.cosmos.network/main/modules/bank/)), it would have the effect of donating said tokens to existing suppliers if the tokens were an accepted type. Otherwise, the tokens would remain inert. - uToken value is not the same as the underlying Token - user confusion is possible and extra calculation (exchange rates) is required for all uToken operations ### Neutral + - Requires an allow-list (Token Registry), to be implemented later ## References -- [Cosmos Bank Keeper](https://github.com/cosmos/cosmos-sdk/blob/v0.44.0/x/bank/spec/02_keepers.md) +- [Cosmos Bank Keeper](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/bank/spec/02_keepers.md) diff --git a/docs/design_docs/007-bad-debt.md b/docs/design_docs/007-bad-debt.md index 8fef47166d..67fe0a4240 100644 --- a/docs/design_docs/007-bad-debt.md +++ b/docs/design_docs/007-bad-debt.md @@ -98,4 +98,4 @@ This could be solved by any Liquidator - but if undercollateralized borrowers ar ### Neutral - Events and logs track when bad debt is repaid by reserves -- Events and logs detect exhaustion of reserves and associated details \ No newline at end of file +- Events and logs detect exhaustion of reserves and associated details diff --git a/docs/testing.md b/docs/testing.md index 8b82fa850f..4138d96afb 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -4,7 +4,8 @@ Rules of thumb: 1. Design packages to make it easy to unit-test. - Unit tests should represent majority of the test. - - Unit tests can be in the same package (to be able to test private methods) → no need to move unit tests to `_test` pacakge. + - Unit tests can be in the same package (to be able to test private methods) → no need to move + unit tests to `_test` package. 2. Integration tests should be in `_test` package. 3. Reduce tight coupling (will make it ) in the software. 4. Add benchmarks (std lib `BenchmarkXXX`) for all functions we are not sure about the complexity. @@ -16,12 +17,12 @@ Testing libraries: - Use `t.Skip` to skip long or not stable tests. **NOTE**: We should always run all tests before release. So the idea is that long tests won't impact daily CI, but we can make rule that this will be run only once a day and before release. 1. Use [gotest.tools](https://pkg.go.dev/gotest.tools/assert) instead of `stretchr/testify/suite`. -1. Use [gomock](github.com/golang/mock/mockgen) to generate mock interfaces. +1. Use [gomock](https://github.com/golang/mock) to generate mock interfaces. 1. Use [rapid](https://github.com/flyingmutant/rapid) for fuzzy testing (especially in unit tests). 1. Use module fixtures. Example in [x/leverage/fixtures](../x/leverage/fixtures) Our CI should use all tests (unit, integration, e2e) except those which are very long or not stable. -Long tests should be used periodically (eg once every second day) instead, to not significatly decrease the pull request experience. +Long tests should be used periodically (eg once every second day) instead, to not significantly decrease the pull request experience. Finally all tests (including QA) must be run on release tag (including `beta` and `rc`). diff --git a/x/incentive/README.md b/x/incentive/README.md index 3dd2fe0b3b..0fb2b66fa9 100644 --- a/x/incentive/README.md +++ b/x/incentive/README.md @@ -7,4 +7,4 @@ This document specifies the `x/incentive` module of the Umee chain. The incentive module allows users to `Bond` collateral `uTokens` from the `x/leverage` module, and governance to create and fund `Incentive Programs` which distribute rewards to users with bonded uTokens over time. Users can `Unbond` tokens over a period of time, after which they can be withdrawn. The incentive module depends on the `x/leverage` module for information about users' bonded collateral, and also requires that the leverage module prevent bonded or currently unbonding collateral from being withdrawn. -There are also a few more advanced interactions, such as instantly unbonding collateral when it is liquidated, and registering an `exponent` when a uToken denom is incentivized for the first time. \ No newline at end of file +There are also a few more advanced interactions, such as instantly unbonding collateral when it is liquidated, and registering an `exponent` when a uToken denom is incentivized for the first time. diff --git a/x/leverage/LIQUIDATION.md b/x/leverage/LIQUIDATION.md index 3e39196579..6a84a1bb1d 100644 --- a/x/leverage/LIQUIDATION.md +++ b/x/leverage/LIQUIDATION.md @@ -14,6 +14,7 @@ This document contains notes on how to do these manually - a more sophisticated Any wallet you control can be used as a liquidator, as long as it has a pool of assets and tokens for gas on the relevant chains. Here is an example setup: + - `100 AXL-USDC` from axelar collateralized on [app.umee.cc](https://app.umee.cc/) with no active borrows - `1 UMEE` on Umee - `1 ATOM` on Cosmos Hub @@ -25,8 +26,9 @@ The main collateral will allow you to borrow any tokens required during liquidat ## Querying for Eligible Liquidation Targets Umee provides a query to list addresses that are eligible for liquidation: -* REST: `https://api.your.node.here/umee/leverage/v1/liquidation-targets` -* CLI: `umeed q leverage liquidation-targets` + +- REST: `https://api.your.node.here/umee/leverage/v1/liquidation-targets` +- CLI: `umeed q leverage liquidation-targets` There is also a courtesy endpoint at `https://api.mainnet.network.umee.cc/umee/leverage/v1/liquidation_targets` which provides a cached output for the query every 5 minutes when available. @@ -120,6 +122,7 @@ Another option would have been to buy `ATOM` on an exchange, or have an initial ### Liquidation Transaction In a liquidation transaction, you need to specify three things: + - target address (`umee1l2jv...`) - repayment coin (`84000ibc/C4CFF...`, which is `0.084 ATOM`) - reward token (`ibc/49788...`, which is `USDC`) @@ -145,6 +148,7 @@ Information on the parameters that determine partial liquidation can be found [h To lock in our profits, we should trade the liquidation rewards we received back into the token denom we repaid. In our case, we + - Transfer `1.03 USDC` from UMEE to Axelar using IBC - Transfer `1.03 USDC` from Axelar to Osmosis using IBC (requires `AXL` gas) - Trade `1.03 USDC` for `0.088 ATOM` on Osmosis @@ -159,6 +163,7 @@ For reference, the repayment looks like: ``` The liquidator account has returned to its initial state, except: + - An extra `0.004 ATOM` in its balance on Umee (profit) - Paid some `ATOM`, `OSMO`, `AXL`, `UMEE` in gas on their respective chains diff --git a/x/leverage/README.md b/x/leverage/README.md index e131be33b1..99bf7fcac0 100644 --- a/x/leverage/README.md +++ b/x/leverage/README.md @@ -173,6 +173,7 @@ For tokens with hith historic prices enabled (indicated by a `HistoricMedians` p The leverage module also makes use of the oracle's historic prices to enforce an additional restriction on borrowing. The logic is: + - For any `MsgBorrow`, `MsgMaxBorrow`, `MsgDecollateralize`, `MsgWithdraw`, or `MsgMaxWithdraw` - The borrower’s borrowed value must be less than their borrow limit, with borrowed value being computed using `PriceModeHigh`, i.e. the higher of either spot price or historic price is used. - Where historic prices are defined as the Median of the last `N` historic medians from the `oracle` module with `N = Token.HistoricMedians` in the leverage registry @@ -301,12 +302,14 @@ See [leverage tx proto](https://github.com/umee-network/umee/blob/main/proto/ume `Update-Registry` gov proposal will adds the new tokens to token registry or update the existing token with new settings. Under certain conditions, tokens will be automatically deleted: + - The token has been blacklisted by a previous proposal or the current one - The token has not been supplied to the module, so there are no uTokens, borrows, or collateral associated with it. The conditions allow for mistakenly registered tokens which have never been used to be removed from the registry. It is not safe to remove a token with active supply or borrows, so those stay listed in the registry when blacklisted. ### CLI + ```bash umeed tx gov submit-proposal [path-to-proposal-json] [flags] ``` @@ -324,60 +327,60 @@ where `proposal.json` contains: ```json { - "messages": [ + "messages": [ + { + "@type": "/umee.leverage.v1.MsgGovUpdateRegistry", + "authority": "umee10d07y265gmmuvt4z0w9aw880jnsr700jg5w6jp", + "title": "Update the Leverage Token Registry", + "description": "Update the uumee token in the leverage registry.", + "add_tokens": [ + { + "base_denom": "uumee", + "reserve_factor": "0.100000000000000000", + "collateral_weight": "0.050000000000000000", + "liquidation_threshold": "0.050000000000000000", + "base_borrow_rate": "0.020000000000000000", + "kink_borrow_rate": "0.200000000000000000", + "max_borrow_rate": "1.500000000000000000", + "kink_utilization": "0.200000000000000000", + "liquidation_incentive": "0.100000000000000000", + "symbol_denom": "UMEE", + "exponent": 6, + "enable_msg_supply": true, + "enable_msg_borrow": true, + "blacklist": false, + "max_collateral_share": "0.900000000000000000", + "max_supply_utilization": "0.900000000000000000", + "min_collateral_liquidity": "0.900000000000000000", + "max_supply": "123123" + } + ], + "update_tokens": [ { - "@type": "/umee.leverage.v1.MsgGovUpdateRegistry", - "authority": "umee10d07y265gmmuvt4z0w9aw880jnsr700jg5w6jp", - "title": "Update the Leverage Token Registry", - "description": "Update the uumee token in the leverage registry.", - "add_tokens": [ - { - "base_denom": "uumee", - "reserve_factor": "0.100000000000000000", - "collateral_weight": "0.050000000000000000", - "liquidation_threshold": "0.050000000000000000", - "base_borrow_rate": "0.020000000000000000", - "kink_borrow_rate": "0.200000000000000000", - "max_borrow_rate": "1.500000000000000000", - "kink_utilization": "0.200000000000000000", - "liquidation_incentive": "0.100000000000000000", - "symbol_denom": "UMEE", - "exponent": 6, - "enable_msg_supply": true, - "enable_msg_borrow": true, - "blacklist": false, - "max_collateral_share": "0.900000000000000000", - "max_supply_utilization": "0.900000000000000000", - "min_collateral_liquidity": "0.900000000000000000", - "max_supply": "123123" - }, - ], - "update_tokens": [ - { - "base_denom": "uatom", - "reserve_factor": "0.100000000000000000", - "collateral_weight": "0.050000000000000000", - "liquidation_threshold": "0.050000000000000000", - "base_borrow_rate": "0.020000000000000000", - "kink_borrow_rate": "0.200000000000000000", - "max_borrow_rate": "1.500000000000000000", - "kink_utilization": "0.200000000000000000", - "liquidation_incentive": "0.100000000000000000", - "symbol_denom": "ATOM", - "exponent": 6, - "enable_msg_supply": true, - "enable_msg_borrow": true, - "blacklist": false, - "max_collateral_share": "0.900000000000000000", - "max_supply_utilization": "0.900000000000000000", - "min_collateral_liquidity": "0.900000000000000000", - "max_supply": "123123" - }, - ] + "base_denom": "uatom", + "reserve_factor": "0.100000000000000000", + "collateral_weight": "0.050000000000000000", + "liquidation_threshold": "0.050000000000000000", + "base_borrow_rate": "0.020000000000000000", + "kink_borrow_rate": "0.200000000000000000", + "max_borrow_rate": "1.500000000000000000", + "kink_utilization": "0.200000000000000000", + "liquidation_incentive": "0.100000000000000000", + "symbol_denom": "ATOM", + "exponent": 6, + "enable_msg_supply": true, + "enable_msg_borrow": true, + "blacklist": false, + "max_collateral_share": "0.900000000000000000", + "max_supply_utilization": "0.900000000000000000", + "min_collateral_liquidity": "0.900000000000000000", + "max_supply": "123123" } - ], - "metadata": "AQ==", - "deposit": "100uumee" + ] + } + ], + "metadata": "AQ==", + "deposit": "100uumee" } ```