diff --git a/.dockerignore b/.dockerignore index a1e4b36e518..ec94acf103e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,6 @@ docs/ networks/ proto/ scripts/ -tests/ tools/ .github/ .git/ diff --git a/.github/workflows/state-compatibility-check.yml b/.github/workflows/check-state-compatibility.yml similarity index 70% rename from .github/workflows/state-compatibility-check.yml rename to .github/workflows/check-state-compatibility.yml index 9a6aabd3a11..7664ddb5575 100644 --- a/.github/workflows/state-compatibility-check.yml +++ b/.github/workflows/check-state-compatibility.yml @@ -37,16 +37,51 @@ env: GOLANG_VERSION: 1.18 GENESIS_URL: https://github.com/osmosis-labs/networks/raw/main/osmosis-1/genesis.json ADDRBOOK_URL: https://dl2.quicksync.io/json/addrbook.osmosis.json - SNAPSHOT_BUCKET: https://osmosis-snapshot.sfo3.cdn.digitaloceanspaces.com + SNAPSHOT_BUCKET: https://snapshots.osmosis.zone RPC_ENDPOINT: https://rpc.osmosis.zone LCD_ENDPOINT: https://lcd.osmosis.zone DELTA_HALT_HEIGHT: 50 - + jobs: + compare_versions: + # Compare current mainnet osmosis major version with the major version of github branch + # Skip the next job if the current github major is greater than the current mainnet major + runs-on: self-hosted + outputs: + should_i_run: ${{ steps.compare_versions.outputs.should_i_run }} + mainnet_major_version: ${{ steps.mainnet_version.outputs.mainnet_major_version }} + steps: + - + name: Get mainnet major version + id: mainnet_version + run: | + # Find current major version via rpc.osmosis.zone/abci_info + RPC_ABCI_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_ENDPOINT }}/abci_info) + MAINNET_MAJOR_VERSION=$(echo $RPC_ABCI_INFO | dasel --plain -r json 'result.response.version' | cut -f 1 -d '.') + + echo "MAINNET_MAJOR_VERSION=$MAINNET_MAJOR_VERSION" >> $GITHUB_ENV + echo "mainnet_major_version=$MAINNET_MAJOR_VERSION" >> $GITHUB_OUTPUT + - + name: Get GitHub branch major version + id: compare_versions + run: | + CURRENT_BRANCH_MAJOR_VERSION=$(echo ${{ github.event.pull_request.base.ref }} | tr -dc '0-9') + SHOULD_I_RUN=$(( $CURRENT_BRANCH_MAJOR_VERSION <= $MAINNET_MAJOR_VERSION )) + + echo -n "Mainnet version: $MAINNET_MAJOR_VERSION | Branch version: $CURRENT_BRANCH_MAJOR_VERSION | Should I run: " + if (( $CURRENT_BRANCH_MAJOR_VERSION <= $MAINNET_MAJOR_VERSION )); + then + echo 'should_i_run=true' >> $GITHUB_OUTPUT; + echo "true" + else + echo 'should_i_run=false' >> $GITHUB_OUTPUT; + echo "false" + fi + check_state_compatibility: # DO NOT CHANGE THIS: please read the note above - if: ${{ github.event.pull_request.head.repo.full_name == 'osmosis-labs/osmosis' }} + if: ${{ github.event.pull_request.head.repo.full_name == 'osmosis-labs/osmosis' && needs.compare_versions.outputs.should_i_run == 'true' }} runs-on: self-hosted steps: - @@ -73,7 +108,7 @@ jobs: # Download genesis file if not present mkdir -p /mnt/data/genesis/osmosis-1/ if [ ! -f "/mnt/data/genesis/osmosis-1/genesis.json" ]; then - wget -O /mnt/data/genesis/osmosis-1/genesis.json ${{ env.GENESIS_URL }} + wget -q -O /mnt/data/genesis/osmosis-1/genesis.json ${{ env.GENESIS_URL }} fi # Copy genesis to config folder @@ -82,23 +117,12 @@ jobs: name: ⏬ Download last pre-epoch snapshot run: | REPO_MAJOR_VERSION=$(echo $(git describe --tags) | cut -f 1 -d '.') # with v prefix - - # Find current major version via rpc.osmosis.zone/abci_info - RPC_ABCI_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_ENDPOINT }}/abci_info) - CHAIN_MAJOR_VERSION=$(echo $RPC_ABCI_INFO | dasel --plain -r json 'result.response.version' | cut -f 1 -d '.') # no v prefix - - # Get correct url to fetch snapshot comparing versions - if [ $REPO_MAJOR_VERSION == v$CHAIN_MAJOR_VERSION ]; then - # I'm in the latest major - SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/osmosis.json - else - SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/$REPO_MAJOR_VERSION/osmosis.json - fi + SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/$REPO_MAJOR_VERSION/snapshots.json # Get the latest pre-epoch snapshot information from bucket SNAPSHOT_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" $SNAPSHOT_INFO_URL) - SNAPSHOT_URL=$(echo $SNAPSHOT_INFO | dasel --plain -r json '(file=osmosis-1-pre-epoch).url') - SNAPSHOT_ID=$(echo $SNAPSHOT_INFO | dasel --plain -r json '(file=osmosis-1-pre-epoch).filename' | cut -f 1 -d '.') + SNAPSHOT_URL=$(echo $SNAPSHOT_INFO | jq -r '.[] | select(.type == "pre-epoch").url') + SNAPSHOT_ID=$(echo $SNAPSHOT_INFO | jq -r '.[] | select(.type == "pre-epoch").filename' | cut -f 1 -d '.') # Download snapshot if not already present mkdir -p /mnt/data/snapshots/$REPO_MAJOR_VERSION/ @@ -114,24 +138,20 @@ jobs: name: 🧪 Configure Osmosis Node run: | CONFIG_FOLDER=$HOME/.osmosisd/config - - # Find current major version via rpc.osmosis.zone/abci_info - RPC_ABCI_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_ENDPOINT }}/abci_info) - CHAIN_MAJOR_VERSION=$(echo $RPC_ABCI_INFO | dasel --plain -r json 'result.response.version' | cut -f 1 -d '.') # Find last epoch block comparing repo version to current chain version REPO_MAJOR_VERSION=$(echo $(git describe --tags) | sed 's/^v//' | cut -f 1 -d '.') # without v prefix - if [ $REPO_MAJOR_VERSION == $CHAIN_MAJOR_VERSION ]; then + if [ $REPO_MAJOR_VERSION == $MAINNET_MAJOR_VERSION ]; then # I'm in the latest major, fetch the epoch info from the lcd endpoint LAST_EPOCH_BLOCK_HEIGHT=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 ${{ env.LCD_ENDPOINT }}/osmosis/epochs/v1beta1/epochs | dasel --plain -r json 'epochs.(identifier=day).current_epoch_start_height') else # I'm in a previous major, calculate the epoch height from the snapshot height # (Snapshot is taken 100 blocks before epoch) - SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/v$REPO_MAJOR_VERSION/osmosis.json + SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/v$REPO_MAJOR_VERSION/snapshots.json SNAPSHOT_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" $SNAPSHOT_INFO_URL) - SNAPSHOT_BLOCK_HEIGHT=$(echo $SNAPSHOT_INFO | dasel --plain -r json '(file=osmosis-1-pre-epoch).height') + SNAPSHOT_BLOCK_HEIGHT=$(echo $SNAPSHOT_INFO | jq -r '.[] | select(.type == "pre-epoch").height') LAST_EPOCH_BLOCK_HEIGHT=$(($SNAPSHOT_BLOCK_HEIGHT + 100)) fi @@ -143,6 +163,8 @@ jobs: # Edit config.toml dasel put string -f $CONFIG_FOLDER/config.toml '.tx_index.indexer' null + dasel put string -f $CONFIG_FOLDER/config.toml '.p2p.persistent_peers' 'b59016320a74525f92dbc3348521c64f2bf3f006@p2p.archive.osmosis.zone:26656' + dasel put string -f $CONFIG_FOLDER/config.toml 'seeds' '' # Edit app.toml dasel put string -f $CONFIG_FOLDER/app.toml '.halt-height' $HALT_HEIGHT @@ -150,7 +172,7 @@ jobs: dasel put string -f $CONFIG_FOLDER/app.toml '.state-sync.snapshot-interval' 0 # Download addrbook - wget -O $CONFIG_FOLDER/addrbook.json ${{ env.ADDRBOOK_URL }} + wget -q -O $CONFIG_FOLDER/addrbook.json ${{ env.ADDRBOOK_URL }} - name: 🧪 Start Osmosis Node run: build/osmosisd start diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 50dc9addb06..6630f31b9ed 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -12,15 +12,15 @@ on: jobs: test: - name: Test Suite + name: Test Cosmwasm Contracts runs-on: ubuntu-latest strategy: matrix: - contract: [{workdir: ./x/ibc-rate-limit/, output: testdata/rate_limiter.wasm, build: artifacts/rate_limiter-x86_64.wasm, name: rate_limiter}] + contract: [{workdir: ./x/ibc-rate-limit/, output: bytecode/rate_limiter.wasm, build: artifacts/rate_limiter.wasm, name: rate_limiter}] steps: - name: Checkout sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6.0.1 with: PATTERNS: | @@ -29,9 +29,8 @@ jobs: go.mod **/**cargo.toml - name: Install toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@1.65.0 with: - toolchain: nightly target: wasm32-unknown-unknown - name: Add the wasm target @@ -39,41 +38,38 @@ jobs: run: > rustup target add wasm32-unknown-unknown; - - - name: Build - working-directory: ${{ matrix.contract.workdir }} - run: > - cargo build --release --target wasm32-unknown-unknown - - name: Test working-directory: ${{ matrix.contract.workdir }} run: > cargo test - - name: Set latest cw-optimizoor version - run: > - echo "CW_OPTIMIZOOR_VERSION=`cargo search cw-optimizoor -q | cut -d '"' -f 2`" >> $GITHUB_ENV - - - name: Cache cw-optimizoor - id: cache-cw-optimizoor - uses: actions/cache@v3 - env: - cache-name: cache-cw-optimizoor - with: - # cargo bin files are stored in `~/.cargo/bin/` on Linux/macOS - path: ~/.cargo/bin/cargo-cw-optimizoor - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.CW_OPTIMIZOOR_VERSION }} - - - if: ${{ steps.cache-cw-optimizoor.outputs.cache-hit != 'true' }} - name: Install cw-optimizoor - continue-on-error: true - run: > - cargo install cw-optimizoor +# - name: Set latest cw-optimizoor version +# run: > +# echo "CW_OPTIMIZOOR_VERSION=0.8.0" >> $GITHUB_ENV +# +# - name: Cache cw-optimizoor +# id: cache-cw-optimizoor +# uses: actions/cache@v3 +# env: +# cache-name: cache-cw-optimizoor +# with: +# # cargo bin files are stored in `~/.cargo/bin/` on Linux/macOS +# path: ~/.cargo/bin/cargo-cw-optimizoor +# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.CW_OPTIMIZOOR_VERSION }} +# +# - if: ${{ steps.cache-cw-optimizoor.outputs.cache-hit != 'true' }} +# name: Install cw-optimizoor +# continue-on-error: true +# run: > +# cargo install cw-optimizoor - name: Optimize working-directory: ${{ matrix.contract.workdir }} run: > - cargo cw-optimizoor + docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/workspace-optimizer:0.12.10 - name: 'Upload optimized contract artifact' uses: actions/upload-artifact@v3 @@ -82,6 +78,13 @@ jobs: path: ${{ matrix.contract.workdir }}${{ matrix.contract.build }} retention-days: 1 + - name: 'Upload Cargo.lock artifact' + uses: actions/upload-artifact@v3 + with: + name: Cargo.lock + path: ${{ matrix.contract.workdir }}Cargo.lock + retention-days: 1 + - name: Check Test Data working-directory: ${{ matrix.contract.workdir }} if: ${{ matrix.contract.output != null }} @@ -98,17 +101,14 @@ jobs: steps: - name: Checkout sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6.0.1 with: PATTERNS: | **/**.rs - name: Install toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@1.65.0 with: - profile: minimal - toolchain: stable - override: true components: rustfmt, clippy - name: Format diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 09d9132f8cf..00000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,149 +0,0 @@ -# This workflow pushes new osmosis docker images on every new tag. -# -# On every new `vX.Y.Z` tag the following images are pushed: -# -# osmolabs/osmosis:X.Y.Z # is pushed -# osmolabs/osmosis:X.Y # is updated to X.Y.Z -# osmolabs/osmosis:X # is updated to X.Y.Z -# osmolabs/osmosis:latest # is updated to X.Y.Z -# -# The same osmosisd binary is copied in different base runner images: -# -# - `osmolabs/osmosis:X.Y.Z` uses `gcr.io/distroless/static` -# - `osmolabs/osmosis:X.Y.Z-distroless` uses `gcr.io/distroless/static` -# - `osmolabs/osmosis:X.Y.Z-nonroot` uses `gcr.io/distroless/static:nonroot` -# - `osmolabs/osmosis:X.Y.Z-alpine` uses `alpine:3.16` -# -# All the images above have support for linux/amd64 and linux/arm64. -# -# Due to QEMU virtualization used to build multi-platform docker images -# this workflow might take a while to complete. - -name: Push Docker Images - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc - -env: - DOCKER_REPOSITORY: osmolabs/osmosis - RUNNER_BASE_IMAGE_DISTROLESS: gcr.io/distroless/static - RUNNER_BASE_IMAGE_NONROOT: gcr.io/distroless/static:nonroot - RUNNER_BASE_IMAGE_ALPINE: alpine:3.16 - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Check out the repo - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Find go version - id: find_go_version - run: | - GO_VERSION=$(cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2) - echo "::set-output name=go_version::$(echo ${GO_VERSION})" - - # Distroless Docker image (default) - - - name: Docker meta (distroless) - id: meta_distroless - uses: docker/metadata-action@v3 - with: - images: ${{ env.DOCKER_REPOSITORY }} - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=semver,pattern={{version}}-distroless - type=semver,pattern={{major}}.{{minor}}-distroless - type=semver,pattern={{major}}-distroless - - - name: Build and push (distroless) - id: build_push_distroless - uses: docker/build-push-action@v2 - with: - file: Dockerfile - context: . - push: true - platforms: linux/amd64,linux/arm64 - build-args: | - GO_VERSION=${{ steps.find_go_version.outputs.go_version }} - RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_DISTROLESS }} - GIT_VERSION=${GITHUB_REF_NAME#v} - GIT_COMMIT=${{ github.sha }} - tags: ${{ steps.meta_distroless.outputs.tags }} - - # Distroless nonroot Docker image - - - name: Docker meta (nonroot) - id: meta_nonroot - uses: docker/metadata-action@v3 - with: - images: ${{ env.DOCKER_REPOSITORY }} - flavor: | - latest=false - suffix=-nonroot - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Build and push (nonroot) - id: build_push_nonroot - uses: docker/build-push-action@v2 - with: - file: Dockerfile - context: . - push: true - platforms: linux/amd64,linux/arm64 - build-args: | - GO_VERSION=${{ steps.find_go_version.outputs.go_version }} - RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_NONROOT }} - GIT_VERSION=${GITHUB_REF_NAME#v} - GIT_COMMIT=$GITHUB_SHA - tags: ${{ steps.meta_nonroot.outputs.tags }} - - # Alpine Docker image - - - name: Docker meta (alpine) - id: meta_alpine - uses: docker/metadata-action@v3 - with: - images: ${{ env.DOCKER_REPOSITORY }} - flavor: | - latest=false - suffix=-alpine - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Build and push (alpine) - id: build_push_alpine - uses: docker/build-push-action@v2 - with: - file: Dockerfile - context: . - push: true - platforms: linux/amd64,linux/arm64 - build-args: | - GO_VERSION=${{ steps.find_go_version.outputs.go_version }} - RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }} - GIT_VERSION=${GITHUB_REF_NAME#v} - GIT_COMMIT=$GITHUB_SHA - tags: ${{ steps.meta_alpine.outputs.tags }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4baa5ff168e..2debe754e0b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -54,9 +54,4 @@ jobs: # within `super-linter`. fetch-depth: 0 - name: Run documentation linter - uses: github/super-linter@v4 - env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_MARKDOWN: true - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: make mdlint diff --git a/.github/workflows/mutest-issue-generate.yml b/.github/workflows/mutest-issue-generate.yml index 44ac6559e39..b80e35cc34e 100644 --- a/.github/workflows/mutest-issue-generate.yml +++ b/.github/workflows/mutest-issue-generate.yml @@ -39,7 +39,7 @@ jobs: name: Get today's date id: date run: | - echo "::set-output name=today::$(date "+%Y/%m/%d")" + echo "name=today::$(date "+%Y/%m/%d")" >> $GITHUB_STATE - name: Read mutation_test_txt file id: result diff --git a/.github/workflows/push-dev-docker-images.yml b/.github/workflows/push-dev-docker-images.yml new file mode 100644 index 00000000000..fd84be06a20 --- /dev/null +++ b/.github/workflows/push-dev-docker-images.yml @@ -0,0 +1,80 @@ +# This workflow pushes new osmosis docker images on: +# +# 1. Every new tag containing a release candidate (e.g. `v1.2.3-rc4`). +# `osmolabs/osmosis-dev:1.2.3-rc4` is pushed. +# 2. Every new commit to the main branch +# `osmolabs/osmosis-dev:main-{SHORT_SHA}-$(date +%s)` is pushed. +# 3. Every new commit to a development branch vN.x (e.g. `v1.x`) +# `osmolabs/osmosis-dev-v1.x:{SHORT_SHA}-$(date +%s)` is pushed. +# +# Note: $(date +%s) is used to sort the tags in the docker registry. +# +# All the images above have support for linux/amd64 (not linux/arm64). +# All the images are based on an alpine image for easy debugging. + +name: Push Development Docker Images + +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ + branches: + - main + - v[0-9]+.x + +env: + RUNNER_BASE_IMAGE_ALPINE: alpine:3.16 + DOCKER_IMAGE_REPOSITORY: osmolabs/osmosis-dev + +jobs: + docker: + runs-on: self-hosted + steps: + - + name: Check out repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Find go version + run: | + GO_VERSION=$(cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2) + echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV + - + name: Create Docker Image Tag for release candidate + if: startsWith(github.ref, 'refs/tags/v') + run: | + GITHUB_TAG=${{ github.ref_name }} + echo "DOCKER_IMAGE_TAG=${GITHUB_TAG#v}" >> $GITHUB_ENV + echo "OSMOSIS_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + - + name: Create Docker Image Tag for vN.x branch + if: "!startsWith(github.ref, 'refs/tags/v')" + run: | + SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-8) + echo "DOCKER_IMAGE_TAG=${{ github.ref_name }}-${SHORT_SHA}-$(date +%s)" >> $GITHUB_ENV + echo "OSMOSIS_VERSION=${{ github.ref_name }}-$SHORT_SHA" >> $GITHUB_ENV + - + name: Build and Push Docker Images + uses: docker/build-push-action@v3 + with: + file: Dockerfile + context: . + push: true + platforms: linux/amd64 + build-args: | + GO_VERSION=${{ env.GO_VERSION }} + RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }} + GIT_VERSION=${{ env.OSMOSIS_VERSION }} + GIT_COMMIT=${{ github.sha }} + tags: | + ${{ env.DOCKER_IMAGE_REPOSITORY }}:${{ env.DOCKER_IMAGE_TAG }} diff --git a/.github/workflows/push-docker-images.yml b/.github/workflows/push-docker-images.yml new file mode 100644 index 00000000000..86867f3caa8 --- /dev/null +++ b/.github/workflows/push-docker-images.yml @@ -0,0 +1,186 @@ +# This workflow pushes new osmosis docker images on every new tag. +# +# On every new `vX.Y.Z` tag the following images are pushed: +# +# osmolabs/osmosis:X.Y.Z # is pushed +# osmolabs/osmosis:X.Y # is updated to X.Y.Z +# osmolabs/osmosis:X # is updated to X.Y.Z +# osmolabs/osmosis:latest # is updated to X.Y.Z +# +# On every new `vX.Y.0` tag the following images are pushed: +# +# osmolabs/osmosis-e2e-init-chain:X.Y.0 # is pushed +# osmolabs/osmosis-e2e-init-chain:X.Y # is updated to X.Y.0 +# osmolabs/osmosis-e2e-init-chain:X # is updated to X.Y.0 +# The same osmosisd binary is copied in different base runner images: +# +# - `osmolabs/osmosis:X.Y.Z` uses `gcr.io/distroless/static-debian11` +# - `osmolabs/osmosis:X.Y.Z-distroless` uses `gcr.io/distroless/static-debian11` +# - `osmolabs/osmosis:X.Y.Z-nonroot` uses `gcr.io/distroless/static-debian11:nonroot` +# - `osmolabs/osmosis:X.Y.Z-alpine` uses `alpine:3.16` +# +# All the images above have support for linux/amd64 and linux/arm64. +# +# Due to QEMU virtualization used to build multi-platform docker images +# this workflow might take a while to complete. + +name: Push Docker Images + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc + +env: + DOCKER_REPOSITORY: osmolabs/osmosis + RUNNER_BASE_IMAGE_DISTROLESS: gcr.io/distroless/static-debian11 + RUNNER_BASE_IMAGE_NONROOT: gcr.io/distroless/static-debian11:nonroot + RUNNER_BASE_IMAGE_ALPINE: alpine:3.16 + +jobs: + osmosisd-images: + runs-on: self-hosted + steps: + - + name: Check out the repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Find go version + id: find_go_version + run: | + GO_VERSION=$(cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2) + echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV + - + name: Parse tag + id: tag + run: | + VERSION=$(echo ${{ github.ref_name }} | sed "s/v//") + MAJOR_VERSION=$(echo $VERSION | cut -d '.' -f 1) + MINOR_VERSION=$(echo $VERSION | cut -d '.' -f 2) + PATCH_VERSION=$(echo $VERSION | cut -d '.' -f 3) + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "MAJOR_VERSION=$MAJOR_VERSION" >> $GITHUB_ENV + echo "MINOR_VERSION=$MINOR_VERSION" >> $GITHUB_ENV + echo "PATCH_VERSION=$PATCH_VERSION" >> $GITHUB_ENV + # Distroless Docker image (default) + - + name: Build and push (distroless) + id: build_push_distroless + uses: docker/build-push-action@v3 + with: + file: Dockerfile + context: . + push: true + platforms: linux/amd64,linux/arm64 + build-args: | + GO_VERSION=${{ env.GO_VERSION }} + RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_DISTROLESS }} + GIT_VERSION=${{ env.VERSION }} + GIT_COMMIT=${{ github.sha }} + tags: | + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }} + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }} + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }} + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}-distroless + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}-distroless + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}-distroless + # Distroless nonroot Docker image + - + name: Build and push (nonroot) + id: build_push_nonroot + uses: docker/build-push-action@v3 + with: + file: Dockerfile + context: . + push: true + platforms: linux/amd64,linux/arm64 + build-args: | + GO_VERSION=${{ env.GO_VERSION }} + RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_NONROOT }} + GIT_VERSION=${{ env.VERSION }} + GIT_COMMIT=${{ github.sha }} + tags: | + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}-nonroot + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}-nonroot + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}-nonroot + # Alpine Docker image + - + name: Build and push (alpine) + id: build_push_alpine + uses: docker/build-push-action@v3 + with: + file: Dockerfile + context: . + push: true + platforms: linux/amd64,linux/arm64 + build-args: | + GO_VERSION=${{ env.GO_VERSION }} + RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }} + GIT_VERSION=${{ env.VERSION }} + GIT_COMMIT=${{ github.sha }} + tags: | + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}-alpine + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}-alpine + ${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}-alpine + e2e-init-chain-images: + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '.0') + runs-on: ubuntu-latest + steps: + - + name: Check out the repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Parse tag + id: tag + run: | + VERSION=$(echo ${{ github.ref_name }} | sed "s/v//") + MAJOR_VERSION=$(echo $VERSION | cut -d '.' -f 1) + MINOR_VERSION=$(echo $VERSION | cut -d '.' -f 2) + PATCH_VERSION=$(echo $VERSION | cut -d '.' -f 3) + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "MAJOR_VERSION=$MAJOR_VERSION" >> $GITHUB_ENV + echo "MINOR_VERSION=$MINOR_VERSION" >> $GITHUB_ENV + echo "PATCH_VERSION=$PATCH_VERSION" >> $GITHUB_ENV + - + name: Build and push + id: build_push_e2e_init_image + uses: docker/build-push-action@v3 + with: + file: tests/e2e/initialization/init.Dockerfile + context: . + push: true + platforms: linux/amd64,linux/arm64 + build-args: | + E2E_SCRIPT_NAME=chain + tags: | + osmolabs/osmosis-e2e-init-chain:${{ env.MAJOR_VERSION }} + osmolabs/osmosis-e2e-init-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }} + osmolabs/osmosis-e2e-init-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }} diff --git a/.github/workflows/test-e2e-makefile.yml b/.github/workflows/test-e2e-makefile.yml new file mode 100644 index 00000000000..27185d5e976 --- /dev/null +++ b/.github/workflows/test-e2e-makefile.yml @@ -0,0 +1,56 @@ +name: Test-E2E-Makefile + +on: + push: + branches: + - "main" +jobs: + e2e: + runs-on: ubuntu-latest + timeout-minutes: 25 + steps: + - + name: Setup Go + uses: actions/setup-go@v2.2.0 + with: + go-version: 1.18 + - + name: Check out repository code + uses: actions/checkout@v2 + - + name: Get git diff + uses: technote-space/get-diff-action@v6.0.1 + with: + PATTERNS: | + **/**.go + go.mod + go.sum + - + name: Get data from build cache + uses: actions/cache@v2 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + ~\AppData\Local\go-build + key: ${{ runner.os }}-go-docker-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-docker-${{ matrix.go-version }}- + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Build e2e init chain image + run: make docker-build-e2e-init-chain + - + name: Test e2e short + run: make test-e2e-short \ No newline at end of file diff --git a/.gitignore b/.gitignore index ff99e2886b4..705d20fc0c9 100644 --- a/.gitignore +++ b/.gitignore @@ -216,10 +216,6 @@ target/ # Generated by rust-optimizer artifacts/ -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - # These are backup files generated by rustfmt **/*.rs.bk @@ -233,4 +229,4 @@ blocks.db # Ignore e2e test artifacts (which clould leak information if commited) .ash_history -.bash_history \ No newline at end of file +.bash_history diff --git a/.markdownlint.yml b/.markdownlint.yml index 926e6625649..cbe0c3ceea8 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -12,8 +12,6 @@ MD042: true MD048: true MD051: true # MD004: false -# # Can't disable MD007 :/ -# MD007: false # MD009: false # MD010: # code_blocks: false diff --git a/CHANGELOG.md b/CHANGELOG.md index ee35bcc74d2..c550a45be9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,18 +45,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features * [#2788](https://github.com/osmosis-labs/osmosis/pull/2788) Add logarithm base 2 implementation. -* [#2739](https://github.com/osmosis-labs/osmosis/pull/2739) Add pool type query +* [#2739](https://github.com/osmosis-labs/osmosis/pull/2739),[#3356](https://github.com/osmosis-labs/osmosis/pull/3356) Add pool type query, and add it to stargate whitelist +* [#2956](https://github.com/osmosis-labs/osmosis/issues/2956) Add queries for calculating amount of shares/tokens you get by providing X tokens/shares when entering/exiting a pool +* [#3217](https://github.com/osmosis-labs/osmosis/pull/3217) Add `CalcJoinPoolShares`, `CalcExitPoolCoinsFromShares`, `CalcJoinPoolNoSwapShares` to the registered Stargate queries list. +* [#3313](https://github.com/osmosis-labs/osmosis/pull/3313) Upgrade to IBC v3.4.0, allowing for IBC transfers with metadata. +* [#3335](https://github.com/osmosis-labs/osmosis/pull/3335) Add v2 spot price queries + - The v1beta1 queries actually have base asset and quote asset reversed, so you were always getting 1/correct spot price. People fixed this by reordering the arguments. + - This PR adds v2 queries for doing the correct thing, and giving people time to migrate from v1beta1 queries to v2. + - It also changes cosmwasm to only allow the v2 queries, as no contracts on Osmosis mainnet uses the v1beta1 queries. + ### Bug fixes * [#2803](https://github.com/osmosis-labs/osmosis/pull/2803) Fix total pool liquidity CLI query. * [#2914](https://github.com/osmosis-labs/osmosis/pull/2914) Remove out of gas panics from node logs * [#2937](https://github.com/osmosis-labs/osmosis/pull/2937) End block ordering - staking after gov and module sorting. +* [#2923](https://github.com/osmosis-labs/osmosis/pull/2923) TWAP calculation now errors if it uses records that have errored previously. +* [#3312](https://github.com/osmosis-labs/osmosis/pull/3312) Add better panic catches within GAMM txs ### Misc Improvements * [#2804](https://github.com/osmosis-labs/osmosis/pull/2804) Improve error handling and messages when parsing pool assets. * [#3035](https://github.com/osmosis-labs/osmosis/pull/3035) Remove `PokePool` from `PoolI` interface. Define on a new WeightedPoolExtension` instead. +* [#3214](https://github.com/osmosis-labs/osmosis/pull/3214) Add basic CLI query support for TWAP. + ## v12.0.0 diff --git a/Dockerfile b/Dockerfile index 2f6bc3e800d..b76aaac7b52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 ARG GO_VERSION="1.18" -ARG RUNNER_IMAGE="gcr.io/distroless/static" +ARG RUNNER_IMAGE="gcr.io/distroless/static-debian11" # -------------------------------------------------------- # Builder @@ -27,7 +27,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ # Cosmwasm - Download correct libwasmvm version RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \ wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \ - -O /lib/libwasmvm_muslc.a && \ + -O /lib/libwasmvm_muslc.a && \ # verify checksum wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1) @@ -39,17 +39,18 @@ COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ go build \ - -mod=readonly \ - -tags "netgo,ledger,muslc" \ - -ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="osmosis" \ - -X github.com/cosmos/cosmos-sdk/version.AppName="osmosisd" \ - -X github.com/cosmos/cosmos-sdk/version.Version=${GIT_VERSION} \ - -X github.com/cosmos/cosmos-sdk/version.Commit=${GIT_COMMIT} \ - -X github.com/cosmos/cosmos-sdk/version.BuildTags='netgo,ledger,muslc' \ - -w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \ - -trimpath \ - -o /osmosis/build/osmosisd \ - /osmosis/cmd/osmosisd/main.go + -mod=readonly \ + -tags "netgo,ledger,muslc" \ + -ldflags \ + "-X github.com/cosmos/cosmos-sdk/version.Name="osmosis" \ + -X github.com/cosmos/cosmos-sdk/version.AppName="osmosisd" \ + -X github.com/cosmos/cosmos-sdk/version.Version=${GIT_VERSION} \ + -X github.com/cosmos/cosmos-sdk/version.Commit=${GIT_COMMIT} \ + -X github.com/cosmos/cosmos-sdk/version.BuildTags='netgo,ledger,muslc' \ + -w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \ + -trimpath \ + -o /osmosis/build/osmosisd \ + /osmosis/cmd/osmosisd/main.go # -------------------------------------------------------- # Runner diff --git a/Makefile b/Makefile index 33117381e6e..8db01b1028b 100644 --- a/Makefile +++ b/Makefile @@ -106,12 +106,15 @@ build-reproducible-amd64: go.sum $(BUILDDIR)/ $(DOCKER) buildx use osmobuilder $(DOCKER) buildx build \ --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg GIT_VERSION=$(VERSION) \ + --build-arg GIT_COMMIT=$(COMMIT) \ + --build-arg RUNNER_IMAGE=alpine:3.16 \ --platform linux/amd64 \ - -t osmosis-amd64 \ + -t osmosis:local-amd64 \ --load \ -f Dockerfile . $(DOCKER) rm -f osmobinary || true - $(DOCKER) create -ti --name osmobinary osmosis-amd64 + $(DOCKER) create -ti --name osmobinary osmosis:local-amd64 $(DOCKER) cp osmobinary:/bin/osmosisd $(BUILDDIR)/osmosisd-linux-amd64 $(DOCKER) rm -f osmobinary @@ -120,12 +123,15 @@ build-reproducible-arm64: go.sum $(BUILDDIR)/ $(DOCKER) buildx use osmobuilder $(DOCKER) buildx build \ --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg GIT_VERSION=$(VERSION) \ + --build-arg GIT_COMMIT=$(COMMIT) \ + --build-arg RUNNER_IMAGE=alpine:3.16 \ --platform linux/arm64 \ - -t osmosis-arm64 \ + -t osmosis:local-arm64 \ --load \ -f Dockerfile . $(DOCKER) rm -f osmobinary || true - $(DOCKER) create -ti --name osmobinary osmosis-arm64 + $(DOCKER) create -ti --name osmobinary osmosis:local-arm64 $(DOCKER) cp osmobinary:/bin/osmosisd $(BUILDDIR)/osmosisd-linux-arm64 $(DOCKER) rm -f osmobinary @@ -261,7 +267,7 @@ test-sim-bench: # In that case, run `make e2e-remove-resources` # manually. # Utilizes Go cache. -test-e2e: OSMOSIS_E2E=True e2e-setup test-e2e-ci +test-e2e: e2e-setup test-e2e-ci # test-e2e-ci runs a full e2e test suite # does not do any validation about the state of the Docker environment @@ -272,7 +278,7 @@ test-e2e-ci: # test-e2e-debug runs a full e2e test suite but does # not attempt to delete Docker resources at the end. test-e2e-debug: e2e-setup - @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) OSMOSIS_E2E_SKIP_CLEANUP=True go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 + @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) OSMOSIS_E2E_SKIP_CLEANUP=True go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 # test-e2e-short runs the e2e test with only short tests. # Does not delete any of the containers after running. @@ -296,10 +302,10 @@ docker-build-debug: @DOCKER_BUILDKIT=1 docker tag osmosis:${COMMIT} osmosis:debug docker-build-e2e-init-chain: - @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain -f tests/e2e/initialization/init.Dockerfile . + @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain --platform=linux/x86_64 -f tests/e2e/initialization/init.Dockerfile . docker-build-e2e-init-node: - @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node -f tests/e2e/initialization/init.Dockerfile . + @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node --platform=linux/x86_64 -f tests/e2e/initialization/init.Dockerfile . e2e-setup: e2e-check-image-sha e2e-remove-resources @echo Finished e2e environment setup, ready to start the test @@ -316,9 +322,9 @@ e2e-remove-resources: ### Docker ### ############################################################################### -RUNNER_BASE_IMAGE_DISTROLESS := gcr.io/distroless/static +RUNNER_BASE_IMAGE_DISTROLESS := gcr.io/distroless/static-debian11 RUNNER_BASE_IMAGE_ALPINE := alpine:3.16 -RUNNER_BASE_IMAGE_NONROOT := gcr.io/distroless/static:nonroot +RUNNER_BASE_IMAGE_NONROOT := gcr.io/distroless/static-debian11:nonroot docker-build: @DOCKER_BUILDKIT=1 docker build \ @@ -399,7 +405,7 @@ localnet-stop: @STATE="" docker-compose -f tests/localosmosis/docker-compose.yml down localnet-clean: - @rm -rfI $(HOME)/.osmosisd/ + @rm -rfI $(HOME)/.osmosisd-local/ localnet-state-export-init: localnet-state-export-clean localnet-state-export-build diff --git a/app/ante.go b/app/ante.go index 4769ec79aaa..5d8964104c8 100644 --- a/app/ante.go +++ b/app/ante.go @@ -11,11 +11,11 @@ import ( ante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/signing" - osmoante "github.com/osmosis-labs/osmosis/v12/ante" - v9 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v9" + osmoante "github.com/osmosis-labs/osmosis/v13/ante" + v9 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v9" - txfeeskeeper "github.com/osmosis-labs/osmosis/v12/x/txfees/keeper" - txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + txfeeskeeper "github.com/osmosis-labs/osmosis/v13/x/txfees/keeper" + txfeestypes "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) // Link to default ante handler used by cosmos sdk: diff --git a/app/app.go b/app/app.go index 747d777355d..18b55868e38 100644 --- a/app/app.go +++ b/app/app.go @@ -39,20 +39,21 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - v10 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v10" - v11 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v11" - v12 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v12" - v13 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v13" - v3 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v3" - v4 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v4" - v5 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v5" - v6 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v6" - v7 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v7" - v8 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v8" - v9 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v9" - _ "github.com/osmosis-labs/osmosis/v12/client/docs/statik" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + v10 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v10" + v11 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v11" + v12 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v12" + v13 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v13" + v3 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v3" + v4 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v4" + v5 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v5" + v6 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v6" + v7 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v7" + v8 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v8" + v9 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v9" + _ "github.com/osmosis-labs/osmosis/v13/client/docs/statik" + ibc_hooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks" ) const appName = "OsmosisApp" @@ -70,7 +71,7 @@ var ( maccPerms = moduleAccountPermissions // module accounts that are allowed to receive tokens. - allowedReceivingModAcc = map[string]bool{} + allowedReceivingModAcc = map[string]bool{ibc_hooks.WasmHookModuleAccountAddr.String(): true} // WasmProposalsEnabled enables all x/wasm proposals when it's value is "true" // and EnableSpecificWasmProposals is empty. Otherwise, all x/wasm proposals @@ -176,6 +177,10 @@ func NewOsmosisApp( wasmDir := filepath.Join(homePath, "wasm") wasmConfig, err := wasm.ReadWasmConfig(appOpts) + + // Uncomment this for debugging contracts. In the future this could be made into a param passed by the tests + //wasmConfig.ContractDebugMode = true + if err != nil { panic(fmt.Sprintf("error while reading wasm config: %s", err)) } @@ -267,6 +272,8 @@ func NewOsmosisApp( app.IBCKeeper, ), ) + // Uncomment to enable postHandlers: + // app.SetPostHandler(NewTxPostHandler()) app.SetEndBlocker(app.EndBlocker) // Register snapshot extensions to enable state-sync for wasm. diff --git a/app/apptesting/gamm.go b/app/apptesting/gamm.go index 6b06817608f..e5f2c4636dc 100644 --- a/app/apptesting/gamm.go +++ b/app/apptesting/gamm.go @@ -3,9 +3,11 @@ package apptesting import ( sdk "github.com/cosmos/cosmos-sdk/types" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var DefaultAcctFunds sdk.Coins = sdk.NewCoins( @@ -15,6 +17,37 @@ var DefaultAcctFunds sdk.Coins = sdk.NewCoins( sdk.NewCoin("baz", sdk.NewInt(10000000)), ) +var DefaultPoolAssets = []balancer.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(300), + Token: sdk.NewCoin("baz", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(400), + Token: sdk.NewCoin("uosmo", sdk.NewInt(5000000)), + }, +} + +var DefaultStableswapLiquidity = sdk.NewCoins( + sdk.NewCoin("foo", sdk.NewInt(10000000)), + sdk.NewCoin("bar", sdk.NewInt(10000000)), + sdk.NewCoin("baz", sdk.NewInt(10000000)), +) + +var ImbalancedStableswapLiquidity = sdk.NewCoins( + sdk.NewCoin("foo", sdk.NewInt(10_000_000_000)), + sdk.NewCoin("bar", sdk.NewInt(20_000_000_000)), + sdk.NewCoin("baz", sdk.NewInt(30_000_000_000)), +) + // PrepareBalancerPoolWithCoins returns a balancer pool // consisted of given coins with equal weight. func (s *KeeperTestHelper) PrepareBalancerPoolWithCoins(coins ...sdk.Coin) uint64 { @@ -63,30 +96,42 @@ func (s *KeeperTestHelper) PrepareBalancerPool() uint64 { return poolId } +func (s *KeeperTestHelper) PrepareBasicStableswapPool() uint64 { + // Mint some assets to the account. + s.FundAcc(s.TestAccs[0], DefaultAcctFunds) + + params := stableswap.PoolParams{ + SwapFee: sdk.NewDec(0), + ExitFee: sdk.NewDec(0), + } + + msg := stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], params, DefaultStableswapLiquidity, []uint64{}, "") + poolId, err := s.App.GAMMKeeper.CreatePool(s.Ctx, msg) + s.NoError(err) + return poolId +} + +func (s *KeeperTestHelper) PrepareImbalancedStableswapPool() uint64 { + // Mint some assets to the account. + s.FundAcc(s.TestAccs[0], ImbalancedStableswapLiquidity) + + params := stableswap.PoolParams{ + SwapFee: sdk.NewDec(0), + ExitFee: sdk.NewDec(0), + } + + msg := stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], params, ImbalancedStableswapLiquidity, []uint64{1, 1, 1}, "") + poolId, err := s.App.GAMMKeeper.CreatePool(s.Ctx, msg) + s.NoError(err) + return poolId +} + // PrepareBalancerPoolWithPoolParams sets up a Balancer pool with poolParams. func (s *KeeperTestHelper) PrepareBalancerPoolWithPoolParams(poolParams balancer.PoolParams) uint64 { // Mint some assets to the account. s.FundAcc(s.TestAccs[0], DefaultAcctFunds) - poolAssets := []balancer.PoolAsset{ - { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), - }, - { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), - }, - { - Weight: sdk.NewInt(300), - Token: sdk.NewCoin("baz", sdk.NewInt(5000000)), - }, - { - Weight: sdk.NewInt(400), - Token: sdk.NewCoin("uosmo", sdk.NewInt(5000000)), - }, - } - msg := balancer.NewMsgCreateBalancerPool(s.TestAccs[0], poolParams, poolAssets, "") + msg := balancer.NewMsgCreateBalancerPool(s.TestAccs[0], poolParams, DefaultPoolAssets, "") poolId, err := s.App.GAMMKeeper.CreatePool(s.Ctx, msg) s.NoError(err) return poolId @@ -110,6 +155,55 @@ func (s *KeeperTestHelper) PrepareBalancerPoolWithPoolAsset(assets []balancer.Po return poolId } +// Modify spotprice of a pool to target spotprice +func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice sdk.Dec, baseDenom string) { + var quoteDenom string + var int64Max = int64(^uint64(0) >> 1) + + s.Require().Positive(targetSpotPrice) + s.Require().Greater(gammtypes.MaxSpotPrice, targetSpotPrice) + pool, _ := s.App.GAMMKeeper.GetPoolAndPoke(s.Ctx, poolID) + denoms, err := s.App.GAMMKeeper.GetPoolDenoms(s.Ctx, poolID) + s.Require().NoError(err) + if denoms[0] == baseDenom { + quoteDenom = denoms[1] + } else { + quoteDenom = denoms[0] + } + + amountTrade := s.CalcAmoutOfTokenToGetTargetPrice(s.Ctx, pool, targetSpotPrice, baseDenom, quoteDenom) + if amountTrade.IsPositive() { + swapIn := sdk.NewCoins(sdk.NewCoin(quoteDenom, sdk.NewInt(amountTrade.RoundInt64()))) + s.FundAcc(s.TestAccs[0], swapIn) + msg := gammtypes.MsgSwapExactAmountIn{ + Sender: s.TestAccs[0].String(), + Routes: []gammtypes.SwapAmountInRoute{{PoolId: poolID, TokenOutDenom: baseDenom}}, + TokenIn: swapIn[0], + TokenOutMinAmount: sdk.ZeroInt(), + } + + gammMsgServer := gammkeeper.NewMsgServerImpl(s.App.GAMMKeeper) + _, err = gammMsgServer.SwapExactAmountIn(sdk.WrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err) + } else { + swapOut := sdk.NewCoins(sdk.NewCoin(quoteDenom, sdk.NewInt(amountTrade.RoundInt64()).Abs())) + swapFee := pool.GetSwapFee(s.Ctx) + tokenIn, err := pool.CalcInAmtGivenOut(s.Ctx, swapOut, baseDenom, swapFee) + s.Require().NoError(err) + s.FundAcc(s.TestAccs[0], sdk.NewCoins(tokenIn)) + msg := gammtypes.MsgSwapExactAmountOut{ + Sender: s.TestAccs[0].String(), + Routes: []gammtypes.SwapAmountOutRoute{{PoolId: poolID, TokenInDenom: baseDenom}}, + TokenInMaxAmount: sdk.NewInt(int64Max), + TokenOut: swapOut[0], + } + + gammMsgServer := gammkeeper.NewMsgServerImpl(s.App.GAMMKeeper) + _, err = gammMsgServer.SwapExactAmountOut(sdk.WrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err) + } +} + func (s *KeeperTestHelper) RunBasicSwap(poolId uint64) { denoms, err := s.App.GAMMKeeper.GetPoolDenoms(s.Ctx, poolId) s.Require().NoError(err) @@ -169,3 +263,27 @@ func (s *KeeperTestHelper) RunBasicJoin(poolId uint64) { _, err = gammMsgServer.JoinPool(sdk.WrapSDKContext(s.Ctx), &msg) s.Require().NoError(err) } + +func (s *KeeperTestHelper) CalcAmoutOfTokenToGetTargetPrice(ctx sdk.Context, pool gammtypes.PoolI, targetSpotPrice sdk.Dec, baseDenom, quoteDenom string) (amountTrade sdk.Dec) { + blPool, ok := pool.(*balancer.Pool) + s.Require().True(ok) + quoteAsset, _ := blPool.GetPoolAsset(quoteDenom) + baseAsset, err := blPool.GetPoolAsset(baseDenom) + s.Require().NoError(err) + + s.Require().NotEqual(baseAsset.Weight, sdk.ZeroInt()) + s.Require().NotEqual(quoteAsset.Weight, sdk.ZeroInt()) + + spotPriceNow, err := blPool.SpotPrice(ctx, baseDenom, quoteDenom) + s.Require().NoError(err) + + // Amount of quote token need to trade to get target spot price + // AmoutQuoteTokenNeedToTrade = AmoutQuoTokenNow * ((targetSpotPrice/spotPriceNow)^((weight_base/(weight_base + weight_quote))) -1 ) + + ratioPrice := targetSpotPrice.Quo(spotPriceNow) + ratioWeight := (baseAsset.Weight.ToDec()).Quo(baseAsset.Weight.ToDec().Add(quoteAsset.Weight.ToDec())) + + amountTrade = quoteAsset.Token.Amount.ToDec().Mul(osmomath.Pow(ratioPrice, ratioWeight).Sub(sdk.OneDec())) + + return amountTrade +} diff --git a/app/apptesting/superfluid.go b/app/apptesting/superfluid.go index d7193d4d509..0d2b4a0934c 100644 --- a/app/apptesting/superfluid.go +++ b/app/apptesting/superfluid.go @@ -4,8 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func (s *KeeperTestHelper) SuperfluidDelegateToDefaultVal(sender sdk.AccAddress, poolId uint64, lockId uint64) error { diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 13394a119b8..c52ebae6f13 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -29,12 +29,12 @@ import ( tmtypes "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - lockupkeeper "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + lockupkeeper "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) type KeeperTestHelper struct { @@ -224,6 +224,17 @@ func (s *KeeperTestHelper) EndBlock() { s.App.EndBlocker(s.Ctx, reqEndBlock) } +func (s *KeeperTestHelper) RunMsg(msg sdk.Msg) (*sdk.Result, error) { + // cursed that we have to copy this internal logic from SDK + router := s.App.GetBaseApp().MsgServiceRouter() + if handler := router.Handler(msg); handler != nil { + // ADR 031 request type routing + return handler(s.Ctx, msg) + } + s.FailNow("msg %v could not be ran", msg) + return nil, fmt.Errorf("msg %v could not be ran", msg) +} + // AllocateRewardsToValidator allocates reward tokens to a distribution module then allocates rewards to the validator address. func (s *KeeperTestHelper) AllocateRewardsToValidator(valAddr sdk.ValAddress, rewardAmt sdk.Int) { validator, found := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) diff --git a/app/encoding.go b/app/encoding.go index dafe7e3e200..adbbe87252d 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,7 +1,7 @@ package app import ( - "github.com/osmosis-labs/osmosis/v12/app/params" + "github.com/osmosis-labs/osmosis/v13/app/params" "github.com/cosmos/cosmos-sdk/std" ) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 83c53e3f2cd..b7de9f919fa 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -33,8 +33,11 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibcratelimit "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit" - ibcratelimittypes "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + + ibchooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks" + ibcratelimit "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit" + ibcratelimittypes "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter" icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host" icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper" @@ -50,31 +53,33 @@ import ( // IBC Transfer: Defines the "transfer" IBC port transfer "github.com/cosmos/ibc-go/v3/modules/apps/transfer" - _ "github.com/osmosis-labs/osmosis/v12/client/docs/statik" - owasm "github.com/osmosis-labs/osmosis/v12/wasmbinding" - epochskeeper "github.com/osmosis-labs/osmosis/v12/x/epochs/keeper" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - incentiveskeeper "github.com/osmosis-labs/osmosis/v12/x/incentives/keeper" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockupkeeper "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - mintkeeper "github.com/osmosis-labs/osmosis/v12/x/mint/keeper" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" - poolincentives "github.com/osmosis-labs/osmosis/v12/x/pool-incentives" - poolincentiveskeeper "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/keeper" - poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid" - superfluidkeeper "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" - tokenfactorykeeper "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/keeper" - tokenfactorytypes "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" - "github.com/osmosis-labs/osmosis/v12/x/twap" - twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types" - "github.com/osmosis-labs/osmosis/v12/x/txfees" - txfeeskeeper "github.com/osmosis-labs/osmosis/v12/x/txfees/keeper" - txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + _ "github.com/osmosis-labs/osmosis/v13/client/docs/statik" + owasm "github.com/osmosis-labs/osmosis/v13/wasmbinding" + epochskeeper "github.com/osmosis-labs/osmosis/v13/x/epochs/keeper" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + incentiveskeeper "github.com/osmosis-labs/osmosis/v13/x/incentives/keeper" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockupkeeper "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + mintkeeper "github.com/osmosis-labs/osmosis/v13/x/mint/keeper" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" + poolincentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives" + poolincentiveskeeper "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/keeper" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid" + superfluidkeeper "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" + tokenfactorykeeper "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/keeper" + tokenfactorytypes "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/twap" + twaptypes "github.com/osmosis-labs/osmosis/v13/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees" + txfeeskeeper "github.com/osmosis-labs/osmosis/v13/x/txfees/keeper" + txfeestypes "github.com/osmosis-labs/osmosis/v13/x/txfees/types" + valsetpref "github.com/osmosis-labs/osmosis/v13/x/valset-pref" + valsetpreftypes "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" ) type AppKeepers struct { @@ -92,34 +97,40 @@ type AppKeepers struct { ScopedWasmKeeper capabilitykeeper.ScopedKeeper // "Normal" keepers - AccountKeeper *authkeeper.AccountKeeper - BankKeeper *bankkeeper.BaseKeeper - AuthzKeeper *authzkeeper.Keeper - StakingKeeper *stakingkeeper.Keeper - DistrKeeper *distrkeeper.Keeper - SlashingKeeper *slashingkeeper.Keeper - IBCKeeper *ibckeeper.Keeper - ICAHostKeeper *icahostkeeper.Keeper - TransferKeeper *ibctransferkeeper.Keeper - EvidenceKeeper *evidencekeeper.Keeper - GAMMKeeper *gammkeeper.Keeper - TwapKeeper *twap.Keeper - LockupKeeper *lockupkeeper.Keeper - EpochsKeeper *epochskeeper.Keeper - IncentivesKeeper *incentiveskeeper.Keeper - MintKeeper *mintkeeper.Keeper - PoolIncentivesKeeper *poolincentiveskeeper.Keeper - TxFeesKeeper *txfeeskeeper.Keeper - SuperfluidKeeper *superfluidkeeper.Keeper - GovKeeper *govkeeper.Keeper - WasmKeeper *wasm.Keeper - ContractKeeper *wasmkeeper.PermissionedKeeper - TokenFactoryKeeper *tokenfactorykeeper.Keeper + AccountKeeper *authkeeper.AccountKeeper + BankKeeper *bankkeeper.BaseKeeper + AuthzKeeper *authzkeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + DistrKeeper *distrkeeper.Keeper + SlashingKeeper *slashingkeeper.Keeper + IBCKeeper *ibckeeper.Keeper + ICAHostKeeper *icahostkeeper.Keeper + TransferKeeper *ibctransferkeeper.Keeper + EvidenceKeeper *evidencekeeper.Keeper + GAMMKeeper *gammkeeper.Keeper + TwapKeeper *twap.Keeper + LockupKeeper *lockupkeeper.Keeper + EpochsKeeper *epochskeeper.Keeper + IncentivesKeeper *incentiveskeeper.Keeper + MintKeeper *mintkeeper.Keeper + PoolIncentivesKeeper *poolincentiveskeeper.Keeper + TxFeesKeeper *txfeeskeeper.Keeper + SuperfluidKeeper *superfluidkeeper.Keeper + GovKeeper *govkeeper.Keeper + WasmKeeper *wasm.Keeper + ContractKeeper *wasmkeeper.PermissionedKeeper + TokenFactoryKeeper *tokenfactorykeeper.Keeper + ValidatorSetPreferenceKeeper *valsetpref.Keeper + // Note: DO NOT USE. This is not yet initialized + SwapRouterKeeper *swaprouter.Keeper // IBC modules // transfer module - TransferModule transfer.AppModule - RateLimitingICS4Wrapper *ibcratelimit.ICS4Wrapper + RawIcs20TransferAppModule transfer.AppModule + RateLimitingICS4Wrapper *ibcratelimit.ICS4Wrapper + TransferStack *ibchooks.IBCMiddleware + Ics20WasmHooks *ibchooks.WasmHooks + HooksICS4Wrapper ibchooks.ICS4Middleware // keys to access the substores keys map[string]*sdk.KVStoreKey @@ -201,36 +212,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.ScopedIBCKeeper, ) - // ChannelKeeper wrapper for rate limiting SendPacket(). The wasmKeeper needs to be added after it's created - rateLimitingParams := appKeepers.GetSubspace(ibcratelimittypes.ModuleName) - rateLimitingParams = rateLimitingParams.WithKeyTable(ibcratelimittypes.ParamKeyTable()) - rateLimitingICS4Wrapper := ibcratelimit.NewICS4Middleware( - appKeepers.IBCKeeper.ChannelKeeper, - appKeepers.AccountKeeper, - nil, - appKeepers.BankKeeper, - rateLimitingParams, - ) - appKeepers.RateLimitingICS4Wrapper = &rateLimitingICS4Wrapper - - // Create Transfer Keepers - transferKeeper := ibctransferkeeper.NewKeeper( - appCodec, - appKeepers.keys[ibctransfertypes.StoreKey], - appKeepers.GetSubspace(ibctransfertypes.ModuleName), - appKeepers.RateLimitingICS4Wrapper, // The ICS4Wrapper is replaced by the rateLimitingICS4Wrapper instead of the channel - appKeepers.IBCKeeper.ChannelKeeper, - &appKeepers.IBCKeeper.PortKeeper, - appKeepers.AccountKeeper, - appKeepers.BankKeeper, - appKeepers.ScopedTransferKeeper, - ) - appKeepers.TransferKeeper = &transferKeeper - appKeepers.TransferModule = transfer.NewAppModule(*appKeepers.TransferKeeper) - transferIBCModule := transfer.NewIBCModule(*appKeepers.TransferKeeper) - - // RateLimiting IBC Middleware - rateLimitingTransferModule := ibcratelimit.NewIBCModule(transferIBCModule, appKeepers.RateLimitingICS4Wrapper) + appKeepers.WireICS20PreWasmKeeper(appCodec, bApp) icaHostKeeper := icahostkeeper.NewKeeper( appCodec, appKeepers.keys[icahosttypes.StoreKey], @@ -248,7 +230,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( ibcRouter := porttypes.NewRouter() ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). // The transferIBC module is replaced by rateLimitingTransferModule - AddRoute(ibctransfertypes.ModuleName, &rateLimitingTransferModule) + AddRoute(ibctransfertypes.ModuleName, appKeepers.TransferStack) // Note: the sealing is done after creating wasmd and wiring that up // create evidence keeper with router @@ -328,6 +310,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.GAMMKeeper, ) appKeepers.PoolIncentivesKeeper = &poolIncentivesKeeper + appKeepers.GAMMKeeper.SetPoolIncentivesKeeper(appKeepers.PoolIncentivesKeeper) tokenFactoryKeeper := tokenfactorykeeper.NewKeeper( appKeepers.keys[tokenfactorytypes.StoreKey], @@ -338,9 +321,17 @@ func (appKeepers *AppKeepers) InitNormalKeepers( ) appKeepers.TokenFactoryKeeper = &tokenFactoryKeeper + validatorSetPreferenceKeeper := valsetpref.NewKeeper( + appKeepers.keys[valsetpreftypes.StoreKey], + appKeepers.GetSubspace(valsetpreftypes.ModuleName), + appKeepers.StakingKeeper, + ) + + appKeepers.ValidatorSetPreferenceKeeper = &validatorSetPreferenceKeeper + // The last arguments can contain custom message handlers, and custom query handlers, // if we want to allow any custom callbacks - supportedFeatures := "iterator,staking,stargate,osmosis" + supportedFeatures := "iterator,staking,stargate,osmosis,cosmwasm_1_1" wasmOpts = append(owasm.RegisterCustomPlugins(appKeepers.GAMMKeeper, appKeepers.BankKeeper, appKeepers.TwapKeeper, appKeepers.TokenFactoryKeeper), wasmOpts...) wasmOpts = append(owasm.RegisterStargateQueries(*bApp.GRPCQueryRouter(), appCodec), wasmOpts...) @@ -365,9 +356,11 @@ func (appKeepers *AppKeepers) InitNormalKeepers( wasmOpts..., ) appKeepers.WasmKeeper = &wasmKeeper - // Update the ICS4Wrapper with the proper contractKeeper + + // Pass the contract keeper to all the structs (generally ICS4Wrappers for ibc middlewares) that need it appKeepers.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(appKeepers.WasmKeeper) appKeepers.RateLimitingICS4Wrapper.ContractKeeper = appKeepers.ContractKeeper + appKeepers.Ics20WasmHooks.ContractKeeper = appKeepers.ContractKeeper // wire up x/wasm to IBC ibcRouter.AddRoute(wasm.ModuleName, wasm.NewIBCHandler(appKeepers.WasmKeeper, appKeepers.IBCKeeper.ChannelKeeper)) @@ -383,7 +376,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)). AddRoute(poolincentivestypes.RouterKey, poolincentives.NewPoolIncentivesProposalHandler(*appKeepers.PoolIncentivesKeeper)). AddRoute(txfeestypes.RouterKey, txfees.NewUpdateFeeTokenProposalHandler(*appKeepers.TxFeesKeeper)). - AddRoute(superfluidtypes.RouterKey, superfluid.NewSuperfluidProposalHandler(*appKeepers.SuperfluidKeeper, *appKeepers.EpochsKeeper)) + AddRoute(superfluidtypes.RouterKey, superfluid.NewSuperfluidProposalHandler(*appKeepers.SuperfluidKeeper, *appKeepers.EpochsKeeper, *appKeepers.GAMMKeeper)) // The gov proposal types can be individually enabled if len(wasmEnabledProposals) != 0 { @@ -397,6 +390,63 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.GovKeeper = &govKeeper } +// Create the IBC Transfer Stack from bottom to top: +// +// * SendPacket. Originates from the transferKeeper and and goes up the stack: +// transferKeeper.SendPacket -> ibc_rate_limit.SendPacket -> ibc_hooks.SendPacket -> channel.SendPacket +// * RecvPacket, message that originates from core IBC and goes down to app, the flow is the other way +// channel.RecvPacket -> ibc_hooks.OnRecvPacket -> ibc_rate_limit.OnRecvPacket -> transfer.OnRecvPacket +// +// After this, the wasm keeper is required to be set on both +// appkeepers.WasmHooks AND appKeepers.RateLimitingICS4Wrapper +func (appKeepers *AppKeepers) WireICS20PreWasmKeeper( + appCodec codec.Codec, + bApp *baseapp.BaseApp) { + // Setup the ICS4Wrapper used by the hooks middleware + wasmHooks := ibchooks.NewWasmHooks(nil) // The contract keeper needs to be set later + appKeepers.Ics20WasmHooks = &wasmHooks + appKeepers.HooksICS4Wrapper = ibchooks.NewICS4Middleware( + appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.Ics20WasmHooks, + ) + + // ChannelKeeper wrapper for rate limiting SendPacket(). The wasmKeeper needs to be added after it's created + rateLimitingParams := appKeepers.GetSubspace(ibcratelimittypes.ModuleName) + rateLimitingParams = rateLimitingParams.WithKeyTable(ibcratelimittypes.ParamKeyTable()) + rateLimitingICS4Wrapper := ibcratelimit.NewICS4Middleware( + appKeepers.HooksICS4Wrapper, + appKeepers.AccountKeeper, + // wasm keeper we set later. + nil, + appKeepers.BankKeeper, + rateLimitingParams, + ) + appKeepers.RateLimitingICS4Wrapper = &rateLimitingICS4Wrapper + + // Create Transfer Keepers + transferKeeper := ibctransferkeeper.NewKeeper( + appCodec, + appKeepers.keys[ibctransfertypes.StoreKey], + appKeepers.GetSubspace(ibctransfertypes.ModuleName), + // The ICS4Wrapper is replaced by the rateLimitingICS4Wrapper instead of the channel + appKeepers.RateLimitingICS4Wrapper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.ScopedTransferKeeper, + ) + appKeepers.TransferKeeper = &transferKeeper + appKeepers.RawIcs20TransferAppModule = transfer.NewAppModule(*appKeepers.TransferKeeper) + transferIBCModule := transfer.NewIBCModule(*appKeepers.TransferKeeper) + + // RateLimiting IBC Middleware + rateLimitingTransferModule := ibcratelimit.NewIBCModule(transferIBCModule, appKeepers.RateLimitingICS4Wrapper) + // Hooks Middleware + hooksTransferModule := ibchooks.NewIBCMiddleware(&rateLimitingTransferModule, &appKeepers.HooksICS4Wrapper) + appKeepers.TransferStack = &hooksTransferModule +} + // InitSpecialKeepers initiates special keepers (crisis appkeeper, upgradekeeper, params keeper) func (appKeepers *AppKeepers) InitSpecialKeepers( appCodec codec.Codec, @@ -556,5 +606,6 @@ func KVStoreKeys() []string { superfluidtypes.StoreKey, wasm.StoreKey, tokenfactorytypes.StoreKey, + valsetpreftypes.StoreKey, } } diff --git a/app/keepers/keys.go b/app/keepers/keys.go index 0dd748966ec..4482336a04d 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -5,7 +5,7 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types" + twaptypes "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) // GenerateKeys generates new keys (KV Store, Transient store, and memory store). diff --git a/app/keepers/modules.go b/app/keepers/modules.go index 88f214644c7..4a66a433464 100644 --- a/app/keepers/modules.go +++ b/app/keepers/modules.go @@ -27,19 +27,22 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" - _ "github.com/osmosis-labs/osmosis/v12/client/docs/statik" - "github.com/osmosis-labs/osmosis/v12/x/epochs" - "github.com/osmosis-labs/osmosis/v12/x/gamm" - "github.com/osmosis-labs/osmosis/v12/x/incentives" - "github.com/osmosis-labs/osmosis/v12/x/lockup" - "github.com/osmosis-labs/osmosis/v12/x/mint" - poolincentives "github.com/osmosis-labs/osmosis/v12/x/pool-incentives" - poolincentivesclient "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/client" - superfluid "github.com/osmosis-labs/osmosis/v12/x/superfluid" - superfluidclient "github.com/osmosis-labs/osmosis/v12/x/superfluid/client" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory" - "github.com/osmosis-labs/osmosis/v12/x/twap/twapmodule" - "github.com/osmosis-labs/osmosis/v12/x/txfees" + _ "github.com/osmosis-labs/osmosis/v13/client/docs/statik" + "github.com/osmosis-labs/osmosis/v13/x/epochs" + "github.com/osmosis-labs/osmosis/v13/x/gamm" + ibc_hooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks" + ibc_rate_limit "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit" + "github.com/osmosis-labs/osmosis/v13/x/incentives" + "github.com/osmosis-labs/osmosis/v13/x/lockup" + "github.com/osmosis-labs/osmosis/v13/x/mint" + poolincentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives" + poolincentivesclient "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/client" + superfluid "github.com/osmosis-labs/osmosis/v13/x/superfluid" + superfluidclient "github.com/osmosis-labs/osmosis/v13/x/superfluid/client" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory" + "github.com/osmosis-labs/osmosis/v13/x/twap/twapmodule" + "github.com/osmosis-labs/osmosis/v13/x/txfees" + valsetprefmodule "github.com/osmosis-labs/osmosis/v13/x/valset-pref/valpref-module" ) // AppModuleBasics returns ModuleBasics for the module BasicManager. @@ -64,6 +67,7 @@ var AppModuleBasics = []module.AppModuleBasic{ ibcclientclient.UpgradeProposalHandler, superfluidclient.SetSuperfluidAssetsProposalHandler, superfluidclient.RemoveSuperfluidAssetsProposalHandler, + superfluidclient.UpdateUnpoolWhitelistProposalHandler, )..., ), params.AppModuleBasic{}, @@ -84,6 +88,9 @@ var AppModuleBasics = []module.AppModuleBasic{ epochs.AppModuleBasic{}, superfluid.AppModuleBasic{}, tokenfactory.AppModuleBasic{}, + valsetprefmodule.AppModuleBasic{}, wasm.AppModuleBasic{}, ica.AppModuleBasic{}, + ibc_hooks.AppModuleBasic{}, + ibc_rate_limit.AppModuleBasic{}, } diff --git a/app/modules.go b/app/modules.go index 3421fec2ba9..8308fb7f2ce 100644 --- a/app/modules.go +++ b/app/modules.go @@ -13,6 +13,8 @@ import ( ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" + ibc_hooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -43,30 +45,32 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" - _ "github.com/osmosis-labs/osmosis/v12/client/docs/statik" - "github.com/osmosis-labs/osmosis/v12/osmoutils/partialord" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - "github.com/osmosis-labs/osmosis/v12/x/epochs" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/incentives" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - "github.com/osmosis-labs/osmosis/v12/x/lockup" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/mint" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" - poolincentives "github.com/osmosis-labs/osmosis/v12/x/pool-incentives" - poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" - superfluid "github.com/osmosis-labs/osmosis/v12/x/superfluid" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory" - tokenfactorytypes "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/twapmodule" - twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types" - "github.com/osmosis-labs/osmosis/v12/x/txfees" - txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + _ "github.com/osmosis-labs/osmosis/v13/client/docs/statik" + "github.com/osmosis-labs/osmosis/v13/osmoutils/partialord" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/epochs" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/mint" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" + poolincentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" + superfluid "github.com/osmosis-labs/osmosis/v13/x/superfluid" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory" + tokenfactorytypes "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/twapmodule" + twaptypes "github.com/osmosis-labs/osmosis/v13/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees" + txfeestypes "github.com/osmosis-labs/osmosis/v13/x/txfees/types" + valsetpreftypes "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" + valsetprefmodule "github.com/osmosis-labs/osmosis/v13/x/valset-pref/valpref-module" ) // moduleAccountPermissions defines module account permissions @@ -74,6 +78,7 @@ import ( var moduleAccountPermissions = map[string][]string{ authtypes.FeeCollectorName: nil, distrtypes.ModuleName: nil, + ibc_hooks.ModuleName: nil, icatypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter, authtypes.Burner}, minttypes.DeveloperVestingModuleAcctName: nil, @@ -90,6 +95,7 @@ var moduleAccountPermissions = map[string][]string{ txfeestypes.NonNativeFeeCollectorName: nil, wasm.ModuleName: {authtypes.Burner}, tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + valsetpreftypes.ModuleName: {authtypes.Staking}, } // appModules return modules to initialize module manager. @@ -124,7 +130,7 @@ func appModules( ibc.NewAppModule(app.IBCKeeper), ica.NewAppModule(nil, app.ICAHostKeeper), params.NewAppModule(*app.ParamsKeeper), - app.TransferModule, + app.RawIcs20TransferAppModule, gamm.NewAppModule(appCodec, *app.GAMMKeeper, app.AccountKeeper, app.BankKeeper), twapmodule.NewAppModule(*app.TwapKeeper), txfees.NewAppModule(*app.TxFeesKeeper), @@ -142,6 +148,8 @@ func appModules( app.EpochsKeeper, ), tokenfactory.NewAppModule(*app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper), + valsetprefmodule.NewAppModule(appCodec, *app.ValidatorSetPreferenceKeeper), + ibc_hooks.NewAppModule(app.AccountKeeper), } } @@ -211,12 +219,15 @@ func OrderInitGenesis(allModuleNames []string) []string { poolincentivestypes.ModuleName, superfluidtypes.ModuleName, tokenfactorytypes.ModuleName, + valsetpreftypes.ModuleName, incentivestypes.ModuleName, epochstypes.ModuleName, lockuptypes.ModuleName, authz.ModuleName, // wasm after ibc transfer wasm.ModuleName, + // ibc_hooks after auth keeper + ibc_hooks.ModuleName, } } diff --git a/app/tx_post_handler.go b/app/tx_post_handler.go new file mode 100644 index 00000000000..2141a3d8484 --- /dev/null +++ b/app/tx_post_handler.go @@ -0,0 +1,9 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func NewTxPostHandler() sdk.AnteHandler { + panic("not implemented") +} diff --git a/app/upgrades/types.go b/app/upgrades/types.go index ea2110d9543..a402ff2e4ee 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -7,7 +7,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" abci "github.com/tendermint/tendermint/abci/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/keepers" ) // BaseAppParamManager defines an interrace that BaseApp is expected to fullfil diff --git a/app/upgrades/v10/constants.go b/app/upgrades/v10/constants.go index 1a89765c0b5..b9aa85082af 100644 --- a/app/upgrades/v10/constants.go +++ b/app/upgrades/v10/constants.go @@ -1,7 +1,7 @@ package v10 import ( - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" ) // Last executed block on the v9 code was 4713064. diff --git a/app/upgrades/v10/fork.go b/app/upgrades/v10/fork.go index 048151da82d..18a1328cd99 100644 --- a/app/upgrades/v10/fork.go +++ b/app/upgrades/v10/fork.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/keepers" ) func RunForkLogic(ctx sdk.Context, appKeepers *keepers.AppKeepers) { diff --git a/app/upgrades/v10/upgrades_test.go b/app/upgrades/v10/upgrades_test.go index dec5f1d4da1..35006f4fd06 100644 --- a/app/upgrades/v10/upgrades_test.go +++ b/app/upgrades/v10/upgrades_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - v10 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v10" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + v10 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v10" ) type UpgradeTestSuite struct { diff --git a/app/upgrades/v11/constants.go b/app/upgrades/v11/constants.go index 14f92a1303e..7b9e82c9f76 100644 --- a/app/upgrades/v11/constants.go +++ b/app/upgrades/v11/constants.go @@ -3,7 +3,7 @@ package v11 import ( store "github.com/cosmos/cosmos-sdk/store/types" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" ) // UpgradeName defines the on-chain upgrade name for the Osmosis v11 upgrade. diff --git a/app/upgrades/v11/upgrades.go b/app/upgrades/v11/upgrades.go index 639dca70113..fe6e92decf8 100644 --- a/app/upgrades/v11/upgrades.go +++ b/app/upgrades/v11/upgrades.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" ) func CreateUpgradeHandler( diff --git a/app/upgrades/v12/constants.go b/app/upgrades/v12/constants.go index c6583ea3f84..b4ccda68728 100644 --- a/app/upgrades/v12/constants.go +++ b/app/upgrades/v12/constants.go @@ -1,8 +1,8 @@ package v12 import ( - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + twaptypes "github.com/osmosis-labs/osmosis/v13/x/twap/types" store "github.com/cosmos/cosmos-sdk/store/types" ) diff --git a/app/upgrades/v12/upgrade_test.go b/app/upgrades/v12/upgrade_test.go index 9cb3892f816..3fa609d62e5 100644 --- a/app/upgrades/v12/upgrade_test.go +++ b/app/upgrades/v12/upgrade_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" ) type UpgradeTestSuite struct { diff --git a/app/upgrades/v12/upgrades.go b/app/upgrades/v12/upgrades.go index 975013b919c..37679efe698 100644 --- a/app/upgrades/v12/upgrades.go +++ b/app/upgrades/v12/upgrades.go @@ -11,12 +11,12 @@ import ( icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + twaptypes "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) // We set the app version to pre-upgrade because it will be incremented by one diff --git a/app/upgrades/v13/constants.go b/app/upgrades/v13/constants.go index 7779df096f6..b3a2f3cc1e2 100644 --- a/app/upgrades/v13/constants.go +++ b/app/upgrades/v13/constants.go @@ -1,16 +1,19 @@ package v13 import ( - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - store "github.com/cosmos/cosmos-sdk/store/types" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + valsetpreftypes "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" ) -// UpgradeName defines the on-chain upgrade name for the Osmosis v9 upgrade. +// UpgradeName defines the on-chain upgrade name for the Osmosis v13 upgrade. const UpgradeName = "v13" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{}, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{valsetpreftypes.StoreKey}, + Deleted: []string{}, // double check bech32ibc + }, } diff --git a/app/upgrades/v13/rate_limiter.wasm b/app/upgrades/v13/rate_limiter.wasm new file mode 100644 index 00000000000..caaa0bd6975 Binary files /dev/null and b/app/upgrades/v13/rate_limiter.wasm differ diff --git a/app/upgrades/v13/upgrade_test.go b/app/upgrades/v13/upgrade_test.go new file mode 100644 index 00000000000..137566eb6e7 --- /dev/null +++ b/app/upgrades/v13/upgrade_test.go @@ -0,0 +1,103 @@ +package v13_test + +import ( + "fmt" + "testing" + + ibcratelimittypes "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" + + "github.com/cosmos/cosmos-sdk/store/prefix" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/stretchr/testify/suite" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + ibc_hooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks" +) + +type UpgradeTestSuite struct { + apptesting.KeeperTestHelper +} + +func (suite *UpgradeTestSuite) SetupTest() { + suite.Setup() +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +const dummyUpgradeHeight = 5 + +func dummyUpgrade(suite *UpgradeTestSuite) { + suite.Ctx = suite.Ctx.WithBlockHeight(dummyUpgradeHeight - 1) + plan := upgradetypes.Plan{Name: "v13", Height: dummyUpgradeHeight} + err := suite.App.UpgradeKeeper.ScheduleUpgrade(suite.Ctx, plan) + suite.Require().NoError(err) + plan, exists := suite.App.UpgradeKeeper.GetUpgradePlan(suite.Ctx) + suite.Require().True(exists) + + suite.Ctx = suite.Ctx.WithBlockHeight(dummyUpgradeHeight) + suite.Require().NotPanics(func() { + beginBlockRequest := abci.RequestBeginBlock{} + suite.App.BeginBlocker(suite.Ctx, beginBlockRequest) + }) +} + +func (suite *UpgradeTestSuite) TestUpgrade() { + testCases := []struct { + name string + pre_upgrade func() + upgrade func() + post_upgrade func() + }{ + { + "Test that the upgrade succeeds", + func() { + acc := suite.App.AccountKeeper.GetAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr) + suite.App.AccountKeeper.RemoveAccount(suite.Ctx, acc) + // Because of SDK version map bug, we can't do the following, and instaed do a massive hack + // vm := suite.App.UpgradeKeeper.GetModuleVersionMap(suite.Ctx) + // delete(vm, ibc_hooks.ModuleName) + // OR + // vm[ibc_hooks.ModuleName] = 0 + // suite.App.UpgradeKeeper.SetModuleVersionMap(suite.Ctx, vm) + upgradeStoreKey := suite.App.AppKeepers.GetKey(upgradetypes.StoreKey) + store := suite.Ctx.KVStore(upgradeStoreKey) + versionStore := prefix.NewStore(store, []byte{upgradetypes.VersionMapByte}) + versionStore.Delete([]byte(ibc_hooks.ModuleName)) + + hasAcc := suite.App.AccountKeeper.HasAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr) + suite.Require().False(hasAcc) + }, + func() { dummyUpgrade(suite) }, + func() { + hasAcc := suite.App.AccountKeeper.HasAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr) + suite.Require().True(hasAcc) + }, + }, + { + "Test that the contract address is set in the params", + func() {}, + func() { dummyUpgrade(suite) }, + func() { + // The contract has been uploaded and the param is set + paramSpace, ok := suite.App.ParamsKeeper.GetSubspace(ibcratelimittypes.ModuleName) + suite.Require().True(ok) + var contract string + paramSpace.GetIfExists(suite.Ctx, ibcratelimittypes.KeyContractAddress, &contract) + suite.Require().NotEmpty(contract) + }, + }, + } + + for _, tc := range testCases { + suite.Run(fmt.Sprintf("Case %s", tc.name), func() { + suite.SetupTest() // reset + + tc.pre_upgrade() + tc.upgrade() + tc.post_upgrade() + }) + } +} diff --git a/app/upgrades/v13/upgrades.go b/app/upgrades/v13/upgrades.go index a58bf8aabb4..8fe71a4c518 100644 --- a/app/upgrades/v13/upgrades.go +++ b/app/upgrades/v13/upgrades.go @@ -1,15 +1,69 @@ package v13 import ( + "embed" + "fmt" + + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + ibcratelimittypes "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) +//go:embed rate_limiter.wasm +var embedFs embed.FS + +func setupRateLimiting(ctx sdk.Context, keepers *keepers.AppKeepers) error { + govModule := keepers.AccountKeeper.GetModuleAddress(govtypes.ModuleName) + code, err := embedFs.ReadFile("rate_limiter.wasm") + if err != nil { + return err + } + contractKeeper := wasmkeeper.NewGovPermissionKeeper(keepers.WasmKeeper) + instantiateConfig := wasmtypes.AccessConfig{Permission: wasmtypes.AccessTypeOnlyAddress, Address: govModule.String()} + codeID, _, err := contractKeeper.Create(ctx, govModule, code, &instantiateConfig) + if err != nil { + return err + } + + transferModule := keepers.AccountKeeper.GetModuleAddress(transfertypes.ModuleName) + + initMsgBz := []byte(fmt.Sprintf(`{ + "gov_module": "%s", + "ibc_module":"%s", + "paths": [] + }`, + govModule, transferModule)) + + addr, _, err := contractKeeper.Instantiate(ctx, codeID, govModule, govModule, initMsgBz, "rate limiting contract", nil) + if err != nil { + return err + } + addrStr, err := sdk.Bech32ifyAddressBytes("osmo", addr) + if err != nil { + return err + } + params, err := ibcratelimittypes.NewParams(addrStr) + if err != nil { + return err + } + paramSpace, ok := keepers.ParamsKeeper.GetSubspace(ibcratelimittypes.ModuleName) + if !ok { + return sdkerrors.New("rate-limiting-upgrades", 2, "can't create paramspace") + } + paramSpace.SetParamSet(ctx, ¶ms) + return nil +} + func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, @@ -18,6 +72,9 @@ func CreateUpgradeHandler( ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { keepers.LockupKeeper.SetParams(ctx, lockuptypes.DefaultParams()) + if err := setupRateLimiting(ctx, keepers); err != nil { + return nil, err + } return mm.RunMigrations(ctx, configurator, fromVM) } } diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go index 089e00c5e34..cda3d988e5d 100644 --- a/app/upgrades/v3/constants.go +++ b/app/upgrades/v3/constants.go @@ -1,6 +1,6 @@ package v3 -import "github.com/osmosis-labs/osmosis/v12/app/upgrades" +import "github.com/osmosis-labs/osmosis/v13/app/upgrades" const ( // UpgradeName defines the on-chain upgrade name for the Osmosis v3 upgrade. diff --git a/app/upgrades/v3/forks.go b/app/upgrades/v3/forks.go index fb1b372dcb8..cdf602f1b62 100644 --- a/app/upgrades/v3/forks.go +++ b/app/upgrades/v3/forks.go @@ -5,7 +5,7 @@ import ( govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/osmosis-labs/osmosis/v12/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/keepers" ) // RunForkLogic executes height-gated on-chain fork logic for the Osmosis v3 diff --git a/app/upgrades/v4/constants.go b/app/upgrades/v4/constants.go index a2a086cbceb..31d9c6e1e0d 100644 --- a/app/upgrades/v4/constants.go +++ b/app/upgrades/v4/constants.go @@ -1,7 +1,7 @@ package v4 import ( - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" store "github.com/cosmos/cosmos-sdk/store/types" ) diff --git a/app/upgrades/v4/upgrade_test.go b/app/upgrades/v4/upgrade_test.go index 8f2e4ab4eac..78c925c4220 100644 --- a/app/upgrades/v4/upgrade_test.go +++ b/app/upgrades/v4/upgrade_test.go @@ -11,8 +11,8 @@ import ( abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/app" - v4 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v4" + "github.com/osmosis-labs/osmosis/v13/app" + v4 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v4" sdk "github.com/cosmos/cosmos-sdk/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go index 9f5ec691fe6..263e1cdd421 100644 --- a/app/upgrades/v4/upgrades.go +++ b/app/upgrades/v4/upgrades.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" ) // CreateUpgradeHandler returns an x/upgrade handler for the Osmosis v4 on-chain diff --git a/app/upgrades/v5/constants.go b/app/upgrades/v5/constants.go index 107f504935d..39f7c149358 100644 --- a/app/upgrades/v5/constants.go +++ b/app/upgrades/v5/constants.go @@ -1,7 +1,7 @@ package v5 import ( - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" store "github.com/cosmos/cosmos-sdk/store/types" ) diff --git a/app/upgrades/v5/upgrades.go b/app/upgrades/v5/upgrades.go index bb077f6b5f6..8fb22147740 100644 --- a/app/upgrades/v5/upgrades.go +++ b/app/upgrades/v5/upgrades.go @@ -10,9 +10,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + txfeestypes "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) func CreateUpgradeHandler( diff --git a/app/upgrades/v5/whitelist_feetokens.go b/app/upgrades/v5/whitelist_feetokens.go index e0a40202bbb..ae31f3fdc18 100644 --- a/app/upgrades/v5/whitelist_feetokens.go +++ b/app/upgrades/v5/whitelist_feetokens.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) // Every asset with a liquid osmo pairing pool on Osmosis, as of 12/01/21 diff --git a/app/upgrades/v6/constants.go b/app/upgrades/v6/constants.go index f36b6270667..44ef07ffde5 100644 --- a/app/upgrades/v6/constants.go +++ b/app/upgrades/v6/constants.go @@ -1,6 +1,6 @@ package v6 -import "github.com/osmosis-labs/osmosis/v12/app/upgrades" +import "github.com/osmosis-labs/osmosis/v13/app/upgrades" const ( // UpgradeName defines the on-chain upgrade name for the Osmosis v6 upgrade. diff --git a/app/upgrades/v6/forks.go b/app/upgrades/v6/forks.go index 5820eb36e70..59d35575bd9 100644 --- a/app/upgrades/v6/forks.go +++ b/app/upgrades/v6/forks.go @@ -3,7 +3,7 @@ package v6 import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/keepers" ) // RunForkLogic executes height-gated on-chain fork logic for the Osmosis v6 diff --git a/app/upgrades/v7/constants.go b/app/upgrades/v7/constants.go index dfa85ee3ccc..1761e2f756d 100644 --- a/app/upgrades/v7/constants.go +++ b/app/upgrades/v7/constants.go @@ -3,8 +3,8 @@ package v7 import ( "github.com/CosmWasm/wasmd/x/wasm" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" store "github.com/cosmos/cosmos-sdk/store/types" ) diff --git a/app/upgrades/v7/upgrades.go b/app/upgrades/v7/upgrades.go index 64af22d5653..39be82eeca0 100644 --- a/app/upgrades/v7/upgrades.go +++ b/app/upgrades/v7/upgrades.go @@ -7,10 +7,10 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - lockupkeeper "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + lockupkeeper "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func CreateUpgradeHandler( diff --git a/app/upgrades/v8/constants.go b/app/upgrades/v8/constants.go index 26ec5f92991..2c4e4e9d5f4 100644 --- a/app/upgrades/v8/constants.go +++ b/app/upgrades/v8/constants.go @@ -1,8 +1,8 @@ package v8 import ( - "github.com/osmosis-labs/osmosis/v12/app/upgrades" - v8constants "github.com/osmosis-labs/osmosis/v12/app/upgrades/v8/constants" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" + v8constants "github.com/osmosis-labs/osmosis/v13/app/upgrades/v8/constants" ) const ( diff --git a/app/upgrades/v8/forks.go b/app/upgrades/v8/forks.go index 0ecd17bc31c..e20ca7fca6c 100644 --- a/app/upgrades/v8/forks.go +++ b/app/upgrades/v8/forks.go @@ -3,7 +3,7 @@ package v8 import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/keepers" ) // RunForkLogic executes height-gated on-chain fork logic for the Osmosis v8 diff --git a/app/upgrades/v8/incentive_props.go b/app/upgrades/v8/incentive_props.go index 723fccf337f..56723236b9c 100644 --- a/app/upgrades/v8/incentive_props.go +++ b/app/upgrades/v8/incentive_props.go @@ -2,9 +2,9 @@ package v8 import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - poolincentiveskeeper "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/keeper" - poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + poolincentiveskeeper "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/keeper" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) // This file implements logic for accelerated incentive proposals. diff --git a/app/upgrades/v8/msg_filter_ante.go b/app/upgrades/v8/msg_filter_ante.go index 9ebc5ff5970..48b127742ad 100644 --- a/app/upgrades/v8/msg_filter_ante.go +++ b/app/upgrades/v8/msg_filter_ante.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) // MsgFilterDecorator defines an AnteHandler decorator for the v8 upgrade that diff --git a/app/upgrades/v8/msg_filter_ante_test.go b/app/upgrades/v8/msg_filter_ante_test.go index 5cfb616ece1..d3a33e71b0c 100644 --- a/app/upgrades/v8/msg_filter_ante_test.go +++ b/app/upgrades/v8/msg_filter_ante_test.go @@ -7,9 +7,9 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app" - v8 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v8" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/app" + v8 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v8" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func noOpAnteDecorator() sdk.AnteHandler { diff --git a/app/upgrades/v8/unpool_whitelist.go b/app/upgrades/v8/unpool_whitelist.go index a74c2f61047..13755cfeb8d 100644 --- a/app/upgrades/v8/unpool_whitelist.go +++ b/app/upgrades/v8/unpool_whitelist.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - superfluidkeeper "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + superfluidkeeper "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" ) const ustDenom = "ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC" diff --git a/app/upgrades/v9/constants.go b/app/upgrades/v9/constants.go index 9a7f993e4d7..922fb7936a4 100644 --- a/app/upgrades/v9/constants.go +++ b/app/upgrades/v9/constants.go @@ -1,13 +1,13 @@ package v9 import ( - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" store "github.com/cosmos/cosmos-sdk/store/types" icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" - tokenfactorytypes "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + tokenfactorytypes "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) // UpgradeName defines the on-chain upgrade name for the Osmosis v9 upgrade. diff --git a/app/upgrades/v9/msg_filter_ante_test.go b/app/upgrades/v9/msg_filter_ante_test.go index 4a9198dd975..531887f1cc1 100644 --- a/app/upgrades/v9/msg_filter_ante_test.go +++ b/app/upgrades/v9/msg_filter_ante_test.go @@ -9,9 +9,9 @@ import ( ibcchanneltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - "github.com/osmosis-labs/osmosis/v12/app" - v8 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v8" - v9 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v9" + "github.com/osmosis-labs/osmosis/v13/app" + v8 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v8" + v9 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v9" ) func noOpAnteDecorator() sdk.AnteHandler { diff --git a/app/upgrades/v9/prop214.go b/app/upgrades/v9/prop214.go index aee4de78f44..4f83272f975 100644 --- a/app/upgrades/v9/prop214.go +++ b/app/upgrades/v9/prop214.go @@ -3,8 +3,8 @@ package v9 import ( sdk "github.com/cosmos/cosmos-sdk/types" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" ) // Executes prop214, https://www.mintscan.io/osmosis/proposals/214 diff --git a/app/upgrades/v9/prop214_test.go b/app/upgrades/v9/prop214_test.go index e7d26a63d3c..db2a6bd8c34 100644 --- a/app/upgrades/v9/prop214_test.go +++ b/app/upgrades/v9/prop214_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - v9 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v9" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + v9 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v9" ) type UpgradeTestSuite struct { diff --git a/app/upgrades/v9/upgrades.go b/app/upgrades/v9/upgrades.go index aa896f3292b..6fe0dc15613 100644 --- a/app/upgrades/v9/upgrades.go +++ b/app/upgrades/v9/upgrades.go @@ -10,15 +10,15 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" - "github.com/osmosis-labs/osmosis/v12/app/keepers" - "github.com/osmosis-labs/osmosis/v12/app/upgrades" + "github.com/osmosis-labs/osmosis/v13/app/keepers" + "github.com/osmosis-labs/osmosis/v13/app/upgrades" ) const preUpgradeAppVersion = 8 diff --git a/chain.schema.json b/chain.schema.json index e9a399008ee..a0114f753f2 100644 --- a/chain.schema.json +++ b/chain.schema.json @@ -2,13 +2,15 @@ "$schema": "http://json-schema.org/draft-07/schema#", "codebase":{ "git_repo": "https://github.com/osmosis-labs/osmosis", - "recommended_version": "v12.2.0", + "recommended_version": "v12.3.0", "compatible_versions": [ - "v12.2.0" + "v12.3.0", + "v12.2.0", + "v12.2.1" ], "binaries": { - "linux/amd64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.2.0/osmosisd-12.2.0-linux-amd64?checksum=sha256:b4a0296b142b1a535f3116021d39660868a83fc66b290ab0891b06211f86fd31", - "linux/arm64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.2.0/osmosisd-12.2.0-linux-arm64?checksum=sha256:84717e741b61ef3616fef403aae42067614e58a0208347cd642f6d03240b7778" + "linux/amd64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.3.0/osmosisd-12.3.0-linux-amd64?checksum=sha256:958210c919d13c281896fa9773c323c5534f0fa46d74807154f737609a00db70", + "linux/arm64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.3.0/osmosisd-12.3.0-linux-arm64?checksum=sha256:a931618c8a839c30e5cecfd2a88055cda1d68cc68557fe3303fe14e2de3bef8f" }, "cosmos_sdk_version": "0.45", "tendermint_version": "0.34", @@ -61,7 +63,7 @@ }, { "name": "v12", - "tag" : "v12.1.0", + "tag" : "v12.3.0", "height" : 6246000 } ] diff --git a/cmd/osmosisd/cmd/balances_from_state_export.go b/cmd/osmosisd/cmd/balances_from_state_export.go index 431862fb864..f7d88039e43 100644 --- a/cmd/osmosisd/cmd/balances_from_state_export.go +++ b/cmd/osmosisd/cmd/balances_from_state_export.go @@ -12,10 +12,10 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" tmtypes "github.com/tendermint/tendermint/types" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" diff --git a/cmd/osmosisd/cmd/genesis.go b/cmd/osmosisd/cmd/genesis.go index fc445cc1c64..3ba3d0ad640 100644 --- a/cmd/osmosisd/cmd/genesis.go +++ b/cmd/osmosisd/cmd/genesis.go @@ -25,12 +25,12 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - appParams "github.com/osmosis-labs/osmosis/v12/app/params" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" - poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) // PrepareGenesisCmd returns prepare-genesis cobra Command. diff --git a/cmd/osmosisd/cmd/root.go b/cmd/osmosisd/cmd/root.go index 112894f7bae..de87e70bb5a 100644 --- a/cmd/osmosisd/cmd/root.go +++ b/cmd/osmosisd/cmd/root.go @@ -7,7 +7,7 @@ import ( "github.com/prometheus/client_golang/prometheus" - "github.com/osmosis-labs/osmosis/v12/app/params" + "github.com/osmosis-labs/osmosis/v13/app/params" "github.com/spf13/cast" "github.com/spf13/cobra" @@ -40,7 +40,7 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - osmosis "github.com/osmosis-labs/osmosis/v12/app" + osmosis "github.com/osmosis-labs/osmosis/v13/app" ) // NewRootCmd creates a new root command for simd. It is called once in the diff --git a/cmd/osmosisd/main.go b/cmd/osmosisd/main.go index d799287caaa..e0d0fb32c9d 100644 --- a/cmd/osmosisd/main.go +++ b/cmd/osmosisd/main.go @@ -5,9 +5,9 @@ import ( svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - osmosis "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/app/params" - "github.com/osmosis-labs/osmosis/v12/cmd/osmosisd/cmd" + osmosis "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/cmd/osmosisd/cmd" ) func main() { diff --git a/cmd/querygen/main.go b/cmd/querygen/main.go index 66070ad7314..7724427427f 100644 --- a/cmd/querygen/main.go +++ b/cmd/querygen/main.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" - "github.com/osmosis-labs/osmosis/v12/cmd/querygen/templates" + "github.com/osmosis-labs/osmosis/v13/cmd/querygen/templates" ) var grpcTemplate template.Template diff --git a/cmd/querygen/templates/queryyml.go b/cmd/querygen/templates/queryyml.go index 410cb88c962..536c9c56b2d 100644 --- a/cmd/querygen/templates/queryyml.go +++ b/cmd/querygen/templates/queryyml.go @@ -10,7 +10,7 @@ import ( type QueryYml struct { // Keeper struct descriptor Keeper Keeper `yaml:"keeper"` - // Path to client folder e.g. "github.com/osmosis-labs/osmosis/v12/x/twap/client" + // Path to client folder e.g. "github.com/osmosis-labs/osmosis/v13/x/twap/client" ClientPath string `yaml:"client_path"` // list of all queries, key is the query name, e.g. `GetArithmeticTwap` Queries map[string]YmlQueryDescriptor `yaml:"queries"` @@ -19,7 +19,7 @@ type QueryYml struct { } type Keeper struct { - // e.g. github.com/osmosis-labs/osmosis/v12/x/twap + // e.g. github.com/osmosis-labs/osmosis/v13/x/twap Path string `yaml:"path"` // e.g. Keeper Struct string `yaml:"struct"` diff --git a/cmd/querygen/templates/queryyml_test.go b/cmd/querygen/templates/queryyml_test.go index 1463794955d..e150ae9a831 100644 --- a/cmd/querygen/templates/queryyml_test.go +++ b/cmd/querygen/templates/queryyml_test.go @@ -11,7 +11,7 @@ func TestParseFilePathFromImportPath(t *testing.T) { importPath string expectedFilePath string }{ - "standard": {importPath: "github.com/osmosis-labs/osmosis/v12/x/twap", expectedFilePath: "x/twap"}, + "standard": {importPath: "github.com/osmosis-labs/osmosis/v13/x/twap", expectedFilePath: "x/twap"}, } for name, test := range tests { t.Run(name, func(t *testing.T) { diff --git a/go.mod b/go.mod index 4ba4834b8a6..e74d905f772 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ -module github.com/osmosis-labs/osmosis/v12 +module github.com/osmosis-labs/osmosis/v13 go 1.18 require ( github.com/CosmWasm/wasmd v0.28.0-osmo-v12 github.com/cosmos/cosmos-proto v1.0.0-alpha8 - github.com/cosmos/cosmos-sdk v0.46.1 + github.com/cosmos/cosmos-sdk v0.46.6 github.com/cosmos/go-bip39 v1.0.0 - github.com/cosmos/iavl v0.19.1 - github.com/cosmos/ibc-go/v3 v3.3.0 + github.com/cosmos/iavl v0.19.4 + github.com/cosmos/ibc-go/v3 v3.4.0 github.com/gogo/protobuf v1.3.3 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.2 @@ -23,14 +23,14 @@ require ( github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.13.0 + github.com/spf13/viper v1.14.0 github.com/stretchr/testify v1.8.1 - github.com/tendermint/tendermint v0.34.22 + github.com/tendermint/tendermint v0.34.24 github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b go.uber.org/multierr v1.8.0 golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e - google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b - google.golang.org/grpc v1.50.0 + google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e + google.golang.org/grpc v1.50.1 gopkg.in/yaml.v2 v2.4.0 mvdan.cc/gofumpt v0.4.0 ) @@ -39,10 +39,11 @@ require ( github.com/Abirdcfly/dupword v0.0.7 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect github.com/alingse/asasalint v0.0.11 // indirect + github.com/cosmos/gogoproto v1.4.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect - github.com/google/btree v1.0.0 // indirect + github.com/google/btree v1.1.2 // indirect github.com/kkHAIKE/contextcheck v1.1.3 // indirect github.com/maratori/testableexamples v1.0.0 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect @@ -52,7 +53,7 @@ require ( github.com/timonwong/loggercheck v0.9.3 // indirect github.com/zimmski/go-mutesting v0.0.0-20210610104036-6d9217011a00 // indirect go.uber.org/atomic v1.10.0 // indirect - go.uber.org/zap v1.22.0 // indirect + go.uber.org/zap v1.23.0 // indirect ) require ( @@ -65,10 +66,10 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/BurntSushi/toml v1.2.1 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/CosmWasm/wasmvm v1.0.0 + github.com/CosmWasm/wasmvm v1.1.1 github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 // indirect github.com/Masterminds/semver v1.5.0 // indirect - github.com/Microsoft/go-winio v0.5.2 // indirect + github.com/Microsoft/go-winio v0.6.0 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect github.com/OpenPeeDeeP/depguard v1.1.1 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect @@ -105,9 +106,9 @@ require ( github.com/dgraph-io/badger/v3 v3.2103.2 // indirect github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/docker/cli v20.10.17+incompatible // indirect - github.com/docker/docker v20.10.17+incompatible // indirect + github.com/docker/docker v20.10.19+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect - github.com/docker/go-units v0.4.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/esimonov/ifshort v1.0.4 // indirect @@ -115,7 +116,7 @@ require ( github.com/fatih/color v1.13.0 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/firefart/nonamedreturns v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -135,7 +136,7 @@ require ( github.com/gogo/gateway v1.1.0 // indirect github.com/golang/glog v1.0.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/snappy v0.0.3 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect @@ -180,7 +181,7 @@ require ( github.com/julz/importas v0.1.0 // indirect github.com/kisielk/errcheck v1.6.2 // indirect github.com/kisielk/gotool v1.0.0 // indirect - github.com/klauspost/compress v1.15.9 // indirect + github.com/klauspost/compress v1.15.11 // indirect github.com/kulti/thelper v0.6.3 // indirect github.com/kunwardeep/paralleltest v1.0.6 // indirect github.com/kyoh86/exportloopref v0.1.8 // indirect @@ -212,7 +213,7 @@ require ( github.com/nishanths/predeclared v0.2.2 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect + github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.3 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect @@ -220,8 +221,8 @@ require ( github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polyfloyd/go-errorlint v1.0.5 // indirect - github.com/prometheus/client_golang v1.13.0 - github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/client_golang v1.14.0 + github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect github.com/quasilyte/go-ruleguard v0.3.18 // indirect @@ -243,13 +244,13 @@ require ( github.com/sivchari/tenv v1.7.0 // indirect github.com/sonatard/noctx v0.0.1 // indirect github.com/sourcegraph/go-diff v0.6.1 // indirect - github.com/spf13/afero v1.8.2 // indirect + github.com/spf13/afero v1.9.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tdakkota/asciicheck v0.1.1 // indirect github.com/tendermint/btcd v0.1.1 // indirect github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect @@ -276,12 +277,12 @@ require ( golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect golang.org/x/mod v0.6.0 // indirect golang.org/x/net v0.1.0 // indirect - golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect + golang.org/x/sync v0.1.0 // indirect golang.org/x/sys v0.1.0 // indirect golang.org/x/term v0.1.0 // indirect golang.org/x/text v0.4.0 // indirect golang.org/x/tools v0.2.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 @@ -293,12 +294,10 @@ require ( ) replace ( - // branch: v0.28.0x-osmo-v12, current tag: v0.28.0-osmo-v12.1 - github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.28.0-osmo-v12.1 - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: osmosis-main. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/2e4ae2f7619a - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221004142537-2e4ae2f7619a - // Use Osmosis fast iavl - github.com/cosmos/iavl => github.com/osmosis-labs/iavl v0.17.3-osmo-v7 + github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.29.2-osmo-v13 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v13.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/8757a61551aa1ea993c85a523e18094ab555b1d7 + // tag: https://github.com/osmosis-labs/cosmos-sdk/releases/tag/sdk-v13.0.0-rc2 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e // use cosmos-compatible protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 // use grpc compatible with cosmos protobufs diff --git a/go.sum b/go.sum index 47644893d17..a0066f8f8e7 100644 --- a/go.sum +++ b/go.sum @@ -26,7 +26,6 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -53,7 +52,6 @@ github.com/Antonboom/nilnil v0.1.1/go.mod h1:L1jBqoWM7AOeTD+tSquifKSesRHs4ZdaxvZ github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= @@ -72,8 +70,8 @@ github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= -github.com/CosmWasm/wasmvm v1.0.0 h1:NRmnHe3xXsKn2uEcB1F5Ha323JVAhON+BI6L177dlKc= -github.com/CosmWasm/wasmvm v1.0.0/go.mod h1:ei0xpvomwSdONsxDuONzV7bL1jSET1M8brEx0FCXc+A= +github.com/CosmWasm/wasmvm v1.1.1 h1:0xtdrmmsP9fibe+x42WcMkp5aQ738BICgcH3FNVLzm4= +github.com/CosmWasm/wasmvm v1.1.1/go.mod h1:ei0xpvomwSdONsxDuONzV7bL1jSET1M8brEx0FCXc+A= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= @@ -84,10 +82,8 @@ github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0/go.mod h1:b3g59n2Y+T5xmc github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= @@ -100,11 +96,9 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrU github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM= -github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -144,8 +138,6 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bkielbasa/cyclop v1.2.0 h1:7Jmnh0yL2DjKfw28p86YTd/B4lRGcNuu12sKE35sM7A= github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M= @@ -196,12 +188,10 @@ github.com/charithe/durationcheck v0.0.9 h1:mPP4ucLrf/rKZiIG/a9IPXHGlh8p4CzgpyTy github.com/charithe/durationcheck v0.0.9/go.mod h1:SSbRIBVfMjCi/kEB6K65XEA83D6prSM8ap1UCpNKtgg= github.com/chavacava/garif v0.0.0-20220630083739-93517212f375 h1:E7LT642ysztPWE0dfz43cWOvMiF42DyTRC+eZIaO4yI= github.com/chavacava/garif v0.0.0-20220630083739-93517212f375/go.mod h1:4m1Rv7xfuwWPNKXlThldNuJvutYM6J95wNuuVmn55To= -github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= @@ -212,26 +202,18 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= -github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= -github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= github.com/cosmos/cosmos-proto v1.0.0-alpha8 h1:d3pCRuMYYvGA5bM0ZbbjKn+AoQD4A7dyNG2wzwWalUw= @@ -239,10 +221,14 @@ github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31e github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= +github.com/cosmos/gogoproto v1.4.2 h1:UeGRcmFW41l0G0MiefWhkPEVEwvu78SZsHBvI78dAYw= +github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= -github.com/cosmos/ibc-go/v3 v3.3.0 h1:r8gYUvQreMQrf4R5RgedK9gcbjLk4uE2q6fuZGjf4n0= -github.com/cosmos/ibc-go/v3 v3.3.0/go.mod h1:VUWLHw0C3USmTQZnTdkuXXdUdLbW8zsK3lV1Ieposog= +github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok= +github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= +github.com/cosmos/ibc-go/v3 v3.4.0 h1:ha3cqEG36pqMWqA1D+kxDWBTZXpeFMd/aZIQF7I0xro= +github.com/cosmos/ibc-go/v3 v3.4.0/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= github.com/cosmos/interchain-accounts v0.1.0 h1:QmuwNsf1Hxl3P5GSGt7Z+JeuHPiZw4Z34R/038P5T6s= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= @@ -251,7 +237,6 @@ github.com/cosmos/ledger-go v0.9.3 h1:WGyZK4ikuLIkbxJm3lEr1tdQYDdTdveTwoVla7hqfh github.com/cosmos/ledger-go v0.9.3/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM= github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= @@ -262,7 +247,6 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ github.com/cristalhq/acmd v0.8.1/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ= github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= -github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/daixiang0/gci v0.8.1 h1:T4xpSC+hmsi4CSyuYfIJdMZAr9o7xZmHpQVygMghGZ4= github.com/daixiang0/gci v0.8.1/go.mod h1:EpVfrztufwVgQRXjnX4zuNinEpLj5OmMjtu/+MB0V0c= @@ -294,12 +278,13 @@ github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55k github.com/docker/cli v20.10.17+incompatible h1:eO2KS7ZFeov5UJeaDmIs1NFEDRf32PaqRpvoEkKBy5M= github.com/docker/cli v20.10.17+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE= -github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v20.10.19+incompatible h1:lzEmjivyNHFHMNAFLXORMBXyGIhw/UP4DvJwvyKYq64= +github.com/docker/docker v20.10.19+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -320,11 +305,8 @@ github.com/esimonov/ifshort v1.0.4/go.mod h1:Pe8zjlRrJ80+q2CxHLfEOfTwxCZ4O+MuhcH github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM= github.com/ettle/strcase v0.1.1 h1:htFueZyVeE1XNnMEfbqp5r67qAN/4r6ya1ysq8Q+Zcw= github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= -github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= -github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -339,15 +321,14 @@ github.com/firefart/nonamedreturns v1.0.4 h1:abzI1p7mAEPYuR4A+VLKn4eNDOycjYo2phm github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= @@ -427,7 +408,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -462,8 +442,9 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 h1:23T5iq8rbUYlhpt5DB4XJkc6BU31uODLD1o1gKvZmD0= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9uMCefW1WDie15eSP/4MssdenaM= @@ -485,8 +466,9 @@ github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6/go.mod h1:0AKcRCk github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 h1:zwtduBRr5SSWhqsYNgcuWO2kFlpdOZbP0+yRjmvPGys= github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -545,7 +527,6 @@ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= @@ -563,16 +544,13 @@ github.com/gostaticanalysis/nilerr v0.1.1 h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3 github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoISdUv3PPQgHY= -github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -583,9 +561,7 @@ github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= @@ -689,8 +665,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= +github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -719,10 +695,8 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/leonklingele/grouper v1.1.0 h1:tC2y/ygPbMFSBOs3DcyaEMKnnwH7eYKzohOtRrf0SAg= github.com/leonklingele/grouper v1.1.0/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -731,7 +705,6 @@ github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG github.com/lufeee/execinquery v1.2.1 h1:hf0Ems4SHcUGBxpGN7Jz78z1ppVkP/837ZlETPCEtOM= github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI= @@ -779,7 +752,6 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -794,7 +766,6 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= @@ -848,8 +819,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -857,18 +828,13 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 h1:rc3tiVYb5z54aKaDfakKn0dDjIyPpTtszkjuMzyt7ec= -github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= +github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= @@ -879,17 +845,14 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= -github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/ory/dockertest/v3 v3.9.1 h1:v4dkG+dlu76goxMiTT2j8zV7s4oPPEppKT8K8p2f1kY= github.com/ory/dockertest/v3 v3.9.1/go.mod h1:42Ir9hmvaAPm0Mgibk6mBPi7SFvTXxEcnztDYOJ//uM= -github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221004142537-2e4ae2f7619a h1:g6jdMY5wRMjsAW6nvFWM0Gg8gVJhyno1AuZLVpmHmss= -github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221004142537-2e4ae2f7619a/go.mod h1:HbTqN2YeBd0fpofiJQRNzhyEJS8ibUW/I44o3B/NsZQ= +github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e h1:A3byMZpvq21iI7yWJUNdHw0nf8jVAbVUsWY9twnXSXE= +github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e/go.mod h1:rud0OaBIuq3+qOqtwT4SR7Q7iSzRp7w41fjninTjfnQ= github.com/osmosis-labs/go-mutesting v0.0.0-20220811235203-65a53b4ea8e3 h1:/imbKy8s1I+z7wx4FbRHOXK2v82xesUCz2EPUqfBDIg= github.com/osmosis-labs/go-mutesting v0.0.0-20220811235203-65a53b4ea8e3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI= -github.com/osmosis-labs/iavl v0.17.3-osmo-v7 h1:6KcADC/WhL7yDmNQxUIJt2XmzNt4FfRmq9gRke45w74= -github.com/osmosis-labs/iavl v0.17.3-osmo-v7/go.mod h1:lJEOIlsd3sVO0JDyXWIXa9/Ur5FBscP26zJx0KxHjto= -github.com/osmosis-labs/wasmd v0.28.0-osmo-v12.1 h1:CZJSa65banZjQNyDhp+nGPr9MRYrIfOU/aO3ww2V1Rg= -github.com/osmosis-labs/wasmd v0.28.0-osmo-v12.1/go.mod h1:7YWBfoD6zPuu6pmqnq/kMNpc+xqOaxEtolJ5/7xHzB8= +github.com/osmosis-labs/wasmd v0.29.2-osmo-v13 h1:HvxAks1ctB3nBx1cXqcmfA0g0BKe7Og77OA2j2rxaJk= +github.com/osmosis-labs/wasmd v0.29.2-osmo-v13/go.mod h1:UlLBU5vuHncwQUM9W8lw+2mEptEMFxxfVWupZ6sXtn4= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= @@ -930,31 +893,28 @@ github.com/polyfloyd/go-errorlint v1.0.5/go.mod h1:APVvOesVSAnne5SClsPxPdfvZTVDo github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= -github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= +github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= @@ -962,18 +922,15 @@ github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8 github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= github.com/quasilyte/go-ruleguard v0.3.18 h1:sd+abO1PEI9fkYennwzHn9kl3nqP6M5vE7FiOzZ+5CE= github.com/quasilyte/go-ruleguard v0.3.18/go.mod h1:lOIzcYlgxrQ2sGJ735EHXmf/e9MJ516j16K/Ifcttvs= @@ -990,7 +947,6 @@ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8 github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= @@ -1024,7 +980,6 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sanposhiho/wastedassign/v2 v2.0.6 h1:+6/hQIHKNJAUixEj6EmOngGIisyeI+T3335lYTyxRoA= github.com/sanposhiho/wastedassign/v2 v2.0.6/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= -github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= @@ -1032,7 +987,6 @@ github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84d github.com/sashamelentyev/usestdlibvars v1.20.0 h1:K6CXjqqtSYSsuyRDDC7Sjn6vTMLiSJa4ZmDkiokoqtw= github.com/sashamelentyev/usestdlibvars v1.20.0/go.mod h1:0GaP+ecfZMXShS0A94CJn6aEuPRILv8h/VuWI9n1ygg= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/securego/gosec/v2 v2.13.1 h1:7mU32qn2dyC81MH9L2kefnQyRMUarfDER3iQyMHcjYM= github.com/securego/gosec/v2 v2.13.1/go.mod h1:EO1sImBMBWFjOTFzMWfTRrZW6M15gm60ljzrmy/wtHo= @@ -1044,7 +998,6 @@ github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxr github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -1059,7 +1012,6 @@ github.com/sivchari/tenv v1.7.0 h1:d4laZMBK6jpe5PWepxlV9S+LC0yXqvYHiq8E6ceoVVE= github.com/sivchari/tenv v1.7.0/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sonatard/noctx v0.0.1 h1:VC1Qhl6Oxx9vvWo3UDgrGXYCeKCe3Wbw7qAWL6FrmTY= github.com/sonatard/noctx v0.0.1/go.mod h1:9D2D/EoULe8Yy2joDHJj7bv3sZoq9AaSb8B4lqBjiZI= @@ -1070,14 +1022,13 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= -github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= +github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= +github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -1088,10 +1039,8 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU= -github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw= +github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= +github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0= github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= @@ -1118,25 +1067,22 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tdakkota/asciicheck v0.1.1 h1:PKzG7JUTUmVspQTDqtkX9eSiLGossXTybutHwTXuO0A= github.com/tdakkota/asciicheck v0.1.1/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0= -github.com/tendermint/tendermint v0.34.22 h1:XMhtC8s8QqJO4l/dn+TkQvevTRSow3Vixjclr41o+2Q= -github.com/tendermint/tendermint v0.34.22/go.mod h1:YpP5vBEAKUT4g6oyfjKgFeZmdB/GjkJAxfF+cgmJg6Y= -github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= +github.com/tendermint/tendermint v0.34.24 h1:879MKKJWYYPJEMMKME+DWUTY4V9f/FBpnZDI82ky+4k= +github.com/tendermint/tendermint v0.34.24/go.mod h1:rXVrl4OYzmIa1I91av3iLv2HS0fGSiucyW9J4aMTpKI= github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b h1:Y3ZPG6gdDCAV2sdGkD759ji/09GzaNu1X3qKTmZIbTo= github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b/go.mod h1:ADqbS9NOSnBRK9R2RtYC61CdsHmVMD/yXAzcMuPexbU= github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= @@ -1155,7 +1101,6 @@ github.com/timonwong/loggercheck v0.9.3 h1:ecACo9fNiHxX4/Bc02rW2+kaJIAMAes7qJ7JK github.com/timonwong/loggercheck v0.9.3/go.mod h1:wUqnk9yAOIKtGA39l1KLE9Iz0QiTocu/YZoOf+OzFdw= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tomarrell/wrapcheck/v2 v2.7.0 h1:J/F8DbSKJC83bAvC6FoZaRjZiZ/iKoueSdrEkmGeacA= github.com/tomarrell/wrapcheck/v2 v2.7.0/go.mod h1:ao7l5p0aOlUNJKI0qVwB4Yjlqutd0IvAB9Rdwyilxvg= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= @@ -1213,9 +1158,7 @@ github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= gitlab.com/bosi/decorder v0.2.3 h1:gX4/RgK16ijY8V+BRQHAySfQAb354T7/xQpDB2n10P0= gitlab.com/bosi/decorder v0.2.3/go.mod h1:9K1RB5+VPNQYtXtTDAzd2OEftsZb1oV0IrJrzChSdGE= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= @@ -1243,8 +1186,8 @@ go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95a go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.22.0 h1:Zcye5DUgBloQ9BaT4qc9BnjOFog5TvBSAGkJ3Nf70c0= -go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U= +go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= +go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1262,7 +1205,6 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -1297,7 +1239,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mobile v0.0.0-20200801112145-973feb4309de/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= @@ -1337,7 +1278,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1365,7 +1305,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -1395,8 +1334,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1419,7 +1358,6 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1453,7 +1391,6 @@ golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1463,7 +1400,6 @@ golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1471,7 +1407,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1480,15 +1415,14 @@ golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= @@ -1499,7 +1433,6 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= @@ -1536,7 +1469,6 @@ golang.org/x/tools v0.0.0-20191018212557-ed542cd5b28a/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1673,9 +1605,8 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b h1:SfSkJugek6xm7lWywqth4r2iTrYLpD8lOj1nMIIhMNM= -google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= +google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e h1:S9GbmC1iCgvbLyAokVCwiO6tVIrU9Y7c5oMx1V/ki/Y= +google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -1691,8 +1622,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= +google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1705,7 +1636,6 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= diff --git a/networks/osmosis-1/upgrades/v13/mainnet/guide.md b/networks/osmosis-1/upgrades/v13/mainnet/guide.md new file mode 100644 index 00000000000..547cd22010b --- /dev/null +++ b/networks/osmosis-1/upgrades/v13/mainnet/guide.md @@ -0,0 +1,127 @@ +# v12 to v13 Mainnet Upgrade Guide + +Osmosis v13 Gov Prop: TODO: Update prop link + +Countdown: TODO: Update upgrade height + +Height: 6246000 TODO: Update upgrade height + +## Memory Requirements + +This upgrade will **not** be resource intensive. With that being said, we still recommend having 64GB of memory. If having 64GB of physical memory is not possible, the next best thing is to set up swap. + +Short version swap setup instructions: + +``` {.sh} +sudo swapoff -a +sudo fallocate -l 32G /swapfile +sudo chmod 600 /swapfile +sudo mkswap /swapfile +sudo swapon /swapfile +``` + +To persist swap after restart: + +``` {.sh} +sudo cp /etc/fstab /etc/fstab.bak +echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab +``` + +In depth swap setup instructions: + + +## First Time Cosmovisor Setup + +If you have never setup Cosmovisor before, follow the following instructions. + +If you have already setup Cosmovisor, skip to the next section. + +We highly recommend validators use cosmovisor to run their nodes. This +will make low-downtime upgrades smoother, as validators don't have to +manually upgrade binaries during the upgrade, and instead can +pre-install new binaries, and cosmovisor will automatically update them +based on on-chain SoftwareUpgrade proposals. + +You should review the docs for cosmovisor located here: + + +If you choose to use cosmovisor, please continue with these +instructions: + +To install Cosmovisor: + +``` {.sh} +go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0 +``` + +After this, you must make the necessary folders for cosmosvisor in your +daemon home directory (\~/.osmosisd). + +``` {.sh} +mkdir -p ~/.osmosisd +mkdir -p ~/.osmosisd/cosmovisor +mkdir -p ~/.osmosisd/cosmovisor/genesis +mkdir -p ~/.osmosisd/cosmovisor/genesis/bin +mkdir -p ~/.osmosisd/cosmovisor/upgrades +``` + +Copy the current v11 osmosisd binary into the +cosmovisor/genesis folder and v12 folder. + +```{.sh} +cp $GOPATH/bin/osmosisd ~/.osmosisd/cosmovisor/genesis/bin +mkdir -p ~/.osmosisd/cosmovisor/upgrades/v12/bin +cp $GOPATH/bin/osmosisd ~/.osmosisd/cosmovisor/upgrades/v12/bin +``` + +Cosmovisor is now ready to be set up for v13. + +Set these environment variables: + +```{.sh} +echo "# Setup Cosmovisor" >> ~/.profile +echo "export DAEMON_NAME=osmosisd" >> ~/.profile +echo "export DAEMON_HOME=$HOME/.osmosisd" >> ~/.profile +echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=false" >> ~/.profile +echo "export DAEMON_LOG_BUFFER_SIZE=512" >> ~/.profile +echo "export DAEMON_RESTART_AFTER_UPGRADE=true" >> ~/.profile +echo "export UNSAFE_SKIP_BACKUP=true" >> ~/.profile +source ~/.profile +``` + +## Cosmovisor Upgrade + +Create the v13 folder, make the build, and copy the daemon over to that folder + +```{.sh} +mkdir -p ~/.osmosisd/cosmovisor/upgrades/v13/bin +cd $HOME/osmosis +git pull +git checkout v13.0.0 +make build +cp build/osmosisd ~/.osmosisd/cosmovisor/upgrades/v13/bin +``` + +Now, at the upgrade height, Cosmovisor will upgrade to the v13 binary + +## Manual Option + +1. Wait for Osmosis to reach the upgrade height (FILL ME IN WITH UPGRADE HEIGHT) TODO: Update upgrade height + +2. Look for a panic message, followed by endless peer logs. Stop the daemon + +3. Run the following commands: + +```{.sh} +cd $HOME/osmosis +git pull +git checkout v13.0.0 +make install +``` + +4. Start the osmosis daemon again, watch the upgrade happen, and then continue to hit blocks + +## Further Help + +If you need more help, please go to or join +our discord at . diff --git a/networks/osmosis-1/upgrades/v13/testnet/guide.md b/networks/osmosis-1/upgrades/v13/testnet/guide.md new file mode 100644 index 00000000000..a1ee7bcd92d --- /dev/null +++ b/networks/osmosis-1/upgrades/v13/testnet/guide.md @@ -0,0 +1,125 @@ +# v12 to v13 Testnet Upgrade Guide + +Countdown: + +Height: 7759340 + +## Memory Requirements + +This upgrade will **not** be resource intensive. With that being said, we still recommend having 64GB of memory. If having 64GB of physical memory is not possible, the next best thing is to set up swap. + +Short version swap setup instructions: + +``` {.sh} +sudo swapoff -a +sudo fallocate -l 32G /swapfile +sudo chmod 600 /swapfile +sudo mkswap /swapfile +sudo swapon /swapfile +``` + +To persist swap after restart: + +``` {.sh} +sudo cp /etc/fstab /etc/fstab.bak +echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab +``` + +In depth swap setup instructions: + + +## First Time Cosmovisor Setup + +If you have never setup Cosmovisor before, follow the following instructions. + +If you have already setup Cosmovisor, skip to the next section. + +We highly recommend validators use cosmovisor to run their nodes. This +will make low-downtime upgrades smoother, as validators don't have to +manually upgrade binaries during the upgrade, and instead can +pre-install new binaries, and cosmovisor will automatically update them +based on on-chain SoftwareUpgrade proposals. + +You should review the docs for cosmovisor located here: + + +If you choose to use cosmovisor, please continue with these +instructions: + +To install Cosmovisor: + +``` {.sh} +go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0 +``` + +After this, you must make the necessary folders for cosmosvisor in your +daemon home directory (\~/.osmosisd). + +``` {.sh} +mkdir -p ~/.osmosisd +mkdir -p ~/.osmosisd/cosmovisor +mkdir -p ~/.osmosisd/cosmovisor/genesis +mkdir -p ~/.osmosisd/cosmovisor/genesis/bin +mkdir -p ~/.osmosisd/cosmovisor/upgrades +``` + +Copy the current v12 osmosisd binary into the +cosmovisor/genesis folder and v12 folder. + +```{.sh} +cp $GOPATH/bin/osmosisd ~/.osmosisd/cosmovisor/genesis/bin +mkdir -p ~/.osmosisd/cosmovisor/upgrades/v12/bin +cp $GOPATH/bin/osmosisd ~/.osmosisd/cosmovisor/upgrades/v12/bin +``` + +Cosmovisor is now ready to be set up for v13. + +Set these environment variables: + +```{.sh} +echo "# Setup Cosmovisor" >> ~/.profile +echo "export DAEMON_NAME=osmosisd" >> ~/.profile +echo "export DAEMON_HOME=$HOME/.osmosisd" >> ~/.profile +echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=false" >> ~/.profile +echo "export DAEMON_LOG_BUFFER_SIZE=512" >> ~/.profile +echo "export DAEMON_RESTART_AFTER_UPGRADE=true" >> ~/.profile +echo "export UNSAFE_SKIP_BACKUP=true" >> ~/.profile +source ~/.profile +``` + +## Cosmovisor Upgrade + +Create the v13 folder, make the build, and copy the daemon over to that folder + +```{.sh} +mkdir -p ~/.osmosisd/cosmovisor/upgrades/v13/bin +cd $HOME/osmosis +git pull +git checkout v13.0.0-rc3 +make build +cp build/osmosisd ~/.osmosisd/cosmovisor/upgrades/v13/bin +``` + +Now, at the upgrade height, Cosmovisor will upgrade to the v13 binary + +## Manual Option + +1. Wait for Osmosis to reach the upgrade height (7759340) + +2. Look for a panic message, followed by endless peer logs. Stop the daemon + +3. Run the following commands: + +```{.sh} +cd $HOME/osmosis +git pull +git checkout v13.0.0-rc3 +make install +``` + +4. Start the osmosis daemon again, watch the upgrade happen, and then continue to hit blocks + +## Further Help + +If you need more help, please go to or join +our discord at . diff --git a/networks/osmosis-1/upgrades/v13/v13_binaries.json b/networks/osmosis-1/upgrades/v13/v13_binaries.json new file mode 100644 index 00000000000..190a8b00299 --- /dev/null +++ b/networks/osmosis-1/upgrades/v13/v13_binaries.json @@ -0,0 +1,6 @@ +{ + "binaries": { + "linux/amd64": "", + "linux/arm64": "" + } +} diff --git a/osmomath/decimal.go b/osmomath/decimal.go index 2bb9e0134c0..821b0f5b4e1 100644 --- a/osmomath/decimal.go +++ b/osmomath/decimal.go @@ -317,6 +317,19 @@ func (d BigDec) Quo(d2 BigDec) BigDec { return BigDec{chopped} } +func (d BigDec) QuoRaw(d2 int64) BigDec { + // multiply precision, so we can chop it later + mul := new(big.Int).Mul(d.i, precisionReuse) + + quo := mul.Quo(mul, big.NewInt(d2)) + chopped := chopPrecisionAndRound(quo) + + if chopped.BitLen() > maxDecBitLen { + panic("Int overflow") + } + return BigDec{chopped} +} + // quotient truncate func (d BigDec) QuoTruncate(d2 BigDec) BigDec { // multiply precision twice diff --git a/osmomath/decimal_test.go b/osmomath/decimal_test.go index 11732ac29e6..b50e9150b6d 100644 --- a/osmomath/decimal_test.go +++ b/osmomath/decimal_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/suite" "gopkg.in/yaml.v2" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" ) type decimalTestSuite struct { diff --git a/osmomath/math_test.go b/osmomath/math_test.go index eb264b3c284..a50cc457485 100644 --- a/osmomath/math_test.go +++ b/osmomath/math_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" "github.com/stretchr/testify/require" ) diff --git a/osmomath/rounding_direction.go b/osmomath/rounding_direction.go index adef0e4e5e0..2685f684a16 100644 --- a/osmomath/rounding_direction.go +++ b/osmomath/rounding_direction.go @@ -10,9 +10,10 @@ import ( type RoundingDirection int const ( - RoundUp RoundingDirection = 1 - RoundDown RoundingDirection = 2 - RoundBankers RoundingDirection = 3 + RoundUnconstrained RoundingDirection = 0 + RoundUp RoundingDirection = 1 + RoundDown RoundingDirection = 2 + RoundBankers RoundingDirection = 3 ) func DivIntByU64ToBigDec(i sdk.Int, u uint64, round RoundingDirection) (BigDec, error) { diff --git a/osmomath/rounding_direction_test.go b/osmomath/rounding_direction_test.go index 3fac4b62c9d..b91d4269036 100644 --- a/osmomath/rounding_direction_test.go +++ b/osmomath/rounding_direction_test.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" ) func TestDivIntByU64ToBigDec(t *testing.T) { diff --git a/osmomath/sigfig_round_test.go b/osmomath/sigfig_round_test.go index a62225de4f0..24640cbaf71 100644 --- a/osmomath/sigfig_round_test.go +++ b/osmomath/sigfig_round_test.go @@ -8,13 +8,12 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" ) func TestSigFigRound(t *testing.T) { // sigfig = 8 - tenToSigFig := gammtypes.SpotPriceSigFigs + tenToSigFig := sdk.NewDec(10).Power(8).TruncateInt() testCases := []struct { name string diff --git a/osmoutils/binary_search.go b/osmoutils/binary_search.go index 7399777b6a4..27ea4b4598f 100644 --- a/osmoutils/binary_search.go +++ b/osmoutils/binary_search.go @@ -5,19 +5,27 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmomath" ) // ErrTolerance is used to define a compare function, which checks if two -// ints are within a certain error tolerance of one another. +// ints are within a certain error tolerance of one another, +// and (optionally) that they are rounding in the correct direction. // ErrTolerance.Compare(a, b) returns true iff: -// |a - b| <= AdditiveTolerance -// |a - b| / min(a, b) <= MultiplicativeTolerance -// Each check is respectively ignored if the entry is nil (sdk.Dec{}, sdk.Int{}) +// * RoundingMode = RoundUp, then b >= a +// * RoundingMode = RoundDown, then b <= a +// * |a - b| <= AdditiveTolerance +// * |a - b| / min(a, b) <= MultiplicativeTolerance +// +// Each check is respectively ignored if the entry is nil. +// So AdditiveTolerance = sdk.Int{} or sdk.ZeroInt() +// MultiplicativeTolerance = sdk.Dec{} +// RoundingDir = RoundUnconstrained. // Note that if AdditiveTolerance == 0, then this is equivalent to a standard compare. type ErrTolerance struct { AdditiveTolerance sdk.Int MultiplicativeTolerance sdk.Dec + RoundingDir osmomath.RoundingDirection } // Compare returns if actual is within errTolerance of expected. @@ -34,6 +42,20 @@ func (e ErrTolerance) Compare(expected sdk.Int, actual sdk.Int) int { comparisonSign = -1 } + // Ensure that even if expected is within tolerance of actual, we don't count it as equal if its in the wrong direction. + // so if were supposed to round down, it must be that `expected >= actual`. + // likewise if were supposed to round up, it must be that `expected <= actual`. + // If neither of the above, then rounding direction does not enforce a constraint. + if e.RoundingDir == osmomath.RoundDown { + if expected.LT(actual) { + return -1 + } + } else if e.RoundingDir == osmomath.RoundUp { + if expected.GT(actual) { + return 1 + } + } + // Check additive tolerance equations if !e.AdditiveTolerance.IsNil() { // if no error accepted, do a direct compare. @@ -49,7 +71,7 @@ func (e ErrTolerance) Compare(expected sdk.Int, actual sdk.Int) int { } // Check multiplicative tolerance equations if !e.MultiplicativeTolerance.IsNil() && !e.MultiplicativeTolerance.IsZero() { - errTerm := diff.ToDec().Quo(sdk.MinInt(expected, actual).ToDec()) + errTerm := diff.ToDec().Quo(sdk.MinInt(expected.Abs(), actual.Abs()).ToDec()) if errTerm.GT(e.MultiplicativeTolerance) { return comparisonSign } @@ -63,6 +85,20 @@ func (e ErrTolerance) Compare(expected sdk.Int, actual sdk.Int) int { // returns 1 if not, and expected > actual. // returns -1 if not, and expected < actual func (e ErrTolerance) CompareBigDec(expected osmomath.BigDec, actual osmomath.BigDec) int { + // Ensure that even if expected is within tolerance of actual, we don't count it as equal if its in the wrong direction. + // so if were supposed to round down, it must be that `expected >= actual`. + // likewise if were supposed to round up, it must be that `expected <= actual`. + // If neither of the above, then rounding direction does not enforce a constraint. + if e.RoundingDir == osmomath.RoundDown { + if expected.LT(actual) { + return -1 + } + } else if e.RoundingDir == osmomath.RoundUp { + if expected.GT(actual) { + return 1 + } + } + diff := expected.Sub(actual).Abs() comparisonSign := 0 @@ -87,7 +123,8 @@ func (e ErrTolerance) CompareBigDec(expected osmomath.BigDec, actual osmomath.Bi } // Check multiplicative tolerance equations if !e.MultiplicativeTolerance.IsNil() && !e.MultiplicativeTolerance.IsZero() { - errTerm := diff.Quo(osmomath.MinDec(expected, actual)) + errTerm := diff.Quo(osmomath.MinDec(expected.Abs(), actual.Abs())) + // fmt.Printf("err term %v\n", errTerm) if errTerm.GT(osmomath.BigDecFromSDKDec(e.MultiplicativeTolerance)) { return comparisonSign } @@ -114,10 +151,10 @@ func BinarySearch(f func(input sdk.Int) (sdk.Int, error), } curIteration := 0 for ; curIteration < maxIterations; curIteration += 1 { - compRes := errTolerance.Compare(curOutput, targetOutput) - if compRes > 0 { + compRes := errTolerance.Compare(targetOutput, curOutput) + if compRes < 0 { upperbound = curEstimate - } else if compRes < 0 { + } else if compRes > 0 { lowerbound = curEstimate } else { return curEstimate, nil @@ -132,6 +169,13 @@ func BinarySearch(f func(input sdk.Int) (sdk.Int, error), return sdk.Int{}, errors.New("hit maximum iterations, did not converge fast enough") } +// SdkDec +type SdkDec[D any] interface { + Add(SdkDec[D]) SdkDec[D] + Quo(SdkDec[D]) SdkDec[D] + QuoRaw(int64) SdkDec[D] +} + // BinarySearchBigDec takes as input: // * an input range [lowerbound, upperbound] // * an increasing function f @@ -155,10 +199,11 @@ func BinarySearchBigDec(f func(input osmomath.BigDec) (osmomath.BigDec, error), } curIteration := 0 for ; curIteration < maxIterations; curIteration += 1 { - compRes := errTolerance.CompareBigDec(curOutput, targetOutput) - if compRes > 0 { + // fmt.Println("binary search, input, target output, cur output", curEstimate, targetOutput, curOutput) + compRes := errTolerance.CompareBigDec(targetOutput, curOutput) + if compRes < 0 { upperbound = curEstimate - } else if compRes < 0 { + } else if compRes > 0 { lowerbound = curEstimate } else { return curEstimate, nil diff --git a/osmoutils/binary_search_test.go b/osmoutils/binary_search_test.go index 9a5e1086970..95f7d5afb56 100644 --- a/osmoutils/binary_search_test.go +++ b/osmoutils/binary_search_test.go @@ -1,12 +1,20 @@ package osmoutils import ( + "fmt" + "math/rand" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmomath" +) + +var ( + withinOne = ErrTolerance{AdditiveTolerance: sdk.OneInt()} + withinFactor8 = ErrTolerance{MultiplicativeTolerance: sdk.NewDec(8)} + zero = osmomath.ZeroDec() ) func TestBinarySearch(t *testing.T) { @@ -43,16 +51,16 @@ func TestBinarySearch(t *testing.T) { // If it is, we return current output // Additive error bounds are solid addition / subtraction bounds to error, while multiplicative bounds take effect after dividing by the minimum between the two compared numbers. }{ - "linear f, no err tolerance, converges": {lineF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 51, sdk.NewInt(1 + (1 << 25)), false}, - "linear f, no err tolerance, does not converge": {lineF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 10, sdk.Int{}, true}, - "cubic f, no err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 51, sdk.NewInt(322539792367616), false}, - "cubic f, no err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 10, sdk.Int{}, true}, - "cubic f, large additive err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 15)), testErrToleranceAdditive, 51, sdk.NewInt(1 << 46), false}, - "cubic f, large additive err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 30)), testErrToleranceAdditive, 10, sdk.Int{}, true}, - "cubic f, large multiplicative err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), testErrToleranceMultiplicative, 51, sdk.NewInt(322539792367616), false}, + "linear f, no err tolerance, converges": {lineF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 51, sdk.NewInt(1 + (1 << 25)), false}, + "linear f, no err tolerance, does not converge": {lineF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 10, sdk.Int{}, true}, + "cubic f, no err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 51, sdk.NewInt(322539792367616), false}, + "cubic f, no err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 10, sdk.Int{}, true}, + "cubic f, large additive err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 15)), testErrToleranceAdditive, 51, sdk.NewInt(1 << 46), false}, + "cubic f, large additive err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 30)), testErrToleranceAdditive, 10, sdk.Int{}, true}, + "cubic f, large multiplicative err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), testErrToleranceMultiplicative, 51, sdk.NewInt(322539792367616), false}, "cubic f, large multiplicative err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), testErrToleranceMultiplicative, 10, sdk.Int{}, true}, - "cubic f, both err tolerances, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 15)), testErrToleranceBoth, 51, sdk.NewInt(1 << 45), false}, - "cubic f, both err tolerances, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 30)), testErrToleranceBoth, 10, sdk.Int{}, true}, + "cubic f, both err tolerances, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 15)), testErrToleranceBoth, 51, sdk.NewInt(1 << 45), false}, + "cubic f, both err tolerances, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 30)), testErrToleranceBoth, 10, sdk.Int{}, true}, } for name, tc := range tests { @@ -68,103 +76,295 @@ func TestBinarySearch(t *testing.T) { } } -func TestBinarySearchBigDec(t *testing.T) { - // straight line function that returns input. Simplest to binary search on, - // binary search directly reveals one bit of the answer in each iteration with this function. - lineF := func(a osmomath.BigDec) (osmomath.BigDec, error) { - return a, nil +// straight line function that returns input. Simplest to binary search on, +// binary search directly reveals one bit of the answer in each iteration with this function. +func lineF(a osmomath.BigDec) (osmomath.BigDec, error) { + return a, nil +} +func cubicF(a osmomath.BigDec) (osmomath.BigDec, error) { + return a.Power(3), nil +} + +var negCubicFConstant = osmomath.NewBigDec(1 << 62).Power(3).Neg() + +func negCubicF(a osmomath.BigDec) (osmomath.BigDec, error) { + return a.Power(3).Add(negCubicFConstant), nil +} + +type searchFn func(osmomath.BigDec) (osmomath.BigDec, error) + +type binarySearchTestCase struct { + f searchFn + lowerbound osmomath.BigDec + upperbound osmomath.BigDec + targetOutput osmomath.BigDec + errTolerance ErrTolerance + maxIterations int + + expectedSolvedInput osmomath.BigDec + expectErr bool + // This binary searches inputs to a monotonic increasing function F + // We stop when the answer is within error bounds stated by errTolerance + // First, (lowerbound + upperbound) / 2 becomes the current estimate. + // A current output is also defined as f(current estimate). In this case f is lineF + // We then compare the current output with the target output to see if it's within error tolerance bounds. If not, continue binary searching by iterating. + // If it is, we return current output + // Additive error bounds are solid addition / subtraction bounds to error, while multiplicative bounds take effect after dividing by the minimum between the two compared numbers. +} + +// This test ensures that we use exactly the expected number of iterations (one bit of x at a time) +// to find the answer to binary search on a line. +func TestBinarySearchLineIterationCounts(t *testing.T) { + tests := map[string]binarySearchTestCase{} + + generateExactTestCases := func(lowerbound, upperbound osmomath.BigDec, + errTolerance ErrTolerance, maxNumIters int) { + tcSetName := fmt.Sprintf("simple linear case: lower %s, upper %s", lowerbound.String(), upperbound.String()) + // first pass get it working with no err tolerance or rounding direction + target := lowerbound.Add(upperbound).QuoRaw(2) + for expectedItersToTarget := 1; expectedItersToTarget < maxNumIters; expectedItersToTarget++ { + // make two test cases, one at expected iter count, one at one below expected + // to guarantee were getting error as expected. + for subFromIter := 0; subFromIter < 2; subFromIter++ { + testCase := binarySearchTestCase{ + f: lineF, + lowerbound: lowerbound, upperbound: upperbound, + targetOutput: target, expectedSolvedInput: target, + errTolerance: errTolerance, + maxIterations: expectedItersToTarget - subFromIter, + expectErr: subFromIter != 0, + } + tcName := fmt.Sprintf("%s, target %s, iters %d, expError %v", + tcSetName, target.String(), expectedItersToTarget, testCase.expectErr) + tests[tcName] = testCase + } + target = lowerbound.Add(target).QuoRaw(2) + } } - cubicF := func(a osmomath.BigDec) (osmomath.BigDec, error) { - // these precision shifts are done implicitly in the int binary search tests - // we keep them here to maintain parity between test cases across implementations - calculation := a.Quo(osmomath.NewBigDec(10).Power(18)) - result := calculation.Power(3) - output := result.Mul(osmomath.NewBigDec(10).Power(18)) - return output, nil + + generateExactTestCases(osmomath.ZeroDec(), osmomath.NewBigDec(1<<20), withinOne, 20) + // we can go further than 50, if we could specify non-integer additive err tolerance. TODO: Add this. + generateExactTestCases(osmomath.NewBigDec(1<<20), osmomath.NewBigDec(1<<50), withinOne, 50) + runBinarySearchTestCases(t, tests, exactlyEqual) +} + +var fnMap = map[string]searchFn{"line": lineF, "cubic": cubicF, "neg_cubic": negCubicF} + +// This function tests that any value in a given range can be reached within expected num iterations. +func TestIterationDepthRandValue(t *testing.T) { + tests := map[string]binarySearchTestCase{} + exactEqual := ErrTolerance{AdditiveTolerance: sdk.ZeroInt()} + withinOne := ErrTolerance{AdditiveTolerance: sdk.OneInt()} + within32 := ErrTolerance{AdditiveTolerance: sdk.OneInt().MulRaw(32)} + + createRandInput := func(fnName string, lowerbound, upperbound int64, + errTolerance ErrTolerance, maxNumIters int, errToleranceName string) { + targetF := fnMap[fnName] + targetX := int64(rand.Intn(int(upperbound-lowerbound-1))) + lowerbound + 1 + target, _ := targetF(osmomath.NewBigDec(targetX)) + testCase := binarySearchTestCase{ + f: lineF, + lowerbound: osmomath.NewBigDec(lowerbound), upperbound: osmomath.NewBigDec(upperbound), + targetOutput: target, expectedSolvedInput: target, + errTolerance: errTolerance, + maxIterations: maxNumIters, + expectErr: false, + } + tcname := fmt.Sprintf("%s: lower %d, upper %d, in %d iter of %s, rand target %d", + fnName, lowerbound, upperbound, maxNumIters, errToleranceName, target) + tests[tcname] = testCase } - lowErrTolerance := ErrTolerance{AdditiveTolerance: sdk.OneInt()} - testErrToleranceAdditive := ErrTolerance{AdditiveTolerance: sdk.NewInt(1 << 20)} - testErrToleranceMultiplicative := ErrTolerance{AdditiveTolerance: sdk.OneInt(), MultiplicativeTolerance: sdk.NewDec(10)} - testErrToleranceBoth := ErrTolerance{AdditiveTolerance: sdk.NewInt(1 << 20), MultiplicativeTolerance: sdk.NewDec(1 << 3)} - tests := map[string]struct { - f func(osmomath.BigDec) (osmomath.BigDec, error) - lowerbound osmomath.BigDec - upperbound osmomath.BigDec - targetOutput osmomath.BigDec - errTolerance ErrTolerance - maxIterations int - expectedSolvedInput osmomath.BigDec - expectErr bool - // This binary searches inputs to a monotonic increasing function F - // We stop when the answer is within error bounds stated by errTolerance - // First, (lowerbound + upperbound) / 2 becomes the current estimate. - // A current output is also defined as f(current estimate). In this case f is lineF - // We then compare the current output with the target output to see if it's within error tolerance bounds. If not, continue binary searching by iterating. - // If it is, we return current output - // Additive error bounds are solid addition / subtraction bounds to error, while multiplicative bounds take effect after dividing by the minimum between the two compared numbers. - }{ - "linear f, no err tolerance, converges": {lineF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec(1 + (1 << 25)), lowErrTolerance, 51, osmomath.NewBigDec(1 + (1 << 25)), false}, - "linear f, no err tolerance, does not converge": {lineF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec(1 + (1 << 25)), lowErrTolerance, 10, osmomath.BigDec{}, true}, - "cubic f, no err tolerance, converges": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec(1 + (1 << 25)), lowErrTolerance, 51, osmomath.NewBigDec(322539792367616), false}, - "cubic f, no err tolerance, does not converge": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec(1 + (1 << 25)), lowErrTolerance, 10, osmomath.BigDec{}, true}, - "cubic f, large additive err tolerance, converges": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec((1 << 15)), testErrToleranceAdditive, 51, osmomath.NewBigDec(1 << 46), false}, - "cubic f, large additive err tolerance, does not converge": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec((1 << 30)), testErrToleranceAdditive, 10, osmomath.BigDec{}, true}, - "cubic f, large multiplicative err tolerance, converges": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec(1 + (1 << 25)), testErrToleranceMultiplicative, 51, osmomath.NewBigDec(322539792367616), false}, - "cubic f, large multiplicative err tolerance, does not converge": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec(1 + (1 << 25)), testErrToleranceMultiplicative, 10, osmomath.BigDec{}, true}, - "cubic f, both err tolerances, converges": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec((1 << 15)), testErrToleranceBoth, 51, osmomath.NewBigDec(1 << 45), false}, - "cubic f, both err tolerances, does not converge": {cubicF, osmomath.ZeroDec(), osmomath.NewBigDec(1 << 50), osmomath.NewBigDec((1 << 30)), testErrToleranceBoth, 10, osmomath.BigDec{}, true}, + for i := 0; i < 1000; i++ { + // Takes a 21st iteration to guaranteeably get 0 + createRandInput("line", 0, 1<<20, exactEqual, 21, "exactly equal") + // Takes 20 iterations to guaranteeably get 1 within 0. + createRandInput("line", 0, 1<<20, withinOne, 20, "within one") + // Takes 15 iterations to guaranteeably get to 32. Needed to reach any number in [0, 31] + createRandInput("line", 0, 1<<20, within32, 15, "within 32") } + runBinarySearchTestCases(t, tests, errToleranceEqual) +} + +type equalityMode int + +const ( + exactlyEqual equalityMode = iota + errToleranceEqual equalityMode = iota + equalWithinOne equalityMode = iota +) +func withRoundingDir(e ErrTolerance, r osmomath.RoundingDirection) ErrTolerance { + return ErrTolerance{ + AdditiveTolerance: e.AdditiveTolerance, + MultiplicativeTolerance: e.MultiplicativeTolerance, + RoundingDir: r, + } +} + +func runBinarySearchTestCases(t *testing.T, tests map[string]binarySearchTestCase, + equality equalityMode) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - actualSolvedInput, err := BinarySearchBigDec(tc.f, tc.lowerbound, tc.upperbound, tc.targetOutput, tc.errTolerance, tc.maxIterations) + actualSolvedInput, err := BinarySearchBigDec( + tc.f, tc.lowerbound, tc.upperbound, tc.targetOutput, tc.errTolerance, tc.maxIterations) if tc.expectErr { require.Error(t, err) } else { require.NoError(t, err) - require.True(osmomath.DecApproxEq(t, tc.expectedSolvedInput, actualSolvedInput, osmomath.OneDec())) + if equality == exactlyEqual { + require.True(osmomath.DecEq(t, tc.expectedSolvedInput, actualSolvedInput)) + } else if equality == errToleranceEqual { + require.True(t, tc.errTolerance.CompareBigDec(tc.expectedSolvedInput, actualSolvedInput) == 0) + } else { + _, valid, msg, dec1, dec2 := osmomath.DecApproxEq(t, tc.expectedSolvedInput, actualSolvedInput, osmomath.OneDec()) + require.True(t, valid, msg+" \n d1 = %s, d2 = %s", dec1, dec2, + tc.expectedSolvedInput, actualSolvedInput) + } } }) } } +func TestBinarySearchBigDec(t *testing.T) { + testErrToleranceAdditive := ErrTolerance{AdditiveTolerance: sdk.NewInt(1 << 30)} + errToleranceBoth := ErrTolerance{AdditiveTolerance: sdk.NewInt(1 << 30), MultiplicativeTolerance: sdk.NewDec(1 << 3)} + + twoTo50 := osmomath.NewBigDec(1 << 50) + twoTo25PlusOne := osmomath.NewBigDec(1 + (1 << 25)) + twoTo25PlusOneCubed := twoTo25PlusOne.Power(3) + + tests := map[string]binarySearchTestCase{ + "cubic f, no err tolerance, converges": {cubicF, zero, twoTo50, twoTo25PlusOneCubed, withinOne, 51, twoTo25PlusOne, false}, + "cubic f, no err tolerance, not converges": {cubicF, zero, twoTo50, twoTo25PlusOneCubed, withinOne, 10, twoTo25PlusOne, true}, + // Target = 2^33 - 2^29, so correct input is 2^11 - e, for 0 < e < 2^10. + // additive error tolerance is 2^30. So we converge at first value + // whose cube is within 2^30 of answer. As were in binary search with power of two bounds + // we go through powers of two first. + // hence we hit at 2^11 first, since (2^11)^3 - target is 2^29, which is within additive err tolerance. + "cubic f, within 2^30, target 2^33 - 2^29": { + cubicF, + zero, twoTo50, + osmomath.NewBigDec((1 << 33) - (1 << 29)), + testErrToleranceAdditive, 51, osmomath.NewBigDec(1 << 11), false}, + // basically same as above, but due to needing to roundup, we converge at a value > 2^11. + // We try (1<<11 + 1<<10)^3 which is way too large. + // notice by trial, that (1 << 11 + 1<<7)^3 - target > 2^30, but that + // (1 << 11 + 1<<6)^3 - target < 2^30, so that is the answer. + "cubic f, within 2^30, roundup, target 2^33 + 2^29": { + cubicF, + zero, twoTo50, + osmomath.NewBigDec((1 << 33) + (1 << 29)), + withRoundingDir(testErrToleranceAdditive, osmomath.RoundUp), + 51, osmomath.NewBigDec(1<<11 + 1<<6), false}, + "cubic f, large multiplicative err tolerance, converges": { + cubicF, + zero, twoTo50, + osmomath.NewBigDec(1 << 30), withinFactor8, 51, osmomath.NewBigDec(1 << 11), false}, + "cubic f, both err tolerances, converges": { + cubicF, + zero, twoTo50, + osmomath.NewBigDec((1 << 33) - (1 << 29)), + errToleranceBoth, 51, osmomath.NewBigDec(1 << 11), false}, + "neg cubic f, no err tolerance, converges": {negCubicF, zero, twoTo50, + twoTo25PlusOneCubed.Add(negCubicFConstant), withinOne, 51, twoTo25PlusOne, false}, + // "neg cubic f, large multiplicative err tolerance, converges": { + // negCubicF, + // zero, twoTo50, + // osmomath.NewBigDec(1 << 30).Add(negCubicFConstant), + // withinFactor8, 51, osmomath.NewBigDec(1 << 11), false}, + } + + runBinarySearchTestCases(t, tests, equalWithinOne) +} + +func TestBinarySearchRoundingBehavior(t *testing.T) { + withinTwoTo30 := ErrTolerance{AdditiveTolerance: sdk.NewInt(1 << 30)} + + twoTo50 := osmomath.NewBigDec(1 << 50) + // twoTo25PlusOne := osmomath.NewBigDec(1 + (1 << 25)) + // twoTo25PlusOneCubed := twoTo25PlusOne.Power(3) + + tests := map[string]binarySearchTestCase{ + "lineF, roundup within 2^30, target 2^32 + 2^30 + 1, expected=2^32 + 2^31": {f: lineF, + lowerbound: zero, upperbound: twoTo50, + targetOutput: osmomath.NewBigDec((1 << 32) + (1 << 30) + 1), + errTolerance: withRoundingDir(withinTwoTo30, osmomath.RoundUp), + maxIterations: 51, + expectedSolvedInput: osmomath.NewBigDec(1<<32 + 1<<31)}, + "lineF, roundup within 2^30, target 2^32 + 2^30 - 1, expected=2^32 + 2^30": {f: lineF, + lowerbound: zero, upperbound: twoTo50, + targetOutput: osmomath.NewBigDec((1 << 32) + (1 << 30) - 1), + errTolerance: withRoundingDir(withinTwoTo30, osmomath.RoundUp), + maxIterations: 51, + expectedSolvedInput: osmomath.NewBigDec(1<<32 + 1<<30)}, + "lineF, rounddown within 2^30, target 2^32 + 2^30 + 1, expected=2^32 + 2^31": {f: lineF, + lowerbound: zero, upperbound: twoTo50, + targetOutput: osmomath.NewBigDec((1 << 32) + (1 << 30) + 1), + errTolerance: withRoundingDir(withinTwoTo30, osmomath.RoundDown), + maxIterations: 51, + expectedSolvedInput: osmomath.NewBigDec(1<<32 + 1<<30)}, + "lineF, rounddown within 2^30, target 2^32 + 2^30 - 1, expected=2^32 + 2^30": {f: lineF, + lowerbound: zero, upperbound: twoTo50, + targetOutput: osmomath.NewBigDec((1 << 32) + (1 << 30) - 1), + errTolerance: withRoundingDir(withinTwoTo30, osmomath.RoundDown), + maxIterations: 51, + expectedSolvedInput: osmomath.NewBigDec(1 << 32)}, + } + + runBinarySearchTestCases(t, + tests, + equalWithinOne) +} + func TestErrTolerance_Compare(t *testing.T) { ZeroErrTolerance := ErrTolerance{AdditiveTolerance: sdk.ZeroInt(), MultiplicativeTolerance: sdk.Dec{}} NonZeroErrAdditive := ErrTolerance{AdditiveTolerance: sdk.NewInt(10), MultiplicativeTolerance: sdk.Dec{}} - NonZeroErrMultiplicative := ErrTolerance{AdditiveTolerance: sdk.ZeroInt(), MultiplicativeTolerance: sdk.NewDec(10)} + NonZeroErrMultiplicative := ErrTolerance{AdditiveTolerance: sdk.Int{}, MultiplicativeTolerance: sdk.NewDec(10)} NonZeroErrBoth := ErrTolerance{AdditiveTolerance: sdk.NewInt(1), MultiplicativeTolerance: sdk.NewDec(10)} tests := []struct { - name string - tol ErrTolerance - intInput sdk.Int - intReference sdk.Int - - bigDecInput osmomath.BigDec - bigDecReference osmomath.BigDec + name string + tol ErrTolerance + intInput int64 + intReference int64 expectedCompareResult int }{ - {"0 tolerance: <", ZeroErrTolerance, sdk.NewInt(1000), sdk.NewInt(1001), osmomath.NewBigDec(1000), osmomath.NewBigDec(1001), -1}, - {"0 tolerance: =", ZeroErrTolerance, sdk.NewInt(1001), sdk.NewInt(1001), osmomath.NewBigDec(1001), osmomath.NewBigDec(1001), 0}, - {"0 tolerance: >", ZeroErrTolerance, sdk.NewInt(1002), sdk.NewInt(1001), osmomath.NewBigDec(1002), osmomath.NewBigDec(1001), 1}, - {"Nonzero additive tolerance: <", NonZeroErrAdditive, sdk.NewInt(420), sdk.NewInt(1001), osmomath.NewBigDec(420), osmomath.NewBigDec(1001), -1}, - {"Nonzero additive tolerance: =", NonZeroErrAdditive, sdk.NewInt(1011), sdk.NewInt(1001), osmomath.NewBigDec(1011), osmomath.NewBigDec(1001), 0}, - {"Nonzero additive tolerance: >", NonZeroErrAdditive, sdk.NewInt(1230), sdk.NewInt(1001), osmomath.NewBigDec(1230), osmomath.NewBigDec(1001), 1}, - {"Nonzero multiplicative tolerance: <", NonZeroErrMultiplicative, sdk.NewInt(1000), sdk.NewInt(1001), osmomath.NewBigDec(1000), osmomath.NewBigDec(1001), -1}, - {"Nonzero multiplicative tolerance: =", NonZeroErrMultiplicative, sdk.NewInt(1001), sdk.NewInt(1001), osmomath.NewBigDec(1001), osmomath.NewBigDec(1001), 0}, - {"Nonzero multiplicative tolerance: >", NonZeroErrMultiplicative, sdk.NewInt(1002), sdk.NewInt(1001), osmomath.NewBigDec(1002), osmomath.NewBigDec(1001), 1}, - {"Nonzero both tolerance: <", NonZeroErrBoth, sdk.NewInt(990), sdk.NewInt(1001), osmomath.NewBigDec(990), osmomath.NewBigDec(1001), -1}, - {"Nonzero both tolerance: =", NonZeroErrBoth, sdk.NewInt(1002), sdk.NewInt(1001), osmomath.NewBigDec(1002), osmomath.NewBigDec(1001), 0}, - {"Nonzero both tolerance: >", NonZeroErrBoth, sdk.NewInt(1011), sdk.NewInt(1001), osmomath.NewBigDec(1011), osmomath.NewBigDec(1001), 1}, + {"0 tolerance: <", ZeroErrTolerance, 1000, 1001, -1}, + {"0 tolerance: =", ZeroErrTolerance, 1001, 1001, 0}, + {"0 tolerance: >", ZeroErrTolerance, 1002, 1001, 1}, + {"Nonzero additive tolerance: <", NonZeroErrAdditive, 420, 1001, -1}, + {"Nonzero additive tolerance: =", NonZeroErrAdditive, 1011, 1001, 0}, + {"Nonzero additive tolerance: >", NonZeroErrAdditive, 1230, 1001, 1}, + {"Nonzero multiplicative tolerance within bounds: <", NonZeroErrMultiplicative, 1000, 1001, 0}, + {"Nonzero multiplicative tolerance within bounds: =", NonZeroErrMultiplicative, 1001, 1001, 0}, + {"Nonzero multiplicative tolerance within bounds: >", NonZeroErrMultiplicative, 1002, 1001, 0}, + {"Nonzero multiplicative tolerance out of bounds: <", NonZeroErrMultiplicative, 100000, 1001, 1}, + {"Nonzero multiplicative tolerance out of bounds: =", NonZeroErrMultiplicative, 100100, 1001, 1}, + {"Nonzero multiplicative tolerance out of bounds: >", NonZeroErrMultiplicative, 100200, 1001, 1}, + {"multiplicative tolerance with negative: >", NonZeroErrMultiplicative, + -20020, -1001, -1}, + {"Nonzero both tolerance: <", NonZeroErrBoth, 990, 1001, -1}, + {"Nonzero both tolerance: =", NonZeroErrBoth, 1002, 1001, 0}, + {"Nonzero both tolerance: >", NonZeroErrBoth, 1011, 1001, 1}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := tt.tol.Compare(tt.intInput, tt.intReference); got != tt.expectedCompareResult { - t.Errorf("ErrTolerance.Compare() = %v, want %v", got, tt.expectedCompareResult) + gotInt := tt.tol.Compare(sdk.NewInt(tt.intInput), sdk.NewInt(tt.intReference)) + if gotInt != tt.expectedCompareResult { + t.Errorf("ErrTolerance.Compare() = %v, want %v", gotInt, tt.expectedCompareResult) + } + gotIntRev := tt.tol.Compare(sdk.NewInt(tt.intReference), sdk.NewInt(tt.intInput)) + if gotIntRev != -tt.expectedCompareResult { + t.Errorf("ErrTolerance.Compare() = %v, want %v", gotIntRev, -tt.expectedCompareResult) + } + gotBigDec := tt.tol.CompareBigDec(osmomath.NewBigDec(tt.intInput), osmomath.NewBigDec(tt.intReference)) + if gotBigDec != tt.expectedCompareResult { + t.Errorf("ErrTolerance.CompareBigDec() = %v, want %v", gotBigDec, tt.expectedCompareResult) } - if got := tt.tol.CompareBigDec(tt.bigDecInput, tt.bigDecReference); got != tt.expectedCompareResult { - t.Errorf("ErrTolerance.CompareBigDec() = %v, want %v", got, tt.expectedCompareResult) + gotBigDecRev := tt.tol.CompareBigDec(osmomath.NewBigDec(tt.intReference), osmomath.NewBigDec(tt.intInput)) + if gotBigDecRev != -tt.expectedCompareResult { + t.Errorf("ErrTolerance.CompareBigDec() = %v, want %v", gotBigDecRev, -tt.expectedCompareResult) } }) } diff --git a/osmoutils/cache_ctx.go b/osmoutils/cache_ctx.go index 0802ddd8eec..6e398cdbc4d 100644 --- a/osmoutils/cache_ctx.go +++ b/osmoutils/cache_ctx.go @@ -30,6 +30,7 @@ func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err err } else { // no error, write the output of f write() + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) } return err } diff --git a/osmoutils/export_test.go b/osmoutils/export_test.go index 4aa31077594..3ae6a32c21b 100644 --- a/osmoutils/export_test.go +++ b/osmoutils/export_test.go @@ -2,8 +2,8 @@ package osmoutils import db "github.com/tendermint/tm-db" -func GatherValuesFromIteratorWithStop[T any](iterator db.Iterator, parseValue func([]byte) (T, error), stopFn func([]byte) bool) ([]T, error) { - return gatherValuesFromIteratorWithStop(iterator, parseValue, stopFn) +func GatherValuesFromIterator[T any](iterator db.Iterator, parseValue func([]byte) (T, error), stopFn func([]byte) bool) ([]T, error) { + return gatherValuesFromIterator(iterator, parseValue, stopFn) } func NoStopFn(key []byte) bool { diff --git a/osmoutils/ibc.go b/osmoutils/ibc.go new file mode 100644 index 00000000000..67f5864463c --- /dev/null +++ b/osmoutils/ibc.go @@ -0,0 +1,51 @@ +package osmoutils + +import ( + "encoding/json" + + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" +) + +// MustExtractDenomFromPacketOnRecv takes a packet with a valid ICS20 token data in the Data field and returns the +// denom as represented in the local chain. +// If the data cannot be unmarshalled this function will panic +func MustExtractDenomFromPacketOnRecv(packet ibcexported.PacketI) string { + var data transfertypes.FungibleTokenPacketData + if err := json.Unmarshal(packet.GetData(), &data); err != nil { + panic("unable to unmarshal ICS20 packet data") + } + + var denom string + if transfertypes.ReceiverChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), data.Denom) { + // remove prefix added by sender chain + voucherPrefix := transfertypes.GetDenomPrefix(packet.GetSourcePort(), packet.GetSourceChannel()) + + unprefixedDenom := data.Denom[len(voucherPrefix):] + + // coin denomination used in sending from the escrow address + denom = unprefixedDenom + + // The denomination used to send the coins is either the native denom or the hash of the path + // if the denomination is not native. + denomTrace := transfertypes.ParseDenomTrace(unprefixedDenom) + if denomTrace.Path != "" { + denom = denomTrace.IBCDenom() + } + } else { + prefixedDenom := transfertypes.GetDenomPrefix(packet.GetDestPort(), packet.GetDestChannel()) + data.Denom + denom = transfertypes.ParseDenomTrace(prefixedDenom).IBCDenom() + } + return denom +} + +// IsAckError checks an IBC acknowledgement to see if it's an error. +// This is a replacement for ack.Success() which is currently not working on some circumstances +func IsAckError(acknowledgement []byte) bool { + var ackErr channeltypes.Acknowledgement_Error + if err := json.Unmarshal(acknowledgement, &ackErr); err == nil && len(ackErr.Error) > 0 { + return true + } + return false +} diff --git a/osmoutils/module_account_test.go b/osmoutils/module_account_test.go index 0b5cfea0356..5cff725bcfb 100644 --- a/osmoutils/module_account_test.go +++ b/osmoutils/module_account_test.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/address" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/osmoutils" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/osmoutils" ) func (s *TestSuite) TestCreateModuleAccount() { diff --git a/osmoutils/partialord/internal/dag/dag_test.go b/osmoutils/partialord/internal/dag/dag_test.go index 9b5a7452458..4d1693cc456 100644 --- a/osmoutils/partialord/internal/dag/dag_test.go +++ b/osmoutils/partialord/internal/dag/dag_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/osmoutils/partialord/internal/dag" + "github.com/osmosis-labs/osmosis/v13/osmoutils/partialord/internal/dag" ) type edge struct { diff --git a/osmoutils/partialord/partialord.go b/osmoutils/partialord/partialord.go index 517d5c3831e..8f60793ab93 100644 --- a/osmoutils/partialord/partialord.go +++ b/osmoutils/partialord/partialord.go @@ -3,7 +3,7 @@ package partialord import ( "sort" - "github.com/osmosis-labs/osmosis/v12/osmoutils/partialord/internal/dag" + "github.com/osmosis-labs/osmosis/v13/osmoutils/partialord/internal/dag" ) type PartialOrdering struct { diff --git a/osmoutils/partialord/partialord_test.go b/osmoutils/partialord/partialord_test.go index 8ce637f1a28..2f1acf105ca 100644 --- a/osmoutils/partialord/partialord_test.go +++ b/osmoutils/partialord/partialord_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/osmoutils/partialord" + "github.com/osmosis-labs/osmosis/v13/osmoutils/partialord" ) func TestAPI(t *testing.T) { diff --git a/osmoutils/slice_helper.go b/osmoutils/slice_helper.go index f4c14a7b975..a7ee4db4eb0 100644 --- a/osmoutils/slice_helper.go +++ b/osmoutils/slice_helper.go @@ -35,3 +35,17 @@ func ReverseSlice[T any](s []T) []T { } return s } + +// ContainsDuplicate checks if there are any duplicate +// elements in the slice. +func ContainsDuplicate[T any](arr []T) bool { + visited := make(map[any]bool, 0) + for i := 0; i < len(arr); i++ { + if visited[arr[i]] { + return true + } else { + visited[arr[i]] = true + } + } + return false +} diff --git a/osmoutils/slice_helper_test.go b/osmoutils/slice_helper_test.go index 3decfee6a7a..cd58fdf1a9b 100644 --- a/osmoutils/slice_helper_test.go +++ b/osmoutils/slice_helper_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/osmoutils" + "github.com/osmosis-labs/osmosis/v13/osmoutils" ) func TestReverseSlice(t *testing.T) { diff --git a/osmoutils/store_helper.go b/osmoutils/store_helper.go index 86cabae4414..2a3c377a69b 100644 --- a/osmoutils/store_helper.go +++ b/osmoutils/store_helper.go @@ -25,13 +25,13 @@ func GatherAllKeysFromStore(storeObj store.KVStore) []string { func GatherValuesFromStore[T any](storeObj store.KVStore, keyStart []byte, keyEnd []byte, parseValue func([]byte) (T, error)) ([]T, error) { iterator := storeObj.Iterator(keyStart, keyEnd) defer iterator.Close() - return gatherValuesFromIteratorWithStop(iterator, parseValue, noStopFn) + return gatherValuesFromIterator(iterator, parseValue, noStopFn) } func GatherValuesFromStorePrefix[T any](storeObj store.KVStore, prefix []byte, parseValue func([]byte) (T, error)) ([]T, error) { iterator := sdk.KVStorePrefixIterator(storeObj, prefix) defer iterator.Close() - return gatherValuesFromIteratorWithStop(iterator, parseValue, noStopFn) + return gatherValuesFromIterator(iterator, parseValue, noStopFn) } func GetValuesUntilDerivedStop[T any](storeObj store.KVStore, keyStart []byte, stopFn func([]byte) bool, parseValue func([]byte) (T, error)) ([]T, error) { @@ -60,7 +60,7 @@ func GetIterValuesWithStop[T any]( iter := makeIterator(storeObj, keyStart, keyEnd, reverse) defer iter.Close() - return gatherValuesFromIteratorWithStop(iter, parseValue, stopFn) + return gatherValuesFromIterator(iter, parseValue, stopFn) } func GetFirstValueAfterPrefixInclusive[T any](storeObj store.KVStore, keyStart []byte, parseValue func([]byte) (T, error)) (T, error) { @@ -82,7 +82,7 @@ func GetFirstValueInRange[T any](storeObj store.KVStore, keyStart []byte, keyEnd return parseValue(iterator.Value()) } -func gatherValuesFromIteratorWithStop[T any](iterator db.Iterator, parseValue func([]byte) (T, error), stopFn func([]byte) bool) ([]T, error) { +func gatherValuesFromIterator[T any](iterator db.Iterator, parseValue func([]byte) (T, error), stopFn func([]byte) bool) ([]T, error) { values := []T{} for ; iterator.Valid(); iterator.Next() { if stopFn(iterator.Key()) { @@ -137,3 +137,16 @@ func MustGetDec(store store.KVStore, key []byte) sdk.Dec { MustGet(store, key, result) return result.Dec } + +// Get returns a value at key by mutating the result parameter. Returns true if the value was found and the +// result mutated correctly. If the value is not in the store, returns false. Returns error only when database or serialization errors occur. (And when an error occurs, returns false) +func Get(store store.KVStore, key []byte, result proto.Message) (found bool, err error) { + b := store.Get(key) + if b == nil { + return false, nil + } + if err := proto.Unmarshal(b, result); err != nil { + return true, err + } + return true, nil +} diff --git a/osmoutils/store_helper_test.go b/osmoutils/store_helper_test.go index bbae8526fbd..33359ba7cdd 100644 --- a/osmoutils/store_helper_test.go +++ b/osmoutils/store_helper_test.go @@ -9,10 +9,10 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + twaptypes "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) type TestSuite struct { @@ -422,7 +422,7 @@ func (s *TestSuite) TestGetFirstValueAfterPrefixInclusive() { } } -func (s *TestSuite) TestGatherValuesFromIteratorWithStop() { +func (s *TestSuite) TestGatherValuesFromIterator() { testcases := map[string]struct { // if prefix is set, startValue and endValue are ignored. // we either create an iterator prefix or a range iterator. @@ -535,7 +535,7 @@ func (s *TestSuite) TestGatherValuesFromIteratorWithStop() { mockParseValueFn = mockParseValueWithError } - actualValues, err := osmoutils.GatherValuesFromIteratorWithStop(iterator, mockParseValueFn, mockStop) + actualValues, err := osmoutils.GatherValuesFromIterator(iterator, mockParseValueFn, mockStop) if tc.expectedErr != nil { s.Require().ErrorContains(err, tc.expectedErr.Error()) @@ -811,6 +811,98 @@ func (s *TestSuite) TestMustGet() { } } +// TestGet tests that Get returns a boolean indicating +// whether value exists for the given key and error +func (s *TestSuite) TestGet() { + tests := map[string]struct { + // keys and values to preset + preSetKeyValues map[string]proto.Message + + // keys and values to attempt to get and validate + expectedGetKeyValues map[string]proto.Message + + actualResultProto proto.Message + + expectFound bool + + expectErr bool + }{ + "basic valid test": { + preSetKeyValues: map[string]proto.Message{ + keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + }, + + expectedGetKeyValues: map[string]proto.Message{ + keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + }, + + actualResultProto: &sdk.DecProto{}, + + expectFound: true, + }, + "attempt to get non-existent key - not found & no err return": { + preSetKeyValues: map[string]proto.Message{ + keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + }, + + expectedGetKeyValues: map[string]proto.Message{ + keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + }, + + actualResultProto: &sdk.DecProto{}, + + expectFound: false, + + expectErr: false, + }, + "invalid proto Dec vs TwapRecord - found but Unmarshal err": { + preSetKeyValues: map[string]proto.Message{ + keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + }, + + expectedGetKeyValues: map[string]proto.Message{ + keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + }, + + actualResultProto: &twaptypes.TwapRecord{}, + + expectFound: true, + + expectErr: true, + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupStoreWithBasePrefix() + + // Setup + for key, value := range tc.preSetKeyValues { + osmoutils.MustSet(s.store, []byte(key), value) + } + + for key, expectedValue := range tc.expectedGetKeyValues { + // System under test. + found, err := osmoutils.Get(s.store, []byte(key), tc.actualResultProto) + // Assertions. + s.Require().Equal(found, tc.expectFound) + if tc.expectErr { + s.Require().Error(err) + } + // make sure found by key & Unmarshal successfully + if !tc.expectErr && tc.expectFound { + s.Require().Equal(expectedValue.String(), tc.actualResultProto.String()) + } + } + }) + } +} + // TestMustSet tests that MustSet updates the store correctly // and panics if an error is encountered. func (s *TestSuite) TestMustSet() { diff --git a/store/README.md b/osmoutils/sumtree/README.md similarity index 91% rename from store/README.md rename to osmoutils/sumtree/README.md index a77a9211c71..d9aeb7abd14 100644 --- a/store/README.md +++ b/osmoutils/sumtree/README.md @@ -69,7 +69,7 @@ TODO: Improve diagrams showing this accumulated weight concept with a binary tre ## Implementation Details -The B-Tree implementation under `osmosis/store` is designed specifically +The B-Tree implementation under `osmoutils/sumtree` is designed specifically for allowing efficient computation of a random prefix sum, with the underlying data being updatable as explained above. @@ -125,8 +125,7 @@ The following constraints are valid for all branch nodes: 4. There are no duplicate child stored in more than one of node's `.Children`. -Example -------- +### Example Here is an example tree data: @@ -145,8 +144,8 @@ Here is an example tree data: The branch nodes will have the following childrens: ``` {.go} -require.Equal(store.Get(nodeKey(2, nil)), Children{{0xaaaa, 60}, {0xbb44, 300}, {0xeeaaaa, 700}}) -require.Equal(store.Get(nodeKey(1, 0xaaaa)), Children{{0xaaaa, 10}, {0xaaaa01, 20}, {0xaabb, 30}}) -require.Equal(store.Get(nodeKey(1, 0xbb44)), Children{{0xbb55, 100}, {0xbe, 200}}) -require.Equal(store.Get(nodeKey(1, 0xeeaaaa)), Children{{0xef1234, 300}, {0xffff, 400}}) +require.Equal(sumtree.Get(nodeKey(2, nil)), Children{{0xaaaa, 60}, {0xbb44, 300}, {0xeeaaaa, 700}}) +require.Equal(sumtree.Get(nodeKey(1, 0xaaaa)), Children{{0xaaaa, 10}, {0xaaaa01, 20}, {0xaabb, 30}}) +require.Equal(sumtree.Get(nodeKey(1, 0xbb44)), Children{{0xbb55, 100}, {0xbe, 200}}) +require.Equal(sumtree.Get(nodeKey(1, 0xeeaaaa)), Children{{0xef1234, 300}, {0xffff, 400}}) ``` diff --git a/store/constants.go b/osmoutils/sumtree/constants.go similarity index 93% rename from store/constants.go rename to osmoutils/sumtree/constants.go index 2fcbde3917a..ea5b72af233 100644 --- a/store/constants.go +++ b/osmoutils/sumtree/constants.go @@ -1,4 +1,4 @@ -package store +package sumtree var nodeKeyPrefix []byte diff --git a/store/legacy/v101/old_tree.json b/osmoutils/sumtree/legacy/v101/old_tree.json similarity index 100% rename from store/legacy/v101/old_tree.json rename to osmoutils/sumtree/legacy/v101/old_tree.json diff --git a/store/legacy/v101/tree.go b/osmoutils/sumtree/legacy/v101/tree.go similarity index 83% rename from store/legacy/v101/tree.go rename to osmoutils/sumtree/legacy/v101/tree.go index e1c687a88bc..b0ca57fcbc2 100644 --- a/store/legacy/v101/tree.go +++ b/osmoutils/sumtree/legacy/v101/tree.go @@ -10,7 +10,7 @@ import ( stypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/store" + "github.com/osmosis-labs/osmosis/v13/osmoutils/sumtree" ) type Child struct { @@ -20,27 +20,27 @@ type Child struct { type Children []Child // branch nodes -func migrateBranchValue(oldValueBz []byte) *store.Node { +func migrateBranchValue(oldValueBz []byte) *sumtree.Node { var oldValue Children fmt.Println(string(oldValueBz)) err := json.Unmarshal(oldValueBz, &oldValue) if err != nil { panic(err) } - cs := make([]*store.Child, len(oldValue)) + cs := make([]*sumtree.Child, len(oldValue)) for i, oldChild := range oldValue { - cs[i] = &store.Child{Index: oldChild.Index, Accumulation: oldChild.Acc} + cs[i] = &sumtree.Child{Index: oldChild.Index, Accumulation: oldChild.Acc} } - return &store.Node{Children: cs} + return &sumtree.Node{Children: cs} } -func migrateLeafValue(index []byte, oldValueBz []byte) *store.Leaf { +func migrateLeafValue(index []byte, oldValueBz []byte) *sumtree.Leaf { oldValue := sdk.ZeroInt() err := json.Unmarshal(oldValueBz, &oldValue) if err != nil { panic(err) } - return store.NewLeaf(index, oldValue) + return sumtree.NewLeaf(index, oldValue) } func nodeKey(level uint16, key []byte) []byte { diff --git a/store/legacy/v101/tree_test.go b/osmoutils/sumtree/legacy/v101/tree_test.go similarity index 92% rename from store/legacy/v101/tree_test.go rename to osmoutils/sumtree/legacy/v101/tree_test.go index 6ee7077b886..f9574d8d60f 100644 --- a/store/legacy/v101/tree_test.go +++ b/osmoutils/sumtree/legacy/v101/tree_test.go @@ -18,13 +18,13 @@ import ( iavlstore "github.com/cosmos/cosmos-sdk/store/iavl" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/store" - v101 "github.com/osmosis-labs/osmosis/v12/store/legacy/v101" + "github.com/osmosis-labs/osmosis/v13/osmoutils/sumtree" + v101 "github.com/osmosis-labs/osmosis/v13/osmoutils/sumtree/legacy/v101" ) func setupStore() sdk.KVStore { db := dbm.NewMemDB() - tree, _ := iavl.NewMutableTree(db, 100) + tree, _ := iavl.NewMutableTree(db, 100, false) _, _, err := tree.SaveVersion() if err != nil { panic(err) @@ -35,7 +35,7 @@ func setupStore() sdk.KVStore { func compareBranch(oldValueBz []byte, valueBz []byte) (err error) { oldValue := v101.Children{} - value := store.Node{} + value := sumtree.Node{} err = json.Unmarshal(oldValueBz, &oldValue) if err != nil { return @@ -57,7 +57,7 @@ func compareBranch(oldValueBz []byte, valueBz []byte) (err error) { func compareLeaf(oldValueBz []byte, valueBz []byte) (err error) { oldValue := sdk.ZeroInt() - value := store.Leaf{} + value := sumtree.Leaf{} err = json.Unmarshal(oldValueBz, &oldValue) if err != nil { return diff --git a/store/node.go b/osmoutils/sumtree/node.go similarity index 99% rename from store/node.go rename to osmoutils/sumtree/node.go index 5f1629508ca..fd62f6f3d3c 100644 --- a/store/node.go +++ b/osmoutils/sumtree/node.go @@ -1,4 +1,4 @@ -package store +package sumtree import ( "bytes" diff --git a/store/tree.go b/osmoutils/sumtree/tree.go similarity index 99% rename from store/tree.go rename to osmoutils/sumtree/tree.go index c30d3f5243a..9db0c53cab6 100644 --- a/store/tree.go +++ b/osmoutils/sumtree/tree.go @@ -1,6 +1,6 @@ /// B+ tree implementation on KVStore -package store +package sumtree import ( "bytes" diff --git a/store/tree.pb.go b/osmoutils/sumtree/tree.pb.go similarity index 87% rename from store/tree.pb.go rename to osmoutils/sumtree/tree.pb.go index b9793006357..df4790f1cfa 100644 --- a/store/tree.pb.go +++ b/osmoutils/sumtree/tree.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/store/v1beta1/tree.proto +// source: osmosis/sumtree/v1beta1/tree.proto -package store +package sumtree import ( fmt "fmt" @@ -33,7 +33,7 @@ func (m *Node) Reset() { *m = Node{} } func (m *Node) String() string { return proto.CompactTextString(m) } func (*Node) ProtoMessage() {} func (*Node) Descriptor() ([]byte, []int) { - return fileDescriptor_72b0b7af579d13be, []int{0} + return fileDescriptor_31a1c5f55b935f78, []int{0} } func (m *Node) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,7 +78,7 @@ func (m *Child) Reset() { *m = Child{} } func (m *Child) String() string { return proto.CompactTextString(m) } func (*Child) ProtoMessage() {} func (*Child) Descriptor() ([]byte, []int) { - return fileDescriptor_72b0b7af579d13be, []int{1} + return fileDescriptor_31a1c5f55b935f78, []int{1} } func (m *Child) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -122,7 +122,7 @@ func (m *Leaf) Reset() { *m = Leaf{} } func (m *Leaf) String() string { return proto.CompactTextString(m) } func (*Leaf) ProtoMessage() {} func (*Leaf) Descriptor() ([]byte, []int) { - return fileDescriptor_72b0b7af579d13be, []int{2} + return fileDescriptor_31a1c5f55b935f78, []int{2} } func (m *Leaf) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -164,29 +164,31 @@ func init() { proto.RegisterType((*Leaf)(nil), "osmosis.store.v1beta1.Leaf") } -func init() { proto.RegisterFile("osmosis/store/v1beta1/tree.proto", fileDescriptor_72b0b7af579d13be) } - -var fileDescriptor_72b0b7af579d13be = []byte{ - // 299 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0xd1, 0x4f, 0x4b, 0xfb, 0x30, - 0x18, 0x07, 0xf0, 0xe6, 0xf7, 0xeb, 0x44, 0xe3, 0x4e, 0x65, 0x42, 0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 0x4b, 0xda, 0x2e, 0x63, 0x95, 0xdc, 0x13, 0xfd, 0xb4, 0xe2, 0x0a, 0x5f, 0x17, 0x3a, - 0xfa, 0xd1, 0xc3, 0x9f, 0x42, 0xfb, 0x86, 0xd3, 0x85, 0x73, 0x01, 0xed, 0x8c, 0xd3, 0x85, 0x19, - 0xf8, 0x57, 0x60, 0x23, 0x67, 0xf3, 0x4d, 0x8d, 0xc0, 0xb6, 0x46, 0xe0, 0xad, 0x46, 0xe0, 0xb9, - 0x41, 0xd6, 0xb6, 0x41, 0xd6, 0x4b, 0x83, 0xac, 0xbb, 0xf3, 0x6f, 0x49, 0xba, 0x3e, 0xe3, 0x8c, - 0xc6, 0xea, 0xa3, 0x20, 0xeb, 0x70, 0xd2, 0xfe, 0x49, 0x7c, 0x60, 0x9e, 0xee, 0xf2, 0x3d, 0x00, - 0x00, 0xff, 0xff, 0x9c, 0xd1, 0x5c, 0x1e, 0xab, 0x01, 0x00, 0x00, +func init() { + proto.RegisterFile("osmosis/sumtree/v1beta1/tree.proto", fileDescriptor_31a1c5f55b935f78) +} + +var fileDescriptor_31a1c5f55b935f78 = []byte{ + // 304 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x41, 0x4b, 0xc3, 0x30, + 0x1c, 0xc5, 0x1b, 0xdd, 0x44, 0xe3, 0x4e, 0x65, 0xc2, 0x18, 0x92, 0x95, 0x1e, 0xa4, 0x97, 0x25, + 0xd6, 0x21, 0xec, 0x28, 0xf3, 0x24, 0x88, 0x42, 0x8f, 0xde, 0xd2, 0x34, 0xeb, 0x82, 0x6d, 0x33, + 0x9b, 0x74, 0xe8, 0xb7, 0xf0, 0x63, 0xed, 0xb8, 0xa3, 0x78, 0x18, 0xd2, 0x7e, 0x11, 0x69, 0x5a, + 0xa7, 0x82, 0xe0, 0x29, 0xff, 0x97, 0xfc, 0x78, 0xef, 0x91, 0x3f, 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xd6, 0xa6, 0x42, 0xd6, 0x5b, 0x85, 0xac, 0x87, 0xcb, 0x1f, 0x4d, 0x5a, 0x9f, 0x71, + 0x42, 0x43, 0xf5, 0x25, 0xc8, 0xca, 0x9f, 0x98, 0xb9, 0xd0, 0x22, 0xd9, 0xed, 0x27, 0x3c, 0x30, + 0xdf, 0x38, 0xf9, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x09, 0x06, 0x72, 0xc1, 0xb9, 0x01, 0x00, 0x00, } func (m *Node) Marshal() (dAtA []byte, err error) { diff --git a/store/tree_test.go b/osmoutils/sumtree/tree_test.go similarity index 93% rename from store/tree_test.go rename to osmoutils/sumtree/tree_test.go index 71221440b2d..7e1b99b3cc1 100644 --- a/store/tree_test.go +++ b/osmoutils/sumtree/tree_test.go @@ -1,4 +1,4 @@ -package store_test +package sumtree_test import ( "bytes" @@ -15,23 +15,23 @@ import ( iavlstore "github.com/cosmos/cosmos-sdk/store/iavl" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/store" + "github.com/osmosis-labs/osmosis/v13/osmoutils/sumtree" ) type TreeTestSuite struct { suite.Suite - tree store.Tree + tree sumtree.Tree } func (suite *TreeTestSuite) SetupTest() { db := dbm.NewMemDB() - tree, err := iavl.NewMutableTree(db, 100) + tree, err := iavl.NewMutableTree(db, 100, false) suite.Require().NoError(err) _, _, err = tree.SaveVersion() suite.Require().Nil(err) kvstore := iavlstore.UnsafeNewStore(tree) - suite.tree = store.NewTree(kvstore, 10) + suite.tree = sumtree.NewTree(kvstore, 10) } func TestTreeTestSuite(t *testing.T) { diff --git a/proto/osmosis/epochs/genesis.proto b/proto/osmosis/epochs/genesis.proto index f68ed384717..f8a2754bf36 100644 --- a/proto/osmosis/epochs/genesis.proto +++ b/proto/osmosis/epochs/genesis.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/epochs/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/epochs/types"; // EpochInfo is a struct that describes the data going into // a timer defined by the x/epochs module. diff --git a/proto/osmosis/epochs/query.proto b/proto/osmosis/epochs/query.proto index 7c0daac62ee..9fde25db080 100644 --- a/proto/osmosis/epochs/query.proto +++ b/proto/osmosis/epochs/query.proto @@ -6,7 +6,7 @@ import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "osmosis/epochs/genesis.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/epochs/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/epochs/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto index b51af412e71..6ee8f13314d 100644 --- a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto +++ b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto @@ -14,7 +14,7 @@ import "google/protobuf/timestamp.proto"; import "cosmos/auth/v1beta1/auth.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer"; // Parameters for changing the weights in a balancer pool smoothly from // a start weight and end weight over a period of time. diff --git a/proto/osmosis/gamm/pool-models/balancer/tx/tx.proto b/proto/osmosis/gamm/pool-models/balancer/tx/tx.proto index 20f7209e64e..5ed0fdc070e 100644 --- a/proto/osmosis/gamm/pool-models/balancer/tx/tx.proto +++ b/proto/osmosis/gamm/pool-models/balancer/tx/tx.proto @@ -4,7 +4,7 @@ package osmosis.gamm.poolmodels.balancer.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/gamm/pool-models/balancer/balancerPool.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer"; service Msg { rpc CreateBalancerPool(MsgCreateBalancerPool) diff --git a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto index 26d5bd47989..582a37b3ec5 100644 --- a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto +++ b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto @@ -10,7 +10,7 @@ import "google/protobuf/timestamp.proto"; import "cosmos/auth/v1beta1/auth.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/stableswap"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap"; // PoolParams defined the parameters that will be managed by the pool // governance in the future. This params are not managed by the chain @@ -65,8 +65,8 @@ message Pool { ]; // for calculation amognst assets with different precisions - repeated uint64 scaling_factor = 7 - [ (gogoproto.moretags) = "yaml:\"stableswap_scaling_factor\"" ]; + repeated uint64 scaling_factors = 7 + [ (gogoproto.moretags) = "yaml:\"stableswap_scaling_factors\"" ]; // scaling_factor_controller is the address can adjust pool scaling factors string scaling_factor_controller = 8 [ (gogoproto.moretags) = "yaml:\"scaling_factor_controller\"" ]; diff --git a/proto/osmosis/gamm/pool-models/stableswap/tx.proto b/proto/osmosis/gamm/pool-models/stableswap/tx.proto index 03d8b1516e9..73a74b06255 100644 --- a/proto/osmosis/gamm/pool-models/stableswap/tx.proto +++ b/proto/osmosis/gamm/pool-models/stableswap/tx.proto @@ -5,7 +5,7 @@ import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "osmosis/gamm/pool-models/stableswap/stableswap_pool.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/stableswap"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap"; service Msg { rpc CreateStableswapPool(MsgCreateStableswapPool) diff --git a/proto/osmosis/gamm/v1beta1/genesis.proto b/proto/osmosis/gamm/v1beta1/genesis.proto index 4727db4d651..d2d71c0ee64 100644 --- a/proto/osmosis/gamm/v1beta1/genesis.proto +++ b/proto/osmosis/gamm/v1beta1/genesis.proto @@ -15,7 +15,7 @@ message Params { ]; } -option go_package = "github.com/osmosis-labs/osmosis/v12/x/gamm/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/types"; // GenesisState defines the gamm module's genesis state. message GenesisState { diff --git a/proto/osmosis/gamm/v1beta1/query.proto b/proto/osmosis/gamm/v1beta1/query.proto index 33600aa5504..9d6a521c097 100644 --- a/proto/osmosis/gamm/v1beta1/query.proto +++ b/proto/osmosis/gamm/v1beta1/query.proto @@ -10,7 +10,7 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/gamm/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/types"; service Query { rpc Pools(QueryPoolsRequest) returns (QueryPoolsResponse) { @@ -26,6 +26,13 @@ service Query { option (google.api.http).get = "/osmosis/gamm/v1beta1/total_liquidity"; } + // PoolsWithFilter allows you to query specific pools with requested + // parameters + rpc PoolsWithFilter(QueryPoolsWithFilterRequest) + returns (QueryPoolsWithFilterResponse) { + option (google.api.http).get = "/osmosis/gamm/v1beta1/filtered_pools"; + } + // Per Pool gRPC Endpoints rpc Pool(QueryPoolRequest) returns (QueryPoolResponse) { option (google.api.http).get = "/osmosis/gamm/v1beta1/pools/{pool_id}"; @@ -38,6 +45,22 @@ service Query { option (google.api.http).get = "/osmosis/gamm/v1beta1/pool_type/{pool_id}"; } + // Simulates joining pool without a swap. Returns the amount of shares you'd + // get and tokens needed to provide + rpc CalcJoinPoolNoSwapShares(QueryCalcJoinPoolNoSwapSharesRequest) + returns (QueryCalcJoinPoolNoSwapSharesResponse) {} + + rpc CalcJoinPoolShares(QueryCalcJoinPoolSharesRequest) + returns (QueryCalcJoinPoolSharesResponse) { + option (google.api.http).get = + "/osmosis/gamm/v1beta1/pools/{pool_id}/join_swap_exact_in"; + } + rpc CalcExitPoolCoinsFromShares(QueryCalcExitPoolCoinsFromSharesRequest) + returns (QueryCalcExitPoolCoinsFromSharesResponse) { + option (google.api.http).get = + "/osmosis/gamm/v1beta1/pools/{pool_id}/exit_swap_share_amount_in"; + } + rpc PoolParams(QueryPoolParamsRequest) returns (QueryPoolParamsResponse) { option (google.api.http).get = "/osmosis/gamm/v1beta1/pools/{pool_id}/params"; @@ -57,6 +80,7 @@ service Query { // SpotPrice defines a gRPC query handler that returns the spot price given // a base denomination and a quote denomination. rpc SpotPrice(QuerySpotPriceRequest) returns (QuerySpotPriceResponse) { + option deprecated = true; option (google.api.http).get = "/osmosis/gamm/v1beta1/pools/{pool_id}/prices"; } @@ -110,6 +134,41 @@ message QueryPoolTypeResponse { string pool_type = 1 [ (gogoproto.moretags) = "yaml:\"pool_type\"" ]; } +//=============================== CalcJoinPoolShares +message QueryCalcJoinPoolSharesRequest { + uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + repeated cosmos.base.v1beta1.Coin tokens_in = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false + ]; +} +message QueryCalcJoinPoolSharesResponse { + string share_out_amount = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"share_out_amount\"", + (gogoproto.nullable) = false + ]; + repeated cosmos.base.v1beta1.Coin tokens_out = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false + ]; +} + +//=============================== CalcExitPoolCoinsFromShares +message QueryCalcExitPoolCoinsFromSharesRequest { + uint64 pool_id = 1; + string share_in_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} +message QueryCalcExitPoolCoinsFromSharesResponse { + repeated cosmos.base.v1beta1.Coin tokens_out = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false + ]; +} + //=============================== PoolParams message QueryPoolParamsRequest { uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; @@ -139,10 +198,29 @@ message QueryTotalSharesResponse { (gogoproto.nullable) = false ]; } - +//=============================== CalcJoinPoolNoSwapShares +message QueryCalcJoinPoolNoSwapSharesRequest { + uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + repeated cosmos.base.v1beta1.Coin tokens_in = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false + ]; +} +message QueryCalcJoinPoolNoSwapSharesResponse { + repeated cosmos.base.v1beta1.Coin tokens_out = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"tokens_out\"", + (gogoproto.nullable) = false + ]; + string shares_out = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} // QuerySpotPriceRequest defines the gRPC request structure for a SpotPrice // query. message QuerySpotPriceRequest { + option deprecated = true; uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; string base_asset_denom = 2 [ (gogoproto.moretags) = "yaml:\"base_asset_denom\"" ]; @@ -152,15 +230,36 @@ message QuerySpotPriceRequest { reserved "withSwapFee"; } +//=============================== PoolsWithFilter + +message QueryPoolsWithFilterRequest { + repeated cosmos.base.v1beta1.Coin min_liquidity = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"min_liquidity\"", + (gogoproto.nullable) = false + ]; + string pool_type = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; +} + +message QueryPoolsWithFilterResponse { + repeated google.protobuf.Any pools = 1 + [ (cosmos_proto.accepts_interface) = "PoolI" ]; + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice // query. message QuerySpotPriceResponse { + option deprecated = true; // String of the Dec. Ex) 10.203uatom string spot_price = 1 [ (gogoproto.moretags) = "yaml:\"spot_price\"" ]; } //=============================== EstimateSwapExactAmountIn message QuerySwapExactAmountInRequest { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; string token_in = 3 [ (gogoproto.moretags) = "yaml:\"token_in\"" ]; @@ -180,6 +279,7 @@ message QuerySwapExactAmountInResponse { //=============================== EstimateSwapExactAmountOut message QuerySwapExactAmountOutRequest { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; repeated SwapAmountOutRoute routes = 3 [ diff --git a/proto/osmosis/gamm/v1beta1/tx.proto b/proto/osmosis/gamm/v1beta1/tx.proto index acaa7b8cb14..1e0c3b61d10 100644 --- a/proto/osmosis/gamm/v1beta1/tx.proto +++ b/proto/osmosis/gamm/v1beta1/tx.proto @@ -4,7 +4,7 @@ package osmosis.gamm.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/gamm/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/types"; service Msg { rpc JoinPool(MsgJoinPool) returns (MsgJoinPoolResponse); diff --git a/proto/osmosis/gamm/v2/query.proto b/proto/osmosis/gamm/v2/query.proto new file mode 100644 index 00000000000..02ec334c9cd --- /dev/null +++ b/proto/osmosis/gamm/v2/query.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; +package osmosis.gamm.v2; + +import "gogoproto/gogo.proto"; +import "osmosis/gamm/v1beta1/tx.proto"; + +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/v2types"; + +service Query { + // SpotPrice defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + rpc SpotPrice(QuerySpotPriceRequest) returns (QuerySpotPriceResponse) { + option (google.api.http).get = "/osmosis/gamm/v2/pools/{pool_id}/prices"; + } +} + +// QuerySpotPriceRequest defines the gRPC request structure for a SpotPrice +// query. +message QuerySpotPriceRequest { + uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + string base_asset_denom = 2 + [ (gogoproto.moretags) = "yaml:\"base_asset_denom\"" ]; + string quote_asset_denom = 3 + [ (gogoproto.moretags) = "yaml:\"quote_asset_denom\"" ]; +} + +// QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice +// query. +message QuerySpotPriceResponse { + // String of the Dec. Ex) 10.203uatom + string spot_price = 1 [ (gogoproto.moretags) = "yaml:\"spot_price\"" ]; +} diff --git a/proto/osmosis/ibc-rate-limit/v1beta1/params.proto b/proto/osmosis/ibc-rate-limit/v1beta1/params.proto index f905809ab28..5f66b2b3d14 100644 --- a/proto/osmosis/ibc-rate-limit/v1beta1/params.proto +++ b/proto/osmosis/ibc-rate-limit/v1beta1/params.proto @@ -3,9 +3,9 @@ package osmosis.ibcratelimit.v1beta1; import "gogoproto/gogo.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v10/x/ibc-rate-limit/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types"; -// Params defines the parameters for the ibc-rate-limiting module. +// Params defines the parameters for the ibc-rate-limit module. message Params { string contract_address = 1 [ (gogoproto.moretags) = "yaml:\"contract_address\"" ]; diff --git a/proto/osmosis/ibc-rate-limit/v1beta1/query.proto b/proto/osmosis/ibc-rate-limit/v1beta1/query.proto new file mode 100644 index 00000000000..01d2eb2ddf8 --- /dev/null +++ b/proto/osmosis/ibc-rate-limit/v1beta1/query.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +package osmosis.ibcratelimit.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "osmosis/ibc-rate-limit/v1beta1/params.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types"; + +// Query defines the gRPC querier service. +service Query { + // Params defines a gRPC query method that returns the ibc-rate-limit module's + // parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/osmosis/ibc-rate-limit/v1beta1/params"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/osmosis/incentives/gauge.proto b/proto/osmosis/incentives/gauge.proto index 63219eb01ab..39fc45deb04 100644 --- a/proto/osmosis/incentives/gauge.proto +++ b/proto/osmosis/incentives/gauge.proto @@ -7,7 +7,7 @@ import "google/protobuf/timestamp.proto"; import "cosmos/base/v1beta1/coin.proto"; import "osmosis/lockup/lock.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/incentives/types"; // Gauge is an object that stores and distributes yields to recipients who // satisfy certain conditions. Currently gauges support conditions around the diff --git a/proto/osmosis/incentives/genesis.proto b/proto/osmosis/incentives/genesis.proto index 7914fa2cf66..402970b0ab9 100644 --- a/proto/osmosis/incentives/genesis.proto +++ b/proto/osmosis/incentives/genesis.proto @@ -6,7 +6,7 @@ import "google/protobuf/duration.proto"; import "osmosis/incentives/params.proto"; import "osmosis/incentives/gauge.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/incentives/types"; // GenesisState defines the incentives module's various parameters when first // initialized diff --git a/proto/osmosis/incentives/params.proto b/proto/osmosis/incentives/params.proto index 49bc9ca5311..9056bb3646d 100644 --- a/proto/osmosis/incentives/params.proto +++ b/proto/osmosis/incentives/params.proto @@ -3,7 +3,7 @@ package osmosis.incentives; import "gogoproto/gogo.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/incentives/types"; // Params holds parameters for the incentives module message Params { diff --git a/proto/osmosis/incentives/query.proto b/proto/osmosis/incentives/query.proto index 3561b3ed7b7..d2d0e64fccb 100644 --- a/proto/osmosis/incentives/query.proto +++ b/proto/osmosis/incentives/query.proto @@ -9,7 +9,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "osmosis/incentives/gauge.proto"; import "osmosis/lockup/lock.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/incentives/types"; // Query defines the gRPC querier service service Query { diff --git a/proto/osmosis/incentives/tx.proto b/proto/osmosis/incentives/tx.proto index fcdfd9e0605..b0881650769 100644 --- a/proto/osmosis/incentives/tx.proto +++ b/proto/osmosis/incentives/tx.proto @@ -7,7 +7,7 @@ import "cosmos/base/v1beta1/coin.proto"; import "osmosis/incentives/gauge.proto"; import "osmosis/lockup/lock.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/incentives/types"; service Msg { rpc CreateGauge(MsgCreateGauge) returns (MsgCreateGaugeResponse); diff --git a/proto/osmosis/lockup/genesis.proto b/proto/osmosis/lockup/genesis.proto index 917e4042dea..ff486713c44 100644 --- a/proto/osmosis/lockup/genesis.proto +++ b/proto/osmosis/lockup/genesis.proto @@ -4,7 +4,7 @@ package osmosis.lockup; import "gogoproto/gogo.proto"; import "osmosis/lockup/lock.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/lockup/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/lockup/types"; // GenesisState defines the lockup module's genesis state. message GenesisState { diff --git a/proto/osmosis/lockup/lock.proto b/proto/osmosis/lockup/lock.proto index 87bb792e1c9..577a8d2b32f 100644 --- a/proto/osmosis/lockup/lock.proto +++ b/proto/osmosis/lockup/lock.proto @@ -6,7 +6,7 @@ import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/lockup/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/lockup/types"; // PeriodLock is a single lock unit by period defined by the x/lockup module. // It's a record of a locked coin at a specific time. It stores owner, duration, diff --git a/proto/osmosis/lockup/params.proto b/proto/osmosis/lockup/params.proto index a46f45f0980..1c66228f3fd 100644 --- a/proto/osmosis/lockup/params.proto +++ b/proto/osmosis/lockup/params.proto @@ -3,7 +3,7 @@ package osmosis.lockup; import "gogoproto/gogo.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/lockup/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/lockup/types"; message Params { repeated string force_unlock_allowed_addresses = 1 diff --git a/proto/osmosis/lockup/query.proto b/proto/osmosis/lockup/query.proto index ef83b784414..8e69afbf17f 100644 --- a/proto/osmosis/lockup/query.proto +++ b/proto/osmosis/lockup/query.proto @@ -9,7 +9,7 @@ import "google/protobuf/duration.proto"; import "osmosis/lockup/lock.proto"; import "osmosis/lockup/params.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/lockup/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/lockup/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/osmosis/lockup/tx.proto b/proto/osmosis/lockup/tx.proto index 272f8cf6e8e..9d5c0642533 100644 --- a/proto/osmosis/lockup/tx.proto +++ b/proto/osmosis/lockup/tx.proto @@ -6,7 +6,7 @@ import "google/protobuf/duration.proto"; import "cosmos/base/v1beta1/coin.proto"; import "osmosis/lockup/lock.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/lockup/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/lockup/types"; // Msg defines the Msg service. service Msg { diff --git a/proto/osmosis/mint/v1beta1/genesis.proto b/proto/osmosis/mint/v1beta1/genesis.proto index ebd40fbc88a..67534debf94 100644 --- a/proto/osmosis/mint/v1beta1/genesis.proto +++ b/proto/osmosis/mint/v1beta1/genesis.proto @@ -4,7 +4,7 @@ package osmosis.mint.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/mint/v1beta1/mint.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/mint/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/mint/types"; // GenesisState defines the mint module's genesis state. message GenesisState { diff --git a/proto/osmosis/mint/v1beta1/mint.proto b/proto/osmosis/mint/v1beta1/mint.proto index 2fec07c8649..d0a8223f4d4 100644 --- a/proto/osmosis/mint/v1beta1/mint.proto +++ b/proto/osmosis/mint/v1beta1/mint.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package osmosis.mint.v1beta1; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/mint/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/mint/types"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; diff --git a/proto/osmosis/mint/v1beta1/query.proto b/proto/osmosis/mint/v1beta1/query.proto index 5697b7b1452..9960e6efb47 100644 --- a/proto/osmosis/mint/v1beta1/query.proto +++ b/proto/osmosis/mint/v1beta1/query.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "osmosis/mint/v1beta1/mint.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/mint/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/mint/types"; // Query provides defines the gRPC querier service. service Query { diff --git a/proto/osmosis/pool-incentives/v1beta1/genesis.proto b/proto/osmosis/pool-incentives/v1beta1/genesis.proto index e0410473571..51302029170 100644 --- a/proto/osmosis/pool-incentives/v1beta1/genesis.proto +++ b/proto/osmosis/pool-incentives/v1beta1/genesis.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "osmosis/pool-incentives/v1beta1/incentives.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types"; // GenesisState defines the pool incentives module's genesis state. message GenesisState { diff --git a/proto/osmosis/pool-incentives/v1beta1/gov.proto b/proto/osmosis/pool-incentives/v1beta1/gov.proto index c69ab2a117c..d37925236d2 100644 --- a/proto/osmosis/pool-incentives/v1beta1/gov.proto +++ b/proto/osmosis/pool-incentives/v1beta1/gov.proto @@ -4,7 +4,7 @@ package osmosis.poolincentives.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/pool-incentives/v1beta1/incentives.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types"; // ReplacePoolIncentivesProposal is a gov Content type for updating the pool // incentives. If a ReplacePoolIncentivesProposal passes, the proposal’s records diff --git a/proto/osmosis/pool-incentives/v1beta1/incentives.proto b/proto/osmosis/pool-incentives/v1beta1/incentives.proto index 7693add19cf..f26183a4040 100644 --- a/proto/osmosis/pool-incentives/v1beta1/incentives.proto +++ b/proto/osmosis/pool-incentives/v1beta1/incentives.proto @@ -4,7 +4,7 @@ package osmosis.poolincentives.v1beta1; import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types"; message Params { option (gogoproto.goproto_stringer) = false; diff --git a/proto/osmosis/pool-incentives/v1beta1/query.proto b/proto/osmosis/pool-incentives/v1beta1/query.proto index 50b046314c7..3af16e93a79 100644 --- a/proto/osmosis/pool-incentives/v1beta1/query.proto +++ b/proto/osmosis/pool-incentives/v1beta1/query.proto @@ -7,7 +7,7 @@ import "google/protobuf/duration.proto"; import "osmosis/incentives/gauge.proto"; import "osmosis/pool-incentives/v1beta1/incentives.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types"; service Query { // GaugeIds takes the pool id and returns the matching gauge ids and durations diff --git a/proto/osmosis/store/v1beta1/tree.proto b/proto/osmosis/sumtree/v1beta1/tree.proto similarity index 83% rename from proto/osmosis/store/v1beta1/tree.proto rename to proto/osmosis/sumtree/v1beta1/tree.proto index 3373406fe49..ff9a1f327c6 100644 --- a/proto/osmosis/store/v1beta1/tree.proto +++ b/proto/osmosis/sumtree/v1beta1/tree.proto @@ -4,7 +4,7 @@ package osmosis.store.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/store"; +option go_package = "github.com/osmosis-labs/osmosis/v13/osmoutils/sumtree"; message Node { repeated Child children = 1; } diff --git a/proto/osmosis/superfluid/genesis.proto b/proto/osmosis/superfluid/genesis.proto index 64440921714..a068d0ff913 100644 --- a/proto/osmosis/superfluid/genesis.proto +++ b/proto/osmosis/superfluid/genesis.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "osmosis/superfluid/superfluid.proto"; import "osmosis/superfluid/params.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/superfluid/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/superfluid/types"; // GenesisState defines the module's genesis state. message GenesisState { diff --git a/proto/osmosis/superfluid/params.proto b/proto/osmosis/superfluid/params.proto index 07d40a56410..754f6a7e8f4 100644 --- a/proto/osmosis/superfluid/params.proto +++ b/proto/osmosis/superfluid/params.proto @@ -4,7 +4,7 @@ package osmosis.superfluid; import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/superfluid/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/superfluid/types"; // Params holds parameters for the superfluid module message Params { diff --git a/proto/osmosis/superfluid/query.proto b/proto/osmosis/superfluid/query.proto index 5470eba8850..71f80d6296a 100644 --- a/proto/osmosis/superfluid/query.proto +++ b/proto/osmosis/superfluid/query.proto @@ -12,7 +12,7 @@ import "osmosis/lockup/lock.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "cosmos/staking/v1beta1/staking.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/superfluid/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/superfluid/types"; // Query defines the gRPC querier service. service Query { @@ -53,6 +53,11 @@ service Query { "/osmosis/superfluid/v1beta1/connected_intermediary_account/{lock_id}"; } + // Returns the amount of delegations of specific denom for all validators + rpc TotalDelegationByValidatorForDenom( + QueryTotalDelegationByValidatorForDenomRequest) + returns (QueryTotalDelegationByValidatorForDenomResponse) {} + // Returns the total amount of osmo superfluidly staked. // Response is denominated in uosmo. rpc TotalSuperfluidDelegations(TotalSuperfluidDelegationsRequest) @@ -112,6 +117,13 @@ service Query { "/osmosis/superfluid/v1beta1/" "total_delegation_by_delegator/{delegator_address}"; } + + // Returns a list of whitelisted pool ids to unpool. + rpc UnpoolWhitelist(QueryUnpoolWhitelistRequest) + returns (QueryUnpoolWhitelistResponse) { + option (google.api.http).get = "/osmosis/superfluid/v1beta1/" + "unpool_whitelist"; + } } message QueryParamsRequest {} @@ -153,6 +165,24 @@ message ConnectedIntermediaryAccountResponse { SuperfluidIntermediaryAccountInfo account = 1; } +message QueryTotalDelegationByValidatorForDenomRequest { string denom = 1; } +message QueryTotalDelegationByValidatorForDenomResponse { + repeated Delegations assets = 1 [ (gogoproto.nullable) = false ]; +} + +message Delegations { + string val_addr = 1; + string amount_sfsd = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"amount_sfsd\"", + (gogoproto.nullable) = false + ]; + string osmo_equivalent = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"osmo_equivalent\"", + (gogoproto.nullable) = false + ]; +} message TotalSuperfluidDelegationsRequest {} message TotalSuperfluidDelegationsResponse { @@ -247,4 +277,8 @@ message QueryTotalDelegationByDelegatorResponse { (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" ]; -} \ No newline at end of file +} + +message QueryUnpoolWhitelistRequest {} + +message QueryUnpoolWhitelistResponse { repeated uint64 pool_ids = 1; } diff --git a/proto/osmosis/superfluid/superfluid.proto b/proto/osmosis/superfluid/superfluid.proto index d1562942e9a..fdf8d5a197e 100644 --- a/proto/osmosis/superfluid/superfluid.proto +++ b/proto/osmosis/superfluid/superfluid.proto @@ -6,7 +6,7 @@ import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/superfluid/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/superfluid/types"; // SuperfluidAssetType indicates whether the superfluid asset is // a native token itself or the lp share of a pool. diff --git a/proto/osmosis/superfluid/tx.proto b/proto/osmosis/superfluid/tx.proto index 88ad3da0150..67b4a915150 100644 --- a/proto/osmosis/superfluid/tx.proto +++ b/proto/osmosis/superfluid/tx.proto @@ -6,7 +6,7 @@ import "google/protobuf/duration.proto"; import "cosmos/base/v1beta1/coin.proto"; import "osmosis/superfluid/superfluid.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/superfluid/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/superfluid/types"; // Msg defines the Msg service. service Msg { diff --git a/proto/osmosis/superfluid/v1beta1/gov.proto b/proto/osmosis/superfluid/v1beta1/gov.proto index 7dd8df1dbc5..dea2dc8732c 100644 --- a/proto/osmosis/superfluid/v1beta1/gov.proto +++ b/proto/osmosis/superfluid/v1beta1/gov.proto @@ -4,7 +4,7 @@ package osmosis.superfluid.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/superfluid/superfluid.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/superfluid/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/superfluid/types"; // SetSuperfluidAssetsProposal is a gov Content type to update the superfluid // assets @@ -29,3 +29,16 @@ message RemoveSuperfluidAssetsProposal { string description = 2; repeated string superfluid_asset_denoms = 3; } + +// UpdateUnpoolWhiteListProposal is a gov Content type to update the +// allowed list of pool ids. +message UpdateUnpoolWhiteListProposal { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + repeated uint64 ids = 3; + bool is_overwrite = 4; +} diff --git a/proto/osmosis/swaprouter/v1beta1/genesis.proto b/proto/osmosis/swaprouter/v1beta1/genesis.proto new file mode 100644 index 00000000000..1fa396ff77e --- /dev/null +++ b/proto/osmosis/swaprouter/v1beta1/genesis.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +package osmosis.swaprouter.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/duration.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"; + +// Params holds parameters for the swaprouter module +message Params { + repeated cosmos.base.v1beta1.Coin pool_creation_fee = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"pool_creation_fee\"", + (gogoproto.nullable) = false + ]; +} + +// GenesisState defines the swaprouter module's genesis state. +message GenesisState { + // the next_pool_id + uint64 next_pool_id = 1; + // params is the container of swaprouter parameters. + Params params = 2 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/osmosis/swaprouter/v1beta1/module_route.proto b/proto/osmosis/swaprouter/v1beta1/module_route.proto new file mode 100644 index 00000000000..76817f53246 --- /dev/null +++ b/proto/osmosis/swaprouter/v1beta1/module_route.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package osmosis.swaprouter.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"; + +// PoolType is an enumeration of all supported pool types. +enum PoolType { + option (gogoproto.goproto_enum_prefix) = false; + + // Balancer is the standard xy=k curve. Its pool model is defined in x/gamm. + Balancer = 0; + // Stableswap is the Solidly cfmm stable swap curve. Its pool model is defined + // in x/gamm. + StableSwap = 1; + // Concentrated is the pool model specific to concentrated liquidity. It is + // defined in x/concentrated-liquidity. + Concentrated = 2; +} + +// ModuleRouter defines a route encapsulating pool type. +// It is used as the value of a mapping from pool id to the pool type, +// allowing the swap router to know which module to route swaps to given the +// pool id. +message ModuleRoute { + // pool_type specifies the type of the pool + PoolType pool_type = 1; +} diff --git a/proto/osmosis/swaprouter/v1beta1/query.proto b/proto/osmosis/swaprouter/v1beta1/query.proto new file mode 100644 index 00000000000..18cfa1b913f --- /dev/null +++ b/proto/osmosis/swaprouter/v1beta1/query.proto @@ -0,0 +1,90 @@ +syntax = "proto3"; +package osmosis.swaprouter.v1beta1; + +import "gogoproto/gogo.proto"; +import "osmosis/swaprouter/v1beta1/genesis.proto"; +import "osmosis/swaprouter/v1beta1/tx.proto"; +import "osmosis/swaprouter/v1beta1/swap_route.proto"; + +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto"; + +service Query { + rpc Params(ParamsRequest) returns (ParamsResponse) { + option (google.api.http).get = "/osmosis/swaprouter/v1beta1/Params"; + } + + // Estimates swap amount out given in. + rpc EstimateSwapExactAmountIn(EstimateSwapExactAmountInRequest) + returns (EstimateSwapExactAmountInResponse) { + option (google.api.http).get = + "/osmosis/gamm/v1beta1/{pool_id}/estimate/swap_exact_amount_in"; + } + + // Estimates swap amount in given out. + rpc EstimateSwapExactAmountOut(EstimateSwapExactAmountOutRequest) + returns (EstimateSwapExactAmountOutResponse) { + option (google.api.http).get = + "/osmosis/gamm/v1beta1/{pool_id}/estimate/swap_exact_amount_out"; + } + + rpc NumPools(NumPoolsRequest) returns (NumPoolsResponse) { + option (google.api.http).get = "/osmosis/swaprouter/v1beta1/num_pools"; + } +} + +//=============================== Params +message ParamsRequest {} +message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; } + +//=============================== EstimateSwapExactAmountIn +message EstimateSwapExactAmountInRequest { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + string token_in = 3 [ (gogoproto.moretags) = "yaml:\"token_in\"" ]; + repeated SwapAmountInRoute routes = 4 [ + (gogoproto.moretags) = "yaml:\"routes\"", + (gogoproto.nullable) = false + ]; +} + +message EstimateSwapExactAmountInResponse { + string token_out_amount = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_out_amount\"", + (gogoproto.nullable) = false + ]; +} + +//=============================== EstimateSwapExactAmountOut +message EstimateSwapExactAmountOutRequest { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + repeated SwapAmountOutRoute routes = 3 [ + (gogoproto.moretags) = "yaml:\"routes\"", + (gogoproto.nullable) = false + ]; + string token_out = 4 [ (gogoproto.moretags) = "yaml:\"token_out\"" ]; +} + +message EstimateSwapExactAmountOutResponse { + string token_in_amount = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_in_amount\"", + (gogoproto.nullable) = false + ]; +} + +//=============================== NumPools +message NumPoolsRequest {} +message NumPoolsResponse { + uint64 num_pools = 1 [ (gogoproto.moretags) = "yaml:\"num_pools\"" ]; +} diff --git a/proto/osmosis/swaprouter/v1beta1/query.yml b/proto/osmosis/swaprouter/v1beta1/query.yml new file mode 100644 index 00000000000..49a084ab39b --- /dev/null +++ b/proto/osmosis/swaprouter/v1beta1/query.yml @@ -0,0 +1,25 @@ +keeper: + path: "github.com/osmosis-labs/osmosis/v13/x/swaprouter" + struct: "Keeper" +client_path: "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client" +queries: + Params: + proto_wrapper: + query_func: "k.GetParams" + cli: + cmd: "GetParams" + EstimateSwapExactAmountIn: + proto_wrapper: + query_func: "k.EstimateSwapExactAmountIn" + cli: + cmd: "EstimateSwapExactAmountIn" + EstimateSwapExactAmountOut: + proto_wrapper: + query_func: "k.EstimateSwapExactAmountOut" + cli: + cmd: "EstimateSwapExactAmountOut" + NumPools: + proto_wrapper: + query_func: "k.NumPools" + cli: + cmd: "NumPools" diff --git a/proto/osmosis/swaprouter/v1beta1/swap_route.proto b/proto/osmosis/swaprouter/v1beta1/swap_route.proto new file mode 100644 index 00000000000..376a740ee10 --- /dev/null +++ b/proto/osmosis/swaprouter/v1beta1/swap_route.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package osmosis.swaprouter.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"; + +message SwapAmountInRoute { + uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + string token_out_denom = 2 + [ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ]; +} + +message SwapAmountOutRoute { + uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + string token_in_denom = 2 + [ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ]; +} diff --git a/proto/osmosis/swaprouter/v1beta1/tx.proto b/proto/osmosis/swaprouter/v1beta1/tx.proto new file mode 100644 index 00000000000..b6e7790dd01 --- /dev/null +++ b/proto/osmosis/swaprouter/v1beta1/tx.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; +package osmosis.swaprouter.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "osmosis/swaprouter/v1beta1/swap_route.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"; + +service Msg { + rpc SwapExactAmountIn(MsgSwapExactAmountIn) + returns (MsgSwapExactAmountInResponse); + rpc SwapExactAmountOut(MsgSwapExactAmountOut) + returns (MsgSwapExactAmountOutResponse); +} + +// ===================== MsgSwapExactAmountIn +message MsgSwapExactAmountIn { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + repeated SwapAmountInRoute routes = 2 [ (gogoproto.nullable) = false ]; + cosmos.base.v1beta1.Coin token_in = 3 [ + (gogoproto.moretags) = "yaml:\"token_in\"", + (gogoproto.nullable) = false + ]; + string token_out_min_amount = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_out_min_amount\"", + (gogoproto.nullable) = false + ]; +} + +message MsgSwapExactAmountInResponse { + string token_out_amount = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_out_amount\"", + (gogoproto.nullable) = false + ]; +} + +// ===================== MsgSwapExactAmountOut +message MsgSwapExactAmountOut { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + repeated SwapAmountOutRoute routes = 2 [ (gogoproto.nullable) = false ]; + string token_in_max_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_in_max_amount\"", + (gogoproto.nullable) = false + ]; + cosmos.base.v1beta1.Coin token_out = 4 [ + (gogoproto.moretags) = "yaml:\"token_out\"", + (gogoproto.nullable) = false + ]; +} + +message MsgSwapExactAmountOutResponse { + string token_in_amount = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_in_amount\"", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto index c73590b3423..cc58a6d5357 100644 --- a/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto +++ b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto @@ -4,7 +4,7 @@ package osmosis.tokenfactory.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types"; // DenomAuthorityMetadata specifies metadata for addresses that have specific // capabilities over a token factory denom. Right now there is only one Admin diff --git a/proto/osmosis/tokenfactory/v1beta1/genesis.proto b/proto/osmosis/tokenfactory/v1beta1/genesis.proto index 2c594cc1d22..e8c2c7c2084 100644 --- a/proto/osmosis/tokenfactory/v1beta1/genesis.proto +++ b/proto/osmosis/tokenfactory/v1beta1/genesis.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto"; import "osmosis/tokenfactory/v1beta1/params.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types"; // GenesisState defines the tokenfactory module's genesis state. message GenesisState { diff --git a/proto/osmosis/tokenfactory/v1beta1/params.proto b/proto/osmosis/tokenfactory/v1beta1/params.proto index 47e0441280a..7e14273d99c 100644 --- a/proto/osmosis/tokenfactory/v1beta1/params.proto +++ b/proto/osmosis/tokenfactory/v1beta1/params.proto @@ -6,7 +6,7 @@ import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types"; // Params defines the parameters for the tokenfactory module. message Params { diff --git a/proto/osmosis/tokenfactory/v1beta1/query.proto b/proto/osmosis/tokenfactory/v1beta1/query.proto index ffa7f550132..7b347161faa 100644 --- a/proto/osmosis/tokenfactory/v1beta1/query.proto +++ b/proto/osmosis/tokenfactory/v1beta1/query.proto @@ -7,7 +7,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto"; import "osmosis/tokenfactory/v1beta1/params.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/osmosis/tokenfactory/v1beta1/tx.proto b/proto/osmosis/tokenfactory/v1beta1/tx.proto index bc7d753bbda..938b1fa9e78 100644 --- a/proto/osmosis/tokenfactory/v1beta1/tx.proto +++ b/proto/osmosis/tokenfactory/v1beta1/tx.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; import "cosmos/bank/v1beta1/bank.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types"; // Msg defines the tokefactory module's gRPC message service. service Msg { diff --git a/proto/osmosis/twap/v1beta1/genesis.proto b/proto/osmosis/twap/v1beta1/genesis.proto index d1833ad60e9..e9c377b0e8b 100644 --- a/proto/osmosis/twap/v1beta1/genesis.proto +++ b/proto/osmosis/twap/v1beta1/genesis.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; import "google/protobuf/duration.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/twap/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/twap/types"; // Params holds parameters for the twap module message Params { diff --git a/proto/osmosis/twap/v1beta1/query.proto b/proto/osmosis/twap/v1beta1/query.proto index 0a10d4bdde8..37fef29c2a8 100644 --- a/proto/osmosis/twap/v1beta1/query.proto +++ b/proto/osmosis/twap/v1beta1/query.proto @@ -12,7 +12,7 @@ import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto"; service Query { rpc Params(ParamsRequest) returns (ParamsResponse) { @@ -23,6 +23,7 @@ service Query { } rpc ArithmeticTwapToNow(ArithmeticTwapToNowRequest) returns (ArithmeticTwapToNowResponse) { + option deprecated = true; option (google.api.http).get = "/osmosis/twap/v1beta1/ArithmeticTwapToNow"; } } diff --git a/proto/osmosis/twap/v1beta1/query.yml b/proto/osmosis/twap/v1beta1/query.yml index 57e514ea6ea..6763392aaaf 100644 --- a/proto/osmosis/twap/v1beta1/query.yml +++ b/proto/osmosis/twap/v1beta1/query.yml @@ -1,7 +1,7 @@ keeper: - path: "github.com/osmosis-labs/osmosis/v12/x/twap" + path: "github.com/osmosis-labs/osmosis/v13/x/twap" struct: "Keeper" -client_path: "github.com/osmosis-labs/osmosis/v12/x/twap/client" +client_path: "github.com/osmosis-labs/osmosis/v13/x/twap/client" queries: ArithmeticTwap: proto_wrapper: diff --git a/proto/osmosis/twap/v1beta1/twap_record.proto b/proto/osmosis/twap/v1beta1/twap_record.proto index d8f1998302b..a57ae9678f1 100644 --- a/proto/osmosis/twap/v1beta1/twap_record.proto +++ b/proto/osmosis/twap/v1beta1/twap_record.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/twap/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/twap/types"; // A TWAP record should be indexed in state by pool_id, (asset pair), timestamp // The asset pair assets should be lexicographically sorted. @@ -54,9 +54,11 @@ message TwapRecord { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - // string geometric_twap_accumulator = 7 [(gogoproto.customtype) = - // "github.com/cosmos/cosmos-sdk/types.Dec", - // (gogoproto.nullable) = false]; + + string geometric_twap_accumulator = 10 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // This field contains the time in which the last spot price error occured. // It is used to alert the caller if they are getting a potentially erroneous diff --git a/proto/osmosis/txfees/v1beta1/feetoken.proto b/proto/osmosis/txfees/v1beta1/feetoken.proto index da948a9418b..3b18f58fabd 100644 --- a/proto/osmosis/txfees/v1beta1/feetoken.proto +++ b/proto/osmosis/txfees/v1beta1/feetoken.proto @@ -3,7 +3,7 @@ package osmosis.txfees.v1beta1; import "gogoproto/gogo.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/txfees/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/txfees/types"; // FeeToken is a struct that specifies a coin denom, and pool ID pair. // This marks the token as eligible for use as a tx fee asset in Osmosis. diff --git a/proto/osmosis/txfees/v1beta1/genesis.proto b/proto/osmosis/txfees/v1beta1/genesis.proto index 820fb872eef..4ac7a282da5 100644 --- a/proto/osmosis/txfees/v1beta1/genesis.proto +++ b/proto/osmosis/txfees/v1beta1/genesis.proto @@ -4,7 +4,7 @@ package osmosis.txfees.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/txfees/v1beta1/feetoken.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/txfees/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/txfees/types"; // GenesisState defines the txfees module's genesis state. message GenesisState { diff --git a/proto/osmosis/txfees/v1beta1/gov.proto b/proto/osmosis/txfees/v1beta1/gov.proto index 69cbbb06c6f..16ab174133c 100644 --- a/proto/osmosis/txfees/v1beta1/gov.proto +++ b/proto/osmosis/txfees/v1beta1/gov.proto @@ -4,7 +4,7 @@ package osmosis.txfees.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/txfees/v1beta1/feetoken.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/txfees/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/txfees/types"; // UpdateFeeTokenProposal is a gov Content type for adding a new whitelisted fee // token. It must specify a denom along with gamm pool ID to use as a spot price diff --git a/proto/osmosis/txfees/v1beta1/query.proto b/proto/osmosis/txfees/v1beta1/query.proto index 4a887abc278..395eb113dcf 100644 --- a/proto/osmosis/txfees/v1beta1/query.proto +++ b/proto/osmosis/txfees/v1beta1/query.proto @@ -7,7 +7,7 @@ import "google/protobuf/duration.proto"; import "osmosis/txfees/v1beta1/feetoken.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/txfees/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/txfees/types"; service Query { // FeeTokens returns a list of all the whitelisted fee tokens and their diff --git a/proto/osmosis/validator-preference/v1beta1/query.proto b/proto/osmosis/valset-pref/v1beta1/query.proto similarity index 68% rename from proto/osmosis/validator-preference/v1beta1/query.proto rename to proto/osmosis/valset-pref/v1beta1/query.proto index 9a6d666c8e4..af4883dc837 100644 --- a/proto/osmosis/validator-preference/v1beta1/query.proto +++ b/proto/osmosis/valset-pref/v1beta1/query.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package osmosis.validatorpreference.v1beta1; +package osmosis.valsetpref.v1beta1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "osmosis/validator-preference/v1beta1/state.proto"; +import "osmosis/valset-pref/v1beta1/state.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/validator-preference/client/queryproto"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/valset-pref/client/queryproto"; option (gogoproto.goproto_getters_all) = false; // Query defines the gRPC querier service. @@ -13,15 +13,14 @@ service Query { // Returns the list of ValidatorPreferences for the user. rpc UserValidatorPreferences(QueryUserValidatorPreferences) returns (QueryUserValidatorPreferenceResponse) { - option (google.api.http).get = - "/osmosis/validator-preference/v1beta1/{user}"; + option (google.api.http).get = "/osmosis/valset-pref/v1beta1/{address}"; } } // Request type for UserValidatorPreferences. message QueryUserValidatorPreferences { // user account address - string user = 1; + string address = 1; } // Response type the QueryUserValidatorPreferences query request diff --git a/proto/osmosis/validator-preference/v1beta1/state.proto b/proto/osmosis/valset-pref/v1beta1/state.proto similarity index 90% rename from proto/osmosis/validator-preference/v1beta1/state.proto rename to proto/osmosis/valset-pref/v1beta1/state.proto index cbfcf56a34d..75ea2642ac8 100644 --- a/proto/osmosis/validator-preference/v1beta1/state.proto +++ b/proto/osmosis/valset-pref/v1beta1/state.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package osmosis.validatorpreference.v1beta1; +package osmosis.valsetpref.v1beta1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/validator-preference/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types"; option (gogoproto.goproto_getters_all) = false; // ValidatorPreference defines the message structure for diff --git a/proto/osmosis/validator-preference/v1beta1/tx.proto b/proto/osmosis/valset-pref/v1beta1/tx.proto similarity index 92% rename from proto/osmosis/validator-preference/v1beta1/tx.proto rename to proto/osmosis/valset-pref/v1beta1/tx.proto index 00967e38c9a..4ccc687c628 100644 --- a/proto/osmosis/validator-preference/v1beta1/tx.proto +++ b/proto/osmosis/valset-pref/v1beta1/tx.proto @@ -1,13 +1,13 @@ syntax = "proto3"; -package osmosis.validatorpreference.v1beta1; +package osmosis.valsetpref.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -import "osmosis/validator-preference/v1beta1/state.proto"; +import "osmosis/valset-pref/v1beta1/state.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v12/x/validator-preference/types"; +option go_package = "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types"; -// Msg defines the validator-preference modules's gRPC message service. +// Msg defines the valset-pref modules's gRPC message service. service Msg { // SetValidatorSetPreference creates a set of validator preference. // This message will process both create + update request. diff --git a/scripts/multinode-local-testnet.sh b/scripts/multinode-local-testnet.sh index 2fd5bb67486..d7731b8f6ae 100755 --- a/scripts/multinode-local-testnet.sh +++ b/scripts/multinode-local-testnet.sh @@ -1,6 +1,9 @@ #!/bin/bash -rm -rf $HOME/.osmosisd/ +set -e +# always returns true so set -e doesn't exit if it is not running. +killall osmosisd || true +rm -rf $HOME/.osmosisd/ # make four osmosis directories mkdir $HOME/.osmosisd @@ -17,8 +20,12 @@ osmosisd keys add validator1 --keyring-backend=test --home=$HOME/.osmosisd/valid osmosisd keys add validator2 --keyring-backend=test --home=$HOME/.osmosisd/validator2 osmosisd keys add validator3 --keyring-backend=test --home=$HOME/.osmosisd/validator3 +update_genesis () { + cat $HOME/.osmosisd/validator1/config/genesis.json | jq "$1" > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +} + # change staking denom to uosmo -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="uosmo"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["staking"]["params"]["bond_denom"]="uosmo"' # create validator node with tokens to transfer to the three other nodes osmosisd add-genesis-account $(osmosisd keys show validator1 -a --keyring-backend=test --home=$HOME/.osmosisd/validator1) 100000000000uosmo,100000000000stake --home=$HOME/.osmosisd/validator1 @@ -27,75 +34,79 @@ osmosisd collect-gentxs --home=$HOME/.osmosisd/validator1 # update staking genesis -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["staking"]["params"]["unbonding_time"]="240s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["staking"]["params"]["unbonding_time"]="240s"' # update crisis variable to uosmo -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="uosmo"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["crisis"]["constant_fee"]["denom"]="uosmo"' # udpate gov genesis -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="60s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uosmo"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["gov"]["voting_params"]["voting_period"]="60s"' +update_genesis '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uosmo"' # update epochs genesis -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["epochs"]["epochs"][1]["duration"]="60s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["epochs"]["epochs"][1]["duration"]="60s"' # update poolincentives genesis -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][0]="120s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][1]="180s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][2]="240s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["poolincentives"]["params"]["minted_denom"]="uosmo"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["poolincentives"]["lockable_durations"][0]="120s"' +update_genesis '.app_state["poolincentives"]["lockable_durations"][1]="180s"' +update_genesis '.app_state["poolincentives"]["lockable_durations"][2]="240s"' +update_genesis '.app_state["poolincentives"]["params"]["minted_denom"]="uosmo"' # update incentives genesis -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][0]="1s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][1]="120s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][2]="180s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][3]="240s"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["incentives"]["params"]["distr_epoch_identifier"]="day"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["incentives"]["lockable_durations"][0]="1s"' +update_genesis '.app_state["incentives"]["lockable_durations"][1]="120s"' +update_genesis '.app_state["incentives"]["lockable_durations"][2]="180s"' +update_genesis '.app_state["incentives"]["lockable_durations"][3]="240s"' +update_genesis '.app_state["incentives"]["params"]["distr_epoch_identifier"]="day"' # update mint genesis -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uosmo"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["mint"]["params"]["epoch_identifier"]="day"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["mint"]["params"]["mint_denom"]="uosmo"' +update_genesis '.app_state["mint"]["params"]["epoch_identifier"]="day"' # update gamm genesis -cat $HOME/.osmosisd/validator1/config/genesis.json | jq '.app_state["gamm"]["params"]["pool_creation_fee"][0]["denom"]="uosmo"' > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +update_genesis '.app_state["gamm"]["params"]["pool_creation_fee"][0]["denom"]="uosmo"' # port key (validator1 uses default ports) # validator1 1317, 9090, 9091, 26658, 26657, 26656, 6060 # validator2 1316, 9088, 9089, 26655, 26654, 26653, 6061 # validator3 1315, 9086, 9087, 26652, 26651, 26650, 6062 -# validator4 1314, 9084, 9085, 26649, 26648, 26647, 6063 # change app.toml values +VALIDATOR2_APP_TOML=$HOME/.osmosisd/validator2/config/app.toml +VALIDATOR3_APP_TOML=$HOME/.osmosisd/validator3/config/app.toml # validator2 -sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1316|g' $HOME/.osmosisd/validator2/config/app.toml -sed -i -E 's|0.0.0.0:9090|0.0.0.0:9088|g' $HOME/.osmosisd/validator2/config/app.toml -sed -i -E 's|0.0.0.0:9091|0.0.0.0:9089|g' $HOME/.osmosisd/validator2/config/app.toml +sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1316|g' $VALIDATOR2_APP_TOML +sed -i -E 's|0.0.0.0:9090|0.0.0.0:9088|g' $VALIDATOR2_APP_TOML +sed -i -E 's|0.0.0.0:9091|0.0.0.0:9089|g' $VALIDATOR2_APP_TOML # validator3 -sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1315|g' $HOME/.osmosisd/validator3/config/app.toml -sed -i -E 's|0.0.0.0:9090|0.0.0.0:9086|g' $HOME/.osmosisd/validator3/config/app.toml -sed -i -E 's|0.0.0.0:9091|0.0.0.0:9087|g' $HOME/.osmosisd/validator3/config/app.toml +sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1315|g' $VALIDATOR3_APP_TOML +sed -i -E 's|0.0.0.0:9090|0.0.0.0:9086|g' $VALIDATOR3_APP_TOML +sed -i -E 's|0.0.0.0:9091|0.0.0.0:9087|g' $VALIDATOR3_APP_TOML # change config.toml values +VALIDATOR1_CONFIG=$HOME/.osmosisd/validator1/config/config.toml +VALIDATOR2_CONFIG=$HOME/.osmosisd/validator2/config/config.toml +VALIDATOR3_CONFIG=$HOME/.osmosisd/validator3/config/config.toml # validator1 -sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $HOME/.osmosisd/validator1/config/config.toml +sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR1_CONFIG # validator2 -sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26655|g' $HOME/.osmosisd/validator2/config/config.toml -sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26654|g' $HOME/.osmosisd/validator2/config/config.toml -sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26653|g' $HOME/.osmosisd/validator2/config/config.toml -sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $HOME/.osmosisd/validator3/config/config.toml -sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $HOME/.osmosisd/validator2/config/config.toml +sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26655|g' $VALIDATOR2_CONFIG +sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26654|g' $VALIDATOR2_CONFIG +sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26653|g' $VALIDATOR2_CONFIG +sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $VALIDATOR2_CONFIG +sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR2_CONFIG # validator3 -sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26652|g' $HOME/.osmosisd/validator3/config/config.toml -sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26651|g' $HOME/.osmosisd/validator3/config/config.toml -sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $HOME/.osmosisd/validator3/config/config.toml -sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $HOME/.osmosisd/validator3/config/config.toml -sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $HOME/.osmosisd/validator3/config/config.toml +sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26652|g' $VALIDATOR3_CONFIG +sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26651|g' $VALIDATOR3_CONFIG +sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $VALIDATOR3_CONFIG +sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $VALIDATOR3_CONFIG +sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR3_CONFIG # copy validator1 genesis file to validator2-3 @@ -104,8 +115,8 @@ cp $HOME/.osmosisd/validator1/config/genesis.json $HOME/.osmosisd/validator3/con # copy tendermint node id of validator1 to persistent peers of validator2-3 -sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$(osmosisd tendermint show-node-id --home=$HOME/.osmosisd/validator1)@$(curl -4 icanhazip.com):26656\"|g" $HOME/.osmosisd/validator2/config/config.toml -sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$(osmosisd tendermint show-node-id --home=$HOME/.osmosisd/validator1)@$(curl -4 icanhazip.com):26656\"|g" $HOME/.osmosisd/validator3/config/config.toml +sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$(osmosisd tendermint show-node-id --home=$HOME/.osmosisd/validator1)@localhost:26656\"|g" $HOME/.osmosisd/validator2/config/config.toml +sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$(osmosisd tendermint show-node-id --home=$HOME/.osmosisd/validator1)@localhost:26656\"|g" $HOME/.osmosisd/validator3/config/config.toml # start all three validators @@ -115,13 +126,13 @@ tmux new -s validator3 -d osmosisd start --home=$HOME/.osmosisd/validator3 # send uosmo from first validator to second validator +echo "Waiting 7 seconds to send funds to validators 2 and 3..." sleep 7 -osmosisd tx bank send validator1 $(osmosisd keys show validator2 -a --keyring-backend=test --home=$HOME/.osmosisd/validator2) 500000000uosmo --keyring-backend=test --home=$HOME/.osmosisd/validator1 --chain-id=testing --yes -sleep 7 -osmosisd tx bank send validator1 $(osmosisd keys show validator3 -a --keyring-backend=test --home=$HOME/.osmosisd/validator3) 400000000uosmo --keyring-backend=test --home=$HOME/.osmosisd/validator1 --chain-id=testing --yes +osmosisd tx bank send validator1 $(osmosisd keys show validator2 -a --keyring-backend=test --home=$HOME/.osmosisd/validator2) 500000000uosmo --keyring-backend=test --home=$HOME/.osmosisd/validator1 --chain-id=testing --broadcast-mode block --node http://localhost:26657 --yes +osmosisd tx bank send validator1 $(osmosisd keys show validator3 -a --keyring-backend=test --home=$HOME/.osmosisd/validator3) 400000000uosmo --keyring-backend=test --home=$HOME/.osmosisd/validator1 --chain-id=testing --broadcast-mode block --node http://localhost:26657 --yes -# create second validator -sleep 7 -osmosisd tx staking create-validator --amount=500000000uosmo --from=validator2 --pubkey=$(osmosisd tendermint show-validator --home=$HOME/.osmosisd/validator2) --moniker="validator2" --chain-id="testing" --commission-rate="0.1" --commission-max-rate="0.2" --commission-max-change-rate="0.05" --min-self-delegation="500000000" --keyring-backend=test --home=$HOME/.osmosisd/validator2 --yes -sleep 7 -osmosisd tx staking create-validator --amount=400000000uosmo --from=validator3 --pubkey=$(osmosisd tendermint show-validator --home=$HOME/.osmosisd/validator3) --moniker="validator3" --chain-id="testing" --commission-rate="0.1" --commission-max-rate="0.2" --commission-max-change-rate="0.05" --min-self-delegation="400000000" --keyring-backend=test --home=$HOME/.osmosisd/validator3 --yes +# create second & third validator +osmosisd tx staking create-validator --amount=500000000uosmo --from=validator2 --pubkey=$(osmosisd tendermint show-validator --home=$HOME/.osmosisd/validator2) --moniker="validator2" --chain-id="testing" --commission-rate="0.1" --commission-max-rate="0.2" --commission-max-change-rate="0.05" --min-self-delegation="500000000" --keyring-backend=test --home=$HOME/.osmosisd/validator2 --broadcast-mode block --node http://localhost:26657 --yes +osmosisd tx staking create-validator --amount=400000000uosmo --from=validator3 --pubkey=$(osmosisd tendermint show-validator --home=$HOME/.osmosisd/validator3) --moniker="validator3" --chain-id="testing" --commission-rate="0.1" --commission-max-rate="0.2" --commission-max-change-rate="0.05" --min-self-delegation="400000000" --keyring-backend=test --home=$HOME/.osmosisd/validator3 --broadcast-mode block --node http://localhost:26657 --yes + +echo "All 3 Validators are up and running!" \ No newline at end of file diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 077606e90cc..9b17c63409e 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -24,7 +24,7 @@ cd .. # move proto files to the right places # # Note: Proto files are suffixed with the current binary version. -cp -r github.com/osmosis-labs/osmosis/v12/* ./ +cp -r github.com/osmosis-labs/osmosis/v13/* ./ rm -rf github.com go mod tidy -compat=1.18 diff --git a/scripts/replace_import_paths.sh b/scripts/replace_import_paths.sh index 36c9e932849..e5763421b82 100755 --- a/scripts/replace_import_paths.sh +++ b/scripts/replace_import_paths.sh @@ -23,7 +23,9 @@ files=$(find ./ -type f -and -not \( -path "./vendor*" -or -path "./.git*" -or - echo "Updating all files" for file in $files; do - replace_paths ${file} + if test -f "$file"; then + replace_paths $file + fi done echo "Updating go.mod and vendoring" @@ -35,5 +37,9 @@ go mod vendor >/dev/null # N.B.: This must be run after go mod vendor. echo "running make proto-gen" make proto-gen >/dev/null + +echo "Run go mod vendor after proto-gen to avoid vendoring issues" +go mod vendor >/dev/null + echo "running make run-querygen" make run-querygen >/dev/null diff --git a/scripts/statesync-rocks.bash b/scripts/statesync-rocks.bash deleted file mode 100644 index d3dd064e718..00000000000 --- a/scripts/statesync-rocks.bash +++ /dev/null @@ -1,70 +0,0 @@ -# microtick and bitcanna contributed significantly here. -# rocksdb works -# This defaults to rocksdb. Read the script, some stuff is commented out based on your system. - - -# PRINT EVERY COMMAND -set -ux - -# uncomment the three lines below to build osmosis - -export GOPATH=~/go -export PATH=$PATH:~/go/bin - -# Use if building on a mac -# export CGO_CFLAGS="-I/opt/homebrew/Cellar/rocksdb/6.27.3/include" -# export CGO_LDFLAGS="-L/opt/homebrew/Cellar/rocksdb/6.27.3/lib -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd -L/opt/homebrew/Cellar/snappy/1.1.9/lib -L/opt/homebrew/Cellar/lz4/1.9.3/lib/ -L /opt/homebrew/Cellar/zstd/1.5.1/lib/" -go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb' -tags rocksdb ./... - -# MAKE HOME FOLDER AND GET GENESIS -osmosisd init osmosis-rocks -wget -O ~/.osmosisd/config/genesis.json https://cloudflare-ipfs.com/ipfs/QmXRvBT3hgoXwwPqbK6a2sXUuArGM8wPyo1ybskyyUwUxs - -# this will let tendermint know that we want rocks -sed -i 's/goleveldb/rocksdb/' ~/.osmosisd/config/config.toml - - -# Uncomment if resyncing a server -# osmosisd unsafe-reset-all --home /osmosis/osmosis - - - -INTERVAL=1500 - -# GET TRUST HASH AND TRUST HEIGHT - -LATEST_HEIGHT=$(curl -s https://osmosis.validator.network/block | jq -r .result.block.header.height); -BLOCK_HEIGHT=$(($LATEST_HEIGHT-$INTERVAL)) -TRUST_HASH=$(curl -s "https://osmosis.validator.network/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) - - -# TELL USER WHAT WE ARE DOING -echo "TRUST HEIGHT: $BLOCK_HEIGHT" -echo "TRUST HASH: $TRUST_HASH" - - -# export state sync vars -export OSMOSISD_P2P_MAX_NUM_OUTBOUND_PEERS=200 -export OSMOSISD_STATESYNC_ENABLE=true -export OSMOSISD_STATESYNC_RPC_SERVERS="https://osmosis.validator.network:443,https://rpc.osmosis.notional.ventures:443,https://rpc-osmosis.ecostake.com:443" -export OSMOSISD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT -export OSMOSISD_STATESYNC_TRUST_HASH=$TRUST_HASH - -# Rockdb won't make this folder, so we make it -mkdir -p ~/.osmosisd/data/snapshots/metadata.db - -# THIS WILL FAIL BECAUSE THE APP VERSION IS CORRECTLY SET IN OSMOSIS -osmosisd start --db_backend rocksdb - - -# --db_path /tmp/osmosisd/db --db_rocksdb_options "compression=kNoCompression" --db_rocksdb_options "compaction_style=kCompactionStyleLevel" --db_rocksdb_options "level_compaction_dynamic_level_bytes=true" --db_rocksdb_options "num_levels=4" --db_rocksdb_options "max_bytes_for_level_base=104857600" --db_rocksdb_options "max_bytes_for_level_multiplier=1" --db_rocksdb_options "max_background_compactions=4" --db_rocksdb_options "max_background_flushes=4" --db_rocksdb_options "write_buffer_size=104857600" --db_rocksdb_options "target_file_size_base=104857600" --db_rocksdb_options "target_file_size_multiplier=1" --db_rocksdb_options "max_write_buffer_number=4" --db_rocksdb_options "min_write_buffer_number_to_merge=2" --db_rocksdb_options "max_grandparent_overlap_factor=10" --db_rocksdb_options "max_bytes_for_level_multiplier_additional=[4,4,4,4]" --db_rocksdb_options "compaction_pri=kOldestSmallestSeqFirst" --db_rocksdb_options "compaction_options_fifo={max_table_files_size=104857600}" --db_rocksdb_options "compaction_options_universal={size_ratio=1, min_merge_width=2, max_merge_width=2, max_size_amplification_percent=20}" --db_rocksdb_options "compaction_options_level_base={compression=kNoCompression, filter_policy=kNoFilter}" --db_rocksdb_options "compaction_options_level_base={compression=kSnappyCompression, filter_policy= - -# THIS WILL FIX THE APP VERSION, contributed by callum and claimens -git clone https://github.com/notional-labs/tendermint -cd tendermint -git checkout remotes/origin/callum/app-version -go install -tags rocksdb ./... -tendermint set-app-version 1 --home ~/.osmosisd - -# THERE, NOW IT'S SYNCED AND YOU CAN PLAY -osmosisd start --db_backend rocksdb diff --git a/scripts/statesync-testnet.bash b/scripts/statesync-testnet.bash new file mode 100644 index 00000000000..0b4d78c85db --- /dev/null +++ b/scripts/statesync-testnet.bash @@ -0,0 +1,46 @@ + +#!/bin/bash +# microtick and bitcanna contributed significantly here. +# rocksdb doesn't work yet + +# PRINT EVERY COMMAND +set -ux + +# uncomment the three lines below to build osmosis + +# export GOPATH=~/go +# export PATH=$PATH:~/go/bin +# go install -./... + + +# MAKE HOME FOLDER AND GET GENESIS +osmosisd init test --chain-id osmo-test-4 +# wget -O ~/.osmosisd/config/genesis.json https://cloudflare-ipfs.com/ipfs/QmXRvBT3hgoXwwPqbK6a2sXUuArGM8wPyo1ybskyyUwUxs + +INTERVAL=1500 + +# GET TRUST HASH AND TRUST HEIGHT + +LATEST_HEIGHT=$(curl -s https://rpc-test.osmosis.zone/block | jq -r .result.block.header.height); +BLOCK_HEIGHT=$(($LATEST_HEIGHT-$INTERVAL)) +TRUST_HASH=$(curl -s "https://rpc-test.osmosis.zone/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) + + +# TELL USER WHAT WE ARE DOING +echo "TRUST HEIGHT: $BLOCK_HEIGHT" +echo "TRUST HASH: $TRUST_HASH" + + +# export state sync vars +export OSMOSISD_P2P_MAX_NUM_OUTBOUND_PEERS=200 +export OSMOSISD_STATESYNC_ENABLE=true +export OSMOSISD_STATESYNC_RPC_SERVERS="https://rpc-test.osmosis.zone:443,https://rpc-test.osmosis.zone:443" +export OSMOSISD_P2P_SEEDS="0f9a9c694c46bd28ad9ad6126e923993fc6c56b1@137.184.181.105:26656" +export OSMOSISD_P2P_PERSISTENT_PEERS="4ab030b7fd75ed895c48bcc899b99c17a396736b@137.184.190.127:26656,3dbffa30baab16cc8597df02945dcee0aa0a4581@143.198.139.33:26656" +export OSMOSISD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT +export OSMOSISD_STATESYNC_TRUST_HASH=$TRUST_HASH + + + +# THERE, NOW IT'S SYNCED AND YOU CAN PLAY +osmosisd start diff --git a/scripts/statesync.bash b/scripts/statesync.bash new file mode 100644 index 00000000000..a059558257d --- /dev/null +++ b/scripts/statesync.bash @@ -0,0 +1,48 @@ +#!/bin/bash +# microtick and bitcanna contributed significantly here. +# rocksdb doesn't work yet +# sage prediction: it will state sync fine with v12.2.1 and it won't work with v12.3.0 and the issue will be a blockheader.apphash error, which is a p2p issue, NOT an issue with the commit state of the store, as those would halt the local osmosis instance. + + + + +# PRINT EVERY COMMAND +set -ux + +# uncomment the three lines below to build osmosis + +go mod edit -replace github.com/tendermint/tm-db=github.com/baabeetaa/tm-db@pebble +go mod tidy +go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb -X github.com/tendermint/tm-db.ForceSync=1' -tags pebbledb ./... + + +# MAKE HOME FOLDER AND GET GENESIS +osmosisd init test +wget -O ~/.osmosisd/config/genesis.json https://github.com/osmosis-labs/osmosis/raw/main/networks/osmosis-1/genesis.json + + +INTERVAL=1500 + +# GET TRUST HASH AND TRUST HEIGHT + +LATEST_HEIGHT=$(curl -s https://rpc.osmosis.zone/block | jq -r .result.block.header.height); +BLOCK_HEIGHT=$(($LATEST_HEIGHT-$INTERVAL)) +TRUST_HASH=$(curl -s "https://rpc.osmosis.zone/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) + + +# TELL USER WHAT WE ARE DOING +echo "TRUST HEIGHT: $BLOCK_HEIGHT" +echo "TRUST HASH: $TRUST_HASH" + + +# export state sync vars +export OSMOSISD_P2P_MAX_NUM_OUTBOUND_PEERS=200 +export OSMOSISD_STATESYNC_ENABLE=true +export OSMOSISD_STATESYNC_RPC_SERVERS="https://rpc.osmosis.zone:443,https://rpc.osmosis.zone:443" +export OSMOSISD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT +export OSMOSISD_STATESYNC_TRUST_HASH=$TRUST_HASH + + + +# THERE, NOW IT'S SYNCED AND YOU CAN PLAY +osmosisd start diff --git a/scripts/statesync.sh b/scripts/statesync.sh deleted file mode 100644 index 1d08f192bd6..00000000000 --- a/scripts/statesync.sh +++ /dev/null @@ -1,52 +0,0 @@ - -#!/bin/bash -# microtick and bitcanna contributed significantly here. -# rocksdb doesn't work yet - -# PRINT EVERY COMMAND -set -ux - -# uncomment the three lines below to build osmosis - -# export GOPATH=~/go -# export PATH=$PATH:~/go/bin -# go install -./... - - -# MAKE HOME FOLDER AND GET GENESIS -osmosisd init test -wget -O ~/.osmosisd/config/genesis.json https://cloudflare-ipfs.com/ipfs/QmXRvBT3hgoXwwPqbK6a2sXUuArGM8wPyo1ybskyyUwUxs - -INTERVAL=1500 - -# GET TRUST HASH AND TRUST HEIGHT - -LATEST_HEIGHT=$(curl -s https://osmosis.validator.network/block | jq -r .result.block.header.height); -BLOCK_HEIGHT=$(($LATEST_HEIGHT-$INTERVAL)) -TRUST_HASH=$(curl -s "https://osmosis.validator.network/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) - - -# TELL USER WHAT WE ARE DOING -echo "TRUST HEIGHT: $BLOCK_HEIGHT" -echo "TRUST HASH: $TRUST_HASH" - - -# export state sync vars -export OSMOSISD_P2P_MAX_NUM_OUTBOUND_PEERS=200 -export OSMOSISD_STATESYNC_ENABLE=true -export OSMOSISD_STATESYNC_RPC_SERVERS="https://osmosis.validator.network:443,https://rpc.osmosis.notional.ventures:443,https://rpc-osmosis.ecostake.com:443" -export OSMOSISD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT -export OSMOSISD_STATESYNC_TRUST_HASH=$TRUST_HASH - -# THIS WILL FAIL BECAUSE THE APP VERSION IS CORRECTLY SET IN OSMOSIS -osmosisd start - -# THIS WILL FIX THE APP VERSION, contributed by callum and claimens -git clone https://github.com/tendermint/tendermint -cd tendermint -git checkout remotes/origin/callum/app-version -go install ./... -tendermint set-app-version 1 --home ~/.osmosisd - -# THERE, NOW IT'S SYNCED AND YOU CAN PLAY -osmosisd start diff --git a/scripts/superfluid-test-startnode.sh b/scripts/superfluid-test-startnode.sh old mode 100644 new mode 100755 index afb9514bd9e..859ef33b703 --- a/scripts/superfluid-test-startnode.sh +++ b/scripts/superfluid-test-startnode.sh @@ -10,35 +10,39 @@ osmosisd add-genesis-account $(osmosisd keys show validator -a --keyring-backend osmosisd gentx validator 500000000stake --keyring-backend=test --home=$HOME/.osmosisd --chain-id=testing osmosisd collect-gentxs --home=$HOME/.osmosisd +update_genesis () { + cat $HOME/.osmosisd/validator1/config/genesis.json | jq "$1" > $HOME/.osmosisd/validator1/config/tmp_genesis.json && mv $HOME/.osmosisd/validator1/config/tmp_genesis.json $HOME/.osmosisd/validator1/config/genesis.json +} + # update staking genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["staking"]["params"]["unbonding_time"]="120s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["staking"]["params"]["unbonding_time"]="120s"' # update governance genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["gov"]["voting_params"]["voting_period"]="10s"' # update epochs genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["epochs"]["epochs"][0]["identifier"]="min"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["epochs"]["epochs"][0]["duration"]="60s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["epochs"]["epochs"][0]["identifier"]="min"' +update_genesis '.app_state["epochs"]["epochs"][0]["duration"]="60s"' # update poolincentives genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][0]="120s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][1]="180s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][2]="240s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["poolincentives"]["lockable_durations"][0]="120s"' +update_genesis '.app_state["poolincentives"]["lockable_durations"][1]="180s"' +update_genesis '.app_state["poolincentives"]["lockable_durations"][2]="240s"' # update incentives genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["params"]["distr_epoch_identifier"]="min"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][0]="1s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][1]="120s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][2]="180s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][3]="240s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["incentives"]["params"]["distr_epoch_identifier"]="min"' +update_genesis '.app_state["incentives"]["lockable_durations"][0]="1s"' +update_genesis '.app_state["incentives"]["lockable_durations"][1]="120s"' +update_genesis '.app_state["incentives"]["lockable_durations"][2]="180s"' +update_genesis '.app_state["incentives"]["lockable_durations"][3]="240s"' # update mint genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["mint"]["params"]["epoch_identifier"]="min"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["mint"]["params"]["epoch_identifier"]="min"' # update gamm genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["gamm"]["params"]["pool_creation_fee"][0]["denom"]="stake"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["gamm"]["params"]["pool_creation_fee"][0]["denom"]="stake"' # update superfluid genesis -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["superfluid"]["params"]["refresh_epoch_identifier"]="min"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +update_genesis '.app_state["superfluid"]["params"]["minimum_risk_factor"]="0.500000000000000000"' osmosisd start --home=$HOME/.osmosisd diff --git a/simulation/executor/internal/executortypes/actions.go b/simulation/executor/internal/executortypes/actions.go index ac26fa0964f..87fd3889e9f 100644 --- a/simulation/executor/internal/executortypes/actions.go +++ b/simulation/executor/internal/executortypes/actions.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) type selectActionFn func(r *rand.Rand) simtypes.ActionsWithMetadata diff --git a/simulation/executor/internal/executortypes/frequency.go b/simulation/executor/internal/executortypes/frequency.go index 502f26fbc44..5f368bca141 100644 --- a/simulation/executor/internal/executortypes/frequency.go +++ b/simulation/executor/internal/executortypes/frequency.go @@ -1,6 +1,6 @@ package executortypes -import "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" +import "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" func totalFrequency(actions []simtypes.ActionsWithMetadata) int { totalFrequency := 0 diff --git a/simulation/executor/internal/executortypes/simmanager.go b/simulation/executor/internal/executortypes/simmanager.go index 63e0473a699..561990bdad3 100644 --- a/simulation/executor/internal/executortypes/simmanager.go +++ b/simulation/executor/internal/executortypes/simmanager.go @@ -15,8 +15,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "golang.org/x/exp/maps" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) // Manager defines a simulation manager that provides the high level utility @@ -109,6 +109,11 @@ func (m Manager) legacyActions(seed int64, cdc codec.JSONCodec) []simtypes.Actio // second pass generate actions actions := []simtypes.ActionsWithMetadata{} for _, moduleName := range m.moduleManager.OrderInitGenesis { + // wasmd simulation has txfee assumptions that don't work with Osmosis. + // TODO: Make an issue / PR on their repo + if moduleName == "wasm" { + continue + } if simModule, ok := m.legacyModules[moduleName]; ok { weightedOps := simModule.WeightedOperations(simState) for _, action := range actionsFromWeightedOperations(moduleName, weightedOps) { diff --git a/simulation/executor/internal/pubsub/manager.go b/simulation/executor/internal/pubsub/manager.go index dbb711814f2..a8460f12f0f 100644 --- a/simulation/executor/internal/pubsub/manager.go +++ b/simulation/executor/internal/pubsub/manager.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "go.uber.org/multierr" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) var _ simtypes.PubSubManager = &Manager{} diff --git a/simulation/executor/legacyconfig.go b/simulation/executor/legacyconfig.go index ef0c6be00a6..8074fb961df 100644 --- a/simulation/executor/legacyconfig.go +++ b/simulation/executor/legacyconfig.go @@ -12,8 +12,8 @@ import ( "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" - "github.com/osmosis-labs/osmosis/v12/simulation/executor/internal/stats" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes/simlogger" + "github.com/osmosis-labs/osmosis/v13/simulation/executor/internal/stats" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/simlogger" ) // List of available flags for the simulator diff --git a/simulation/executor/mock_tendermint.go b/simulation/executor/mock_tendermint.go index 6e21f7da8ea..1963edc880c 100644 --- a/simulation/executor/mock_tendermint.go +++ b/simulation/executor/mock_tendermint.go @@ -14,7 +14,7 @@ import ( tmtypes "github.com/tendermint/tendermint/types" "golang.org/x/exp/maps" - markov "github.com/osmosis-labs/osmosis/v12/simulation/simtypes/transitionmatrix" + markov "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/transitionmatrix" ) type mockValidator struct { diff --git a/simulation/executor/params.go b/simulation/executor/params.go index b63d9c63028..60d56a164e2 100644 --- a/simulation/executor/params.go +++ b/simulation/executor/params.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/simulation" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - markov "github.com/osmosis-labs/osmosis/v12/simulation/simtypes/transitionmatrix" + markov "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/transitionmatrix" ) const ( diff --git a/simulation/executor/simulate.go b/simulation/executor/simulate.go index 2209e28ea50..c2cf2a57513 100644 --- a/simulation/executor/simulate.go +++ b/simulation/executor/simulate.go @@ -21,9 +21,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/osmosis-labs/osmosis/v12/simulation/executor/internal/executortypes" - "github.com/osmosis-labs/osmosis/v12/simulation/executor/internal/stats" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/simulation/executor/internal/executortypes" + "github.com/osmosis-labs/osmosis/v13/simulation/executor/internal/stats" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) const AverageBlockTime = 6 * time.Second diff --git a/simulation/executor/simulate_dev.go b/simulation/executor/simulate_dev.go index b100450c8a4..04c368a1fe7 100644 --- a/simulation/executor/simulate_dev.go +++ b/simulation/executor/simulate_dev.go @@ -13,8 +13,8 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/simulation/executor/internal/stats" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/simulation/executor/internal/stats" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) type simState struct { diff --git a/simulation/executor/types.go b/simulation/executor/types.go index b06903d2ca0..5006a7d5d00 100644 --- a/simulation/executor/types.go +++ b/simulation/executor/types.go @@ -8,7 +8,7 @@ import ( legacysim "github.com/cosmos/cosmos-sdk/types/simulation" abci "github.com/tendermint/tendermint/abci/types" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) // AppStateFn returns the app state json bytes and the genesis accounts diff --git a/simulation/executor/util.go b/simulation/executor/util.go index 6ac79e465a5..3e063029b26 100644 --- a/simulation/executor/util.go +++ b/simulation/executor/util.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) func getTestingMode(tb testing.TB) (testingMode bool, t *testing.T, b *testing.B) { diff --git a/simulation/simtypes/account.go b/simulation/simtypes/account.go index 9b375bf52da..5e247bb7d31 100644 --- a/simulation/simtypes/account.go +++ b/simulation/simtypes/account.go @@ -3,10 +3,11 @@ package simtypes import ( "errors" "fmt" - "math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" + + sdkrand "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/random" ) func (sim *SimCtx) RandomSimAccount() simulation.Account { @@ -181,17 +182,7 @@ func (sim *SimCtx) RandExponentialCoin(ctx sdk.Context, addr sdk.AccAddress) sdk // TODO: Reconsider if this becomes problematic in the future, but currently thinking it // should be fine for simulation. r := sim.GetSeededRand("Exponential distribution") - lambda := float64(10) - sample := r.ExpFloat64() / lambda - // truncate exp at 1, which will only be reached in .0045% of the time. - // .000045 ~= (1 - CDF(1, Exp[\lambda=10])) = e^{-10} - sample = math.Min(1, sample) - // Do some hacky scaling to get this into an SDK decimal, - // were going to treat it as an integer in the range [0, 10000] - maxRange := int64(10000) - intSample := int64(math.Round(sample * float64(maxRange))) - newAmount := coin.Amount.MulRaw(intSample).QuoRaw(maxRange) - return sdk.NewCoin(coin.Denom, newAmount) + return sdkrand.RandExponentialCoin(r, coin) } func (sim *SimCtx) RandCoinSubset(ctx sdk.Context, addr sdk.AccAddress, denoms []string) sdk.Coins { diff --git a/simulation/simtypes/random/sdkrand.go b/simulation/simtypes/random/sdkrand.go index 89c950ef346..a39bb7d2b71 100644 --- a/simulation/simtypes/random/sdkrand.go +++ b/simulation/simtypes/random/sdkrand.go @@ -2,6 +2,7 @@ package sdkrand import ( "errors" + "math" "math/big" "math/rand" "time" @@ -137,32 +138,36 @@ func RandSubsetCoins(r *rand.Rand, coins sdk.Coins) sdk.Coins { return subset.Sort() } -// DeriveRand derives a new Rand deterministically from another random source. -// Unlike rand.New(rand.NewSource(seed)), the result is "more random" -// depending on the source and state of r. -// -// NOTE: not crypto safe. -func DeriveRand(r *rand.Rand) *rand.Rand { - const num = 8 // TODO what's a good number? Too large is too slow. - ms := multiSource(make([]rand.Source, num)) - - for i := 0; i < num; i++ { - ms[i] = rand.NewSource(r.Int63()) +func RandCoin(r *rand.Rand, coins sdk.Coins) sdk.Coins { + if len(coins) == 0 { + return sdk.Coins{} } - - return rand.New(ms) -} - -type multiSource []rand.Source - -func (ms multiSource) Int63() (r int64) { - for _, source := range ms { - r ^= source.Int63() + // make sure at least one coin added + denomIdx := r.Intn(len(coins)) + coin := coins[denomIdx] + amt, err := RandPositiveInt(r, coin.Amount) + // malformed coin. 0 amt in coins + if err != nil { + return sdk.Coins{} } - return r + return sdk.Coins{sdk.NewCoin(coin.Denom, amt)} } -func (ms multiSource) Seed(seed int64) { - panic("multiSource Seed should not be called") +// RandGeometricCoin uniformly samples a denom from the addr's balances. +// Then it samples an Exponentially distributed amount of the addr's coins, with rate = 10. +// (Meaning that on average it samples 10% of the chosen balance) +// Pre-condition: Addr must have a spendable balance +func RandExponentialCoin(r *rand.Rand, coin sdk.Coin) sdk.Coin { + lambda := float64(10) + sample := r.ExpFloat64() / lambda + // truncate exp at 1, which will only be reached in .0045% of the time. + // .000045 ~= (1 - CDF(1, Exp[\lambda=10])) = e^{-10} + sample = math.Min(1, sample) + // Do some hacky scaling to get this into an SDK decimal, + // were going to treat it as an integer in the range [0, 10000] + maxRange := int64(10000) + intSample := int64(math.Round(sample * float64(maxRange))) + newAmount := coin.Amount.MulRaw(intSample).QuoRaw(maxRange) + return sdk.NewCoin(coin.Denom, newAmount) } diff --git a/simulation/simtypes/randutil.go b/simulation/simtypes/randutil.go index ceafab414ef..a2f20237804 100644 --- a/simulation/simtypes/randutil.go +++ b/simulation/simtypes/randutil.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "golang.org/x/exp/constraints" - sdkrand "github.com/osmosis-labs/osmosis/v12/simulation/simtypes/random" + sdkrand "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/random" ) func RandLTBound[T constraints.Integer](sim *SimCtx, upperbound T) T { diff --git a/simulation/simtypes/txbuilder.go b/simulation/simtypes/txbuilder.go index 73aab81db19..8ff083b1953 100644 --- a/simulation/simtypes/txbuilder.go +++ b/simulation/simtypes/txbuilder.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/osmosis-labs/osmosis/v12/app/params" + "github.com/osmosis-labs/osmosis/v13/app/params" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" authsign "github.com/cosmos/cosmos-sdk/x/auth/signing" diff --git a/tests/e2e/configurer/base.go b/tests/e2e/configurer/base.go index 6ce67da251d..a9eb3b1b3d7 100644 --- a/tests/e2e/configurer/base.go +++ b/tests/e2e/configurer/base.go @@ -13,10 +13,10 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/chain" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/containers" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/util" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/chain" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/containers" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/util" ) // baseConfigurer is the base implementation for the diff --git a/tests/e2e/configurer/chain/chain.go b/tests/e2e/configurer/chain/chain.go index e9e55a55c87..23fa0594e34 100644 --- a/tests/e2e/configurer/chain/chain.go +++ b/tests/e2e/configurer/chain/chain.go @@ -9,11 +9,11 @@ import ( "github.com/stretchr/testify/require" coretypes "github.com/tendermint/tendermint/rpc/core/types" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/config" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/config" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/containers" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/containers" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) type Config struct { diff --git a/tests/e2e/configurer/chain/commands.go b/tests/e2e/configurer/chain/commands.go index 335d4924eca..74025dc829e 100644 --- a/tests/e2e/configurer/chain/commands.go +++ b/tests/e2e/configurer/chain/commands.go @@ -9,11 +9,11 @@ import ( "strings" "time" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/config" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/util" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/config" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/util" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -105,7 +105,7 @@ func (n *NodeConfig) FailIBCTransfer(from, recipient, amount string) { cmd := []string{"osmosisd", "tx", "ibc-transfer", "transfer", "transfer", "channel-0", recipient, amount, fmt.Sprintf("--from=%s", from)} - _, _, err := n.containerManager.ExecTxCmdWithSuccessString(n.t, n.chainId, n.Name, cmd, "Rate Limit exceeded") + _, _, err := n.containerManager.ExecTxCmdWithSuccessString(n.t, n.chainId, n.Name, cmd, "rate limit exceeded") require.NoError(n.t, err) n.LogActionF("Failed to send IBC transfer (as expected)") diff --git a/tests/e2e/configurer/chain/node.go b/tests/e2e/configurer/chain/node.go index b1345334692..7d2ce3987ed 100644 --- a/tests/e2e/configurer/chain/node.go +++ b/tests/e2e/configurer/chain/node.go @@ -12,8 +12,8 @@ import ( rpchttp "github.com/tendermint/tendermint/rpc/client/http" coretypes "github.com/tendermint/tendermint/rpc/core/types" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/containers" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/containers" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) type NodeConfig struct { diff --git a/tests/e2e/configurer/chain/queries.go b/tests/e2e/configurer/chain/queries.go index f40782b1a9e..1b53ca5a31f 100644 --- a/tests/e2e/configurer/chain/queries.go +++ b/tests/e2e/configurer/chain/queries.go @@ -18,10 +18,10 @@ import ( "github.com/stretchr/testify/require" tmabcitypes "github.com/tendermint/tendermint/abci/types" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/util" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" - twapqueryproto "github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/util" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" + twapqueryproto "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" ) func (n *NodeConfig) QueryGRPCGateway(path string, parameters ...string) ([]byte, error) { @@ -66,7 +66,6 @@ func (n *NodeConfig) QueryGRPCGateway(path string, parameters ...string) ([]byte return nil, err } if resp.StatusCode != http.StatusOK { - n.t.Error(string(bz)) return nil, fmt.Errorf("unexpected status code: %d, body: %s", resp.StatusCode, string(bz)) } return bz, nil @@ -85,15 +84,16 @@ func (n *NodeConfig) QueryBalances(address string) (sdk.Coins, error) { return balancesResp.GetBalances(), nil } -func (n *NodeConfig) QueryTotalSupply() (sdk.Coins, error) { - bz, err := n.QueryGRPCGateway("cosmos/bank/v1beta1/supply") +func (n *NodeConfig) QuerySupplyOf(denom string) (sdk.Int, error) { + path := fmt.Sprintf("cosmos/bank/v1beta1/supply/%s", denom) + bz, err := n.QueryGRPCGateway(path) require.NoError(n.t, err) - var supplyResp banktypes.QueryTotalSupplyResponse + var supplyResp banktypes.QuerySupplyOfResponse if err := util.Cdc.UnmarshalJSON(bz, &supplyResp); err != nil { - return sdk.Coins{}, err + return sdk.NewInt(0), err } - return supplyResp.GetSupply(), nil + return supplyResp.Amount.Amount, nil } func (n *NodeConfig) QueryContractsFromId(codeId int) ([]string, error) { @@ -187,6 +187,7 @@ func (n *NodeConfig) QueryArithmeticTwapToNow(poolId uint64, baseAsset, quoteAss return sdk.Dec{}, err } + // nolint: staticcheck var response twapqueryproto.ArithmeticTwapToNowResponse err = util.Cdc.UnmarshalJSON(bz, &response) require.NoError(n.t, err) // this error should not happen @@ -208,6 +209,7 @@ func (n *NodeConfig) QueryArithmeticTwap(poolId uint64, baseAsset, quoteAsset st return sdk.Dec{}, err } + // nolint: staticcheck var response twapqueryproto.ArithmeticTwapResponse err = util.Cdc.UnmarshalJSON(bz, &response) require.NoError(n.t, err) // this error should not happen diff --git a/tests/e2e/configurer/current.go b/tests/e2e/configurer/current.go index cadcc92c469..2f36ba27b27 100644 --- a/tests/e2e/configurer/current.go +++ b/tests/e2e/configurer/current.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/chain" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/containers" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/chain" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/containers" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) type CurrentBranchConfigurer struct { diff --git a/tests/e2e/configurer/factory.go b/tests/e2e/configurer/factory.go index a9a80f8a9d8..a26d3ee95de 100644 --- a/tests/e2e/configurer/factory.go +++ b/tests/e2e/configurer/factory.go @@ -4,9 +4,9 @@ import ( "errors" "testing" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/chain" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/containers" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/chain" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/containers" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) type Configurer interface { diff --git a/tests/e2e/configurer/upgrade.go b/tests/e2e/configurer/upgrade.go index 7bae6f27b0d..a93b13e83c7 100644 --- a/tests/e2e/configurer/upgrade.go +++ b/tests/e2e/configurer/upgrade.go @@ -9,11 +9,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/chain" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/config" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/containers" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/chain" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/config" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/containers" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) type UpgradeSettings struct { diff --git a/tests/e2e/containers/config.go b/tests/e2e/containers/config.go index 0c223477132..03f3503b5ba 100644 --- a/tests/e2e/containers/config.go +++ b/tests/e2e/containers/config.go @@ -24,10 +24,10 @@ const ( // It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset // for this functionality to be used. previousVersionOsmoRepository = "osmolabs/osmosis" - previousVersionOsmoTag = "12.1" + previousVersionOsmoTag = "12.2" // Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion) previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain" - previousVersionInitTag = "v12.1.0-e2e-v1" + previousVersionInitTag = "v12.2.0" // Hermes repo/version for relayer relayerRepository = "osmolabs/hermes" relayerTag = "0.13.0" diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 567441cd3c9..5e06c72df6a 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/suite" - configurer "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer" + configurer "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer" ) const ( diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index ec98a290877..bc6331cb35a 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -10,15 +10,16 @@ import ( "time" paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" - ibcratelimittypes "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + + ibcratelimittypes "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" sdk "github.com/cosmos/cosmos-sdk/types" coretypes "github.com/tendermint/tendermint/rpc/core/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/configurer/config" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/configurer/config" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) // TestIBCTokenTransfer tests that IBC token transfers work as expected. @@ -141,12 +142,8 @@ func (s *IntegrationTestSuite) TestIBCTokenTransferRateLimiting() { node, err := chainA.GetDefaultNode() s.NoError(err) - supply, err := node.QueryTotalSupply() + osmoSupply, err := node.QuerySupplyOf("uosmo") s.NoError(err) - osmoSupply := supply.AmountOf("uosmo") - - // balance, err := node.QueryBalances(chainA.NodeConfigs[1].PublicAddress) - // s.NoError(err) f, err := osmoSupply.ToDec().Float64() s.NoError(err) @@ -162,8 +159,10 @@ func (s *IntegrationTestSuite) TestIBCTokenTransferRateLimiting() { // co up two levels projectDir := filepath.Dir(filepath.Dir(wd)) fmt.Println(wd, projectDir) - err = copyFile(projectDir+"/x/ibc-rate-limit/testdata/rate_limiter.wasm", wd+"/scripts/rate_limiter.wasm") + err = copyFile(projectDir+"/x/ibc-rate-limit/bytecode/rate_limiter.wasm", wd+"/scripts/rate_limiter.wasm") s.NoError(err) + // set LatestCodeId to 1 since we upload a contract in the upgrade handler for v13 + chainA.LatestCodeId = 1 node.StoreWasmCode("rate_limiter.wasm", initialization.ValidatorWalletName) chainA.LatestCodeId += 1 node.InstantiateWasmContract( @@ -214,7 +213,7 @@ func (s *IntegrationTestSuite) TestIBCTokenTransferRateLimiting() { if err != nil { return false } - return val != "" + return val == contracts[0] }, 1*time.Minute, 10*time.Millisecond, @@ -388,9 +387,9 @@ func (s *IntegrationTestSuite) TestTWAP() { // These must be equal because they are calculated over time ranges with the stable and equal spot price. // There are potential rounding errors requiring us to approximate the comparison. - osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsAB, twapFromAfterToNowAB, sdk.NewDecWithPrec(1, 3)) - osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsBC, twapFromAfterToNowBC, sdk.NewDecWithPrec(1, 3)) - osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsCA, twapFromAfterToNowCA, sdk.NewDecWithPrec(1, 3)) + osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsAB, twapFromAfterToNowAB, sdk.NewDecWithPrec(2, 3)) + osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsBC, twapFromAfterToNowBC, sdk.NewDecWithPrec(2, 3)) + osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsCA, twapFromAfterToNowCA, sdk.NewDecWithPrec(2, 3)) if !s.skipUpgrade { // TODO: we should reduce the pruning time in the v11 @@ -521,7 +520,7 @@ func (s *IntegrationTestSuite) TestStateSync() { // start the state synchin node. err = stateSynchingNode.Run() - s.NoError(err) + s.Require().NoError(err) // ensure that the state synching node cathes up to the running node. s.Require().Eventually(func() bool { @@ -537,7 +536,7 @@ func (s *IntegrationTestSuite) TestStateSync() { // stop the state synching node. err = chainA.RemoveNode(stateSynchingNode.Name) - s.NoError(err) + s.Require().NoError(err) } func (s *IntegrationTestSuite) TestExpeditedProposals() { diff --git a/tests/e2e/initialization/chain/main.go b/tests/e2e/initialization/chain/main.go index 7704b2ebd96..690ec3b1c68 100644 --- a/tests/e2e/initialization/chain/main.go +++ b/tests/e2e/initialization/chain/main.go @@ -7,7 +7,7 @@ import ( "os" "time" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) func main() { diff --git a/tests/e2e/initialization/config.go b/tests/e2e/initialization/config.go index adb86b44c34..1296a65c239 100644 --- a/tests/e2e/initialization/config.go +++ b/tests/e2e/initialization/config.go @@ -18,15 +18,15 @@ import ( "github.com/gogo/protobuf/proto" tmjson "github.com/tendermint/tendermint/libs/json" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" - poolitypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" - twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types" - txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types" - - "github.com/osmosis-labs/osmosis/v12/tests/e2e/util" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" + poolitypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" + twaptypes "github.com/osmosis-labs/osmosis/v13/x/twap/types" + txfeestypes "github.com/osmosis-labs/osmosis/v13/x/txfees/types" + + "github.com/osmosis-labs/osmosis/v13/tests/e2e/util" ) // NodeConfig is a confiuration for the node supplied from the test runner diff --git a/tests/e2e/initialization/init.go b/tests/e2e/initialization/init.go index f7ded105a2d..2ec408b02c3 100644 --- a/tests/e2e/initialization/init.go +++ b/tests/e2e/initialization/init.go @@ -6,7 +6,7 @@ import ( "path/filepath" "time" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/util" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/util" ) func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod, expeditedVotingPeriod time.Duration, forkHeight int) (*Chain, error) { diff --git a/tests/e2e/initialization/init_test.go b/tests/e2e/initialization/init_test.go index 7ff20a0e9b2..c5e49dc674a 100644 --- a/tests/e2e/initialization/init_test.go +++ b/tests/e2e/initialization/init_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) const forkHeight = 10 diff --git a/tests/e2e/initialization/node.go b/tests/e2e/initialization/node.go index 3f7bd869561..c3be975ceec 100644 --- a/tests/e2e/initialization/node.go +++ b/tests/e2e/initialization/node.go @@ -29,8 +29,8 @@ import ( "github.com/tendermint/tendermint/privval" tmtypes "github.com/tendermint/tendermint/types" - osmosisApp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/util" + osmosisApp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/util" ) type internalNode struct { diff --git a/tests/e2e/initialization/node/main.go b/tests/e2e/initialization/node/main.go index 7f51510d55d..6eefcc5f6ae 100644 --- a/tests/e2e/initialization/node/main.go +++ b/tests/e2e/initialization/node/main.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/initialization" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/initialization" ) func main() { diff --git a/tests/e2e/initialization/util.go b/tests/e2e/initialization/util.go index ce7991b46e2..019b5ea9e4f 100644 --- a/tests/e2e/initialization/util.go +++ b/tests/e2e/initialization/util.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/unknownproto" sdktx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/osmosis-labs/osmosis/v12/tests/e2e/util" + "github.com/osmosis-labs/osmosis/v13/tests/e2e/util" ) func decodeTx(txBytes []byte) (*sdktx.Tx, error) { diff --git a/tests/e2e/scripts/rate_limiter.wasm b/tests/e2e/scripts/rate_limiter.wasm old mode 100755 new mode 100644 index f3f763f30a4..354ec60ae9d Binary files a/tests/e2e/scripts/rate_limiter.wasm and b/tests/e2e/scripts/rate_limiter.wasm differ diff --git a/tests/e2e/util/codec.go b/tests/e2e/util/codec.go index 446b442ce3d..5910d19fdb3 100644 --- a/tests/e2e/util/codec.go +++ b/tests/e2e/util/codec.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - osmosisApp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/app/params" + osmosisApp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/app/params" ) var ( diff --git a/tests/localosmosis/docker-compose.yml b/tests/localosmosis/docker-compose.yml index c03b2f1736d..d8f5a54d87c 100644 --- a/tests/localosmosis/docker-compose.yml +++ b/tests/localosmosis/docker-compose.yml @@ -15,7 +15,7 @@ services: - ./scripts/nativeDenomPoolB.json:/osmosis/nativeDenomPoolB.json - ./scripts/nativeDenomThreeAssetPool.json:/osmosis/nativeDenomThreeAssetPool.json - ./scripts/setup.sh:/osmosis/setup.sh - - $HOME/.osmosisd/:/osmosis/.osmosisd/ + - $HOME/.osmosisd-local/:/osmosis/.osmosisd/ entrypoint: - /osmosis/setup.sh command: diff --git a/tests/localosmosis/state_export/docker-compose.yml b/tests/localosmosis/state_export/docker-compose.yml index d12cdf4b4d7..fd52e032ad8 100644 --- a/tests/localosmosis/state_export/docker-compose.yml +++ b/tests/localosmosis/state_export/docker-compose.yml @@ -14,7 +14,7 @@ services: - ./scripts/start.sh:/osmosis/start.sh - ./scripts/testnetify.py:/osmosis/testnetify.py - ./state_export.json:/osmosis/state_export.json - - $HOME/.osmosisd/:/osmosis/.osmosisd/ + - $HOME/.osmosisd-local/:/osmosis/.osmosisd/ entrypoint: - /osmosis/start.sh environment: diff --git a/tests/simulator/osmosis_helper.go b/tests/simulator/osmosis_helper.go index 0cfb9a0c7ba..aa4500681ef 100644 --- a/tests/simulator/osmosis_helper.go +++ b/tests/simulator/osmosis_helper.go @@ -7,10 +7,10 @@ import ( "github.com/cosmos/cosmos-sdk/types/simulation" db "github.com/tendermint/tm-db" - simexec "github.com/osmosis-labs/osmosis/v12/simulation/executor" + simexec "github.com/osmosis-labs/osmosis/v13/simulation/executor" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" ) func OsmosisAppCreator(logger log.Logger, db db.DB) simtypes.AppCreator { diff --git a/tests/simulator/sim_test.go b/tests/simulator/sim_test.go index 7070f34ddb0..1182ce49525 100644 --- a/tests/simulator/sim_test.go +++ b/tests/simulator/sim_test.go @@ -12,8 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp/helpers" - osmosim "github.com/osmosis-labs/osmosis/v12/simulation/executor" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes/simlogger" + osmosim "github.com/osmosis-labs/osmosis/v13/simulation/executor" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/simlogger" ) // Profile with: diff --git a/tests/simulator/state.go b/tests/simulator/state.go index 84ac6ed80cd..cf04838e2e3 100644 --- a/tests/simulator/state.go +++ b/tests/simulator/state.go @@ -7,9 +7,9 @@ import ( "os" "time" - "github.com/osmosis-labs/osmosis/v12/app" - osmosim "github.com/osmosis-labs/osmosis/v12/simulation/executor" - osmosimtypes "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/app" + osmosim "github.com/osmosis-labs/osmosis/v13/simulation/executor" + osmosimtypes "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index cf87fe65143..c57452ae1e6 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -9,12 +9,12 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/osmosis-labs/osmosis/v12/wasmbinding/bindings" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/wasmbinding/bindings" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" - tokenfactorykeeper "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/keeper" - tokenfactorytypes "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + tokenfactorykeeper "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/keeper" + tokenfactorytypes "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) // CustomMessageDecorator returns decorator for custom CosmWasm bindings messages diff --git a/wasmbinding/queries.go b/wasmbinding/queries.go index 59129c1d5ec..59df2e89161 100644 --- a/wasmbinding/queries.go +++ b/wasmbinding/queries.go @@ -8,11 +8,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/wasmbinding/bindings" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - tokenfactorykeeper "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/keeper" - twapkeeper "github.com/osmosis-labs/osmosis/v12/x/twap" + "github.com/osmosis-labs/osmosis/v13/wasmbinding/bindings" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + tokenfactorykeeper "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/keeper" + twapkeeper "github.com/osmosis-labs/osmosis/v13/x/twap" ) type QueryPlugin struct { @@ -119,7 +119,7 @@ func (qp QueryPlugin) ArithmeticTwap(ctx sdk.Context, arithmeticTwap *bindings.A startTime := time.UnixMilli(arithmeticTwap.StartTime) endTime := time.UnixMilli(arithmeticTwap.EndTime) - twap, err := qp.twapKeeper.GetArithmeticTwap(ctx, poolId, quoteAssetDenom, baseAssetDenom, startTime, endTime) + twap, err := qp.twapKeeper.GetArithmeticTwap(ctx, poolId, baseAssetDenom, quoteAssetDenom, startTime, endTime) if err != nil { return nil, sdkerrors.Wrap(err, "gamm arithmetic twap") } @@ -137,7 +137,7 @@ func (qp QueryPlugin) ArithmeticTwapToNow(ctx sdk.Context, arithmeticTwap *bindi baseAssetDenom := arithmeticTwap.BaseAssetDenom startTime := time.UnixMilli(arithmeticTwap.StartTime) - twap, err := qp.twapKeeper.GetArithmeticTwapToNow(ctx, poolId, quoteAssetDenom, baseAssetDenom, startTime) + twap, err := qp.twapKeeper.GetArithmeticTwapToNow(ctx, poolId, baseAssetDenom, quoteAssetDenom, startTime) if err != nil { return nil, sdkerrors.Wrap(err, "gamm arithmetic twap") } diff --git a/wasmbinding/query_plugin.go b/wasmbinding/query_plugin.go index 44d840279c3..1016043b47f 100644 --- a/wasmbinding/query_plugin.go +++ b/wasmbinding/query_plugin.go @@ -11,7 +11,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" - "github.com/osmosis-labs/osmosis/v12/wasmbinding/bindings" + "github.com/osmosis-labs/osmosis/v13/wasmbinding/bindings" ) // StargateQuerier dispatches whitelisted stargate queries diff --git a/wasmbinding/query_plugin_test.go b/wasmbinding/query_plugin_test.go index 0d40b7f423c..5ee920d01ea 100644 --- a/wasmbinding/query_plugin_test.go +++ b/wasmbinding/query_plugin_test.go @@ -16,13 +16,18 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" proto "github.com/golang/protobuf/proto" "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/app" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + gammv2types "github.com/osmosis-labs/osmosis/v13/x/gamm/v2types" - "github.com/osmosis-labs/osmosis/v12/wasmbinding" + "github.com/osmosis-labs/osmosis/v13/app" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + + "github.com/osmosis-labs/osmosis/v13/wasmbinding" ) type StargateTestSuite struct { @@ -47,10 +52,11 @@ func (suite *StargateTestSuite) TestStargateQuerier() { testSetup func() path string requestData func() []byte - responseProtoStruct interface{} + responseProtoStruct codec.ProtoMarshaler expectedQuerierError bool expectedUnMarshalError bool resendRequest bool + checkResponseStruct bool }{ { name: "happy path", @@ -63,6 +69,35 @@ func (suite *StargateTestSuite) TestStargateQuerier() { }, responseProtoStruct: &epochtypes.QueryEpochsInfoResponse{}, }, + { + name: "happy path gamm", + path: "/osmosis.gamm.v2.Query/SpotPrice", + testSetup: func() { + pk := ed25519.GenPrivKey().PubKey() + sender := sdk.AccAddress(pk.Address()) + err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, sender, apptesting.DefaultAcctFunds) + suite.Require().NoError(err) + msg := balancer.NewMsgCreateBalancerPool(sender, + balancer.NewPoolParams(sdk.ZeroDec(), sdk.ZeroDec(), nil), + apptesting.DefaultPoolAssets, "") + _, err = suite.app.GAMMKeeper.CreatePool(suite.ctx, msg) + suite.NoError(err) + }, + requestData: func() []byte { + queryrequest := gammv2types.QuerySpotPriceRequest{ + PoolId: 1, + BaseAssetDenom: "bar", + QuoteAssetDenom: "uosmo", + } + bz, err := proto.Marshal(&queryrequest) + suite.Require().NoError(err) + return bz + }, + checkResponseStruct: true, + responseProtoStruct: &gammv2types.QuerySpotPriceResponse{ + SpotPrice: sdk.NewDecWithPrec(5, 1).String(), + }, + }, { name: "unregistered path(not whitelisted)", path: "/osmosis.lockup.Query/AccountLockedLongerDuration", @@ -192,6 +227,13 @@ func (suite *StargateTestSuite) TestStargateQuerier() { suite.Require().Error(err) return } + if tc.checkResponseStruct { + expectedResponse, err := proto.Marshal(tc.responseProtoStruct) + suite.Require().NoError(err) + expJsonResp, err := wasmbinding.ConvertProtoToJSONMarshal(tc.responseProtoStruct, expectedResponse, suite.app.AppCodec()) + suite.Require().NoError(err) + suite.Require().Equal(expJsonResp, stargateResponse) + } suite.Require().NoError(err) diff --git a/wasmbinding/stargate_whitelist.go b/wasmbinding/stargate_whitelist.go index 68d7e987366..e3fd3fae74e 100644 --- a/wasmbinding/stargate_whitelist.go +++ b/wasmbinding/stargate_whitelist.go @@ -13,16 +13,17 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" - poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" - superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" - tokenfactorytypes "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" - twapquerytypes "github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto" - txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + gammv2types "github.com/osmosis-labs/osmosis/v13/x/gamm/v2types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" + superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" + tokenfactorytypes "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" + twapquerytypes "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" + txfeestypes "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) // stargateWhitelist keeps whitelist and its deterministic @@ -77,7 +78,12 @@ func init() { setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/PoolParams", &gammtypes.QueryPoolParamsResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/TotalPoolLiquidity", &gammtypes.QueryTotalPoolLiquidityResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/TotalShares", &gammtypes.QueryTotalSharesResponse{}) - setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/SpotPrice", &gammtypes.QuerySpotPriceResponse{}) + setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/CalcJoinPoolShares", &gammtypes.QueryCalcJoinPoolSharesResponse{}) + setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares", &gammtypes.QueryCalcExitPoolCoinsFromSharesResponse{}) + setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares", &gammtypes.QueryCalcJoinPoolNoSwapSharesResponse{}) + setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/PoolType", &gammtypes.QueryPoolTypeResponse{}) + setWhitelistedQuery("/osmosis.gamm.v2.Query/SpotPrice", &gammv2types.QuerySpotPriceResponse{}) + setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/EstimateSwapExactAmountIn", &gammtypes.QuerySwapExactAmountInResponse{}) // incentives setWhitelistedQuery("/osmosis.incentives.Query/ModuleToDistributeCoins", &incentivestypes.ModuleToDistributeCoinsResponse{}) diff --git a/wasmbinding/test/custom_msg_test.go b/wasmbinding/test/custom_msg_test.go index 6bf57bd72a1..9b49239c8e9 100644 --- a/wasmbinding/test/custom_msg_test.go +++ b/wasmbinding/test/custom_msg_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" "github.com/stretchr/testify/require" @@ -13,8 +13,8 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/wasmbinding/bindings" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/wasmbinding/bindings" ) func TestCreateDenomMsg(t *testing.T) { diff --git a/wasmbinding/test/custom_query_test.go b/wasmbinding/test/custom_query_test.go index 276eacbbff0..639889f03cb 100644 --- a/wasmbinding/test/custom_query_test.go +++ b/wasmbinding/test/custom_query_test.go @@ -15,10 +15,10 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/wasmbinding" - "github.com/osmosis-labs/osmosis/v12/wasmbinding/bindings" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/wasmbinding" + "github.com/osmosis-labs/osmosis/v13/wasmbinding/bindings" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" ) // we must pay this many uosmo for every pool we create diff --git a/wasmbinding/test/helpers_test.go b/wasmbinding/test/helpers_test.go index b36e995da13..2bf9457249c 100644 --- a/wasmbinding/test/helpers_test.go +++ b/wasmbinding/test/helpers_test.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app" + "github.com/osmosis-labs/osmosis/v13/app" ) func CreateTestInput() (*app.OsmosisApp, sdk.Context) { diff --git a/wasmbinding/test/messages_test.go b/wasmbinding/test/messages_test.go index 89ec7af2b5a..1851cff40f5 100644 --- a/wasmbinding/test/messages_test.go +++ b/wasmbinding/test/messages_test.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/wasmbinding" - "github.com/osmosis-labs/osmosis/v12/wasmbinding/bindings" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/wasmbinding" + "github.com/osmosis-labs/osmosis/v13/wasmbinding/bindings" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/wasmbinding/test/queries_test.go b/wasmbinding/test/queries_test.go index 2b096a828c8..334418a17d6 100644 --- a/wasmbinding/test/queries_test.go +++ b/wasmbinding/test/queries_test.go @@ -9,8 +9,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/wasmbinding" - "github.com/osmosis-labs/osmosis/v12/wasmbinding/bindings" + "github.com/osmosis-labs/osmosis/v13/wasmbinding" + "github.com/osmosis-labs/osmosis/v13/wasmbinding/bindings" ) func TestFullDenom(t *testing.T) { diff --git a/wasmbinding/test/store_run_test.go b/wasmbinding/test/store_run_test.go index 3a88d32b0d8..6f276149818 100644 --- a/wasmbinding/test/store_run_test.go +++ b/wasmbinding/test/store_run_test.go @@ -13,7 +13,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app" + "github.com/osmosis-labs/osmosis/v13/app" ) func TestNoStorageWithoutProposal(t *testing.T) { @@ -29,7 +29,7 @@ func TestNoStorageWithoutProposal(t *testing.T) { // upload reflect code wasmCode, err := os.ReadFile("../testdata/hackatom.wasm") require.NoError(t, err) - _, err = contractKeeper.Create(ctx, creator, wasmCode, nil) + _, _, err = contractKeeper.Create(ctx, creator, wasmCode, nil) require.Error(t, err) } diff --git a/wasmbinding/wasm.go b/wasmbinding/wasm.go index 3187fd0582f..0d67c535449 100644 --- a/wasmbinding/wasm.go +++ b/wasmbinding/wasm.go @@ -9,9 +9,9 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - gammkeeper "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - tokenfactorykeeper "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/keeper" - twap "github.com/osmosis-labs/osmosis/v12/x/twap" + gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + tokenfactorykeeper "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/keeper" + twap "github.com/osmosis-labs/osmosis/v13/x/twap" ) func RegisterCustomPlugins( diff --git a/x/README.md b/x/README.md index 391dd8e95ea..80a50d930b7 100644 --- a/x/README.md +++ b/x/README.md @@ -11,6 +11,7 @@ Osmosis implements the following custom modules: * These go towards gauges defined by the `incentives` module * `superfluid` - Defines superfluid staking, allowing DeFi assets to have their osmo-backing be staked. * `tokenfactory` - Allows minting of new tokens of the form `factory/{creator address}/{subdenom}` for user-defined subdenoms. +* `twap` - The TWAP package is responsible for being able to serve TWAPs for every AMM pool. * `txfees` - Contains logic for whitelisting txfee tokens, making them easily priceable in osmo, and auto-swapping to osmo. * Also contains logic for custom Osmosis mempool logic, though this should perhaps relocate. diff --git a/x/epochs/client/cli/cli_test.go b/x/epochs/client/cli/cli_test.go index bb7c3553ae4..a0e56a55689 100644 --- a/x/epochs/client/cli/cli_test.go +++ b/x/epochs/client/cli/cli_test.go @@ -4,9 +4,9 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/epochs/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/epochs/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go index cbc5778e164..b3827abd60c 100644 --- a/x/epochs/client/cli/query.go +++ b/x/epochs/client/cli/query.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/epochs/client/cli/query_test.go b/x/epochs/client/cli/query_test.go index 7011acbbf92..d03511c37ca 100644 --- a/x/epochs/client/cli/query_test.go +++ b/x/epochs/client/cli/query_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) type QueryTestSuite struct { diff --git a/x/epochs/client/cli/tx.go b/x/epochs/client/cli/tx.go index cc07b3ce5bc..46932dbef9f 100644 --- a/x/epochs/client/cli/tx.go +++ b/x/epochs/client/cli/tx.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags". - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) // GetTxCmd returns the transaction commands for this module. diff --git a/x/epochs/keeper/abci.go b/x/epochs/keeper/abci.go index dcf62ad8940..95af7831090 100644 --- a/x/epochs/keeper/abci.go +++ b/x/epochs/keeper/abci.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/epochs/keeper/abci_test.go b/x/epochs/keeper/abci_test.go index 9aeabfdbb47..f60dfa75cf1 100644 --- a/x/epochs/keeper/abci_test.go +++ b/x/epochs/keeper/abci_test.go @@ -7,12 +7,12 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - simapp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + simapp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" "golang.org/x/exp/maps" - "github.com/osmosis-labs/osmosis/v12/osmoutils" + "github.com/osmosis-labs/osmosis/v13/osmoutils" ) // This test is responsible for testing how epochs increment based off diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go index bb91aaa90d1..7067ce5dc0c 100644 --- a/x/epochs/keeper/epoch.go +++ b/x/epochs/keeper/epoch.go @@ -6,7 +6,7 @@ import ( "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/epochs/keeper/epoch_test.go b/x/epochs/keeper/epoch_test.go index 97d76ec190b..455f8e5e208 100644 --- a/x/epochs/keeper/epoch_test.go +++ b/x/epochs/keeper/epoch_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "time" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) func (suite *KeeperTestSuite) TestAddEpochInfo() { diff --git a/x/epochs/keeper/genesis.go b/x/epochs/keeper/genesis.go index f39234ee49c..594a38eed1b 100644 --- a/x/epochs/keeper/genesis.go +++ b/x/epochs/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) // InitGenesis sets epoch info from genesis diff --git a/x/epochs/keeper/genesis_test.go b/x/epochs/keeper/genesis_test.go index 2d492cacb81..da5f76da058 100644 --- a/x/epochs/keeper/genesis_test.go +++ b/x/epochs/keeper/genesis_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - simapp "github.com/osmosis-labs/osmosis/v12/app" + simapp "github.com/osmosis-labs/osmosis/v13/app" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) func TestEpochsExportGenesis(t *testing.T) { diff --git a/x/epochs/keeper/grpc_query.go b/x/epochs/keeper/grpc_query.go index 71abcd5ce55..e56ea69bfd7 100644 --- a/x/epochs/keeper/grpc_query.go +++ b/x/epochs/keeper/grpc_query.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) var _ types.QueryServer = Querier{} diff --git a/x/epochs/keeper/grpc_query_test.go b/x/epochs/keeper/grpc_query_test.go index 09a3242da7a..ff4fc48b154 100644 --- a/x/epochs/keeper/grpc_query_test.go +++ b/x/epochs/keeper/grpc_query_test.go @@ -3,7 +3,7 @@ package keeper_test import ( gocontext "context" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) func (suite *KeeperTestSuite) TestQueryEpochInfos() { diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go index 61c6afa583f..13f09a17159 100644 --- a/x/epochs/keeper/keeper.go +++ b/x/epochs/keeper/keeper.go @@ -5,7 +5,7 @@ import ( "github.com/tendermint/tendermint/libs/log" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/epochs/keeper/keeper_test.go b/x/epochs/keeper/keeper_test.go index 45af5f9c9d0..437a9d98e06 100644 --- a/x/epochs/keeper/keeper_test.go +++ b/x/epochs/keeper/keeper_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) type KeeperTestSuite struct { diff --git a/x/epochs/module.go b/x/epochs/module.go index 10508c60793..71ab4c8f2d9 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -28,9 +28,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/osmosis-labs/osmosis/v12/x/epochs/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/epochs/keeper" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/epochs/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/epochs/keeper" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) var ( diff --git a/x/epochs/types/genesis.pb.go b/x/epochs/types/genesis.pb.go index 171db200266..546c75c28bd 100644 --- a/x/epochs/types/genesis.pb.go +++ b/x/epochs/types/genesis.pb.go @@ -210,34 +210,34 @@ var fileDescriptor_7ecf3e4d59074cbd = []byte{ // 479 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x3f, 0x8f, 0xd3, 0x30, 0x1c, 0xad, 0x69, 0x29, 0xad, 0xef, 0x10, 0x60, 0x1d, 0x47, 0xa8, 0x20, 0x09, 0x61, 0x89, 0x04, - 0x38, 0x6a, 0x61, 0x82, 0x01, 0xa9, 0x80, 0xf8, 0x23, 0x24, 0xa4, 0x94, 0x01, 0xb1, 0x54, 0x49, - 0xeb, 0x26, 0x96, 0x9a, 0x38, 0x8a, 0x7f, 0x39, 0xd1, 0x8d, 0x8f, 0xd0, 0x91, 0x8f, 0x74, 0xe3, - 0x8d, 0x4c, 0x05, 0xb5, 0x1b, 0xe3, 0x7d, 0x02, 0x14, 0x3b, 0x29, 0x85, 0x3b, 0x74, 0x5b, 0xec, + 0x38, 0x6a, 0x8f, 0x09, 0x06, 0xa4, 0x02, 0xe2, 0x8f, 0x90, 0x90, 0x52, 0x06, 0xc4, 0x52, 0x25, + 0xad, 0x9b, 0x58, 0x6a, 0xe2, 0x28, 0xfe, 0xe5, 0x44, 0x37, 0x3e, 0x42, 0x47, 0x3e, 0xd2, 0x8d, + 0x37, 0x32, 0x15, 0xd4, 0x6e, 0x8c, 0xf7, 0x09, 0x50, 0xec, 0xa4, 0x14, 0xee, 0x10, 0x5b, 0xec, 0xf7, 0x7e, 0xef, 0xf9, 0x3d, 0xfd, 0x82, 0xef, 0x08, 0x99, 0x08, 0xc9, 0xa5, 0xc7, 0x32, 0x31, 0x89, 0xa5, 0x17, 0xb1, 0x94, 0x49, 0x2e, 0x69, 0x96, 0x0b, 0x10, 0xe4, 0xb0, 0x42, 0xa9, 0x46, - 0xe9, 0x51, 0x3f, 0x64, 0x10, 0xf4, 0x7b, 0x07, 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 0x91, 0x02, 0x4f, 0x23, 0x3d, + 0xc8, 0xa6, 0x46, 0xdb, 0x46, 0x6e, 0xc7, 0x3f, 0x50, 0xe8, 0xf3, 0x0a, 0x1c, 0x69, 0x8c, 0x3c, + 0xc5, 0xbd, 0x8b, 0xdc, 0x62, 0xc6, 0xa3, 0x18, 0x8c, 0x8e, 0x8a, 0x7a, 0xeb, 0x9c, 0xe1, 0x6b, + 0x05, 0xbf, 0x6d, 0x75, 0xae, 0x5c, 0xef, 0x38, 0xef, 0xf1, 0xfe, 0x2b, 0xbd, 0x92, 0x23, 0x08, + 0x80, 0x91, 0x67, 0xb8, 0xad, 0x77, 0xd1, 0x40, 0x76, 0xd3, 0xdd, 0x1b, 0xdc, 0xa3, 0x17, 0xaf, + 0x28, 0xdd, 0xee, 0xd1, 0xb0, 0x55, 0xe6, 0xf7, 0xab, 0xb1, 0xe1, 0xbb, 0x93, 0xb5, 0x89, 0x4e, + 0xd7, 0x26, 0xfa, 0xb1, 0x36, 0xd1, 0x72, 0x63, 0x36, 0x4e, 0x37, 0x66, 0xe3, 0xdb, 0xc6, 0x6c, + 0x7c, 0x1a, 0x44, 0x1c, 0xe2, 0x22, 0xa4, 0x13, 0x91, 0x78, 0x95, 0xe8, 0xa3, 0x79, 0x10, 0xca, + 0xfa, 0xe0, 0x1d, 0xf7, 0x8f, 0xbc, 0xcf, 0xf5, 0x8f, 0x02, 0x8b, 0x8c, 0xc9, 0xb0, 0xad, 0xfa, + 0x3e, 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x8a, 0xb1, 0xa0, 0x47, 0x03, 0x00, 0x00, } func (m *EpochInfo) Marshal() (dAtA []byte, err error) { diff --git a/x/epochs/types/hooks.go b/x/epochs/types/hooks.go index dfa17ed05f8..2546c5cdfb4 100644 --- a/x/epochs/types/hooks.go +++ b/x/epochs/types/hooks.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" + "github.com/osmosis-labs/osmosis/v13/osmoutils" ) type EpochHooks interface { diff --git a/x/epochs/types/hooks_test.go b/x/epochs/types/hooks_test.go index 419e7722978..e83db2d578c 100644 --- a/x/epochs/types/hooks_test.go +++ b/x/epochs/types/hooks_test.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) type KeeperTestSuite struct { diff --git a/x/epochs/types/query.pb.go b/x/epochs/types/query.pb.go index 241829bca76..b2164e2f17c 100644 --- a/x/epochs/types/query.pb.go +++ b/x/epochs/types/query.pb.go @@ -211,30 +211,30 @@ var fileDescriptor_574bd176519c765f = []byte{ // 410 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xcf, 0x6e, 0xd3, 0x30, 0x18, 0x8f, 0x5b, 0xa8, 0x84, 0x29, 0x17, 0x0b, 0x95, 0x10, 0x21, 0x53, 0x82, 0x80, 0x0a, 0xa9, - 0x31, 0x09, 0x37, 0x2e, 0xa0, 0x22, 0x0e, 0x48, 0x5c, 0xc8, 0xb1, 0x17, 0x94, 0x04, 0x37, 0xb5, - 0xd4, 0xda, 0x69, 0xec, 0x54, 0xf4, 0xca, 0x13, 0x20, 0xa1, 0xbd, 0xc0, 0x9e, 0x65, 0x87, 0x1e, - 0x2b, 0xed, 0xb2, 0xd3, 0x34, 0xb5, 0x7b, 0x90, 0x29, 0x4e, 0x52, 0x75, 0x5d, 0x3a, 0x6d, 0xb7, - 0xc4, 0xbf, 0xbf, 0xdf, 0x67, 0x43, 0x4b, 0xc8, 0xa9, 0x90, 0x4c, 0x12, 0x9a, 0x88, 0x68, 0x2c, - 0xc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 0xf9, 0x6f, 0x1d, 0xa5, 0xf5, 0x75, + 0xaf, 0x19, 0xee, 0x90, 0x7b, 0xa7, 0x35, 0xf8, 0x58, 0x5b, 0xa0, 0x63, 0x00, 0xe1, 0xb6, 0xa3, + 0x44, 0xce, 0xa1, 0x39, 0xaa, 0x57, 0x64, 0x91, 0x7b, 0xf3, 0xf3, 0x7a, 0xf6, 0xfb, 0x7f, 0x67, + 0x57, 0x47, 0xb5, 0x36, 0xc2, 0x64, 0xef, 0x52, 0xca, 0xdb, 0xcb, 0x7f, 0xd1, 0x09, 0x80, 0xcd, + 0xdd, 0xf9, 0xd0, 0xa7, 0x3b, 0x93, 0x2a, 0xd6, 0x68, 0xb9, 0x0f, 0x50, 0x14, 0xed, 0xba, 0xba, + 0xdd, 0x07, 0xf4, 0xee, 0x50, 0xbb, 0x1b, 0xab, 0x1d, 0xfc, 0x5c, 0xae, 0x31, 0x58, 0xad, 0x31, + 0xb8, 0x5c, 0x63, 0xf0, 0x7f, 0x83, 0x8d, 0xd5, 0x06, 0x1b, 0xe7, 0x1b, 0x6c, 0x0c, 0x7b, 0x11, + 0x53, 0xe3, 0x34, 0x70, 0x42, 0x31, 0x2d, 0xad, 0xba, 0x13, 0x3f, 0x90, 0x5b, 0xdf, 0xb9, 0xdb, + 0x27, 0x7f, 0x4b, 0x77, 0xb5, 0x88, 0xa9, 0x0c, 0x1a, 0xfa, 0x3d, 0xf6, 0xaf, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x72, 0x9c, 0x8a, 0x84, 0x43, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/gamm/client/cli/cli_test.go b/x/gamm/client/cli/cli_test.go index fdab0216ed7..8958d2c578a 100644 --- a/x/gamm/client/cli/cli_test.go +++ b/x/gamm/client/cli/cli_test.go @@ -7,12 +7,12 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/gamm/client/cli" - gammtestutil "github.com/osmosis-labs/osmosis/v12/x/gamm/client/testutil" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/gamm/client/cli" + gammtestutil "github.com/osmosis-labs/osmosis/v13/x/gamm/client/testutil" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" diff --git a/x/gamm/client/cli/flags.go b/x/gamm/client/cli/flags.go index f7abe3db117..0cb98129b54 100644 --- a/x/gamm/client/cli/flags.go +++ b/x/gamm/client/cli/flags.go @@ -7,6 +7,7 @@ import ( const ( // Will be parsed to string. FlagPoolFile = "pool-file" + FlagPoolType = "pool-type" // Names of fields in pool json file. PoolFileWeights = "weights" @@ -37,9 +38,11 @@ const ( FlagSwapRouteAmounts = "swap-route-amounts" // Will be parsed to []string. FlagSwapRouteDenoms = "swap-route-denoms" + // FlagScalingFactors represents the flag name for the scaling factors. + FlagScalingFactors = "scaling-factors" ) -type createPoolInputs struct { +type createBalancerPoolInputs struct { Weights string `json:"weights"` InitialDeposit string `json:"initial-deposit"` SwapFee string `json:"swap-fee"` @@ -48,6 +51,15 @@ type createPoolInputs struct { SmoothWeightChangeParams smoothWeightChangeParamsInputs `json:"lbp-params"` } +type createStableswapPoolInputs struct { + InitialDeposit string `json:"initial-deposit"` + SwapFee string `json:"swap-fee"` + ExitFee string `json:"exit-fee"` + FutureGovernor string `json:"future-governor"` + ScalingFactorController string `json:"scaling-factor-controller"` + ScalingFactors string `json:"scaling-factors"` +} + type smoothWeightChangeParamsInputs struct { StartTime string `json:"start-time"` Duration string `json:"duration"` @@ -57,16 +69,16 @@ type smoothWeightChangeParamsInputs struct { func FlagSetQuerySwapRoutes() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) - fs.StringArray(FlagSwapRoutePoolIds, []string{""}, "swap route pool id") - fs.StringArray(FlagSwapRouteDenoms, []string{""}, "swap route amount") + fs.String(FlagSwapRoutePoolIds, "", "swap route pool id") + fs.String(FlagSwapRouteDenoms, "", "swap route amount") return fs } func FlagSetSwapAmountOutRoutes() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) - fs.StringArray(FlagSwapRoutePoolIds, []string{""}, "swap route pool ids") - fs.StringArray(FlagSwapRouteDenoms, []string{""}, "swap route denoms") + fs.String(FlagSwapRoutePoolIds, "", "swap route pool ids") + fs.String(FlagSwapRouteDenoms, "", "swap route denoms") return fs } @@ -74,6 +86,8 @@ func FlagSetCreatePool() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) fs.String(FlagPoolFile, "", "Pool json file path (if this path is given, other create pool flags should not be used)") + fs.String(FlagPoolType, "uniswap", "Pool type (either \"balancer\", \"uniswap\", or \"stableswap\"") + return fs } @@ -104,3 +118,12 @@ func FlagSetJoinSwapExternAmount() *flag.FlagSet { return fs } + +func FlagSetAdjustScalingFactors() *flag.FlagSet { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + fs.Uint64(FlagPoolId, 0, "The id of pool") + fs.String(FlagScalingFactors, "", "The scaling factors") + + return fs +} diff --git a/x/gamm/client/cli/parse.go b/x/gamm/client/cli/parse.go index 6a16ee9aa2a..951db760378 100644 --- a/x/gamm/client/cli/parse.go +++ b/x/gamm/client/cli/parse.go @@ -9,15 +9,23 @@ import ( "github.com/spf13/pflag" ) -type XCreatePoolInputs createPoolInputs +// TODO: move these to exported types within an internal package +type XCreatePoolInputs createBalancerPoolInputs type XCreatePoolInputsExceptions struct { XCreatePoolInputs Other *string // Other won't raise an error } +type XCreateStableswapPoolInputs createStableswapPoolInputs + +type XCreateStableswapPoolInputsExceptions struct { + XCreateStableswapPoolInputs + Other *string // Other won't raise an error +} + // UnmarshalJSON should error if there are fields unexpected. -func (release *createPoolInputs) UnmarshalJSON(data []byte) error { +func (release *createBalancerPoolInputs) UnmarshalJSON(data []byte) error { var createPoolE XCreatePoolInputsExceptions dec := json.NewDecoder(bytes.NewReader(data)) dec.DisallowUnknownFields() // Force @@ -26,12 +34,48 @@ func (release *createPoolInputs) UnmarshalJSON(data []byte) error { return err } - *release = createPoolInputs(createPoolE.XCreatePoolInputs) + *release = createBalancerPoolInputs(createPoolE.XCreatePoolInputs) + return nil +} + +func parseCreateBalancerPoolFlags(fs *pflag.FlagSet) (*createBalancerPoolInputs, error) { + pool := &createBalancerPoolInputs{} + poolFile, _ := fs.GetString(FlagPoolFile) + + if poolFile == "" { + return nil, fmt.Errorf("must pass in a pool json using the --%s flag", FlagPoolFile) + } + + contents, err := os.ReadFile(poolFile) + if err != nil { + return nil, err + } + + // make exception if unknown field exists + err = pool.UnmarshalJSON(contents) + if err != nil { + return nil, err + } + + return pool, nil +} + +// UnmarshalJSON should error if there are fields unexpected. +func (release *createStableswapPoolInputs) UnmarshalJSON(data []byte) error { + var createPoolE XCreateStableswapPoolInputsExceptions + dec := json.NewDecoder(bytes.NewReader(data)) + dec.DisallowUnknownFields() // Force + + if err := dec.Decode(&createPoolE); err != nil { + return err + } + + *release = createStableswapPoolInputs(createPoolE.XCreateStableswapPoolInputs) return nil } -func parseCreatePoolFlags(fs *pflag.FlagSet) (*createPoolInputs, error) { - pool := &createPoolInputs{} +func parseCreateStableswapPoolFlags(fs *pflag.FlagSet) (*createStableswapPoolInputs, error) { + pool := &createStableswapPoolInputs{} poolFile, _ := fs.GetString(FlagPoolFile) if poolFile == "" { diff --git a/x/gamm/client/cli/query.go b/x/gamm/client/cli/query.go index 86e511f62fe..51a10ed2757 100644 --- a/x/gamm/client/cli/query.go +++ b/x/gamm/client/cli/query.go @@ -6,14 +6,18 @@ import ( "strconv" "strings" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/spf13/cobra" "gopkg.in/yaml.v2" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // GetQueryCmd returns the cli query commands for this module. @@ -38,6 +42,8 @@ func GetQueryCmd() *cobra.Command { GetCmdEstimateSwapExactAmountIn(), GetCmdEstimateSwapExactAmountOut(), GetCmdTotalPoolLiquidity(), + GetCmdQueryPoolsWithFilter(), + GetCmdPoolType(), ) return cmd @@ -382,6 +388,7 @@ func GetCmdSpotPrice() *cobra.Command { return err } + // nolint: staticcheck res, err := queryClient.SpotPrice(cmd.Context(), &types.QuerySpotPriceRequest{ PoolId: uint64(poolID), BaseAssetDenom: args[1], @@ -504,3 +511,107 @@ $ %s query gamm estimate-swap-exact-amount-out 1 osm11vmx8jtggpd9u7qr0t8vxclycz8 return cmd } + +// GetCmdQueryPoolsWithFilter returns pool with filter +func GetCmdQueryPoolsWithFilter() *cobra.Command { + cmd := &cobra.Command{ + Use: "pools-with-filter ", + Short: "Query pools with filter", + Long: strings.TrimSpace( + fmt.Sprintf(`Query pools with filter. The possible filter options are: + +1. By Pool type: Either "Balancer" or "Stableswap" +2. By min pool liquidity by providing min coins + +Note that if both filters are to be applied, "min_liquidity" always needs to be provided as the first argument. + +Example: +$ %s query gamm pools-with-filter +`, + version.AppName, + ), + ), + Args: cobra.RangeArgs(1, 2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + var min_liquidity sdk.Coins + var pool_type string + if len(args) == 1 { + coins, err := sdk.ParseCoinsNormalized(args[0]) + if err != nil { + pool_type = args[0] + } + min_liquidity = coins + } else { + coins, err := sdk.ParseCoinsNormalized(args[0]) + if err != nil { + return status.Errorf(codes.InvalidArgument, "invalid token: %s", err.Error()) + } + + min_liquidity = coins + pool_type = args[1] + } + + res, err := queryClient.PoolsWithFilter(cmd.Context(), &types.QueryPoolsWithFilterRequest{ + MinLiquidity: min_liquidity, + PoolType: pool_type, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdPoolType returns pool type given pool id. +func GetCmdPoolType() *cobra.Command { + cmd := &cobra.Command{ + Use: "pool-type ", + Short: "Query pool type", + Long: strings.TrimSpace( + fmt.Sprintf(`Query pool type +Example: +$ %s query gamm pool-type +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + poolID, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + res, err := queryClient.PoolType(cmd.Context(), &types.QueryPoolTypeRequest{ + PoolId: uint64(poolID), + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/gamm/client/cli/query_test.go b/x/gamm/client/cli/query_test.go index 649a849ca7f..a3f632664cf 100644 --- a/x/gamm/client/cli/query_test.go +++ b/x/gamm/client/cli/query_test.go @@ -4,10 +4,11 @@ import ( gocontext "context" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) type QueryTestSuite struct { @@ -24,6 +25,19 @@ func (s *QueryTestSuite) SetupSuite() { } func (s *QueryTestSuite) TestQueriesNeverAlterState() { + var ( + fooDenom = apptesting.DefaultPoolAssets[0].Token.Denom + barDenom = apptesting.DefaultPoolAssets[1].Token.Denom + bazDenom = apptesting.DefaultPoolAssets[2].Token.Denom + uosmoDenom = apptesting.DefaultPoolAssets[3].Token.Denom + + basicValidTokensIn = sdk.NewCoins( + sdk.NewCoin(fooDenom, sdk.OneInt()), + sdk.NewCoin(barDenom, sdk.OneInt()), + sdk.NewCoin(bazDenom, sdk.OneInt()), + sdk.NewCoin(uosmoDenom, sdk.OneInt())) + ) + testCases := []struct { name string query string @@ -63,7 +77,7 @@ func (s *QueryTestSuite) TestQueriesNeverAlterState() { { "Query spot price", "/osmosis.gamm.v1beta1.Query/SpotPrice", - &types.QuerySpotPriceRequest{PoolId: 1, BaseAssetDenom: "foo", QuoteAssetDenom: "bar"}, + &types.QuerySpotPriceRequest{PoolId: 1, BaseAssetDenom: fooDenom, QuoteAssetDenom: barDenom}, &types.QuerySpotPriceResponse{}, }, { @@ -84,6 +98,24 @@ func (s *QueryTestSuite) TestQueriesNeverAlterState() { &types.QueryTotalSharesRequest{PoolId: 1}, &types.QueryTotalSharesResponse{}, }, + { + "Query estimate for join pool shares with no swap", + "/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares", + &types.QueryCalcJoinPoolNoSwapSharesRequest{PoolId: 1, TokensIn: basicValidTokensIn}, + &types.QueryCalcJoinPoolNoSwapSharesResponse{}, + }, + { + "Query estimate for join pool shares with no swap", + "/osmosis.gamm.v1beta1.Query/CalcJoinPoolShares", + &types.QueryCalcJoinPoolSharesRequest{PoolId: 1, TokensIn: basicValidTokensIn}, + &types.QueryCalcJoinPoolSharesResponse{}, + }, + { + "Query exit pool coins from shares", + "/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares", + &types.QueryCalcExitPoolCoinsFromSharesRequest{PoolId: 1, ShareInAmount: sdk.OneInt()}, + &types.QueryCalcExitPoolCoinsFromSharesResponse{}, + }, } for _, tc := range testCases { diff --git a/x/gamm/client/cli/tx.go b/x/gamm/client/cli/tx.go index b82f7372faf..2fe57502ceb 100644 --- a/x/gamm/client/cli/tx.go +++ b/x/gamm/client/cli/tx.go @@ -4,13 +4,15 @@ import ( "errors" "fmt" "strconv" + "strings" "time" "github.com/spf13/cobra" flag "github.com/spf13/pflag" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -37,6 +39,7 @@ func NewTxCmd() *cobra.Command { NewJoinSwapShareAmountOut(), NewExitSwapExternAmountOut(), NewExitSwapShareAmountIn(), + NewStableSwapAdjustScalingFactorsCmd(), ) return txCmd @@ -47,7 +50,7 @@ func NewCreatePoolCmd() *cobra.Command { Use: "create-pool [flags]", Short: "create a new pool and provide the liquidity to it", Long: `Must provide path to a pool JSON file (--pool-file) describing the pool to be created`, - Example: `Sample pool JSON file contents: + Example: `Sample pool JSON file contents for balancer: { "weights": "4uatom,4osmo,2uakt", "initial-deposit": "100uatom,5osmo,20uakt", @@ -55,6 +58,15 @@ func NewCreatePoolCmd() *cobra.Command { "exit-fee": "0.01", "future-governor": "168h" } + +For stableswap (demonstrating need for a 1:1000 scaling factor, see doc) +{ + "initial-deposit": "1000000uusdc,1000miliusdc", + "swap-fee": "0.01", + "exit-fee": "0.01", + "future-governor": "168h", + "scaling-factors": "1000,1" +} `, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { @@ -63,12 +75,27 @@ func NewCreatePoolCmd() *cobra.Command { return err } - txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()). + WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - txf, msg, err := NewBuildCreateBalancerPoolMsg(clientCtx, txf, cmd.Flags()) + poolType, err := cmd.Flags().GetString(FlagPoolType) if err != nil { return err } + poolType = strings.ToLower(poolType) + + var msg sdk.Msg + if poolType == "balancer" || poolType == "uniswap" { + txf, msg, err = NewBuildCreateBalancerPoolMsg(clientCtx, txf, cmd.Flags()) + if err != nil { + return err + } + } else if poolType == "stableswap" { + txf, msg, err = NewBuildCreateStableswapPoolMsg(clientCtx, txf, cmd.Flags()) + if err != nil { + return err + } + } return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) }, @@ -322,8 +349,37 @@ func NewExitSwapShareAmountIn() *cobra.Command { return cmd } +func NewStableSwapAdjustScalingFactorsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "adjust-scaling-factors --pool-id=[pool-id] --scaling-factors=[scaling-factors]", + Short: "adjust scaling factors", + Example: "osmosisd adjust-scaling-factors --pool-id=1 --scaling-factors=\"100, 100\"", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + txf, msg, err := NewStableSwapAdjustScalingFactorsMsg(clientCtx, txf, cmd.Flags()) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + cmd.Flags().AddFlagSet(FlagSetAdjustScalingFactors()) + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(FlagPoolId) + + return cmd +} + func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { - pool, err := parseCreatePoolFlags(fs) + pool, err := parseCreateBalancerPoolFlags(fs) if err != nil { return txf, nil, fmt.Errorf("failed to parse pool: %w", err) } @@ -421,6 +477,61 @@ func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs return txf, msg, nil } +// Apologies to whoever has to touch this next, this code is horrendous +func NewBuildCreateStableswapPoolMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + flags, err := parseCreateStableswapPoolFlags(fs) + if err != nil { + return txf, nil, fmt.Errorf("failed to parse pool: %w", err) + } + + deposit, err := ParseCoinsNoSort(flags.InitialDeposit) + if err != nil { + return txf, nil, err + } + + swapFee, err := sdk.NewDecFromStr(flags.SwapFee) + if err != nil { + return txf, nil, err + } + + exitFee, err := sdk.NewDecFromStr(flags.ExitFee) + if err != nil { + return txf, nil, err + } + + poolParams := &stableswap.PoolParams{ + SwapFee: swapFee, + ExitFee: exitFee, + } + + scalingFactors := []uint64{} + trimmedSfString := strings.Trim(flags.ScalingFactors, "[] {}") + if len(trimmedSfString) > 0 { + ints := strings.Split(trimmedSfString, ",") + for _, i := range ints { + u, err := strconv.ParseUint(i, 10, 64) + if err != nil { + return txf, nil, err + } + scalingFactors = append(scalingFactors, u) + } + if len(scalingFactors) != len(deposit) { + return txf, nil, fmt.Errorf("number of scaling factors doesn't match number of assets") + } + } + + msg := &stableswap.MsgCreateStableswapPool{ + Sender: clientCtx.GetFromAddress().String(), + PoolParams: poolParams, + InitialPoolLiquidity: deposit, + ScalingFactors: scalingFactors, + ScalingFactorController: flags.ScalingFactorController, + FuturePoolGovernor: flags.FutureGovernor, + } + + return txf, msg, nil +} + func NewBuildJoinPoolMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { poolId, err := fs.GetUint64(FlagPoolId) if err != nil { @@ -502,58 +613,62 @@ func NewBuildExitPoolMsg(clientCtx client.Context, txf tx.Factory, fs *flag.Flag } func swapAmountInRoutes(fs *flag.FlagSet) ([]types.SwapAmountInRoute, error) { - swapRoutePoolIds, err := fs.GetStringArray(FlagSwapRoutePoolIds) + swapRoutePoolIds, err := fs.GetString(FlagSwapRoutePoolIds) + swapRoutePoolIdsArray := strings.Split(swapRoutePoolIds, ",") if err != nil { return nil, err } - swapRouteDenoms, err := fs.GetStringArray(FlagSwapRouteDenoms) + swapRouteDenoms, err := fs.GetString(FlagSwapRouteDenoms) + swapRouteDenomsArray := strings.Split(swapRouteDenoms, ",") if err != nil { return nil, err } - if len(swapRoutePoolIds) != len(swapRouteDenoms) { + if len(swapRoutePoolIdsArray) != len(swapRouteDenomsArray) { return nil, errors.New("swap route pool ids and denoms mismatch") } routes := []types.SwapAmountInRoute{} - for index, poolIDStr := range swapRoutePoolIds { + for index, poolIDStr := range swapRoutePoolIdsArray { pID, err := strconv.Atoi(poolIDStr) if err != nil { return nil, err } routes = append(routes, types.SwapAmountInRoute{ PoolId: uint64(pID), - TokenOutDenom: swapRouteDenoms[index], + TokenOutDenom: swapRouteDenomsArray[index], }) } return routes, nil } func swapAmountOutRoutes(fs *flag.FlagSet) ([]types.SwapAmountOutRoute, error) { - swapRoutePoolIds, err := fs.GetStringArray(FlagSwapRoutePoolIds) + swapRoutePoolIds, err := fs.GetString(FlagSwapRoutePoolIds) + swapRoutePoolIdsArray := strings.Split(swapRoutePoolIds, ",") if err != nil { return nil, err } - swapRouteDenoms, err := fs.GetStringArray(FlagSwapRouteDenoms) + swapRouteDenoms, err := fs.GetString(FlagSwapRouteDenoms) + swapRouteDenomsArray := strings.Split(swapRouteDenoms, ",") if err != nil { return nil, err } - if len(swapRoutePoolIds) != len(swapRouteDenoms) { + if len(swapRoutePoolIdsArray) != len(swapRouteDenomsArray) { return nil, errors.New("swap route pool ids and denoms mismatch") } routes := []types.SwapAmountOutRoute{} - for index, poolIDStr := range swapRoutePoolIds { + for index, poolIDStr := range swapRoutePoolIdsArray { pID, err := strconv.Atoi(poolIDStr) if err != nil { return nil, err } routes = append(routes, types.SwapAmountOutRoute{ PoolId: uint64(pID), - TokenInDenom: swapRouteDenoms[index], + TokenInDenom: swapRouteDenomsArray[index], }) } return routes, nil @@ -713,3 +828,50 @@ func NewBuildExitSwapShareAmountInMsg(clientCtx client.Context, tokenOutDenom, s return txf, msg, nil } + +func NewStableSwapAdjustScalingFactorsMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + poolID, err := fs.GetUint64(FlagPoolId) + if err != nil { + return txf, nil, err + } + + scalingFactorsStr, err := fs.GetString(FlagScalingFactors) + if err != nil { + return txf, nil, err + } + + scalingFactorsStrSlice := strings.Split(scalingFactorsStr, ",") + + scalingFactors := make([]uint64, len(scalingFactorsStrSlice)) + for i, scalingFactorStr := range scalingFactorsStrSlice { + scalingFactor, err := strconv.ParseUint(scalingFactorStr, 10, 64) + if err != nil { + return txf, nil, err + } + scalingFactors[i] = scalingFactor + } + + msg := &stableswap.MsgStableSwapAdjustScalingFactors{ + Sender: clientCtx.GetFromAddress().String(), + PoolID: poolID, + ScalingFactors: scalingFactors, + } + + return txf, msg, nil +} + +// ParseCoinsNoSort parses coins from coinsStr but does not sort them. +// Returns error if parsing fails. +func ParseCoinsNoSort(coinsStr string) (sdk.Coins, error) { + coinStrs := strings.Split(coinsStr, ",") + decCoins := make(sdk.DecCoins, len(coinStrs)) + for i, coinStr := range coinStrs { + coin, err := sdk.ParseDecCoin(coinStr) + if err != nil { + return sdk.Coins{}, err + } + + decCoins[i] = coin + } + return sdk.NormalizeCoins(decCoins), nil +} diff --git a/x/gamm/client/cli/tx_test.go b/x/gamm/client/cli/tx_test.go new file mode 100644 index 00000000000..93518ebd6df --- /dev/null +++ b/x/gamm/client/cli/tx_test.go @@ -0,0 +1,71 @@ +package cli_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v13/x/gamm/client/cli" +) + +func TestParseCoinsNoSort(t *testing.T) { + const ( + a = "aaa" + b = "bbb" + c = "ccc" + d = "ddd" + ) + + var ( + ten = sdk.NewInt(10) + + coinA = sdk.NewCoin(a, ten) + coinB = sdk.NewCoin(b, ten) + coinC = sdk.NewCoin(c, ten) + coinD = sdk.NewCoin(d, ten) + ) + + tests := map[string]struct { + coinsStr string + expectedCoins sdk.Coins + }{ + "ascending": { + coinsStr: "10aaa,10bbb,10ccc,10ddd", + expectedCoins: sdk.Coins{ + coinA, + coinB, + coinC, + coinD, + }, + }, + "descending": { + coinsStr: "10ddd,10ccc,10bbb,10aaa", + expectedCoins: sdk.Coins{ + coinD, + coinC, + coinB, + coinA, + }, + }, + "mixed with different values.": { + coinsStr: "100ddd,20bbb,300aaa,40ccc", + expectedCoins: sdk.Coins{ + sdk.NewCoin(d, sdk.NewInt(100)), + sdk.NewCoin(b, sdk.NewInt(20)), + sdk.NewCoin(a, sdk.NewInt(300)), + sdk.NewCoin(c, sdk.NewInt(40)), + }, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + + coins, err := cli.ParseCoinsNoSort(tc.coinsStr) + + require.NoError(t, err) + require.Equal(t, tc.expectedCoins, coins) + }) + } +} diff --git a/x/gamm/client/docs/README.md b/x/gamm/client/docs/README.md index c9587bdf658..6255c349500 100644 --- a/x/gamm/client/docs/README.md +++ b/x/gamm/client/docs/README.md @@ -2,5 +2,6 @@ TODO add an index here explaining each tx type -- [`create-pool`](./create-pool.md) +- [`create-balancer-pool`](./create-pool.md) - [`create-lbp-pool`](./create-lbp-pool.md) +- [`create-stableswap-pool`](./create-stableswap-pool.md) diff --git a/x/gamm/client/docs/create-pool.md b/x/gamm/client/docs/create-balancer-pool.md similarity index 100% rename from x/gamm/client/docs/create-pool.md rename to x/gamm/client/docs/create-balancer-pool.md diff --git a/x/gamm/client/docs/create-stableswap-pool.md b/x/gamm/client/docs/create-stableswap-pool.md new file mode 100644 index 00000000000..1a61a13753a --- /dev/null +++ b/x/gamm/client/docs/create-stableswap-pool.md @@ -0,0 +1,25 @@ +# Create-pool + +In a create-stableswap-pool tx, it is important that the initial-deposit, and scaling factors, match the 1:1 price of the pool. + +So you want the scaling factors to be such that `deposit_asset_1 / scaling_factor_1` is intended to have the same economic value as `deposit_asset_2 / scaling_factor_2`. + +The below is an example of the pool.json file for a pool with $1 worth of `uusdc` and an imagined asset `miliusdc`. So namely, `1 USDC = 10^6 uusdc = 10^3 miliusdc`. This implies a need for a `1000:1` scaling factor. + +Here is what this would look like: + +pool.json + +``` {.json} +{ + "initial-deposit": "1000000uusdc,1000miliusdc", + "scaling-factors": "1000,1", + "swap-fee": "0.005", + "exit-fee": "0.00", + "future-governor": "168h", + "scaling-factor-controller": "" +} +``` + +There is also an optional field called `scaling-factor-controller`, +where you give a certain address the ability to control the scaling factors. \ No newline at end of file diff --git a/x/gamm/client/testutil/test_helpers.go b/x/gamm/client/testutil/test_helpers.go index d551be2f6d7..9e68396c2c4 100644 --- a/x/gamm/client/testutil/test_helpers.go +++ b/x/gamm/client/testutil/test_helpers.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - gammcli "github.com/osmosis-labs/osmosis/v12/x/gamm/client/cli" + gammcli "github.com/osmosis-labs/osmosis/v13/x/gamm/client/cli" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/gamm/keeper/export_test.go b/x/gamm/keeper/export_test.go index 31119cbf1c7..14e63a44b9b 100644 --- a/x/gamm/keeper/export_test.go +++ b/x/gamm/keeper/export_test.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // SetParams sets the total set of params. @@ -19,3 +19,8 @@ func (k Keeper) SetPool(ctx sdk.Context, pool types.PoolI) error { func (k Keeper) GetNextPoolIdAndIncrement(ctx sdk.Context) uint64 { return k.getNextPoolIdAndIncrement(ctx) } + +func (k Keeper) GetOsmoRoutedMultihopTotalSwapFee(ctx sdk.Context, route types.MultihopRoute) ( + totalPathSwapFee sdk.Dec, sumOfSwapFees sdk.Dec, err error) { + return k.getOsmoRoutedMultihopTotalSwapFee(ctx, route) +} diff --git a/x/gamm/keeper/gas_test.go b/x/gamm/keeper/gas_test.go index 7f505ca59c0..1a723829a08 100644 --- a/x/gamm/keeper/gas_test.go +++ b/x/gamm/keeper/gas_test.go @@ -4,9 +4,9 @@ import ( "fmt" "strconv" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - balancertypes "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/gamm/keeper/genesis.go b/x/gamm/keeper/genesis.go index 813d69a1e4f..9a9afd56b3b 100644 --- a/x/gamm/keeper/genesis.go +++ b/x/gamm/keeper/genesis.go @@ -4,7 +4,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // InitGenesis initializes the x/gamm module's state from a provided genesis diff --git a/x/gamm/keeper/genesis_test.go b/x/gamm/keeper/genesis_test.go index c5a592bec09..d8519358471 100644 --- a/x/gamm/keeper/genesis_test.go +++ b/x/gamm/keeper/genesis_test.go @@ -11,10 +11,10 @@ import ( "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - osmoapp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/gamm" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + osmoapp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/gamm" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func TestGammInitGenesis(t *testing.T) { diff --git a/x/gamm/keeper/grpc_query.go b/x/gamm/keeper/grpc_query.go index 3af3ae40609..159fc948d7d 100644 --- a/x/gamm/keeper/grpc_query.go +++ b/x/gamm/keeper/grpc_query.go @@ -3,7 +3,6 @@ package keeper import ( "context" "fmt" - "math/big" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -14,24 +13,11 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/v2types" ) -var sdkIntMaxValue = sdk.NewInt(0) - -func init() { - maxInt := big.NewInt(2) - maxInt = maxInt.Exp(maxInt, big.NewInt(256), nil) - - _sdkIntMaxValue, ok := sdk.NewIntFromString(maxInt.Sub(maxInt, big.NewInt(1)).String()) - if !ok { - panic("Failed to calculate the max value of sdk.Int") - } - - sdkIntMaxValue = _sdkIntMaxValue -} - var _ types.QueryServer = Querier{} // Querier defines a wrapper around the x/gamm keeper providing gRPC method @@ -44,6 +30,16 @@ func NewQuerier(k Keeper) Querier { return Querier{Keeper: k} } +// QuerierV2 defines a wrapper around the x/gamm keeper providing gRPC method +// handlers for v2 queries. +type QuerierV2 struct { + Keeper +} + +func NewV2Querier(k Keeper) QuerierV2 { + return QuerierV2{Keeper: k} +} + // Pool checks if a pool exists and their respective poolWeights. func (q Querier) Pool( ctx context.Context, @@ -94,13 +90,7 @@ func (q Querier) Pools( return err } - // TODO: pools query should not be balancer specific - pool, ok := poolI.(*balancer.Pool) - if !ok { - return fmt.Errorf("pool (%d) is not basic pool", pool.GetId()) - } - - any, err := codectypes.NewAnyWithValue(pool) + any, err := codectypes.NewAnyWithValue(poolI) if err != nil { return err } @@ -140,6 +130,140 @@ func (q Querier) PoolType(ctx context.Context, req *types.QueryPoolTypeRequest) }, err } +// CalcJoinPoolShares queries the amount of shares you get by providing specific amount of tokens +func (q Querier) CalcJoinPoolShares(ctx context.Context, req *types.QueryCalcJoinPoolSharesRequest) (*types.QueryCalcJoinPoolSharesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + if req.TokensIn == nil { + return nil, status.Error(codes.InvalidArgument, "no tokens in") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + pool, err := q.Keeper.getPoolForSwap(sdkCtx, req.PoolId) + if err != nil { + return nil, err + } + + numShares, newLiquidity, err := pool.CalcJoinPoolShares(sdkCtx, req.TokensIn, pool.GetSwapFee(sdkCtx)) + if err != nil { + return nil, err + } + + return &types.QueryCalcJoinPoolSharesResponse{ + ShareOutAmount: numShares, + TokensOut: newLiquidity, + }, nil +} + +// PoolsWithFilter query allows to query pools with specific parameters +func (q Querier) PoolsWithFilter(ctx context.Context, req *types.QueryPoolsWithFilterRequest) (*types.QueryPoolsWithFilterResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + store := sdkCtx.KVStore(q.Keeper.storeKey) + poolStore := prefix.NewStore(store, types.KeyPrefixPools) + + var response = []*codectypes.Any{} + pageRes, err := query.FilteredPaginate(poolStore, req.Pagination, func(_, value []byte, accumulate bool) (bool, error) { + pool, err := q.Keeper.UnmarshalPool(value) + if err != nil { + return false, err + } + + poolId := pool.GetId() + + // if liquidity specified in request + if len(req.MinLiquidity) > 0 { + poolLiquidity := pool.GetTotalPoolLiquidity(sdkCtx) + + if !poolLiquidity.IsAllGTE(req.MinLiquidity) { + return false, nil + } + } + + // if pool type specified in request + if req.PoolType != "" { + poolType, err := q.GetPoolType(sdkCtx, poolId) + if err != nil { + return false, types.ErrPoolNotFound + } + + if poolType != req.PoolType { + return false, nil + } + } + + any, err := codectypes.NewAnyWithValue(pool) + if err != nil { + return false, err + } + + if accumulate { + response = append(response, any) + } + + return true, nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryPoolsWithFilterResponse{ + Pools: response, + Pagination: pageRes, + }, nil +} + +// CalcExitPoolCoinsFromShares queries the amount of tokens you get by exiting a specific amount of shares +func (q Querier) CalcExitPoolCoinsFromShares(ctx context.Context, req *types.QueryCalcExitPoolCoinsFromSharesRequest) (*types.QueryCalcExitPoolCoinsFromSharesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + pool, err := q.Keeper.GetPoolAndPoke(sdkCtx, req.PoolId) + if err != nil { + return nil, types.ErrPoolNotFound + } + + exitFee := pool.GetExitFee(sdkCtx) + + totalSharesAmount := pool.GetTotalShares() + if req.ShareInAmount.GTE(totalSharesAmount) || req.ShareInAmount.LTE(sdk.ZeroInt()) { + return nil, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative") + } + + exitCoins, err := pool.CalcExitPoolCoinsFromShares(sdkCtx, req.ShareInAmount, exitFee) + if err != nil { + return nil, err + } + + return &types.QueryCalcExitPoolCoinsFromSharesResponse{TokensOut: exitCoins}, nil +} + +// CalcJoinPoolNoSwapShares returns the amount of shares you'd get if joined a pool without a swap and tokens which need to be provided +func (q Querier) CalcJoinPoolNoSwapShares(ctx context.Context, req *types.QueryCalcJoinPoolNoSwapSharesRequest) (*types.QueryCalcJoinPoolNoSwapSharesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + pool, err := q.GetPoolAndPoke(sdkCtx, req.PoolId) + if err != nil { + return nil, err + } + + sharesOut, tokensJoined, err := pool.CalcJoinPoolNoSwapShares(sdkCtx, req.TokensIn, pool.GetSwapFee(sdkCtx)) + if err != nil { + return nil, err + } + + return &types.QueryCalcJoinPoolNoSwapSharesResponse{ + TokensOut: tokensJoined, + SharesOut: sharesOut, + }, nil +} + // PoolParams queries a specified pool for its params. func (q Querier) PoolParams(ctx context.Context, req *types.QueryPoolParamsRequest) (*types.QueryPoolParamsResponse, error) { if req == nil { @@ -209,6 +333,7 @@ func (q Querier) TotalShares(ctx context.Context, req *types.QueryTotalSharesReq } // SpotPrice returns target pool asset prices on base and quote assets. +// nolint: staticcheck func (q Querier) SpotPrice(ctx context.Context, req *types.QuerySpotPriceRequest) (*types.QuerySpotPriceResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -234,6 +359,31 @@ func (q Querier) SpotPrice(ctx context.Context, req *types.QuerySpotPriceRequest }, nil } +func (q QuerierV2) SpotPrice(ctx context.Context, req *v2types.QuerySpotPriceRequest) (*v2types.QuerySpotPriceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.BaseAssetDenom == "" { + return nil, status.Error(codes.InvalidArgument, "invalid base asset denom") + } + + if req.QuoteAssetDenom == "" { + return nil, status.Error(codes.InvalidArgument, "invalid quote asset denom") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sp, err := q.Keeper.CalculateSpotPrice(sdkCtx, req.PoolId, req.QuoteAssetDenom, req.BaseAssetDenom) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &v2types.QuerySpotPriceResponse{ + SpotPrice: sp.String(), + }, nil +} + // TotalLiquidity returns total liquidity across all pools. func (q Querier) TotalLiquidity(ctx context.Context, _ *types.QueryTotalLiquidityRequest) (*types.QueryTotalLiquidityResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -249,23 +399,10 @@ func (q Querier) EstimateSwapExactAmountIn(ctx context.Context, req *types.Query return nil, status.Error(codes.InvalidArgument, "empty request") } - if req.Sender == "" { - return nil, status.Error(codes.InvalidArgument, "address cannot be empty") - } - if req.TokenIn == "" { return nil, status.Error(codes.InvalidArgument, "invalid token") } - if err := types.SwapAmountInRoutes(req.Routes).Validate(); err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - sender, err := sdk.AccAddressFromBech32(req.Sender) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) - } - tokenIn, err := sdk.ParseCoinNormalized(req.TokenIn) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid token: %s", err.Error()) @@ -273,7 +410,7 @@ func (q Querier) EstimateSwapExactAmountIn(ctx context.Context, req *types.Query sdkCtx := sdk.UnwrapSDKContext(ctx) - tokenOutAmount, err := q.Keeper.MultihopSwapExactAmountIn(sdkCtx, sender, req.Routes, tokenIn, sdk.NewInt(1)) + tokenOutAmount, err := q.Keeper.MultihopEstimateOutGivenExactAmountIn(sdkCtx, req.Routes, tokenIn) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -289,23 +426,10 @@ func (q Querier) EstimateSwapExactAmountOut(ctx context.Context, req *types.Quer return nil, status.Error(codes.InvalidArgument, "empty request") } - if req.Sender == "" { - return nil, status.Error(codes.InvalidArgument, "address cannot be empty") - } - if req.TokenOut == "" { return nil, status.Error(codes.InvalidArgument, "invalid token") } - if err := types.SwapAmountOutRoutes(req.Routes).Validate(); err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - sender, err := sdk.AccAddressFromBech32(req.Sender) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) - } - tokenOut, err := sdk.ParseCoinNormalized(req.TokenOut) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid token: %s", err.Error()) @@ -313,7 +437,7 @@ func (q Querier) EstimateSwapExactAmountOut(ctx context.Context, req *types.Quer sdkCtx := sdk.UnwrapSDKContext(ctx) - tokenInAmount, err := q.Keeper.MultihopSwapExactAmountOut(sdkCtx, sender, req.Routes, sdkIntMaxValue, tokenOut) + tokenInAmount, err := q.Keeper.MultihopEstimateInGivenExactAmountOut(sdkCtx, req.Routes, tokenOut) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/gamm/keeper/grpc_query_test.go b/x/gamm/keeper/grpc_query_test.go index 6bbcb39bca3..83c223fee08 100644 --- a/x/gamm/keeper/grpc_query_test.go +++ b/x/gamm/keeper/grpc_query_test.go @@ -2,13 +2,418 @@ package keeper_test import ( gocontext "context" + "errors" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/v2types" ) +func (suite *KeeperTestSuite) TestCalcExitPoolCoinsFromShares() { + queryClient := suite.queryClient + ctx := suite.Ctx + poolId := suite.PrepareBalancerPool() + exitFee := sdk.ZeroDec() + + testCases := []struct { + name string + poolId uint64 + shareInAmount sdk.Int + expectedErr error + }{ + { + "valid test case", + poolId, + sdk.NewInt(1000000000000000000), + nil, + }, + { + "pool id does not exist", + poolId + 1, + sdk.NewInt(1000000000000000000), + types.ErrPoolNotFound, + }, + { + "zero share in amount", + poolId, + sdk.ZeroInt(), + sdkerrors.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative"), + }, + { + "negative share in amount", + poolId, + sdk.NewInt(-10000), + sdkerrors.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative"), + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + out, err := queryClient.CalcExitPoolCoinsFromShares(gocontext.Background(), &types.QueryCalcExitPoolCoinsFromSharesRequest{ + PoolId: tc.poolId, + ShareInAmount: tc.shareInAmount, + }) + if tc.expectedErr == nil { + poolRes, err := queryClient.Pool(gocontext.Background(), &types.QueryPoolRequest{ + PoolId: tc.poolId, + }) + suite.Require().NoError(err) + + var pool types.PoolI + err = suite.App.InterfaceRegistry().UnpackAny(poolRes.Pool, &pool) + suite.Require().NoError(err) + + exitCoins, err := pool.CalcExitPoolCoinsFromShares(ctx, tc.shareInAmount, exitFee) + suite.Require().NoError(err) + + // For each coin in exitCoins we are looking for a match in our response + // We need to find exactly len(out) such matches + coins_checked := 0 + for _, coin := range exitCoins { + for _, actual_coin := range out.TokensOut { + if coin.Denom == actual_coin.Denom { + suite.Require().Equal(coin.Amount, actual_coin.Amount) + coins_checked++ + } + } + } + suite.Require().Equal(out.TokensOut, exitCoins) + } else { + suite.Require().ErrorIs(err, tc.expectedErr) + } + }) + } +} + +func (suite *KeeperTestSuite) TestCalcJoinPoolNoSwapShares() { + queryClient := suite.queryClient + ctx := suite.Ctx + poolId := suite.PrepareBalancerPool() + swapFee := sdk.ZeroDec() + + testCases := []struct { + name string + poolId uint64 + tokensIn sdk.Coins + expectedErr error + }{ + { + "valid uneven multi asset join test case", + poolId, + sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000000)), sdk.NewCoin("bar", sdk.NewInt(5000000)), sdk.NewCoin("baz", sdk.NewInt(5000000)), sdk.NewCoin("uosmo", sdk.NewInt(5000000))), + nil, + }, + { + "valid even multi asset join test case", + poolId, + sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500000)), sdk.NewCoin("bar", sdk.NewInt(1000000)), sdk.NewCoin("baz", sdk.NewInt(1500000)), sdk.NewCoin("uosmo", sdk.NewInt(2000000))), + nil, + }, + { + "invalid single asset join test case", + poolId, + sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + errors.New("no-swap joins require LP'ing with all assets in pool"), + }, + { + "pool id does not exist", + poolId + 1, + sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + types.PoolDoesNotExistError{PoolId: poolId + 1}, + }, + { + "token in denom does not exist", + poolId, + sdk.NewCoins(sdk.NewCoin("random", sdk.NewInt(10000))), + sdkerrors.Wrapf(types.ErrDenomNotFoundInPool, "input denoms must already exist in the pool (%s)", "random"), + }, + { + "join pool with incorrect amount of assets", + poolId, + sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(10000)), sdk.NewCoin("bar", sdk.NewInt(10000))), + errors.New("no-swap joins require LP'ing with all assets in pool"), + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + out, err := queryClient.CalcJoinPoolNoSwapShares(gocontext.Background(), &types.QueryCalcJoinPoolNoSwapSharesRequest{ + PoolId: tc.poolId, + TokensIn: tc.tokensIn, + }) + if tc.expectedErr == nil { + poolRes, err := queryClient.Pool(gocontext.Background(), &types.QueryPoolRequest{ + PoolId: tc.poolId, + }) + suite.Require().NoError(err) + + var pool types.PoolI + err = suite.App.InterfaceRegistry().UnpackAny(poolRes.Pool, &pool) + suite.Require().NoError(err) + + numShares, numLiquidity, err := pool.CalcJoinPoolNoSwapShares(ctx, tc.tokensIn, swapFee) + suite.Require().NoError(err) + suite.Require().Equal(numShares, out.SharesOut) + suite.Require().Equal(numLiquidity, out.TokensOut) + } else { + suite.Require().EqualError(err, tc.expectedErr.Error()) + } + }) + } +} + +func (suite *KeeperTestSuite) TestPoolsWithFilter() { + var ( + defaultAcctFunds sdk.Coins = sdk.NewCoins( + sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), + sdk.NewCoin("foo", sdk.NewInt(10000000)), + sdk.NewCoin("bar", sdk.NewInt(10000000)), + sdk.NewCoin("baz", sdk.NewInt(10000000)), + ) + defaultPoolParams = balancer.PoolParams{ + SwapFee: sdk.ZeroDec(), + ExitFee: sdk.ZeroDec(), + } + ) + + testCases := []struct { + name string + num_pools int + expected_num_pools_response int + min_liquidity sdk.Coins + pool_type string + poolAssets []balancertypes.PoolAsset + expectedErr error + }{ + { + name: "valid tc with both filters for min liquidity and pool type", + num_pools: 1, + expected_num_pools_response: 1, + min_liquidity: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(50000)), sdk.NewCoin("bar", sdk.NewInt(50000))), + pool_type: "Balancer", + poolAssets: []balancertypes.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + }, + expectedErr: nil, + }, + { + name: "only min liquidity specified (too high for pools - return 0 pools)", + num_pools: 1, + expected_num_pools_response: 0, + min_liquidity: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500000000)), sdk.NewCoin("bar", sdk.NewInt(500000000))), + poolAssets: []balancertypes.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + }, + expectedErr: nil, + }, + { + name: "wrong pool type specified", + num_pools: 1, + expected_num_pools_response: 0, + min_liquidity: nil, + pool_type: "balaswap", + poolAssets: []balancertypes.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + }, + expectedErr: nil, + }, + { + name: "2 parameters specified + single-token min liquidity", + num_pools: 1, + expected_num_pools_response: 4, + min_liquidity: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500))), + pool_type: "Balancer", + poolAssets: []balancertypes.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + }, + expectedErr: nil, + }, + { + name: "min_liquidity denom not present in pool", + num_pools: 1, + expected_num_pools_response: 0, + min_liquidity: sdk.NewCoins(sdk.NewCoin("whoami", sdk.NewInt(500))), + poolAssets: []balancertypes.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + }, + expectedErr: nil, + }, + { + name: "only min liquidity specified - valid", + num_pools: 1, + expected_num_pools_response: 6, + min_liquidity: sdk.NewCoins(sdk.NewCoin("foo", sdk.ZeroInt()), sdk.NewCoin("bar", sdk.ZeroInt())), + poolAssets: []balancertypes.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + }, + expectedErr: nil, + }, + { + name: "only valid pool type specified", + num_pools: 1, + expected_num_pools_response: 7, + pool_type: "Balancer", + poolAssets: []balancertypes.PoolAsset{ + { + Weight: sdk.NewInt(100), + Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + }, + { + Weight: sdk.NewInt(200), + Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + }, + }, + expectedErr: nil, + }, + } + for _, tc := range testCases { + suite.Run(tc.name, func() { + for i := 0; i < tc.num_pools; i++ { + suite.prepareCustomBalancerPool( + defaultAcctFunds, + tc.poolAssets, + defaultPoolParams, + ) + } + res, err := suite.queryClient.PoolsWithFilter(suite.Ctx.Context(), &types.QueryPoolsWithFilterRequest{ + MinLiquidity: tc.min_liquidity, + PoolType: tc.pool_type, + }) + if tc.expectedErr == nil { + suite.Require().NoError(err) + suite.Require().Equal(tc.expected_num_pools_response, len(res.Pools)) + } else { + suite.Require().ErrorIs(err, tc.expectedErr) + } + }) + } +} + +func (suite *KeeperTestSuite) TestCalcJoinPoolShares() { + queryClient := suite.queryClient + ctx := suite.Ctx + poolId := suite.PrepareBalancerPool() + swapFee := sdk.ZeroDec() + + testCases := []struct { + name string + poolId uint64 + tokensIn sdk.Coins + expectedErr error + }{ + { + "valid uneven multi asset join test case", + poolId, + sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000000)), sdk.NewCoin("bar", sdk.NewInt(5000000)), sdk.NewCoin("baz", sdk.NewInt(5000000)), sdk.NewCoin("uosmo", sdk.NewInt(5000000))), + nil, + }, + { + "valid even multi asset join test case", + poolId, + sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500000)), sdk.NewCoin("bar", sdk.NewInt(1000000)), sdk.NewCoin("baz", sdk.NewInt(1500000)), sdk.NewCoin("uosmo", sdk.NewInt(2000000))), + nil, + }, + { + "valid single asset join test case", + poolId, + sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + nil, + }, + { + "pool id does not exist", + poolId + 1, + sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + types.PoolDoesNotExistError{PoolId: poolId + 1}, + }, + { + "token in denom does not exist", + poolId, + sdk.NewCoins(sdk.NewCoin("random", sdk.NewInt(10000))), + sdkerrors.Wrapf(types.ErrDenomNotFoundInPool, "input denoms must already exist in the pool (%s)", "random"), + }, + { + "join pool with incorrect amount of assets", + poolId, + sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(10000)), sdk.NewCoin("bar", sdk.NewInt(10000))), + errors.New("balancer pool only supports LP'ing with one asset or all assets in pool"), + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + out, err := queryClient.CalcJoinPoolShares(gocontext.Background(), &types.QueryCalcJoinPoolSharesRequest{ + PoolId: tc.poolId, + TokensIn: tc.tokensIn, + }) + if tc.expectedErr == nil { + poolRes, err := queryClient.Pool(gocontext.Background(), &types.QueryPoolRequest{ + PoolId: tc.poolId, + }) + suite.Require().NoError(err) + + var pool types.PoolI + err = suite.App.InterfaceRegistry().UnpackAny(poolRes.Pool, &pool) + suite.Require().NoError(err) + + numShares, numLiquidity, err := pool.CalcJoinPoolShares(ctx, tc.tokensIn, swapFee) + suite.Require().NoError(err) + suite.Require().Equal(numShares, out.ShareOutAmount) + suite.Require().Equal(numLiquidity, out.TokensOut) + } else { + suite.Require().EqualError(err, tc.expectedErr.Error()) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryPool() { queryClient := suite.queryClient @@ -88,15 +493,21 @@ func (suite *KeeperTestSuite) TestQueryPools() { } func (suite *KeeperTestSuite) TestPoolType() { - poolId := suite.PrepareBalancerPool() + poolIdBalancer := suite.PrepareBalancerPool() + poolIdStableswap := suite.PrepareBasicStableswapPool() // error when querying invalid pool ID - _, err := suite.queryClient.PoolType(gocontext.Background(), &types.QueryPoolTypeRequest{PoolId: poolId + 1}) + _, err := suite.queryClient.PoolType(gocontext.Background(), &types.QueryPoolTypeRequest{PoolId: poolIdStableswap + 1}) suite.Require().Error(err) - res, err := suite.queryClient.PoolType(gocontext.Background(), &types.QueryPoolTypeRequest{PoolId: poolId}) + res, err := suite.queryClient.PoolType(gocontext.Background(), &types.QueryPoolTypeRequest{PoolId: poolIdBalancer}) suite.Require().NoError(err) - suite.Require().Equal("Balancer", res.PoolType) + suite.Require().Equal(balancer.PoolTypeName, res.PoolType) + + res, err = suite.queryClient.PoolType(gocontext.Background(), + &types.QueryPoolTypeRequest{PoolId: poolIdStableswap}) + suite.Require().NoError(err) + suite.Require().Equal(stableswap.PoolTypeName, res.PoolType) } func (suite *KeeperTestSuite) TestQueryNumPools1() { @@ -295,3 +706,268 @@ func (suite *KeeperTestSuite) TestQueryBalancerPoolSpotPrice() { }) } } + +func (suite *KeeperTestSuite) TestV2QueryBalancerPoolSpotPrice() { + v2queryClient := v2types.NewQueryClient(suite.QueryHelper) + coins := sdk.NewCoins( + sdk.NewInt64Coin("tokenA", 1000), + sdk.NewInt64Coin("tokenB", 2000), + sdk.NewInt64Coin("tokenC", 3000), + sdk.NewInt64Coin("tokenD", 4000), + sdk.NewInt64Coin("tokenE", 4000), // 4000 intentional + ) + poolID := suite.PrepareBalancerPoolWithCoins(coins...) + + testCases := []struct { + name string + req *v2types.QuerySpotPriceRequest + expectErr bool + result string + }{ + { + name: "non-existant pool", + req: &v2types.QuerySpotPriceRequest{ + PoolId: 0, + BaseAssetDenom: "tokenA", + QuoteAssetDenom: "tokenB", + }, + expectErr: true, + }, + { + name: "missing asset denoms", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolID, + }, + expectErr: true, + }, + { + name: "missing pool ID and quote denom", + req: &v2types.QuerySpotPriceRequest{ + BaseAssetDenom: "tokenA", + }, + expectErr: true, + }, + { + name: "missing pool ID and base denom", + req: &v2types.QuerySpotPriceRequest{ + QuoteAssetDenom: "tokenB", + }, + expectErr: true, + }, + { + name: "tokenA in terms of tokenB", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolID, + BaseAssetDenom: "tokenA", + QuoteAssetDenom: "tokenB", + }, + result: sdk.NewDec(2).String(), + }, + { + name: "tokenB in terms of tokenA", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolID, + BaseAssetDenom: "tokenB", + QuoteAssetDenom: "tokenA", + }, + result: sdk.NewDecWithPrec(5, 1).String(), + }, + { + name: "tokenC in terms of tokenD (rounded decimal of 4/3)", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolID, + BaseAssetDenom: "tokenC", + QuoteAssetDenom: "tokenD", + }, + result: sdk.MustNewDecFromStr("1.333333330000000000").String(), + }, + { + name: "tokenD in terms of tokenE (1)", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolID, + BaseAssetDenom: "tokenD", + QuoteAssetDenom: "tokenE", + }, + result: sdk.OneDec().String(), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + result, err := v2queryClient.SpotPrice(gocontext.Background(), tc.req) + if tc.expectErr { + suite.Require().Error(err, "expected error") + } else { + suite.Require().NoError(err, "unexpected error") + suite.Require().Equal(tc.result, result.SpotPrice) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryStableswapPoolSpotPrice() { + queryClient := suite.queryClient + poolIDEven := suite.PrepareBasicStableswapPool() + poolIDUneven := suite.PrepareImbalancedStableswapPool() + + testCases := []struct { + name string + req *types.QuerySpotPriceRequest + expectErr bool + result string + }{ + { + name: "non-existent pool", + req: &types.QuerySpotPriceRequest{ + PoolId: 0, + BaseAssetDenom: "foo", + QuoteAssetDenom: "bar", + }, + expectErr: true, + }, + { + name: "missing asset denoms", + req: &types.QuerySpotPriceRequest{ + PoolId: poolIDEven, + }, + expectErr: true, + }, + { + name: "missing pool ID and quote denom", + req: &types.QuerySpotPriceRequest{ + BaseAssetDenom: "foo", + }, + expectErr: true, + }, + { + name: "missing pool ID and base denom", + req: &types.QuerySpotPriceRequest{ + QuoteAssetDenom: "bar", + }, + expectErr: true, + }, + { + name: "valid request for foo/bar in even pool", + req: &types.QuerySpotPriceRequest{ + PoolId: poolIDEven, + BaseAssetDenom: "bar", + QuoteAssetDenom: "foo", + }, + result: "1.000000000000000000", + }, + { + name: "foo in terms of bar for in a 1:2:3, foo bar baz pool", + req: &types.QuerySpotPriceRequest{ + PoolId: poolIDUneven, + BaseAssetDenom: "bar", + QuoteAssetDenom: "foo", + }, + result: "1.454545450000000000", + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + result, err := queryClient.SpotPrice(gocontext.Background(), tc.req) + if tc.expectErr { + suite.Require().Error(err, "expected error") + } else { + suite.Require().NoError(err, "unexpected error") + // We allow for a small geometric error due to our spot price being an approximation + expectedSpotPrice := sdk.MustNewDecFromStr(tc.result) + actualSpotPrice := sdk.MustNewDecFromStr(result.SpotPrice) + diff := (expectedSpotPrice.Sub(actualSpotPrice)).Abs() + errTerm := diff.Quo(sdk.MinDec(expectedSpotPrice, actualSpotPrice)) + + suite.Require().True(errTerm.LT(sdk.NewDecWithPrec(1, 3)), "Expected: %d, Actual: %d", expectedSpotPrice, actualSpotPrice) + } + }) + } +} + +func (suite *KeeperTestSuite) TestV2QueryStableswapPoolSpotPrice() { + v2queryClient := v2types.NewQueryClient(suite.QueryHelper) + poolIDEven := suite.PrepareBasicStableswapPool() + poolIDUneven := suite.PrepareImbalancedStableswapPool() + + testCases := []struct { + name string + req *v2types.QuerySpotPriceRequest + expectErr bool + result string + }{ + { + name: "non-existent pool", + req: &v2types.QuerySpotPriceRequest{ + PoolId: 0, + BaseAssetDenom: "foo", + QuoteAssetDenom: "bar", + }, + expectErr: true, + }, + { + name: "missing asset denoms", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolIDEven, + }, + expectErr: true, + }, + { + name: "missing pool ID and quote denom", + req: &v2types.QuerySpotPriceRequest{ + BaseAssetDenom: "foo", + }, + expectErr: true, + }, + { + name: "missing pool ID and base denom", + req: &v2types.QuerySpotPriceRequest{ + QuoteAssetDenom: "bar", + }, + expectErr: true, + }, + { + name: "foo in terms of bar in even pool", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolIDEven, + BaseAssetDenom: "bar", + QuoteAssetDenom: "foo", + }, + result: "1.000000000000000000", + }, + { + name: "foo in terms of bar in uneven pool", + req: &v2types.QuerySpotPriceRequest{ + PoolId: poolIDUneven, + BaseAssetDenom: "foo", + QuoteAssetDenom: "bar", + }, + result: "1.454545450000000000", + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + result, err := v2queryClient.SpotPrice(gocontext.Background(), tc.req) + if tc.expectErr { + suite.Require().Error(err, "expected error") + } else { + suite.Require().NoError(err, "unexpected error") + + // We allow for a small geometric error due to our spot price being an approximation + expectedSpotPrice := sdk.MustNewDecFromStr(tc.result) + actualSpotPrice := sdk.MustNewDecFromStr(result.SpotPrice) + diff := (expectedSpotPrice.Sub(actualSpotPrice)).Abs() + errTerm := diff.Quo(sdk.MinDec(expectedSpotPrice, actualSpotPrice)) + + suite.Require().True(errTerm.LT(sdk.NewDecWithPrec(1, 3)), "Expected: %d, Actual: %d", expectedSpotPrice, actualSpotPrice) + } + }) + } +} diff --git a/x/gamm/keeper/internal/events/emit.go b/x/gamm/keeper/internal/events/emit.go index 35eaf75f883..6c7ca600eee 100644 --- a/x/gamm/keeper/internal/events/emit.go +++ b/x/gamm/keeper/internal/events/emit.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func EmitSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { diff --git a/x/gamm/keeper/internal/events/emit_test.go b/x/gamm/keeper/internal/events/emit_test.go index 2778df85f61..78a39965cec 100644 --- a/x/gamm/keeper/internal/events/emit_test.go +++ b/x/gamm/keeper/internal/events/emit_test.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper/internal/events" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper/internal/events" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) type GammEventsTestSuite struct { diff --git a/x/gamm/keeper/invariants.go b/x/gamm/keeper/invariants.go index 9843623bf9c..feae3aa7e60 100644 --- a/x/gamm/keeper/invariants.go +++ b/x/gamm/keeper/invariants.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) const poolBalanceInvariantName = "pool-account-balance-equals-expected" diff --git a/x/gamm/keeper/keeper.go b/x/gamm/keeper/keeper.go index f920103c3dc..6297125deb5 100644 --- a/x/gamm/keeper/keeper.go +++ b/x/gamm/keeper/keeper.go @@ -3,7 +3,7 @@ package keeper import ( "fmt" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,9 +29,10 @@ type Keeper struct { hooks types.GammHooks // keepers - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper - communityPoolKeeper types.CommunityPoolKeeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + communityPoolKeeper types.CommunityPoolKeeper + poolIncentivesKeeper types.PoolIncentivesKeeper } func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, communityPoolKeeper types.CommunityPoolKeeper) Keeper { @@ -71,6 +72,10 @@ func (k *Keeper) SetHooks(gh types.GammHooks) *Keeper { return k } +func (k *Keeper) SetPoolIncentivesKeeper(poolIncentivesKeeper types.PoolIncentivesKeeper) { + k.poolIncentivesKeeper = poolIncentivesKeeper +} + // GetParams returns the total set params. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramSpace.GetParamSet(ctx, ¶ms) diff --git a/x/gamm/keeper/keeper_test.go b/x/gamm/keeper/keeper_test.go index cf0a08a3acd..21a7fc0c0e4 100644 --- a/x/gamm/keeper/keeper_test.go +++ b/x/gamm/keeper/keeper_test.go @@ -7,11 +7,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - balancertypes "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/stableswap" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) type KeeperTestSuite struct { diff --git a/x/gamm/keeper/msg_server.go b/x/gamm/keeper/msg_server.go index 3d13c404906..0b755013b58 100644 --- a/x/gamm/keeper/msg_server.go +++ b/x/gamm/keeper/msg_server.go @@ -6,8 +6,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) type msgServer struct { @@ -26,16 +27,16 @@ func NewBalancerMsgServerImpl(keeper *Keeper) balancer.MsgServer { } } -// func NewStableswapMsgServerImpl(keeper *Keeper) stableswap.MsgServer { -// return &msgServer{ -// keeper: keeper, -// } -// } +func NewStableswapMsgServerImpl(keeper *Keeper) stableswap.MsgServer { + return &msgServer{ + keeper: keeper, + } +} var ( - _ types.MsgServer = msgServer{} - _ balancer.MsgServer = msgServer{} - // _ stableswap.MsgServer = msgServer{} + _ types.MsgServer = msgServer{} + _ balancer.MsgServer = msgServer{} + _ stableswap.MsgServer = msgServer{} ) // CreateBalancerPool is a create balancer pool message. @@ -44,23 +45,23 @@ func (server msgServer) CreateBalancerPool(goCtx context.Context, msg *balancer. return &balancer.MsgCreateBalancerPoolResponse{PoolID: poolId}, err } -// func (server msgServer) CreateStableswapPool(goCtx context.Context, msg *stableswap.MsgCreateStableswapPool) (*stableswap.MsgCreateStableswapPoolResponse, error) { -// poolId, err := server.CreatePool(goCtx, msg) -// if err != nil { -// return nil, err -// } -// return &stableswap.MsgCreateStableswapPoolResponse{PoolID: poolId}, nil -// } +func (server msgServer) CreateStableswapPool(goCtx context.Context, msg *stableswap.MsgCreateStableswapPool) (*stableswap.MsgCreateStableswapPoolResponse, error) { + poolId, err := server.CreatePool(goCtx, msg) + if err != nil { + return nil, err + } + return &stableswap.MsgCreateStableswapPoolResponse{PoolID: poolId}, nil +} -// func (server msgServer) StableSwapAdjustScalingFactors(goCtx context.Context, msg *stableswap.MsgStableSwapAdjustScalingFactors) (*stableswap.MsgStableSwapAdjustScalingFactorsResponse, error) { -// ctx := sdk.UnwrapSDKContext(goCtx) +func (server msgServer) StableSwapAdjustScalingFactors(goCtx context.Context, msg *stableswap.MsgStableSwapAdjustScalingFactors) (*stableswap.MsgStableSwapAdjustScalingFactorsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) -// if err := server.keeper.SetStableSwapScalingFactors(ctx, msg.ScalingFactors, msg.PoolID, msg.ScalingFactorGovernor); err != nil { -// return nil, err -// } + if err := server.keeper.setStableSwapScalingFactors(ctx, msg.PoolID, msg.ScalingFactors, msg.Sender); err != nil { + return nil, err + } -// return &stableswap.MsgStableSwapAdjustScalingFactorsResponse{}, nil -// } + return &stableswap.MsgStableSwapAdjustScalingFactorsResponse{}, nil +} // CreatePool attempts to create a pool returning the newly created pool ID or an error upon failure. // The pool creation fee is used to fund the community pool. diff --git a/x/gamm/keeper/msg_server_test.go b/x/gamm/keeper/msg_server_test.go index ed54935ce6e..662d4650c11 100644 --- a/x/gamm/keeper/msg_server_test.go +++ b/x/gamm/keeper/msg_server_test.go @@ -3,8 +3,8 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) const ( @@ -30,10 +30,10 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn_Events() { expectedMessageEvents int }{ "zero hops": { - routes: []types.SwapAmountInRoute{}, - tokenIn: sdk.NewCoin("foo", sdk.NewInt(tokenIn)), - tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), - expectedMessageEvents: 1, // 1 gamm. + routes: []types.SwapAmountInRoute{}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(tokenIn)), + tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), + expectError: true, }, "one hop": { routes: []types.SwapAmountInRoute{ @@ -129,10 +129,10 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut_Events() { expectedMessageEvents int }{ "zero hops": { - routes: []types.SwapAmountOutRoute{}, - tokenOut: sdk.NewCoin("foo", sdk.NewInt(tokenOut)), - tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), - expectedMessageEvents: 1, // 1 gamm. + routes: []types.SwapAmountOutRoute{}, + tokenOut: sdk.NewCoin("foo", sdk.NewInt(tokenOut)), + tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), + expectError: true, }, "one hop": { routes: []types.SwapAmountOutRoute{ diff --git a/x/gamm/keeper/multihop.go b/x/gamm/keeper/multihop.go index ed08c003b9a..57ddebaa3c3 100644 --- a/x/gamm/keeper/multihop.go +++ b/x/gamm/keeper/multihop.go @@ -2,8 +2,10 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // MultihopSwapExactAmountIn defines the input denom and input amount for the first pool, @@ -16,12 +18,36 @@ func (k Keeper) MultihopSwapExactAmountIn( tokenIn sdk.Coin, tokenOutMinAmount sdk.Int, ) (tokenOutAmount sdk.Int, err error) { - for i, route := range routes { - swapFeeMultiplier := sdk.OneDec() - if types.SwapAmountInRoutes(routes).IsOsmoRoutedMultihop() { - swapFeeMultiplier = types.MultihopSwapFeeMultiplierForOsmoPools.Clone() + var ( + isMultiHopRouted bool + routeSwapFee sdk.Dec + sumOfSwapFees sdk.Dec + ) + + route := types.SwapAmountInRoutes(routes) + if err := route.Validate(); err != nil { + return sdk.Int{}, err + } + + // In this loop, we check if: + // - the route is of length 2 + // - route 1 and route 2 don't trade via the same pool + // - route 1 contains uosmo + // - both route 1 and route 2 are incentivized pools + // + // If all of the above is true, then we collect the additive and max fee between the + // two pools to later calculate the following: + // total_swap_fee = total_swap_fee = max(swapfee1, swapfee2) + // fee_per_pool = total_swap_fee * ((pool_fee) / (swapfee1 + swapfee2)) + if k.isOsmoRoutedMultihop(ctx, route, routes[0].TokenOutDenom, tokenIn.Denom) { + isMultiHopRouted = true + routeSwapFee, sumOfSwapFees, err = k.getOsmoRoutedMultihopTotalSwapFee(ctx, route) + if err != nil { + return sdk.Int{}, err } + } + for i, route := range routes { // To prevent the multihop swap from being interrupted prematurely, we keep // the minimum expected output at a very low number until the last pool _outMinAmount := sdk.NewInt(1) @@ -35,7 +61,14 @@ func (k Keeper) MultihopSwapExactAmountIn( return sdk.Int{}, poolErr } - swapFee := pool.GetSwapFee(ctx).Mul(swapFeeMultiplier) + swapFee := pool.GetSwapFee(ctx) + + // If we determined the route is an osmo multi-hop and both routes are incentivized, + // we modify the swap fee accordingly. + if isMultiHopRouted { + swapFee = routeSwapFee.Mul((swapFee.Quo(sumOfSwapFees))) + } + tokenOutAmount, err = k.swapExactAmountIn(ctx, sender, pool, tokenIn, route.TokenOutDenom, _outMinAmount, swapFee) if err != nil { return sdk.Int{}, err @@ -47,6 +80,61 @@ func (k Keeper) MultihopSwapExactAmountIn( return tokenOutAmount, err } +func (k Keeper) MultihopEstimateOutGivenExactAmountIn( + ctx sdk.Context, + routes []types.SwapAmountInRoute, + tokenIn sdk.Coin, +) (tokenOutAmount sdk.Int, err error) { + var ( + isMultiHopRouted bool + routeSwapFee sdk.Dec + sumOfSwapFees sdk.Dec + ) + + route := types.SwapAmountInRoutes(routes) + if err := route.Validate(); err != nil { + return sdk.Int{}, err + } + + if k.isOsmoRoutedMultihop(ctx, route, routes[0].TokenOutDenom, tokenIn.Denom) { + isMultiHopRouted = true + routeSwapFee, sumOfSwapFees, err = k.getOsmoRoutedMultihopTotalSwapFee(ctx, route) + if err != nil { + return sdk.Int{}, err + } + } + + for _, route := range routes { + // Execute the expected swap on the current routed pool + pool, poolErr := k.getPoolForSwap(ctx, route.PoolId) + if poolErr != nil { + return sdk.Int{}, poolErr + } + + swapFee := pool.GetSwapFee(ctx) + + // If we determined the route is an osmo multi-hop and both routes are incentivized, + // we modify the swap fee accordingly. + if isMultiHopRouted { + swapFee = routeSwapFee.Mul((swapFee.Quo(sumOfSwapFees))) + } + + tokenOut, err := pool.CalcOutAmtGivenIn(ctx, sdk.Coins{tokenIn}, route.TokenOutDenom, swapFee) + if err != nil { + return sdk.Int{}, err + } + + tokenOutAmount = tokenOut.Amount + if !tokenOutAmount.IsPositive() { + return sdk.Int{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "token amount must be positive") + } + + // Chain output of current pool as the input for the next routed pool + tokenIn = sdk.NewCoin(route.TokenOutDenom, tokenOutAmount) + } + return tokenOutAmount, err +} + // MultihopSwapExactAmountOut defines the output denom and output amount for the last pool. // Calculation starts by providing the tokenOutAmount of the final pool to calculate the required tokenInAmount // the calculated tokenInAmount is used as defined tokenOutAmount of the previous pool, calculating in reverse order of the swap @@ -58,14 +146,37 @@ func (k Keeper) MultihopSwapExactAmountOut( tokenInMaxAmount sdk.Int, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { - swapFeeMultiplier := sdk.OneDec() + isMultiHopRouted, routeSwapFee, sumOfSwapFees := false, sdk.Dec{}, sdk.Dec{} + route := types.SwapAmountOutRoutes(routes) + if err := route.Validate(); err != nil { + return sdk.Int{}, err + } - if types.SwapAmountOutRoutes(routes).IsOsmoRoutedMultihop() { - swapFeeMultiplier = types.MultihopSwapFeeMultiplierForOsmoPools.Clone() + // in this loop, we check if: + // - the route is of length 2 + // - route 1 and route 2 don't trade via the same pool + // - route 1 contains uosmo + // - both route 1 and route 2 are incentivized pools + // if all of the above is true, then we collect the additive and max fee between the two pools to later calculate the following: + // total_swap_fee = total_swap_fee = max(swapfee1, swapfee2) + // fee_per_pool = total_swap_fee * ((pool_fee) / (swapfee1 + swapfee2)) + if k.isOsmoRoutedMultihop(ctx, route, routes[0].TokenInDenom, tokenOut.Denom) { + isMultiHopRouted = true + routeSwapFee, sumOfSwapFees, err = k.getOsmoRoutedMultihopTotalSwapFee(ctx, route) + if err != nil { + return sdk.Int{}, err + } } - // Determine what the estimated input would be for each pool along the multihop route - insExpected, err := k.createMultihopExpectedSwapOuts(ctx, routes, tokenOut, swapFeeMultiplier) + // Determine what the estimated input would be for each pool along the multi-hop route + // if we determined the route is an osmo multi-hop and both routes are incentivized, + // we utilize a separate function that calculates the discounted swap fees + var insExpected []sdk.Int + if isMultiHopRouted { + insExpected, err = k.createOsmoMultihopExpectedSwapOuts(ctx, routes, tokenOut, routeSwapFee, sumOfSwapFees) + } else { + insExpected, err = k.createMultihopExpectedSwapOuts(ctx, routes, tokenOut) + } if err != nil { return sdk.Int{}, err } @@ -92,7 +203,12 @@ func (k Keeper) MultihopSwapExactAmountOut( if poolErr != nil { return sdk.Int{}, poolErr } - swapFee := pool.GetSwapFee(ctx).Mul(swapFeeMultiplier) + + swapFee := pool.GetSwapFee(ctx) + if isMultiHopRouted { + swapFee = routeSwapFee.Mul((swapFee.Quo(sumOfSwapFees))) + } + _tokenInAmount, swapErr := k.swapExactAmountOut(ctx, sender, pool, route.TokenInDenom, insExpected[i], _tokenOut, swapFee) if swapErr != nil { return sdk.Int{}, swapErr @@ -109,6 +225,85 @@ func (k Keeper) MultihopSwapExactAmountOut( return tokenInAmount, nil } +func (k Keeper) MultihopEstimateInGivenExactAmountOut( + ctx sdk.Context, + routes []types.SwapAmountOutRoute, + tokenOut sdk.Coin, +) (tokenInAmount sdk.Int, err error) { + isMultiHopRouted, routeSwapFee, sumOfSwapFees := false, sdk.Dec{}, sdk.Dec{} + route := types.SwapAmountOutRoutes(routes) + if err := route.Validate(); err != nil { + return sdk.Int{}, err + } + + if k.isOsmoRoutedMultihop(ctx, route, routes[0].TokenInDenom, tokenOut.Denom) { + isMultiHopRouted = true + routeSwapFee, sumOfSwapFees, err = k.getOsmoRoutedMultihopTotalSwapFee(ctx, route) + if err != nil { + return sdk.Int{}, err + } + } + + // Determine what the estimated input would be for each pool along the multi-hop route + // if we determined the route is an osmo multi-hop and both routes are incentivized, + // we utilize a separate function that calculates the discounted swap fees + var insExpected []sdk.Int + if isMultiHopRouted { + insExpected, err = k.createOsmoMultihopExpectedSwapOuts(ctx, routes, tokenOut, routeSwapFee, sumOfSwapFees) + } else { + insExpected, err = k.createMultihopExpectedSwapOuts(ctx, routes, tokenOut) + } + if err != nil { + return sdk.Int{}, err + } + if len(insExpected) == 0 { + return sdk.Int{}, nil + } + + return insExpected[0], nil +} + +func (k Keeper) isOsmoRoutedMultihop(ctx sdk.Context, route types.MultihopRoute, inDenom, outDenom string) (isRouted bool) { + if route.Length() != 2 { + return false + } + intemediateDenoms := route.IntermediateDenoms() + if len(intemediateDenoms) != 1 || intemediateDenoms[0] != appparams.BaseCoinUnit { + return false + } + if inDenom == outDenom { + return false + } + poolIds := route.PoolIds() + if poolIds[0] == poolIds[1] { + return false + } + + route0Incentivized := k.poolIncentivesKeeper.IsPoolIncentivized(ctx, poolIds[0]) + route1Incentivized := k.poolIncentivesKeeper.IsPoolIncentivized(ctx, poolIds[1]) + + return route0Incentivized && route1Incentivized +} + +func (k Keeper) getOsmoRoutedMultihopTotalSwapFee(ctx sdk.Context, route types.MultihopRoute) ( + totalPathSwapFee sdk.Dec, sumOfSwapFees sdk.Dec, err error) { + additiveSwapFee := sdk.ZeroDec() + maxSwapFee := sdk.ZeroDec() + + for _, poolId := range route.PoolIds() { + pool, poolErr := k.getPoolForSwap(ctx, poolId) + if poolErr != nil { + return sdk.Dec{}, sdk.Dec{}, poolErr + } + swapFee := pool.GetSwapFee(ctx) + additiveSwapFee = additiveSwapFee.Add(swapFee) + maxSwapFee = sdk.MaxDec(maxSwapFee, swapFee) + } + averageSwapFee := additiveSwapFee.QuoInt64(2) + maxSwapFee = sdk.MaxDec(maxSwapFee, averageSwapFee) + return maxSwapFee, additiveSwapFee, nil +} + // createMultihopExpectedSwapOuts defines the output denom and output amount for the last pool in // the route of pools the caller is intending to hop through in a fixed-output multihop tx. It estimates the input // amount for this last pool and then chains that input as the output of the previous pool in the route, repeating @@ -117,7 +312,35 @@ func (k Keeper) MultihopSwapExactAmountOut( func (k Keeper) createMultihopExpectedSwapOuts( ctx sdk.Context, routes []types.SwapAmountOutRoute, - tokenOut sdk.Coin, swapFeeMultiplier sdk.Dec, + tokenOut sdk.Coin, +) ([]sdk.Int, error) { + insExpected := make([]sdk.Int, len(routes)) + for i := len(routes) - 1; i >= 0; i-- { + route := routes[i] + + pool, err := k.getPoolForSwap(ctx, route.PoolId) + if err != nil { + return nil, err + } + + tokenIn, err := pool.CalcInAmtGivenOut(ctx, sdk.NewCoins(tokenOut), route.TokenInDenom, pool.GetSwapFee(ctx)) + if err != nil { + return nil, err + } + + insExpected[i] = tokenIn.Amount + tokenOut = tokenIn + } + + return insExpected, nil +} + +// createOsmoMultihopExpectedSwapOuts does the same as createMultihopExpectedSwapOuts, however discounts the swap fee +func (k Keeper) createOsmoMultihopExpectedSwapOuts( + ctx sdk.Context, + routes []types.SwapAmountOutRoute, + tokenOut sdk.Coin, + cumulativeRouteSwapFee, sumOfSwapFees sdk.Dec, ) ([]sdk.Int, error) { insExpected := make([]sdk.Int, len(routes)) for i := len(routes) - 1; i >= 0; i-- { @@ -128,7 +351,8 @@ func (k Keeper) createMultihopExpectedSwapOuts( return nil, err } - tokenIn, err := pool.CalcInAmtGivenOut(ctx, sdk.NewCoins(tokenOut), route.TokenInDenom, pool.GetSwapFee(ctx).Mul(swapFeeMultiplier)) + swapFee := pool.GetSwapFee(ctx) + tokenIn, err := pool.CalcInAmtGivenOut(ctx, sdk.NewCoins(tokenOut), route.TokenInDenom, cumulativeRouteSwapFee.Mul((swapFee.Quo(sumOfSwapFees)))) if err != nil { return nil, err } diff --git a/x/gamm/keeper/multihop_test.go b/x/gamm/keeper/multihop_test.go index 89ffc29ce11..8922ed848b0 100644 --- a/x/gamm/keeper/multihop_test.go +++ b/x/gamm/keeper/multihop_test.go @@ -4,14 +4,564 @@ import ( "errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" +) + +var ( + fooCoin = sdk.NewCoin("foo", sdk.NewInt(1000000000)) + barCoin = sdk.NewCoin("bar", sdk.NewInt(1000000000)) + bazCoin = sdk.NewCoin("baz", sdk.NewInt(1000000000)) + uosmoCoin = sdk.NewCoin("uosmo", sdk.NewInt(1000000000)) ) -func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountIn() { +func (suite *KeeperTestSuite) TestBalancerPoolMultihopSwapExactAmountIn() { + type param struct { + routes []types.SwapAmountInRoute + incentivizedGauges []uint64 + fourAssetPools int + poolAssets []sdk.Coins + poolFee []sdk.Dec + tokenIn sdk.Coin + tokenOutMinAmount sdk.Int + } + + poolDefaultSwapFee := sdk.NewDecWithPrec(1, 2) // 1% pool swap fee default + + tests := []struct { + name string + param param + expectPass bool + expectReducedFeeApplied bool + }{ + { + name: "Swap - [foo -> bar](pool 1) - [bar -> baz](pool 2), both pools 1 percent fee", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: "bar", + }, + { + PoolId: 2, + TokenOutDenom: "baz", + }, + }, + incentivizedGauges: []uint64{}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, barCoin), sdk.NewCoins(barCoin, bazCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectPass: true, + }, + { + name: "Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: "uosmo", + }, + { + PoolId: 2, + TokenOutDenom: "baz", + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, uosmoCoin), sdk.NewCoins(uosmoCoin, bazCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectReducedFeeApplied: true, + expectPass: true, + }, + { + name: "Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, (pool 1) 1 percent fee, (pool 2) 10 percent fee", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: "uosmo", + }, + { + PoolId: 2, + TokenOutDenom: "baz", + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, uosmoCoin), sdk.NewCoins(uosmoCoin, bazCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, sdk.NewDecWithPrec(1, 1)}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectReducedFeeApplied: true, + expectPass: true, + }, + { + name: "Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: "uosmo", + }, + { + PoolId: 2, + TokenOutDenom: "baz", + }, + { + PoolId: 3, + TokenOutDenom: "bar", + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, uosmoCoin), sdk.NewCoins(uosmoCoin, bazCoin), sdk.NewCoins(bazCoin, barCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee, poolDefaultSwapFee}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectReducedFeeApplied: false, + expectPass: true, + }, + { + name: "Swap between four asset pools - [foo -> bar](pool 1) - [bar -> baz](pool 2), all pools 1 percent fee", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: "bar", + }, + { + PoolId: 2, + TokenOutDenom: "baz", + }, + }, + fourAssetPools: 2, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectReducedFeeApplied: false, + expectPass: true, + }, + { + name: "Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2), with a half fee applied, both pools 1 percent fee", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: "uosmo", + }, + { + PoolId: 2, + TokenOutDenom: "baz", + }, + }, + fourAssetPools: 2, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectReducedFeeApplied: true, + expectPass: true, + }, + { + name: "Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: "uosmo", + }, + { + PoolId: 2, + TokenOutDenom: "baz", + }, + { + PoolId: 3, + TokenOutDenom: "bar", + }, + }, + fourAssetPools: 3, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee, poolDefaultSwapFee}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectReducedFeeApplied: false, + expectPass: true, + }, + } + + for _, test := range tests { + suite.SetupTest() + + suite.Run(test.name, func() { + keeper := suite.App.GAMMKeeper + + // Create two asset pools with desired swap fee, if specified. Fund acc with respective coins + for i, coin := range test.param.poolAssets { + suite.PrepareBalancerPoolWithCoins(coin[0], coin[1]) + suite.FundAcc(suite.TestAccs[0], sdk.NewCoins(coin[0], coin[1])) + suite.updatePoolSwapFee(suite.Ctx, uint64(i+1), test.param.poolFee[i]) + } + + // Create four asset pools with desired swap fee, if specified. + for i := 0; i < test.param.fourAssetPools; i++ { + suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: test.param.poolFee[i], + ExitFee: sdk.NewDec(0), + }) + } + + // if test specifies incentivized gauges, set them here + if len(test.param.incentivizedGauges) > 0 { + var records []poolincentivestypes.DistrRecord + totalWeight := sdk.NewInt(int64(len(test.param.incentivizedGauges))) + for _, gauge := range test.param.incentivizedGauges { + records = append(records, poolincentivestypes.DistrRecord{GaugeId: gauge, Weight: sdk.OneInt()}) + } + distInfo := poolincentivestypes.DistrInfo{ + TotalWeight: totalWeight, + Records: records, + } + suite.App.PoolIncentivesKeeper.SetDistrInfo(suite.Ctx, distInfo) + } + + // calcOutAmountAsSeparateSwaps calculates the multi-hop swap as separate swaps, while also + // utilizing a cacheContext so the state does not change + calcOutAmountAsSeparateSwaps := func(osmoFeeReduced bool) sdk.Coin { + cacheCtx, _ := suite.Ctx.CacheContext() + + if osmoFeeReduced { + // extract route from swap + route := types.SwapAmountInRoutes(test.param.routes) + // utilizing the extracted route, determine the routeSwapFee and sumOfSwapFees + // these two variables are used to calculate the overall swap fee utilizing the following formula + // swapFee = routeSwapFee * ((pool_fee) / (sumOfSwapFees)) + routeSwapFee, sumOfSwapFees, err := keeper.GetOsmoRoutedMultihopTotalSwapFee(suite.Ctx, route) + suite.Require().NoError(err) + for _, hop := range test.param.routes { + // extract the current pool's swap fee + hopPool, err := keeper.GetPoolAndPoke(cacheCtx, hop.PoolId) + suite.Require().NoError(err) + currentPoolSwapFee := hopPool.GetSwapFee(cacheCtx) + // utilize the routeSwapFee, sumOfSwapFees, and current pool swap fee to calculate the new reduced swap fee + swapFee := routeSwapFee.Mul((currentPoolSwapFee.Quo(sumOfSwapFees))) + // update the pools swap fee directly + err = suite.updatePoolSwapFee(cacheCtx, hop.PoolId, swapFee) + suite.Require().NoError(err) + } + } + nextTokenIn := test.param.tokenIn + // we then do individual swaps until we reach the end of the swap route + for _, hop := range test.param.routes { + tokenOut, err := keeper.SwapExactAmountIn(cacheCtx, suite.TestAccs[0], hop.PoolId, nextTokenIn, hop.TokenOutDenom, sdk.OneInt()) + suite.Require().NoError(err) + nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) + } + return nextTokenIn + } + + if test.expectPass { + var expectedMultihopTokenOutAmount sdk.Coin + // calculate the swap as separate swaps with either the reduced swap fee or normal fee + expectedMultihopTokenOutAmount = calcOutAmountAsSeparateSwaps(test.expectReducedFeeApplied) + // compare the expected tokenOut to the actual tokenOut + multihopTokenOutAmount, err := keeper.MultihopSwapExactAmountIn(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenIn, test.param.tokenOutMinAmount) + suite.Require().NoError(err) + suite.Require().Equal(expectedMultihopTokenOutAmount.Amount.String(), multihopTokenOutAmount.String()) + } else { + _, err := keeper.MultihopSwapExactAmountIn(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenIn, test.param.tokenOutMinAmount) + suite.Require().NoError(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestBalancerPoolMultihopSwapExactAmountOut() { + type param struct { + routes []types.SwapAmountOutRoute + incentivizedGauges []uint64 + fourAssetPools int + poolAssets []sdk.Coins + poolFee []sdk.Dec + tokenInMaxAmount sdk.Int + tokenOut sdk.Coin + } + + poolDefaultSwapFee := sdk.NewDecWithPrec(1, 2) // 1% pool swap fee default + + tests := []struct { + name string + param param + expectPass bool + expectReducedFeeApplied bool + }{ + { + name: "Swap - [foo -> bar](pool 1) - [bar -> baz](pool 2), both pools 1 percent fee", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: "foo", + }, + { + PoolId: 2, + TokenInDenom: "bar", + }, + }, + incentivizedGauges: []uint64{}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, barCoin), sdk.NewCoins(barCoin, bazCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin("baz", sdk.NewInt(100000)), + }, + expectPass: true, + }, + { + name: "Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: "foo", + }, + { + PoolId: 2, + TokenInDenom: "uosmo", + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, uosmoCoin), sdk.NewCoins(uosmoCoin, bazCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin("baz", sdk.NewInt(100000)), + }, + expectPass: true, + expectReducedFeeApplied: true, + }, + { + name: "Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, (pool 1) 1 percent fee, (pool 2) 10 percent fee", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: "foo", + }, + { + PoolId: 2, + TokenInDenom: "uosmo", + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, uosmoCoin), sdk.NewCoins(uosmoCoin, bazCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, sdk.NewDecWithPrec(1, 1)}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin("baz", sdk.NewInt(100000)), + }, + expectPass: true, + expectReducedFeeApplied: true, + }, + { + name: "Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: "foo", + }, + { + PoolId: 2, + TokenInDenom: "uosmo", + }, + { + PoolId: 3, + TokenInDenom: "baz", + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolAssets: []sdk.Coins{sdk.NewCoins(fooCoin, uosmoCoin), sdk.NewCoins(uosmoCoin, bazCoin), sdk.NewCoins(bazCoin, barCoin)}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee, poolDefaultSwapFee}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin("bar", sdk.NewInt(100000)), + }, + expectReducedFeeApplied: false, + expectPass: true, + }, + { + name: "Swap between four asset pools - [foo -> bar](pool 1) - [bar -> baz](pool 2), all pools 1 percent fee", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: "foo", + }, + { + PoolId: 2, + TokenInDenom: "bar", + }, + }, + fourAssetPools: 2, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenOut: sdk.NewCoin("baz", sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), + }, + expectReducedFeeApplied: false, + expectPass: true, + }, + { + name: "Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2), with a half fee applied, both pools 1 percent fee", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: "foo", + }, + { + PoolId: 2, + TokenInDenom: "uosmo", + }, + }, + fourAssetPools: 2, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee}, + tokenOut: sdk.NewCoin("baz", sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), + }, + expectReducedFeeApplied: true, + expectPass: true, + }, + { + name: "Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: "foo", + }, + { + PoolId: 2, + TokenInDenom: "uosmo", + }, + { + PoolId: 3, + TokenInDenom: "baz", + }, + }, + fourAssetPools: 3, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, + poolFee: []sdk.Dec{poolDefaultSwapFee, poolDefaultSwapFee, poolDefaultSwapFee}, + tokenOut: sdk.NewCoin("bar", sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), + }, + expectReducedFeeApplied: false, + expectPass: true, + }, + } + + for _, test := range tests { + suite.SetupTest() + + suite.Run(test.name, func() { + keeper := suite.App.GAMMKeeper + + // Create two asset pools with desired swap fee, if specified. Fund acc with respective coins + for i, coin := range test.param.poolAssets { + suite.PrepareBalancerPoolWithCoins(coin[0], coin[1]) + suite.FundAcc(suite.TestAccs[0], sdk.NewCoins(coin[0], coin[1])) + suite.updatePoolSwapFee(suite.Ctx, uint64(i+1), test.param.poolFee[i]) + } + + // Create four asset pools with desired swap fee, if specified. + for i := 0; i < test.param.fourAssetPools; i++ { + suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: test.param.poolFee[i], + ExitFee: sdk.NewDec(0), + }) + } + + // if test specifies incentivized gauges, set them here + if len(test.param.incentivizedGauges) > 0 { + var records []poolincentivestypes.DistrRecord + totalWeight := sdk.NewInt(int64(len(test.param.incentivizedGauges))) + for _, gauge := range test.param.incentivizedGauges { + records = append(records, poolincentivestypes.DistrRecord{GaugeId: gauge, Weight: sdk.OneInt()}) + } + distInfo := poolincentivestypes.DistrInfo{ + TotalWeight: totalWeight, + Records: records, + } + suite.App.PoolIncentivesKeeper.SetDistrInfo(suite.Ctx, distInfo) + } + + // calcInAmountAsSeparateSwaps calculates the multi-hop swap as separate swaps, while also + // utilizing a cacheContext so the state does not change + calcInAmountAsSeparateSwaps := func(osmoFeeReduced bool) sdk.Coin { + cacheCtx, _ := suite.Ctx.CacheContext() + + if osmoFeeReduced { + // extract route from swap + route := types.SwapAmountOutRoutes(test.param.routes) + // utilizing the extracted route, determine the routeSwapFee and sumOfSwapFees + // these two variables are used to calculate the overall swap fee utilizing the following formula + // swapFee = routeSwapFee * ((pool_fee) / (sumOfSwapFees)) + routeSwapFee, sumOfSwapFees, err := keeper.GetOsmoRoutedMultihopTotalSwapFee(suite.Ctx, route) + suite.Require().NoError(err) + for _, hop := range test.param.routes { + // extract the current pool's swap fee + hopPool, err := keeper.GetPoolAndPoke(cacheCtx, hop.PoolId) + suite.Require().NoError(err) + currentPoolSwapFee := hopPool.GetSwapFee(cacheCtx) + // utilize the routeSwapFee, sumOfSwapFees, and current pool swap fee to calculate the new reduced swap fee + swapFee := routeSwapFee.Mul((currentPoolSwapFee.Quo(sumOfSwapFees))) + // update the pools swap fee directly + err = suite.updatePoolSwapFee(cacheCtx, hop.PoolId, swapFee) + suite.Require().NoError(err) + } + } + + nextTokenOut := test.param.tokenOut + // we then do individual swaps until we reach the end of the swap route + for i := len(test.param.routes) - 1; i >= 0; i-- { + hop := test.param.routes[i] + tokenOut, err := keeper.SwapExactAmountOut(cacheCtx, suite.TestAccs[0], hop.PoolId, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut) + suite.Require().NoError(err) + nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) + } + return nextTokenOut + } + + if test.expectPass { + var expectedMultihopTokenOutAmount sdk.Coin + // calculate the swap as separate swaps with either the reduced swap fee or normal fee + expectedMultihopTokenOutAmount = calcInAmountAsSeparateSwaps(test.expectReducedFeeApplied) + // compare the expected tokenOut to the actual tokenOut + multihopTokenOutAmount, err := keeper.MultihopSwapExactAmountOut(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenInMaxAmount, test.param.tokenOut) + suite.Require().NoError(err) + suite.Require().Equal(expectedMultihopTokenOutAmount.Amount.String(), multihopTokenOutAmount.String()) + } else { + _, err := keeper.MultihopSwapExactAmountOut(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenInMaxAmount, test.param.tokenOut) + suite.Require().NoError(err) + } + }) + } +} + +// TestEstimateMultihopSwapExactAmountIn tests that the estimation done via `EstimateSwapExactAmountIn` +// results in the same amount of token out as the actual swap. +func (suite *KeeperTestSuite) TestEstimateMultihopSwapExactAmountIn() { type param struct { routes []types.SwapAmountInRoute + estimateRoutes []types.SwapAmountInRoute tokenIn sdk.Coin tokenOutMinAmount sdk.Int } @@ -35,6 +585,16 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountIn() TokenOutDenom: "baz", }, }, + estimateRoutes: []types.SwapAmountInRoute{ + { + PoolId: 3, + TokenOutDenom: "bar", + }, + { + PoolId: 4, + TokenOutDenom: "baz", + }, + }, tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), tokenOutMinAmount: sdk.NewInt(1), }, @@ -53,6 +613,16 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountIn() TokenOutDenom: "baz", }, }, + estimateRoutes: []types.SwapAmountInRoute{ + { + PoolId: 3, + TokenOutDenom: "uosmo", + }, + { + PoolId: 4, + TokenOutDenom: "baz", + }, + }, tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), tokenOutMinAmount: sdk.NewInt(1), }, @@ -68,9 +638,10 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountIn() suite.Run(test.name, func() { keeper := suite.App.GAMMKeeper poolDefaultSwapFee := sdk.NewDecWithPrec(1, 2) // 1% - poolZeroSwapFee := sdk.ZeroDec() - // Prepare pools + // Prepare 4 pools, + // Two pools for calculating `MultihopSwapExactAmountIn` + // and two pools for calculating `EstimateMultihopSwapExactAmountIn` suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ SwapFee: poolDefaultSwapFee, ExitFee: sdk.NewDec(0), @@ -80,87 +651,57 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountIn() ExitFee: sdk.NewDec(0), }) - // Calculate the chained spot price. - calcSpotPrice := func() sdk.Dec { - dec := sdk.NewDec(1) - tokenInDenom := test.param.tokenIn.Denom - for i, route := range test.param.routes { - if i != 0 { - tokenInDenom = test.param.routes[i-1].TokenOutDenom - } - pool, err := keeper.GetPoolAndPoke(suite.Ctx, route.PoolId) - suite.NoError(err, "test: %v", test.name) - - sp, err := pool.SpotPrice(suite.Ctx, tokenInDenom, route.TokenOutDenom) - suite.NoError(err, "test: %v", test.name) - dec = dec.Mul(sp) - } - return dec - } - - calcOutAmountAsSeparateSwaps := func(adjustedPoolSwapFee sdk.Dec) sdk.Coin { - cacheCtx, _ := suite.Ctx.CacheContext() - - if adjustedPoolSwapFee != poolDefaultSwapFee { - for _, hop := range test.param.routes { - err := suite.updatePoolSwapFee(cacheCtx, hop.PoolId, adjustedPoolSwapFee) - suite.NoError(err, "test: %v", test.name) - } - } - - nextTokenIn := test.param.tokenIn - for _, hop := range test.param.routes { - tokenOut, err := keeper.SwapExactAmountIn(cacheCtx, suite.TestAccs[0], hop.PoolId, nextTokenIn, hop.TokenOutDenom, sdk.OneInt()) - suite.Require().NoError(err) - nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) - } - return nextTokenIn - } - - if test.expectPass { - tokenOutCalculatedAsSeparateSwaps := calcOutAmountAsSeparateSwaps(poolDefaultSwapFee) - tokenOutCalculatedAsSeparateSwapsWithoutFee := calcOutAmountAsSeparateSwaps(poolZeroSwapFee) - - spotPriceBefore := calcSpotPrice() + firstEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + secondEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) - multihopTokenOutAmount, err := keeper.MultihopSwapExactAmountIn(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenIn, test.param.tokenOutMinAmount) - suite.NoError(err, "test: %v", test.name) - - spotPriceAfter := calcSpotPrice() - - // Ratio of the token out should be between the before spot price and after spot price. - sp := test.param.tokenIn.Amount.ToDec().Quo(multihopTokenOutAmount.ToDec()) - suite.True(sp.GT(spotPriceBefore) && sp.LT(spotPriceAfter), "test: %v", test.name) - - if test.reducedFeeApplied { - // we have 3 values: - // ---------------- tokenOutCalculatedAsSeparateSwapsWithoutFee - // diffA - // ---------------- multihopTokenOutAmount (with half fees) - // diffB - // ---------------- tokenOutCalculatedAsSeparateSwaps (with full fees) - // here we want to test, that difference between this 3 values around 50% (fee is actually halved) - // we do not have exact 50% reduce due to amm math rounding - // playing with input values for this test can result in different discount % - // so lets check, that we have around 50% +-1% reduction - diffA := tokenOutCalculatedAsSeparateSwapsWithoutFee.Amount.Sub(multihopTokenOutAmount) - diffB := multihopTokenOutAmount.Sub(tokenOutCalculatedAsSeparateSwaps.Amount) - diffDistinctionPercent := diffA.Sub(diffB).Abs().ToDec().Quo(diffA.Add(diffB).ToDec()) - suite.Require().True(diffDistinctionPercent.LT(sdk.MustNewDecFromStr("0.01"))) - } else { - suite.Require().True(multihopTokenOutAmount.Equal(tokenOutCalculatedAsSeparateSwaps.Amount)) - } - } else { - _, err := keeper.MultihopSwapExactAmountIn(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenIn, test.param.tokenOutMinAmount) - suite.Error(err, "test: %v", test.name) - } + firstEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + // calculate token out amount using `MultihopSwapExactAmountIn` + multihopTokenOutAmount, err := keeper.MultihopSwapExactAmountIn( + suite.Ctx, + suite.TestAccs[0], + test.param.routes, + test.param.tokenIn, + test.param.tokenOutMinAmount) + suite.Require().NoError(err) + + // calculate token out amount using `EstimateMultihopSwapExactAmountIn` + estimateMultihopTokenOutAmount, err := keeper.MultihopEstimateOutGivenExactAmountIn( + suite.Ctx, + test.param.estimateRoutes, + test.param.tokenIn) + suite.Require().NoError(err) + + // ensure that the token out amount is same + suite.Require().Equal(multihopTokenOutAmount, estimateMultihopTokenOutAmount) + + // ensure that pool state has not been altered after estimation + firstEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + suite.Require().Equal(firstEstimatePool, firstEstimatePoolAfterSwap) + suite.Require().Equal(secondEstimatePool, secondEstimatePoolAfterSwap) }) } } -func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountOut() { +// TestEstimateMultihopSwapExactAmountOut tests that the estimation done via `EstimateSwapExactAmountOut` +// results in the same amount of token in as the actual swap. +func (suite *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { type param struct { routes []types.SwapAmountOutRoute + estimateRoutes []types.SwapAmountOutRoute tokenInMaxAmount sdk.Int tokenOut sdk.Coin } @@ -184,6 +725,16 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountOut() TokenInDenom: "bar", }, }, + estimateRoutes: []types.SwapAmountOutRoute{ + { + PoolId: 3, + TokenInDenom: "foo", + }, + { + PoolId: 4, + TokenInDenom: "bar", + }, + }, tokenInMaxAmount: sdk.NewInt(90000000), tokenOut: sdk.NewCoin("baz", sdk.NewInt(100000)), }, @@ -202,6 +753,16 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountOut() TokenInDenom: "uosmo", }, }, + estimateRoutes: []types.SwapAmountOutRoute{ + { + PoolId: 3, + TokenInDenom: "foo", + }, + { + PoolId: 4, + TokenInDenom: "uosmo", + }, + }, tokenInMaxAmount: sdk.NewInt(90000000), tokenOut: sdk.NewCoin("baz", sdk.NewInt(100000)), }, @@ -217,9 +778,10 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountOut() suite.Run(test.name, func() { keeper := suite.App.GAMMKeeper poolDefaultSwapFee := sdk.NewDecWithPrec(1, 2) // 1% - poolZeroSwapFee := sdk.ZeroDec() - // Prepare pools + // Prepare 4 pools, + // Two pools for calculating `MultihopSwapExactAmountOut` + // and two pools for calculating `EstimateMultihopSwapExactAmountOut` suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ SwapFee: poolDefaultSwapFee, // 1% ExitFee: sdk.NewDec(0), @@ -228,82 +790,43 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleMultihopSwapExactAmountOut() SwapFee: poolDefaultSwapFee, ExitFee: sdk.NewDec(0), }) - - // Calculate the chained spot price. - calcSpotPrice := func() sdk.Dec { - dec := sdk.NewDec(1) - for i, route := range test.param.routes { - tokenOutDenom := test.param.tokenOut.Denom - if i != len(test.param.routes)-1 { - tokenOutDenom = test.param.routes[i+1].TokenInDenom - } - - pool, err := keeper.GetPoolAndPoke(suite.Ctx, route.PoolId) - suite.NoError(err, "test: %v", test.name) - - sp, err := pool.SpotPrice(suite.Ctx, route.TokenInDenom, tokenOutDenom) - suite.NoError(err, "test: %v", test.name) - dec = dec.Mul(sp) - } - return dec - } - - calcInAmountAsSeparateSwaps := func(adjustedPoolSwapFee sdk.Dec) sdk.Coin { - cacheCtx, _ := suite.Ctx.CacheContext() - - if adjustedPoolSwapFee != poolDefaultSwapFee { - for _, hop := range test.param.routes { - err := suite.updatePoolSwapFee(cacheCtx, hop.PoolId, adjustedPoolSwapFee) - suite.NoError(err, "test: %v", test.name) - } - } - - nextTokenOut := test.param.tokenOut - for i := len(test.param.routes) - 1; i >= 0; i-- { - hop := test.param.routes[i] - tokenOut, err := keeper.SwapExactAmountOut(cacheCtx, suite.TestAccs[0], hop.PoolId, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut) - suite.Require().NoError(err) - nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) - } - return nextTokenOut - } - - if test.expectPass { - tokenInCalculatedAsSeparateSwaps := calcInAmountAsSeparateSwaps(poolDefaultSwapFee) - tokenInCalculatedAsSeparateSwapsWithoutFee := calcInAmountAsSeparateSwaps(poolZeroSwapFee) - - spotPriceBefore := calcSpotPrice() - multihopTokenInAmount, err := keeper.MultihopSwapExactAmountOut(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenInMaxAmount, test.param.tokenOut) - suite.Require().NoError(err, "test: %v", test.name) - - spotPriceAfter := calcSpotPrice() - // Ratio of the token out should be between the before spot price and after spot price. - // This is because the swap increases the spot price - sp := multihopTokenInAmount.ToDec().Quo(test.param.tokenOut.Amount.ToDec()) - suite.True(sp.GT(spotPriceBefore) && sp.LT(spotPriceAfter), "multi-hop spot price wrong, test: %v", test.name) - - if test.reducedFeeApplied { - // we have 3 values: - // ---------------- tokenInCalculatedAsSeparateSwaps (with full fees) - // diffA - // ---------------- multihopTokenInAmount (with half fees) - // diffB - // ---------------- tokenInCalculatedAsSeparateSwapsWithoutFee - // here we want to test, that difference between this 3 values around 50% (fee is actually halved) - // we do not have exact 50% reduce due to amm math rounding - // playing with input values for this test can result in different discount % - // so lets check, that we have around 50% +-1% reduction - diffA := tokenInCalculatedAsSeparateSwaps.Amount.Sub(multihopTokenInAmount) - diffB := multihopTokenInAmount.Sub(tokenInCalculatedAsSeparateSwapsWithoutFee.Amount) - diffDistinctionPercent := diffA.Sub(diffB).Abs().ToDec().Quo(diffA.Add(diffB).ToDec()) - suite.Require().True(diffDistinctionPercent.LT(sdk.MustNewDecFromStr("0.01"))) - } else { - suite.Require().True(multihopTokenInAmount.Equal(tokenInCalculatedAsSeparateSwaps.Amount)) - } - } else { - _, err := keeper.MultihopSwapExactAmountOut(suite.Ctx, suite.TestAccs[0], test.param.routes, test.param.tokenInMaxAmount, test.param.tokenOut) - suite.Error(err, "test: %v", test.name) - } + firstEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, // 1% + ExitFee: sdk.NewDec(0), + }) + secondEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + firstEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + multihopTokenInAmount, err := keeper.MultihopSwapExactAmountOut( + suite.Ctx, + suite.TestAccs[0], + test.param.routes, + test.param.tokenInMaxAmount, + test.param.tokenOut) + suite.Require().NoError(err, "test: %v", test.name) + + estimateMultihopTokenInAmount, err := keeper.MultihopEstimateInGivenExactAmountOut( + suite.Ctx, + test.param.estimateRoutes, + test.param.tokenOut) + suite.Require().NoError(err, "test: %v", test.name) + + suite.Require().Equal(multihopTokenInAmount, estimateMultihopTokenInAmount) + + // ensure that pool state has not been altered after estimation + firstEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + suite.Require().Equal(firstEstimatePool, firstEstimatePoolAfterSwap) + suite.Require().Equal(secondEstimatePool, secondEstimatePoolAfterSwap) }) } } diff --git a/x/gamm/keeper/pool.go b/x/gamm/keeper/pool.go index 53a55119d25..940ef3e6bfc 100644 --- a/x/gamm/keeper/pool.go +++ b/x/gamm/keeper/pool.go @@ -8,9 +8,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func (k Keeper) MarshalPool(pool types.PoolI) ([]byte, error) { @@ -249,7 +250,9 @@ func (k Keeper) GetPoolType(ctx sdk.Context, poolId uint64) (string, error) { switch pool := pool.(type) { case *balancer.Pool: - return "Balancer", nil + return balancer.PoolTypeName, nil + case *stableswap.Pool: + return stableswap.PoolTypeName, nil default: errMsg := fmt.Sprintf("unrecognized %s pool type: %T", types.ModuleName, pool) return "", sdkerrors.Wrap(sdkerrors.ErrUnpackAny, errMsg) @@ -262,3 +265,22 @@ func (k Keeper) getNextPoolIdAndIncrement(ctx sdk.Context) uint64 { k.setNextPoolId(ctx, nextPoolId+1) return nextPoolId } + +// setStableSwapScalingFactors sets the stable swap scaling factors. +// errors if the pool does not exist, the sender is not the scaling factor controller, or due to other +// internal errors. +func (k Keeper) setStableSwapScalingFactors(ctx sdk.Context, poolId uint64, scalingFactors []uint64, sender string) error { + pool, err := k.GetPoolAndPoke(ctx, poolId) + if err != nil { + return err + } + stableswapPool, ok := pool.(*stableswap.Pool) + if !ok { + return fmt.Errorf("pool id %d is not of type stableswap pool", poolId) + } + if err := stableswapPool.SetScalingFactors(ctx, scalingFactors, sender); err != nil { + return err + } + + return k.setPool(ctx, stableswapPool) +} diff --git a/x/gamm/keeper/pool_service.go b/x/gamm/keeper/pool_service.go index 0f630e10a7e..9be704b9ac8 100644 --- a/x/gamm/keeper/pool_service.go +++ b/x/gamm/keeper/pool_service.go @@ -7,9 +7,9 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/osmosis-labs/osmosis/v12/osmomath" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // CalculateSpotPrice returns the spot price of the quote asset in terms of the base asset, @@ -202,6 +202,14 @@ func (k Keeper) JoinPoolNoSwap( shareOutAmount sdk.Int, tokenInMaxs sdk.Coins, ) (tokenIn sdk.Coins, sharesOut sdk.Int, err error) { + // defer to catch panics, in case something internal overflows. + defer func() { + if r := recover(); r != nil { + tokenIn = sdk.Coins{} + sharesOut = sdk.Int{} + err = fmt.Errorf("function JoinPoolNoSwap failed due to internal reason: %v", r) + } + }() // all pools handled within this method are pointer references, `JoinPool` directly updates the pools pool, err := k.GetPoolAndPoke(ctx, poolId) if err != nil { @@ -252,7 +260,8 @@ func getMaximalNoSwapLPAmount(ctx sdk.Context, pool types.PoolI, shareOutAmount // shares currently in the pool. It is intended to be used in scenarios where you want shareRatio := shareOutAmount.ToDec().QuoInt(totalSharesAmount) if shareRatio.LTE(sdk.ZeroDec()) { - return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative") + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "Too few shares out wanted. "+ + "(debug: getMaximalNoSwapLPAmount share ratio is zero or negative)") } poolLiquidity := pool.GetTotalPoolLiquidity(ctx) @@ -281,13 +290,21 @@ func (k Keeper) JoinSwapExactAmountIn( poolId uint64, tokensIn sdk.Coins, shareOutMinAmount sdk.Int, -) (sdk.Int, error) { +) (sharesOut sdk.Int, err error) { + // defer to catch panics, in case something internal overflows. + defer func() { + if r := recover(); r != nil { + sharesOut = sdk.Int{} + err = fmt.Errorf("function JoinSwapExactAmountIn failed due to internal reason: %v", r) + } + }() + pool, err := k.getPoolForSwap(ctx, poolId) if err != nil { return sdk.Int{}, err } - sharesOut, err := pool.JoinPool(ctx, tokensIn, pool.GetSwapFee(ctx)) + sharesOut, err = pool.JoinPool(ctx, tokensIn, pool.GetSwapFee(ctx)) switch { case err != nil: return sdk.ZeroInt(), err @@ -318,6 +335,14 @@ func (k Keeper) JoinSwapShareAmountOut( shareOutAmount sdk.Int, tokenInMaxAmount sdk.Int, ) (tokenInAmount sdk.Int, err error) { + // defer to catch panics, in case something internal overflows. + defer func() { + if r := recover(); r != nil { + tokenInAmount = sdk.Int{} + err = fmt.Errorf("function JoinSwapShareAmountOut failed due to internal reason: %v", r) + } + }() + pool, err := k.getPoolForSwap(ctx, poolId) if err != nil { return sdk.Int{}, err @@ -361,8 +386,10 @@ func (k Keeper) ExitPool( } totalSharesAmount := pool.GetTotalShares() - if shareInAmount.GTE(totalSharesAmount) || shareInAmount.LTE(sdk.ZeroInt()) { - return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative") + if shareInAmount.GTE(totalSharesAmount) { + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "Trying to exit >= the number of shares contained in the pool.") + } else if shareInAmount.LTE(sdk.ZeroInt()) { + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "Trying to exit a negative amount of shares") } exitFee := pool.GetExitFee(ctx) exitCoins, err = pool.ExitPool(ctx, shareInAmount, exitFee) diff --git a/x/gamm/keeper/pool_service_test.go b/x/gamm/keeper/pool_service_test.go index 4ea5b77821b..d99c256770b 100644 --- a/x/gamm/keeper/pool_service_test.go +++ b/x/gamm/keeper/pool_service_test.go @@ -6,10 +6,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - balancertypes "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var ( diff --git a/x/gamm/keeper/pool_test.go b/x/gamm/keeper/pool_test.go index 22d99dabfdb..3a2da9ead92 100644 --- a/x/gamm/keeper/pool_test.go +++ b/x/gamm/keeper/pool_test.go @@ -5,10 +5,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - balancertypes "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/stableswap" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // import ( @@ -18,7 +18,7 @@ import ( // "github.com/cosmos/cosmos-sdk/simapp" // sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/osmosis-labs/osmosis/v12/x/gamm/types" +// "github.com/osmosis-labs/osmosis/v13/x/gamm/types" // ) // func (suite *KeeperTestSuite) TestCleanupPool() { diff --git a/x/gamm/keeper/share.go b/x/gamm/keeper/share.go index a856a5d69bf..6443a4a3263 100644 --- a/x/gamm/keeper/share.go +++ b/x/gamm/keeper/share.go @@ -3,8 +3,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper/internal/events" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper/internal/events" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func (k Keeper) applyJoinPoolStateChange(ctx sdk.Context, pool types.PoolI, joiner sdk.AccAddress, numShares sdk.Int, joinCoins sdk.Coins) error { diff --git a/x/gamm/keeper/swap.go b/x/gamm/keeper/swap.go index f048784c269..040cfe16723 100644 --- a/x/gamm/keeper/swap.go +++ b/x/gamm/keeper/swap.go @@ -2,12 +2,13 @@ package keeper import ( "errors" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper/internal/events" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper/internal/events" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // SwapExactAmountIn attempts to swap one asset, tokenIn, for another asset @@ -50,6 +51,13 @@ func (k Keeper) swapExactAmountIn( } tokensIn := sdk.Coins{tokenIn} + defer func() { + if r := recover(); r != nil { + tokenOutAmount = sdk.Int{} + err = fmt.Errorf("function swapExactAmountIn failed due to internal reason: %v", r) + } + }() + // Executes the swap in the pool and stores the output. Updates pool assets but // does not actually transfer any tokens to or from the pool. tokenOutCoin, err := pool.SwapOutAmtGivenIn(ctx, tokensIn, tokenOutDenom, swapFee) @@ -109,6 +117,13 @@ func (k Keeper) swapExactAmountOut( return sdk.Int{}, errors.New("cannot trade same denomination in and out") } + defer func() { + if r := recover(); r != nil { + tokenInAmount = sdk.Int{} + err = fmt.Errorf("function swapExactAmountOut failed due to internal reason: %v", r) + } + }() + poolOutBal := pool.GetTotalPoolLiquidity(ctx).AmountOf(tokenOut.Denom) if tokenOut.Amount.GTE(poolOutBal) { return sdk.Int{}, sdkerrors.Wrapf(types.ErrTooManyTokensOut, diff --git a/x/gamm/keeper/swap_test.go b/x/gamm/keeper/swap_test.go index b924d098ced..c6466dd6520 100644 --- a/x/gamm/keeper/swap_test.go +++ b/x/gamm/keeper/swap_test.go @@ -7,9 +7,9 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/tests/mocks" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/tests/mocks" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var _ = suite.TestingSuite(nil) diff --git a/x/gamm/keeper/total_liquidity.go b/x/gamm/keeper/total_liquidity.go index 7ad5ce867e7..f29044b3276 100644 --- a/x/gamm/keeper/total_liquidity.go +++ b/x/gamm/keeper/total_liquidity.go @@ -4,7 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func (k Keeper) GetTotalLiquidity(ctx sdk.Context) sdk.Coins { diff --git a/x/gamm/module.go b/x/gamm/module.go index efe35309d58..1c00edd0620 100644 --- a/x/gamm/module.go +++ b/x/gamm/module.go @@ -25,13 +25,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - "github.com/osmosis-labs/osmosis/v12/x/gamm/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/stableswap" - simulation "github.com/osmosis-labs/osmosis/v12/x/gamm/simulation" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/gamm/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + simulation "github.com/osmosis-labs/osmosis/v13/x/gamm/simulation" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/v2types" ) var ( @@ -50,7 +51,7 @@ func (AppModuleBasic) Name() string { return types.ModuleName } func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterLegacyAminoCodec(cdc) balancer.RegisterLegacyAminoCodec(cdc) - // stableswap.RegisterLegacyAminoCodec(cdc) + stableswap.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the gamm @@ -74,7 +75,8 @@ func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) { } func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck + v2types.RegisterQueryHandlerClient(context.Background(), mux, v2types.NewQueryClient(clientCtx)) //nolint:errcheck } func (b AppModuleBasic) GetTxCmd() *cobra.Command { @@ -103,8 +105,9 @@ type AppModule struct { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper)) balancer.RegisterMsgServer(cfg.MsgServer(), keeper.NewBalancerMsgServerImpl(&am.keeper)) - // stableswap.RegisterMsgServer(cfg.MsgServer(), keeper.NewStableswapMsgServerImpl(&am.keeper)) + stableswap.RegisterMsgServer(cfg.MsgServer(), keeper.NewStableswapMsgServerImpl(&am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) + v2types.RegisterQueryServer(cfg.QueryServer(), keeper.NewV2Querier(am.keeper)) } func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, diff --git a/x/gamm/pool-models/balancer/amm.go b/x/gamm/pool-models/balancer/amm.go index 18d3f756a19..2867cc2ff9d 100644 --- a/x/gamm/pool-models/balancer/amm.go +++ b/x/gamm/pool-models/balancer/amm.go @@ -6,8 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/osmomath" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // subPoolAssetWeights subtracts the weights of two different pool asset slices. diff --git a/x/gamm/pool-models/balancer/amm_test.go b/x/gamm/pool-models/balancer/amm_test.go index d0dfbda13f2..f348349876d 100644 --- a/x/gamm/pool-models/balancer/amm_test.go +++ b/x/gamm/pool-models/balancer/amm_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/test_helpers" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/test_helpers" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) type BalancerTestSuite struct { diff --git a/x/gamm/pool-models/balancer/balancerPool.pb.go b/x/gamm/pool-models/balancer/balancerPool.pb.go index f2312a4994f..ed9e9067dd6 100644 --- a/x/gamm/pool-models/balancer/balancerPool.pb.go +++ b/x/gamm/pool-models/balancer/balancerPool.pb.go @@ -301,56 +301,56 @@ var fileDescriptor_7e991f749f68c2a4 = []byte{ // 831 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x4f, 0xe3, 0x46, 0x14, 0x8f, 0x93, 0x40, 0x96, 0xc9, 0x76, 0x2b, 0x66, 0x73, 0x30, 0x41, 0x8d, 0xd1, 0x54, 0xaa, - 0x56, 0xd5, 0xc6, 0x56, 0x68, 0x4f, 0x7b, 0x59, 0x6d, 0x16, 0x5a, 0x71, 0xa3, 0xa6, 0x12, 0xa5, - 0x42, 0xb2, 0x26, 0xc9, 0xc4, 0xb6, 0xb0, 0x3d, 0x96, 0x67, 0x12, 0xe0, 0x1b, 0xf4, 0xc8, 0x91, - 0xde, 0xb8, 0xf7, 0xda, 0x7e, 0x07, 0xd4, 0x5e, 0x38, 0x56, 0x3d, 0xb8, 0x15, 0xf4, 0xd4, 0x63, - 0x3e, 0x41, 0x35, 0x7f, 0x9c, 0x04, 0x9a, 0xa8, 0xa0, 0x3d, 0x65, 0xde, 0x9b, 0xf7, 0x7e, 0xef, - 0xf7, 0xde, 0xfb, 0x8d, 0x03, 0xbe, 0xa4, 0x2c, 0xa6, 0x2c, 0x64, 0x8e, 0x8f, 0xe3, 0xd8, 0x49, + 0x56, 0xd5, 0xc6, 0x56, 0x76, 0x7b, 0xda, 0xcb, 0x6a, 0x03, 0xb4, 0xe2, 0x46, 0x4d, 0x25, 0x4a, + 0x85, 0x64, 0x4d, 0x92, 0x89, 0x6d, 0x61, 0x7b, 0x2c, 0xcf, 0x24, 0xc0, 0x37, 0xe8, 0x91, 0x23, + 0xbd, 0x71, 0xef, 0xb5, 0xfd, 0x0e, 0x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0xce, 0x2d, 0x63, 0x92, 0x5b, 0x48, - 0x77, 0xb5, 0xbc, 0x00, 0x72, 0x4d, 0xb6, 0x04, 0x05, 0xfd, 0x64, 0x80, 0xb5, 0xe9, 0xae, 0xe0, - 0x2e, 0x58, 0xe1, 0xf4, 0x84, 0x24, 0xfa, 0x81, 0x6c, 0xd8, 0xfa, 0xdd, 0x8b, 0x27, 0x37, 0x65, - 0xf4, 0x9e, 0x86, 0x49, 0xb7, 0xa1, 0xb7, 0xfa, 0x5c, 0x6f, 0x55, 0x64, 0x21, 0x57, 0x65, 0xc3, - 0x43, 0xb0, 0xaa, 0x78, 0xe8, 0x61, 0xbe, 0x7d, 0xc2, 0x30, 0xf7, 0x12, 0x3e, 0xc9, 0xad, 0x8f, - 0x14, 0xac, 0x42, 0x41, 0xae, 0x86, 0x43, 0xbf, 0x54, 0x41, 0x55, 0xb0, 0x85, 0xaf, 0x41, 0x0d, - 0x0f, 0x06, 0x19, 0x61, 0x4c, 0xab, 0x01, 0x4e, 0x72, 0xeb, 0x85, 0x4a, 0xd2, 0x17, 0xc8, 0x2d, - 0x42, 0xe0, 0x0b, 0x50, 0x0e, 0x07, 0x92, 0x4b, 0xd5, 0x2d, 0x87, 0x03, 0x38, 0x04, 0x75, 0xa9, - 0xbf, 0x7b, 0xf3, 0xdf, 0x5a, 0x2e, 0x64, 0x3d, 0xf1, 0x07, 0x0f, 0xa8, 0xf8, 0x94, 0x7a, 0x73, - 0x58, 0xc8, 0x05, 0xe9, 0x4c, 0xb4, 0xdf, 0x80, 0xc6, 0x70, 0xc4, 0x47, 0x19, 0x51, 0x21, 0x3e, - 0x1d, 0x93, 0x2c, 0xa1, 0x99, 0x59, 0x95, 0x94, 0xad, 0x19, 0xd4, 0xa2, 0x28, 0xe4, 0x42, 0xe5, - 0x16, 0x0c, 0xbe, 0xd6, 0x4e, 0x78, 0x04, 0x9e, 0x73, 0xca, 0x71, 0xe4, 0xb1, 0x00, 0x67, 0x84, - 0x99, 0x2b, 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xc9, 0xca, 0xb8, 0xd7, 0x47, 0xa1, 0x0f, 0xd5, 0x87, 0x92, 0xf7, 0xbb, 0xf5, + 0xef, 0xaf, 0xac, 0xd2, 0xe5, 0x95, 0x55, 0xfa, 0xe5, 0xa7, 0xf6, 0x8a, 0x20, 0xba, 0xd7, 0x3d, + 0xba, 0xbe, 0x6d, 0x19, 0x37, 0xb7, 0x2d, 0xe3, 0xcf, 0xdb, 0x96, 0x71, 0x71, 0xd7, 0x2a, 0xdd, + 0xdc, 0xb5, 0x4a, 0xbf, 0xdd, 0xb5, 0x4a, 0xdf, 0xbd, 0x9f, 0x2b, 0xac, 0x3b, 0x6d, 0x47, 0xb8, + 0xc7, 0x0a, 0xc3, 0x19, 0x77, 0xde, 0x3a, 0x67, 0xcb, 0xff, 0x50, 0x7b, 0xab, 0xf2, 0x23, 0xff, + 0xf6, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d, 0xba, 0x2b, 0xb9, 0x7c, 0x07, 0x00, 0x00, } func (m *SmoothWeightChangeParams) Marshal() (dAtA []byte, err error) { diff --git a/x/gamm/pool-models/balancer/codec.go b/x/gamm/pool-models/balancer/codec.go index e6e5674a30f..748c77dd16c 100644 --- a/x/gamm/pool-models/balancer/codec.go +++ b/x/gamm/pool-models/balancer/codec.go @@ -1,7 +1,7 @@ package balancer import ( - types "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + types "github.com/osmosis-labs/osmosis/v13/x/gamm/types" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/gamm/pool-models/balancer/constants.go b/x/gamm/pool-models/balancer/constants.go index ed733539c92..f11f02e699a 100644 --- a/x/gamm/pool-models/balancer/constants.go +++ b/x/gamm/pool-models/balancer/constants.go @@ -17,4 +17,6 @@ var ( // // This is done so that smooth weight changes have enough precision to actually be smooth. GuaranteedWeightPrecision int64 = 1 << 30 + + PoolTypeName string = "Balancer" ) diff --git a/x/gamm/pool-models/balancer/marshal_test.go b/x/gamm/pool-models/balancer/marshal_test.go index 90611b23730..403944d72e7 100644 --- a/x/gamm/pool-models/balancer/marshal_test.go +++ b/x/gamm/pool-models/balancer/marshal_test.go @@ -8,7 +8,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/gamm/pool-models/balancer/msgs.go b/x/gamm/pool-models/balancer/msgs.go index b79f6d9c467..3ef674b4aea 100644 --- a/x/gamm/pool-models/balancer/msgs.go +++ b/x/gamm/pool-models/balancer/msgs.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) const ( diff --git a/x/gamm/pool-models/balancer/msgs_test.go b/x/gamm/pool-models/balancer/msgs_test.go index 90bb608acc3..d057745baaa 100644 --- a/x/gamm/pool-models/balancer/msgs_test.go +++ b/x/gamm/pool-models/balancer/msgs_test.go @@ -8,9 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" - appParams "github.com/osmosis-labs/osmosis/v12/app/params" - balancer "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" + balancer "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func TestMsgCreateBalancerPool(t *testing.T) { diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index ddbbecf00c1..5f8201aff18 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -10,8 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/cfmm_common" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/cfmm_common" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) //nolint:deadcode diff --git a/x/gamm/pool-models/balancer/pool_asset.go b/x/gamm/pool-models/balancer/pool_asset.go index b6ebae5a8c5..dbeecda70fe 100644 --- a/x/gamm/pool-models/balancer/pool_asset.go +++ b/x/gamm/pool-models/balancer/pool_asset.go @@ -5,7 +5,7 @@ import ( "sort" "strings" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" "gopkg.in/yaml.v2" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/gamm/pool-models/balancer/pool_params.go b/x/gamm/pool-models/balancer/pool_params.go index 2cdf659b99d..00c9647b8e4 100644 --- a/x/gamm/pool-models/balancer/pool_params.go +++ b/x/gamm/pool-models/balancer/pool_params.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func NewPoolParams(swapFee, exitFee sdk.Dec, params *SmoothWeightChangeParams) PoolParams { diff --git a/x/gamm/pool-models/balancer/pool_suite_test.go b/x/gamm/pool-models/balancer/pool_suite_test.go index aa25cac11b4..57a57bed248 100644 --- a/x/gamm/pool-models/balancer/pool_suite_test.go +++ b/x/gamm/pool-models/balancer/pool_suite_test.go @@ -11,11 +11,11 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - v10 "github.com/osmosis-labs/osmosis/v12/app/upgrades/v10" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + v10 "github.com/osmosis-labs/osmosis/v13/app/upgrades/v10" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) const ( diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index 63066309006..e51c19acaca 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -9,10 +9,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/test_helpers" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/test_helpers" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var ( @@ -573,8 +574,10 @@ func (suite *BalancerTestSuite) TestBalancerCalculateAmountOutAndIn_InverseRelat pool := createTestPool(suite.T(), swapFeeDec, exitFeeDec, poolAssetOut, poolAssetIn) suite.Require().NotNil(pool) + errTolerance := osmoutils.ErrTolerance{ + AdditiveTolerance: sdk.OneInt(), MultiplicativeTolerance: sdk.Dec{}} sut := func() { - test_helpers.TestCalculateAmountOutAndIn_InverseRelationship(suite.T(), ctx, pool, poolAssetIn.Token.Denom, poolAssetOut.Token.Denom, tc.initialCalcOut, swapFeeDec) + test_helpers.TestCalculateAmountOutAndIn_InverseRelationship(suite.T(), ctx, pool, poolAssetIn.Token.Denom, poolAssetOut.Token.Denom, tc.initialCalcOut, swapFeeDec, errTolerance) } balancerPool, ok := pool.(*balancer.Pool) diff --git a/x/gamm/pool-models/balancer/tx.pb.go b/x/gamm/pool-models/balancer/tx.pb.go index 406ee7bb812..29c4b5e83a0 100644 --- a/x/gamm/pool-models/balancer/tx.pb.go +++ b/x/gamm/pool-models/balancer/tx.pb.go @@ -154,32 +154,32 @@ func init() { var fileDescriptor_0647ee155de97433 = []byte{ // 427 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xc1, 0x6e, 0xd3, 0x30, - 0x18, 0x80, 0xeb, 0xb5, 0x2a, 0xc2, 0x15, 0x07, 0xac, 0x81, 0xa2, 0x22, 0x92, 0x28, 0x5c, 0xc2, - 0xa1, 0xb6, 0x1a, 0x38, 0x71, 0x99, 0x08, 0x13, 0xd3, 0x0e, 0x93, 0x46, 0x6e, 0xe3, 0x32, 0x39, - 0x8b, 0x09, 0x95, 0x92, 0x38, 0xb2, 0xdd, 0xaa, 0xbc, 0x05, 0x4f, 0xc0, 0x91, 0x67, 0xe0, 0x11, - 0x76, 0xdc, 0x91, 0x53, 0x84, 0xd2, 0x37, 0xe8, 0x13, 0x20, 0xdb, 0x09, 0x1a, 0x52, 0x26, 0x90, - 0x76, 0x73, 0x7e, 0x7f, 0xff, 0xf7, 0xff, 0xbf, 0xf3, 0xc3, 0x05, 0x97, 0x25, 0x97, 0x2b, 0x49, - 0x72, 0x5a, 0x96, 0xa4, 0xe6, 0xbc, 0x58, 0x94, 0x3c, 0x63, 0x85, 0x24, 0x29, 0x2d, 0x68, 0x75, - 0xc5, 0x04, 0x51, 0x5b, 0xa2, 0xb6, 0xb8, 0x16, 0x5c, 0x71,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, - 0xc1, 0x97, 0x4b, 0x98, 0xac, 0x79, 0x25, 0x19, 0x7a, 0x01, 0x1f, 0x18, 0xcd, 0x2a, 0x33, 0x4f, - 0x38, 0x89, 0x61, 0xdb, 0x78, 0x53, 0x8d, 0x9c, 0x1e, 0x27, 0x53, 0x7d, 0x75, 0x9a, 0x45, 0xdf, - 0x01, 0x1c, 0x9f, 0xc9, 0x1c, 0x7d, 0x03, 0x10, 0x0d, 0xfc, 0x85, 0x23, 0xfc, 0xbf, 0x6b, 0x81, - 0x07, 0x9b, 0x99, 0x9f, 0xdc, 0x53, 0xd0, 0x4f, 0x13, 0x5f, 0x5c, 0xb7, 0x2e, 0xb8, 0x69, 0x5d, - 0xf0, 0xab, 0x75, 0xc1, 0xd7, 0x9d, 0x3b, 0xba, 0xd9, 0xb9, 0xa3, 0x9f, 0x3b, 0x77, 0xf4, 0xf1, - 0x28, 0x5f, 0xa9, 0xcf, 0xeb, 0x14, 0x5f, 0xf1, 0x92, 0x74, 0xc5, 0x16, 0x05, 0x4d, 0x65, 0xff, - 0x41, 0x36, 0xcb, 0x88, 0x6c, 0xef, 0xde, 0xcb, 0x74, 0x6a, 0x76, 0xf1, 0xd5, 0xef, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x16, 0x03, 0xec, 0xd7, 0x32, 0x03, 0x00, 0x00, + 0x18, 0x80, 0xeb, 0xb5, 0x0a, 0xc2, 0x15, 0x07, 0xac, 0x81, 0xa2, 0x22, 0x92, 0x28, 0x5c, 0xc2, + 0xa1, 0xb6, 0xda, 0x71, 0xe2, 0x32, 0x11, 0x26, 0xa6, 0x1d, 0x26, 0x8d, 0xdc, 0xc6, 0x65, 0x72, + 0x16, 0x13, 0x2a, 0x25, 0x71, 0x64, 0xbb, 0x55, 0x79, 0x0b, 0x9e, 0x80, 0x23, 0xcf, 0xc0, 0x23, + 0xec, 0xb8, 0x23, 0xa7, 0x08, 0xa5, 0x6f, 0xd0, 0x27, 0x40, 0xb6, 0x13, 0x34, 0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 0x8f, 0xac, 0xc7, 0x04, 0x24, 0x7a, 0x0f, 0x0f, 0x3f, 0xae, 0xd5, + 0x5a, 0xb0, 0x2b, 0xa3, 0xcb, 0xf9, 0x86, 0x89, 0x8a, 0x0b, 0x77, 0x62, 0x66, 0xf3, 0xf7, 0x8d, + 0xff, 0xcc, 0x76, 0x32, 0x44, 0x85, 0x09, 0xb2, 0x61, 0x5d, 0xe1, 0xb4, 0x0f, 0x9e, 0xc0, 0xe7, + 0x83, 0x2f, 0x97, 0x30, 0x59, 0xf3, 0x4a, 0x32, 0xf4, 0x02, 0x3e, 0x30, 0x9a, 0x55, 0x66, 0x9e, + 0x70, 0x12, 0xc3, 0xb6, 0xf1, 0x1d, 0x8d, 0x9c, 0x9d, 0x24, 0x8e, 0xbe, 0x3a, 0xcb, 0x96, 0xdf, + 0x00, 0x1c, 0x9f, 0xcb, 0x1c, 0x7d, 0x05, 0x10, 0x0d, 0xfc, 0x85, 0x63, 0xfc, 0xaf, 0x6b, 0x81, + 0x07, 0x9b, 0x99, 0x9d, 0xfe, 0xa7, 0xa0, 0x9f, 0x26, 0xbe, 0xbc, 0x69, 0x3d, 0x70, 0xdb, 0x7a, + 0xe0, 0x67, 0xeb, 0x81, 0x2f, 0x3b, 0x6f, 0x74, 0xbb, 0xf3, 0x46, 0x3f, 0x76, 0xde, 0xe8, 0xc3, + 0x71, 0xbe, 0x52, 0x9f, 0xd6, 0x29, 0xbe, 0xe6, 0x25, 0xe9, 0x8a, 0xcd, 0x0b, 0x9a, 0xca, 0xfe, + 0x83, 0x6c, 0x16, 0x47, 0x64, 0x7b, 0xff, 0x5e, 0xa6, 0x8e, 0xd9, 0xc5, 0xa3, 0x5f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x09, 0x14, 0x1c, 0x57, 0x32, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/gamm/pool-models/balancer/util_test.go b/x/gamm/pool-models/balancer/util_test.go index 357a4d78773..d4b1bb7f6fe 100644 --- a/x/gamm/pool-models/balancer/util_test.go +++ b/x/gamm/pool-models/balancer/util_test.go @@ -12,9 +12,9 @@ import ( tmtypes "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func createTestPool(t *testing.T, swapFee, exitFee sdk.Dec, poolAssets ...balancer.PoolAsset) types.PoolI { diff --git a/x/gamm/pool-models/internal/cfmm_common/lp.go b/x/gamm/pool-models/internal/cfmm_common/lp.go index 5d830801f29..e14d246040d 100644 --- a/x/gamm/pool-models/internal/cfmm_common/lp.go +++ b/x/gamm/pool-models/internal/cfmm_common/lp.go @@ -6,8 +6,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) const errMsgFormatSharesLargerThanMax = "%s resulted shares is larger than the max amount of %s" @@ -114,10 +115,6 @@ func MaximalExactRatioJoin(p types.PoolI, ctx sdk.Context, tokensIn sdk.Coins) ( return numShares, remCoins, nil } -// Need to get something that makes the result correct within 1 LP share. -// If we fail to reach it within maxIterations, we return an error. -var singleAssetJoinCorrectnessThreshold = sdk.NewInt(1) - // We binary search a number of LP shares, s.t. if we exited the pool with the updated liquidity, // and swapped all the tokens back to the input denom, we'd get the same amount. (under 0 swap fee) // Thanks to CFMM path-independence, we can estimate slippage with these swaps to be sure to get the right numbers here. @@ -133,6 +130,7 @@ func BinarySearchSingleAssetJoin( ) (numLPShares sdk.Int, err error) { // use dummy context ctx := sdk.Context{} + // should be guaranteed to converge if above 256 since sdk.Int has 256 bits maxIterations := 300 // upperbound of number of LP shares = existingShares * tokenIn.Amount / pool.totalLiquidity.AmountOf(tokenIn.Denom) existingTokenLiquidity := pool.GetTotalPoolLiquidity(ctx).AmountOf(tokenIn.Denom) @@ -153,22 +151,25 @@ func BinarySearchSingleAssetJoin( return sdk.Int{}, err } - return SwapAllCoinsToSingleAsset(poolWithUpdatedLiquidity, ctx, exitedCoins, swapToDenom) + return SwapAllCoinsToSingleAsset(poolWithUpdatedLiquidity, ctx, exitedCoins, swapToDenom, sdk.ZeroDec()) } - errTolerance := osmoutils.ErrTolerance{AdditiveTolerance: singleAssetJoinCorrectnessThreshold, MultiplicativeTolerance: sdk.OneDec()} + // We accept an additive tolerance of 1 LP share error and round down + errTolerance := osmoutils.ErrTolerance{AdditiveTolerance: sdk.OneInt(), MultiplicativeTolerance: sdk.Dec{}, RoundingDir: osmomath.RoundDown} - // we set the target at input amount minus additive tolerance so we never output more tokens than were passed in numLPShares, err = osmoutils.BinarySearch( estimateCoinOutGivenShares, - LPShareLowerBound, LPShareUpperBound, tokenIn.Amount.Sub(singleAssetJoinCorrectnessThreshold), errTolerance, maxIterations) + LPShareLowerBound, LPShareUpperBound, tokenIn.Amount, errTolerance, maxIterations) + if err != nil { + return sdk.Int{}, err + } - return numLPShares, err + return numLPShares, nil } // SwapAllCoinsToSingleAsset iterates through each token in the input set and trades it against the same pool sequentially -func SwapAllCoinsToSingleAsset(pool types.PoolI, ctx sdk.Context, inTokens sdk.Coins, swapToDenom string) (sdk.Int, error) { - swapFee := sdk.ZeroDec() +func SwapAllCoinsToSingleAsset(pool types.PoolI, ctx sdk.Context, inTokens sdk.Coins, swapToDenom string, + swapFee sdk.Dec) (sdk.Int, error) { tokenOutAmt := inTokens.AmountOfNoDenomValidation(swapToDenom) for _, coin := range inTokens { if coin.Denom == swapToDenom { diff --git a/x/gamm/pool-models/internal/cfmm_common/lp_test.go b/x/gamm/pool-models/internal/cfmm_common/lp_test.go index bf8fb3329aa..eabc0ec76d0 100644 --- a/x/gamm/pool-models/internal/cfmm_common/lp_test.go +++ b/x/gamm/pool-models/internal/cfmm_common/lp_test.go @@ -6,10 +6,10 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/cfmm_common" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/stableswap" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/cfmm_common" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/gamm/pool-models/internal/test_helpers/test_helpers.go b/x/gamm/pool-models/internal/test_helpers/test_helpers.go index caa0aaab84e..3dec5f4c928 100644 --- a/x/gamm/pool-models/internal/test_helpers/test_helpers.go +++ b/x/gamm/pool-models/internal/test_helpers/test_helpers.go @@ -1,6 +1,7 @@ package test_helpers import ( + "math/rand" "testing" "github.com/cosmos/cosmos-sdk/store/rootmulti" @@ -11,8 +12,10 @@ import ( tmtypes "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + sdkrand "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/random" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // CfmmCommonTestSuite is the common test suite struct of Constant Function Market Maker, @@ -38,6 +41,7 @@ func TestCalculateAmountOutAndIn_InverseRelationship( assetOutDenom string, initialCalcOut int64, swapFee sdk.Dec, + errTolerance osmoutils.ErrTolerance, ) { initialOut := sdk.NewInt64Coin(assetOutDenom, initialCalcOut) initialOutCoins := sdk.NewCoins(initialOut) @@ -64,12 +68,117 @@ func TestCalculateAmountOutAndIn_InverseRelationship( if preFeeTokenIn.Equal(sdk.OneInt()) { require.True(t, actual.GT(expected)) } else { - // allow a rounding error of up to 1 for this relation - tol := sdk.NewDec(1) - osmoassert.DecApproxEq(t, expected, actual, tol) + if expected.Sub(actual).Abs().GT(sdk.OneDec()) { + compRes := errTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(expected), osmomath.BigDecFromSDKDec(actual)) + require.True(t, compRes == 0, "expected %s, actual %s, not within error tolerance %v", + expected, actual, errTolerance) + } } } +func TestSlippageRelationWithLiquidityIncrease( + testname string, + t *testing.T, + ctx sdk.Context, + createPoolWithLiquidity func(sdk.Context, sdk.Coins) types.PoolI, + initLiquidity sdk.Coins, +) { + TestSlippageRelationOutGivenIn(testname, t, ctx, createPoolWithLiquidity, initLiquidity) + TestSlippageRelationInGivenOut(testname, t, ctx, createPoolWithLiquidity, initLiquidity) +} + +func TestSlippageRelationOutGivenIn( + testname string, + t *testing.T, + ctx sdk.Context, + createPoolWithLiquidity func(sdk.Context, sdk.Coins) types.PoolI, + initLiquidity sdk.Coins, +) { + r := rand.New(rand.NewSource(100)) + swapInAmt := sdkrand.RandCoin(r, initLiquidity[:1]) + swapOutDenom := initLiquidity[1].Denom + + curPool := createPoolWithLiquidity(ctx, initLiquidity) + fee := curPool.GetSwapFee(ctx) + + curLiquidity := initLiquidity + curOutAmount, err := curPool.CalcOutAmtGivenIn(ctx, swapInAmt, swapOutDenom, fee) + require.NoError(t, err) + for i := 0; i < 50; i++ { + newLiquidity := curLiquidity.Add(curLiquidity...) + curPool = createPoolWithLiquidity(ctx, newLiquidity) + + // ensure out amount goes down as liquidity increases + newOutAmount, err := curPool.CalcOutAmtGivenIn(ctx, swapInAmt, swapOutDenom, fee) + require.NoError(t, err) + require.True(t, newOutAmount.Amount.GTE(curOutAmount.Amount), + "%s: swap with new liquidity %s yielded less than swap with old liquidity %s."+ + " Swap amount in %s. new swap out: %s, old swap out %s", testname, newLiquidity, curLiquidity, + swapInAmt, newOutAmount, curOutAmount) + + curLiquidity, curOutAmount = newLiquidity, newOutAmount + } +} + +func TestSlippageRelationInGivenOut( + testname string, + t *testing.T, + ctx sdk.Context, + createPoolWithLiquidity func(sdk.Context, sdk.Coins) types.PoolI, + initLiquidity sdk.Coins, +) { + r := rand.New(rand.NewSource(100)) + swapOutAmt := sdkrand.RandCoin(r, initLiquidity[:1]) + swapInDenom := initLiquidity[1].Denom + + curPool := createPoolWithLiquidity(ctx, initLiquidity) + fee := curPool.GetSwapFee(ctx) + + // we first ensure that the pool has sufficient liquidity to accommodate + // a swap that yields `swapOutAmt` without more than doubling input reserves + curLiquidity := initLiquidity + for !isWithinBounds(ctx, curPool, swapOutAmt, swapInDenom, fee) { + // increase pool liquidity by 10x + for i, coin := range initLiquidity { + curLiquidity[i] = sdk.NewCoin(coin.Denom, coin.Amount.Mul(sdk.NewInt(10))) + } + curPool = createPoolWithLiquidity(ctx, curLiquidity) + } + + curInAmount, err := curPool.CalcInAmtGivenOut(ctx, swapOutAmt, swapInDenom, fee) + + require.NoError(t, err) + for i := 0; i < 50; i++ { + newLiquidity := curLiquidity.Add(curLiquidity...) + curPool = createPoolWithLiquidity(ctx, newLiquidity) + + // ensure required in amount goes down as liquidity increases + newInAmount, err := curPool.CalcInAmtGivenOut(ctx, swapOutAmt, swapInDenom, fee) + require.NoError(t, err) + require.True(t, newInAmount.Amount.LTE(curInAmount.Amount), + "%s: swap with new liquidity %s required greater input than swap with old liquidity %s."+ + " Swap amount out %s. new swap in: %s, old swap in %s", testname, newLiquidity, curLiquidity, + swapOutAmt, newInAmount, curInAmount) + + curLiquidity, curInAmount = newLiquidity, newInAmount + } +} + +// returns true if the pool can accommodate an InGivenOut swap with `tokenOut` amount out, false otherwise +func isWithinBounds(ctx sdk.Context, pool types.PoolI, tokenOut sdk.Coins, tokenInDenom string, swapFee sdk.Dec) (b bool) { + b = true + defer func() { + if r := recover(); r != nil { + b = false + } + }() + _, err := pool.CalcInAmtGivenOut(ctx, tokenOut, tokenInDenom, swapFee) + if err != nil { + b = false + } + return b +} + func TestCfmmCommonTestSuite(t *testing.T) { t.Parallel() suite.Run(t, new(CfmmCommonTestSuite)) diff --git a/x/gamm/pool-models/stableswap/README.md b/x/gamm/pool-models/stableswap/README.md index 30cfca5eaaa..f6ece702395 100644 --- a/x/gamm/pool-models/stableswap/README.md +++ b/x/gamm/pool-models/stableswap/README.md @@ -1,4 +1,4 @@ -# Solidly Stableswap +# Generalized Solidly Stableswap Stableswaps are pools that offer low slippage for two assets that are intended to be tightly correlated. There is a price ratio they are expected to be at, and the AMM offers low slippage around this price. @@ -9,26 +9,22 @@ invariant: $f(x, y) = xy(x^2 + y^2) = k$ It is generalized to the multi-asset setting as $f(a_1, ..., a_n) = a_1 * ... * a_n (a_1^2 + ... + a_n^2)$ -## Choice of curve - -{TODO: Include some high level summary of the curve} - ## Pool configuration -One key concept, is that the pool has a native concept of +One key concept, is that the pool has a native concept of ### Scaling factor handling An important concept thats up to now, not been mentioned is how do we set the expected price ratio. In the choice of curve section, we see that its the case that when `x_reserves ~= y_reserves`, that spot price is very close to `1`. However, there are a couple issues with just this in practice: -1) Precision of pegged coins may differ. Suppose `1 Foo = 10^12 base units`, whereas `1 WrappedFoo = 10^6 base units`, but `1 Foo` is expected to trade near the price of `1 Wrapped Foo`. -2) Relatedly, suppose theres a token called `TwoFoo` which should trade around `1 TwoFoo = 2 Foo` -3) For staking derivatives, where value accrues within the token, the expected price to concentrate around dynamically changes (very slowly). +1. Precision of pegged coins may differ. Suppose `1 Foo = 10^12 base units`, whereas `1 WrappedFoo = 10^6 base units`, but `1 Foo` is expected to trade near the price of `1 Wrapped Foo`. +2. Relatedly, suppose theres a token called `TwoFoo` which should trade around `1 TwoFoo = 2 Foo` +3. For staking derivatives, where value accrues within the token, the expected price to concentrate around dynamically changes (very slowly). To handle these cases, we introduce scaling factors. A scaling factor maps from "raw coin units" to "amm math units", by dividing. To handle the first case, we would make `Foo` have a scaling factor of `10^6`, and `WrappedFoo` have a scaling factor of `1`. -This mapping is done via `raw coin units / scaling factor`. +This mapping is done via `raw coin units / scaling factor`. We use a decimal object for amm math units, however we still have to be precise about how we round. We introduce an enum `rounding mode` for this, with three modes: `RoundUp`, `RoundDown`, `RoundBankers`. @@ -78,21 +74,26 @@ Due to the CFMM equation $f$ being a symmetric function, we can without loss of We then take a more convenient expression to work with, via variable substition. -$$\begin{equation} + +$$ +\begin{equation} v = \begin{cases} 1, & \text{if } n=2 \\ \prod\negthinspace \negthinspace \thinspace^{n}_{i=3} \space a_i, & \text{otherwise} \end{cases} - \end{equation}$$ + \end{equation} +$$ -$$\begin{equation} +$$ +\begin{equation} w = \begin{cases} 0, & \text{if}\ n=2 \\ \sum\negthinspace \negthinspace \thinspace^{n}_{i=3} \space {a_i^2}, & \text{otherwise} \end{cases} - \end{equation}$$ + \end{equation} +$$ $$\text{then } g(x,y,v,w) = xyv(x^2 + y^2 + w) = f(x,y, a_3, ... a_n)$$ @@ -112,7 +113,7 @@ The method to compute this under 0 swap fee is implied by the CFMM equation itse $g(x_0, y_0, v, w) = k = g(x_0 + a, y_0 - b, v, w)$. As $k$ is linearly related to $v$, and $v$ is unchanged throughout the swap, we can simplify the equation to be reasoning about $k' = \frac{k}{v}$ as the constant, and $h$ instead of $g$ We then model the solution by finding a function $\text{solve cfmm}(x, w, k') = y\text{ s.t. }h(x, y, w) = k'$. -Then we can solve the swap amount out by first computing $k'$ as $k' = h(x_0, y_0, w)$, and +Then we can solve the swap amount out by first computing $k'$ as $k' = h(x_0, y_0, w)$, and computing $y_f := \text{solve cfmm}(x_0 + a, w, k')$. We then get that $b = y_0 - y_f$. So all we need is an equation for $\text{solve cfmm}$! Its essentially inverting a multi-variate polynomial, and in this case is solvable: [wolfram alpha link](https://www.wolframalpha.com/input?i=solve+for+y+in+x+*+y+*+%28x%5E2+%2B+y%5E2+%2B+w%29+%3D+k) @@ -125,36 +126,96 @@ Instead there is a more generic way to compute these, which we detail in the nex #### Iterative search solution -Instead of using the direct solution for $\text{solve cfmm}(x, w, k')$, instead notice that $h(x, y, w)$ is an increasing function in $y$. -So we can simply binary search for $y$ such that $h(x, y, w) = k'$, and we are guaranteed convergence within some error bound. +Instead of using the direct solution for $\text{solve cfmm}(x, w, k')$, instead notice that $h(x, y, w)$ is an increasing function in $y$. +So we can simply binary search for $y$ such that $h(x, y, w) = k'$, and we are guaranteed convergence within some error bound. -In order to do a binary search, we need bounds on $y$. -The lowest lowerbound is $0$, and the largest upperbound is $\infty$. -The maximal upperbound is obviously unworkable, and in general binary searching around wide ranges is unfortunate, as we expect most trades to be centered around $y_0$. -This would suggest that we should do something smarter to iteratively approach the right value for the upperbound at least. -Notice that $h$ is super-linearly related in $y$, and at most cubically related to $y$. -This means that $\forall c \in \mathbb{R}^+, c * h(x,y,w) < h(x,c*y,w) < c^3 * h(x,y,w)$. +In order to do a binary search, we need bounds on $y$. +The lowest lowerbound is $0$, and the largest upperbound is $\infty$. +The maximal upperbound is obviously unworkable, and in general binary searching around wide ranges is unfortunate, as we expect most trades to be centered around $y_0$. +This would suggest that we should do something smarter to iteratively approach the right value for the upperbound at least. +Notice that $h$ is super-linearly related in $y$, and at most cubically related to $y$. +This means that $\forall c \in \mathbb{R}^+, c * h(x,y,w) < h(x,c*y,w) < c^3 * h(x,y,w)$. We can use this fact to get a pretty-good initial upperbound guess for $y$ using the linear estimate. In the lowerbound case, we leave it as lower-bounded by $0$, otherwise we would need to take a cubed root to get a better estimate. +##### Altering binary search equations due to error tolerance + +Great, we have a binary search to finding an input `new_y_reserve`, such that we get a value `k` within some error bound close to the true desired `k`! We can prove that an error by a factor of `e` in `k`, implies an error of a factor less than `e` in `new_y_reserve`. So we could set `e` to be close to some correctness bound we want. Except... `new_y_reserve >> y_in`, so we'd need an extremely high error tolerance for this to work. So we actually want to adapt the equations, to reduce the "common terms" in `k` that we need to binary search over, to help us search. To do this, we open up what are we doing again, and re-expose `y_out` as a variable we explicitly search over (and therefore get error terms in `k` implying error in `y_out`) + +What we are doing above in the binary search is setting `k_target` and searching over `y_f` until we get `k_iter` {within tolerance} to `k_target`. Sine we want to change to iterating over $y_{out}$, we unroll that $y_f = y_0 - y_{out}$ where they are defined as: +$$k_{target} = x_0 y_0 (x_0^2 + y_0^2 + w)$$ +$$k_{iter}(y_0 - y_{out}) = h(x_f, y_0 - y_{out}, w) = x_f (y_0 - y_{out}) (x_f^2 + (y_0 - y_{out})^2 + w)$$ + +But we can remove many of these terms! First notice that `x_f` is a constant factor in `k_iter`, so we can just divide `k_target` by `x_f` to remove that. Then we switch what we search over, from `y_f` to `y_out`, by fixing `y_0`, so were at: + +$$k_{target} = x_0 y_0 (x_0^2 + y_0^2 + w) / x_f$$ + +$$k_{iter}(y_{out}) = (y_0 - y_{out}) (x_f^2 + (y_0 - y_{out})^2 + w) = (y_0 - y_{out}) (x_f^2 + w) + (y_0 - y_{out})^3$$ + +So $k_{iter}(y_{out})$ is a cubic polynomial in $y_{out}$. Next we remove the terms that have no dependence on `y_{delta}` (the constant term in the polynomial). To do this first we rewrite this to make the polynomial clearer: + +$$k_{iter}(y_{out}) = (y_0 - y_{out}) (x_f^2 + w) + y_0^3 - 3y_0^2 y_{out} + 3 y_0 y_{out}^2 - y_{out}^3$$ + +$$k_{iter}(y_{out}) = y_0 (x_f^2 + w) - y_{out}(x_f^2 + w) + y_0^3 - 3y_0^2 y_{out} + 3 y_0 y_{out}^2 - y_{out}^3$$ + +$$k_{iter}(y_{out}) = -y_{out}^3 + 3 y_0 y_{out}^2 - (x_f^2 + w + 3y_0^2)y_{out} + (y_0 (x_f^2 + w) + y_0^3)$$ + +So we can subtract this constant term `y_0 (x_f^2 + w) + y_0^3`, which for `y_out < y_0` is the dominant term in the expression! + +So lets define this as: + +$$k_{target} = \frac{x_0 y_0 (x_0^2 + y_0^2 + w)}{x_f} - (y_0 (x_f^2 + w) + y_0^3)$$ + +$$k_{iter}(y_{out}) = -y_{out}^3 + 3 y_0 y_{out}^2 - (x_f^2 + w + 3y_0^2)y_{out}$$ + +We prove [here](#err_proof) that an error of a multiplicative `e` between `target_k` and `iter_k`, implies an error of less than a factor of `10e` in `y_{out}`, as long as `|y_{out}| < y_0`. (The proven bounds are actually better) + +We target an error of less than `10^{-8}` in `y_{out}`, so we conservatively set a bound of `10^{-12}` for `e_k`. + +##### Combined pseudocode + +Now we want to wrap this binary search into `solve_cfmm`. We changed the API slightly, from what was previously denoted, to have this "y_0" term, in order to derive initial bounds. + +One complexity is that in the iterative search, we iterate over $y_f$, but then translate to $y_0$ in the internal equations. +So we also use the + ```python -def iterative_search(x_f, y_0, w, k, err_tolerance): - k_0 = h(x_f, y_0, w) +# solve_y returns y_out s.t. CFMM_eq(x_f, y_f, w) = k = CFMM_eq(x_0, y_0, w) +# for x_f = x_0 + x_in. +def solve_y(x_0, y_0, w, x_in): + x_f = x_0 + x_in + err_tolerance = {"within factor of 10^-12", RoundUp} + y_f = iterative_search(x_0, x_f, y_0, w, err_tolerance) + y_out = y_0 - y_f + return y_out + +def iter_k_fn(x_f, y_0, w): + def f(y_f): + y_out = y_0 - y_f + return -(y_out)**3 + 3 y_0 * y_out^2 - (x_f**2 + w + 3*y_0**2) * y_out + +def iterative_search(x_0, x_f, y_0, w, err_tolerance): + target_k = target_k_fn(x_0, y_0, w, x_f) + iter_k_calculator = iter_k_fn(x_f, y_0, w) + + # use original CFMM to get y_f reserve bounds + bound_estimation_target_k = cfmm(x_0, y_0, w) + bound_estimation_k0 = cfmm(x_f, y_0, w) lowerbound, upperbound = y_0, y_0 - k_ratio = k_0 / k + k_ratio = bound_estimation_k0 / bound_estimation_target_k if k_ratio < 1: # k_0 < k. Need to find an upperbound. Worst case assume a linear relationship, gives an upperbound - # TODO: In the future, we can derive better bounds via reasoning about coefficients in the cubic - # These are quite close when we are in the "stable" part of the curve though. + # We could derive better bounds via reasoning about coefficients in the cubic, + # however this is deemed as not worth it, since the solution is quite close + # when we are in the "stable" part of the curve. upperbound = ceil(y_0 / k_ratio) elif k_ratio > 1: # need to find a lowerbound. We could use a cubic relation, but for now we just set it to 0. lowerbound = 0 - else: + else: return y_0 # means x_f = x_0 - k_calculator = lambda y_est: h(x_f, y_est, w) max_iteration_count = 100 - return binary_search(lowerbound, upperbound, k_calculator, k, err_tolerance) + return binary_search(lowerbound, upperbound, k_calculator, target_k, err_tolerance) def binary_search(lowerbound, upperbound, approximation_fn, target, max_iteration_count, err_tolerance): iter_count = 0 @@ -168,23 +229,34 @@ def binary_search(lowerbound, upperbound, approximation_fn, target, max_iteratio upperbound = cur_y_guess else if cur_k_guess < target: lowerbound = cur_y_guess - + if iter_count == max_iteration_count: return Error("max iteration count reached") return cur_y_guess ``` -As we changed API slightly, to have this "y_0" guess, we use the following as `solve_y` pseudocode here on out: -```python -# solve_cfmm returns y_f s.t. CFMM_eq(x_f, y_f, w) = k -# for the no-v variant of CFMM_eq -def solve_y(x_0, y_0, w, in_amt): - x_f = x_0 + in_amt - k = CFMM_eq(x_0, y_0, w) - err_tolerance = {"within .0001%"} # TODO: Detail what we choose / how we reason about choice - return iterative_search(x_f, y_0, w, k, err_tolerance): -``` +##### Setting the error tolerance + +What remains is setting the error tolerance. We need two properties: + +- The returned value to be within some correctness threshold of the true value +- The returned value to be rounded correctly (always ending with the user having fewer funds to avoid pool drain attacks). Mitigated by swap fees for normal swaps, but needed for 0-fee to be safe. + +The error tolerance we set is defined in terms of error in `k`, which itself implies some error in `y`. +An error of `e_k` in `k`, implies an error `e_y` in `y` that is less than `e_k`. We prove this [here](#err_proof) (and show that `e_y` is actually much less than the error in `e_k`, but for simplicity ignore this fact). We want `y` to be within a factor of `10^(-12)` of its true value. +To ensure the returned value is always rounded correctly, we define the rounding behavior expected. + +- If `x_in` is positive, then we take `y_out` units of `y` out of the pool. `y_out` should be rounded down. Note that `y_f < y_0` here. Therefore to round `y_out = y_0 - y_f` down, given fixed `y_0`, we want to round `y_f` up. +- If `x_in` is negative, then `y_out` is also negative. The reason is that this is called in CalcInAmtGivenOut, so confusingly `x_in` is the known amount out, as a negative quantity. `y_out` is negative as well, to express that we get that many tokens out. (Since negative, `-y_out` is how many we add into the pool). We want `y_out` to be a larger negative, which means we want to round it down. Note that `y_f > y_0` here. Therefore `y_out = y_0 - y_f` is more negative, the higher `y_f` is. Thus we want to round `y_f` up. + +And therefore we round up in both cases. + +##### Further optimization + +- The astute observer may notice that the equation we are solving in $\text{solve cfmm}$ is actually a cubic polynomial in $y$, with an always-positive derivative. +We should then be able to use newton's root finding algorithm to solve for the solution with quadratic convergence. +We do not pursue this today, due to other engineering tradeoffs, and insufficient analysis being done. #### Using this in swap methods @@ -205,6 +277,7 @@ The amount of tokens that we treat as going into the "0-swap fee" pool we define Then we simply call `solve_y` with the input reserves, and `amm_in`. + ```python def CalcOutAmountGivenExactAmountIn(pool, in_coin, out_denom, swap_fee): in_reserve, out_reserve, rem_reserves = pool.ScaledLiquidity(in_coin, out_denom, RoundingMode.RoundDown) @@ -218,6 +291,7 @@ def CalcOutAmountGivenExactAmountIn(pool, in_coin, out_denom, swap_fee): ##### SwapExactAmountOut + When we scale liquidity, we round down, as lower reserves -> higher slippage. Similarly when we scale the exact token out, we round up to increase required token in. @@ -225,8 +299,8 @@ We model the `solve_y` call as we are doing a known change to the `out_reserve`, To handle the swapfee, we apply the swapfee on the resultant needed input amount. We do this by having `token_in = amm_in / (1 - swapfee)`. - + ```python def CalcInAmountGivenExactAmountOut(pool, out_coin, in_denom, swap_fee): in_reserve, out_reserve, rem_reserves = pool.ScaledLiquidity(in_denom, out_coin, RoundingMode.RoundDown) @@ -244,6 +318,57 @@ We see correctness of the swap fee, by imagining what happens if we took this re {Something we have to be careful of is precision handling, notes on why and how we deal with it.} + + +#### Proof that |e_y| < 100|e_k| + + + +The function $f(y_{out}) = -y_{out}^3 + 3 y_0 y_{out}^2 - (x_f^2 + w + 3y_0^2)y_{out}$ is monotonically increasing over the reals. +You can prove this, by seeing that its [derivative's](https://www.wolframalpha.com/input?i=d%2Fdx+-x%5E3+%2B+3a+x%5E2+-+%28b+%2B+3a%5E2%29+x+) 0 values are both imaginary, and therefore has no local minima or maxima in the reals. +Therefore, there exists exactly one real $y_{out}$ s.t. $f(y_{out}) = k$. +Via binary search, we solve for a value $y_{out}^{\*}$ such that $\left|\frac{ k - k^{\*} }{k}\right| < e_k$, where $k^{\*} = f(y_{out}^{\*})$. We seek to then derive bounds on $e_y = \left|\frac{ y_{out} - y_{out}^{\*} }{y_{out}}\right|$ in relation to $e_k$. + +**Theorem**: $e_y < 100 e_k$ as long as $|y_{out}| <= .9y_0$. +**Informal**, we claim that for $.9y_0 < |y_{out}| < y_0$, `e_y` is "close" to `e_k` under expected parameterizations. And for $y_{out}$ significantly less than $.9y_0$, the error bounds are much better. (Often better than $e_k$) + + +Let $y_{out} - y_{out}^* = a_y$, we are going to assume that $a_y << y_{out}$, and will justify this later. But due to this, we treat $a_y^c = 0$ for $c > 1$. This then implies that $y_{out}^2 - y_{out}^{*2} = y_{out}^2 - (y_{out} - a_y)^2 \approx 2y_{out}a_y$, and similarly $y_{out}^3 - y_{out}^{*3} \approx 3y_{out}^2 a_y$ + +Now we are prepared to start bounding this. +$$k - k^{\*} = -(y_{out}^3 - y_{out}^{3\*}) + 3y_0(y_{out}^2 - y_{out}^{2\*}) - (x_f^2 + w + 3y_0^2)(y_{out} - y_{out}^{\*})$$ + +$$k - k^{\*} \approx -(3y_{out}^2 a_y) + 3y_0 (2y_{out}a_y) - (x_f^2 + w + 3y_0^2)a_y$$ + +$$k - k^{\*} \approx a_y(-3y_{out}^2 + 6y_0y_{out} - (x_f^2 + w + 3y_0^2))$$ + +Rewrite $k = y_{out}(-y_{out}^2 + 3y_0y_{out} - (x_f^2 + w + 3y_0^2))$ + +$$e_k > \left|\frac{ k - k^{\*} }{k}\right| = \left|\frac{a_y}{y_{out}} \frac{(-3y_{out}^2 + 6y_0y_{out} - (x_f^2 + w + 3y_0^2))}{(-y_{out}^2 + 3y_0y_{out} - (x_f^2 + w + 3y_0^2))}\right|$$ + +Notice that $\left|\frac{a_y}{y_{out}}\right| = e_y$! Therefore + +$$e_k > e_y\left|\frac{(-3y_{out}^2 + 6y_0y_{out} - (x_f^2 + w + 3y_0^2))}{(-y_{out}^2 + 3y_0y_{out} - (x_f^2 + w + 3y_0^2))}\right|$$ + +We bound the right hand side, with the assistance of wolfram alpha. Let $a = y_{out}, b = y_0, c = x_f^2 + w$. Then we see from [wolfram alpha here](https://www.wolframalpha.com/input?i=%7C%28-3a%5E2+%2B+6ab+-+%28c+%2B+3b%5E2%29%29+%2F+%28-a%5E2+%2B+3ab+-+%28c+%2B+3b%5E2%29%29+%7C+%3E+.01), that this right hand expression is provably greater than `.01` if some set of decisions hold. We describe the solution set that satisfies our use case here: + +* When $y_{out} > 0$ + * Use solution set: $a > 0, b > \frac{2}{3} a, c > \frac{1}{99} (-299a^2 + 597ab - 297b^2)$ + * $a > 0$ by definition. + * $b > \frac{2}{3} a$, as thats equivalent to $y_0 > \frac{2}{3} y_{out}$. We already assume that $y_0 >= y_{out}$. + * Set $y_{out} = .9y_0$, per our theorem assumption. So $b = .9a$. Take $c = x^2 + w = 0$. Then [we can show that](https://www.wolframalpha.com/input?i=0+%3E+-299a%5E2+%2B+597ab+-+297b%5E2%2C+when+b%3D+.90a) $(-299a^2 + 597ab - 297b^2) < 0$ for all $a$. This completes the constraint set. +* When $y_{out} < 0$ + * Use solution set: $a < 0, b > \frac{2}{3} a, c > -a^2 + 3ab - 3b^2$ + * $a < 0$ by definition. + * $b > \frac{2}{3} a$, as $y_0$ is positive. + * $c > 0$ is by definition, so we just need to bound when $-a^2 + 3ab - 3b^2 < 0$. This is always the case as long as one of $a$ or $b$ is non-zero, per [here](https://www.wolframalpha.com/input?i=-a%5E2+%2B+3ab+-+3b%5E2+%3C+0). + +Tieing this all together, we have that $e_k > .01e_y$. Therefore $e_y < 100 e_k$, satisfying our theoerem! + +To show the informal claims, the constraint that led to this 100x error blowup was trying to accomodate high $y_{out}$. When $y_{out}$ is smaller, the error is far lower. (Often to the case that $e_y < e_k$, you can convince yourself of this by setting the ratio to being greater than 1 in wolfram alpha) When $y_{out}$ is bigger than $.9y_0$, we can rely on x_f^2 + w being much larger to lower this error. In these cases, the $x_f$ term must be large relative to $y_0$, which would yield a far better error bound. + +TODO: Justify a_y << y_out. (This should be easy, assume its not, that leads to e_k being high. Ratio test probably easiest. Maybe just add a sentence to that effect) + ### Spot Price Spot price for an AMM pool is the derivative of its `CalculateOutAmountGivenIn` equation. @@ -269,25 +394,48 @@ Both of these methods can be implemented via generic AMM techniques. #### JoinPool -The JoinPool API only supports JoinPoolNoSwap if +The JoinPool API only supports JoinPoolNoSwap if #### Join pool single asset in -Couple ways to define JoinPool Exit Pool relation +There are a couple ways to define `JoinPoolSingleAssetIn`. The simplest way is to define it from its intended relation from the CFMM, with Exit pool. We describe this below under the zero swap fee case. -## Code structure +Let `pool_{L, S}` represent a pool with liquidity `L`, and `S` total LP shares. +If we call `pool_{L, S}.JoinPoolSingleAssetIn(tokensIn) -> (N, pool_{L + tokensIn, S + N})`, or in others we get out `N` new LP shares, and a pool with with tokensIn added to liquidity. +It must then be the case that `pool_{L+tokensIn, S+N}.ExitPool(N) -> (tokensExited, pool_{L + tokensIn - tokensExited, S})`. +Then if we swap all of `tokensExited` back to tokensIn, under 0 swap fee, we should get back to `pool_{L, S}` under the CFMM property. -## Testing strategy +In other words, if we single asset join pool, and then exit pool, we should return back to the same CFMM `k` value we started with. Then if we swap back to go entirely back into our input asset, we should have exactly many tokens as we started with, under 0 swap fee. -* Simulator integrations: - * Pool creation - * JoinPool + ExitPool gives a token amount out that is lte input - * SingleTokenIn + ExitPool + Swap to base token gives a token amount that is less than input - * CFMM k adjusting in the correct direction after every action -* Fuzz test binary search algorithm, to see that it still works correctly across wide scale ranges -* Fuzz test approximate equality of iterative approximation swap algorithm and direct equation swap. -* Flow testing the entire stableswap scaling factor update process +We can solve this relation with a binary search over the amount of LP shares to give! -## Extensions +Thus we are left with how to account swap fee. We currently account for swap fee, by considering the asset ratio in the pool. If post scaling factors, the pool liquidity is say 60:20:20, where 60 is the asset were bringing in, then we consider "only (1 - 60%) = 40%" of the input as getting swapped. So we charge the swap fee on 40% of our single asset join in input. So the pseudocode for this is roughly: + +```python +def JoinPoolSingleAssetIn(pool, tokenIn): + swapFeeApplicableFraction = 1 - (pool.ScaledLiquidityOf(tokenIn.Denom) / pool.SumOfAllScaledLiquidity()) + effectiveSwapFee = pool.SwapFee * swapFeeApplicableFraction + effectiveTokenIn = RoundDown(tokenIn * (1 - effectiveSwapFee)) + return BinarySearchSingleJoinLpShares(pool, effectiveTokenIn) +``` + +We leave the rounding mode for the scaling factor division unspecified. +This is because its expected to be tiny (as the denominator is larger than the numerator, and we are operating in BigDec), +and it should be dominated by the later step of rounding down. + +## Code structure + +## Testing strategy -* The astute observer may notice that the equation we are solving in $\text{solve cfmm}$ is actually a cubic polynomial in $y$, with an always-positive derivative. We should then be able to use newton's root finding algorithm to solve for the solution with quadratic convergence. We do not pursue this today, due to other engineering tradeoffs, and insufficient analysis being done. +- Unit tests for every pool interface method +- Msg tests for custom messages + - CreatePool + - SetScalingFactors +- Simulator integrations: + - Pool creation + - JoinPool + ExitPool gives a token amount out that is lte input + - SingleTokenIn + ExitPool + Swap to base token gives a token amount that is less than input + - CFMM k adjusting in the correct direction after every action +- Fuzz test binary search algorithm, to see that it still works correctly across wide scale ranges +- Fuzz test approximate equality of iterative approximation swap algorithm and direct equation swap. +- Flow testing the entire stableswap scaling factor update process diff --git a/x/gamm/pool-models/stableswap/amm.go b/x/gamm/pool-models/stableswap/amm.go index 9f2ffc83fbf..9574db6fc8d 100644 --- a/x/gamm/pool-models/stableswap/amm.go +++ b/x/gamm/pool-models/stableswap/amm.go @@ -5,10 +5,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmomath" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/cfmm_common" - types "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/cfmm_common" + types "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var ( @@ -32,23 +32,36 @@ func cfmmConstant(xReserve, yReserve osmomath.BigDec) osmomath.BigDec { return xy.Mul(x2.Add(y2)) } -// multi-asset CFMM is xyv(x^2 + y^2 + w) = k, -// where u is the product of the reserves of assets -// outside of x and y (e.g. u = wz), and v is the sum -// of their squares (e.g. v = w^2 + z^2). -// When u = 1 and v = 0, this is equivalent to solidly's CFMM -// {TODO: Update this comment} -func cfmmConstantMultiNoV(xReserve, yReserve, vSumSquares osmomath.BigDec) osmomath.BigDec { - if !xReserve.IsPositive() || !yReserve.IsPositive() || vSumSquares.IsNegative() { +// Simplified multi-asset CFMM is xy(x^2 + y^2 + w) = k, +// where w is the sum of the squares of the +// reserve assets (e.g. w = m^2 + n^2). +// When w = 0, this is equivalent to solidly's CFMM +// We use this version for calculations since the u +// term in the full CFMM is constant. +func cfmmConstantMultiNoV(xReserve, yReserve, wSumSquares osmomath.BigDec) osmomath.BigDec { + if !xReserve.IsPositive() || !yReserve.IsPositive() || wSumSquares.IsNegative() { + panic("invalid input: reserves must be positive") + } + + return cfmmConstantMultiNoVY(xReserve, yReserve, wSumSquares).Mul(yReserve) +} + +// returns x(x^2 + y^2 + w) = k +// For use in comparing values with the same y +func cfmmConstantMultiNoVY(xReserve, yReserve, wSumSquares osmomath.BigDec) osmomath.BigDec { + if !xReserve.IsPositive() || !yReserve.IsPositive() || wSumSquares.IsNegative() { panic("invalid input: reserves must be positive") } - xy := xReserve.Mul(yReserve) x2 := xReserve.Mul(xReserve) y2 := yReserve.Mul(yReserve) - return xy.Mul(x2.Add(y2).Add(vSumSquares)) + return xReserve.Mul(x2.Add(y2).Add(wSumSquares)) } +// full multi-asset CFMM is xyu(x^2 + y^2 + w) = k, +// where u is the product of asset reserves (e.g. u = m * n) +// and w is the sum of the squares of their squares (e.g. w = m^2 + n^2). +// When u = 1 and w = 0, this is equivalent to solidly's CFMM func cfmmConstantMulti(xReserve, yReserve, u, v osmomath.BigDec) osmomath.BigDec { if !u.IsPositive() { panic("invalid input: reserves must be positive") @@ -56,13 +69,12 @@ func cfmmConstantMulti(xReserve, yReserve, u, v osmomath.BigDec) osmomath.BigDec return cfmmConstantMultiNoV(xReserve, yReserve, v).Mul(u) } -// solidly CFMM is xy(x^2 + y^2) = k, and our multi-asset CFMM is xyz(x^2 + y^2 + w) = k +// Solidly's CFMM is xy(x^2 + y^2) = k, and our multi-asset CFMM is xyz(x^2 + y^2 + w) = k // So we want to solve for a given addition of `b` units of y into the pool, // how many units `a` of x do we get out. -// So we solve the following expression for `a` in two-asset pools: -// xy(x^2 + y^2) = (x - a)(y + b)((x - a)^2 + (y + b)^2) -// and the following expression for `a` in multi-asset pools: -// xyz(x^2 + y^2 + w) = (x - a)(y + b)z((x - a)^2 + (y + b)^2 + w) +// So we solve the following expression for `a`: +// xy(x^2 + y^2 + w) = (x - a)(y + b)((x - a)^2 + (y + b)^2 + w) +// with w set to 0 for 2 asset pools func solveCfmm(xReserve, yReserve osmomath.BigDec, remReserves []osmomath.BigDec, yIn osmomath.BigDec) osmomath.BigDec { wSumSquares := osmomath.ZeroDec() for _, assetReserve := range remReserves { @@ -236,60 +248,116 @@ var ( k_threshold = osmomath.NewDecWithPrec(1, 1) // Correct within a factor of 1 * 10^{-1} ) -// solveCFMMBinarySearch searches the correct dx using binary search over constant K. -func solveCFMMBinarySearchMulti(xReserve, yReserve, wSumSquares, yIn osmomath.BigDec) osmomath.BigDec { - if !xReserve.IsPositive() || !yReserve.IsPositive() || wSumSquares.IsNegative() { - panic("invalid input: reserves and input must be positive") - } else if yIn.Abs().GTE(yReserve) { - panic("cannot input more than pool reserves") +// $$k_{target} = \frac{x_0 y_0 (x_0^2 + y_0^2 + w)}{y_f} - (x_0 (y_f^2 + w) + x_0^3)$$ +func targetKCalculator(x0, y0, w, yf osmomath.BigDec) osmomath.BigDec { + // cfmmNoV(x0, y0, w) = x_0 y_0 (x_0^2 + y_0^2 + w) + startK := cfmmConstantMultiNoV(x0, y0, w) + // remove extra yf term + yfRemoved := startK.Quo(yf) + // removed constant term from expression + // namely - (x_0 (y_f^2 + w) + x_0^3) = x_0(y_f^2 + w + x_0^2) + // innerTerm = y_f^2 + w + x_0^2 + innerTerm := yf.Mul(yf).Add(w).Add((x0.Mul(x0))) + constantTerm := innerTerm.Mul(x0) + return yfRemoved.Sub(constantTerm) +} + +// $$k_{iter}(x_f) = -x_{out}^3 + 3 x_0 x_{out}^2 - (y_f^2 + w + 3x_0^2)x_{out}$$ +// where x_out = x_0 - x_f +func iterKCalculator(x0, w, yf osmomath.BigDec) func(osmomath.BigDec) (osmomath.BigDec, error) { + // compute coefficients first + cubicCoeff := osmomath.OneDec().Neg() + quadraticCoeff := x0.MulInt64(3) + linearCoeff := quadraticCoeff.Mul(x0).Add(w).Add(yf.Mul(yf)).Neg() + return func(xf osmomath.BigDec) (osmomath.BigDec, error) { + xOut := x0.Sub(xf) + // horners method + // ax^3 + bx^2 + cx = x(c + x(b + ax)) + res := cubicCoeff.Mul(xOut) + res = res.Add(quadraticCoeff).Mul(xOut) + res = res.Add(linearCoeff).Mul(xOut) + return res, nil } - yFinal := yReserve.Add(yIn) - xLowEst, xHighEst := xReserve, xReserve +} + +var ( + zero = osmomath.ZeroDec() + one = osmomath.OneDec() +) + +func deriveUpperLowerXFinalReserveBounds(xReserve, yReserve, wSumSquares, yFinal osmomath.BigDec) ( + xFinalLowerbound, xFinalUpperbound osmomath.BigDec, +) { + xFinalLowerbound, xFinalUpperbound = xReserve, xReserve + k0 := cfmmConstantMultiNoV(xReserve, yFinal, wSumSquares) k := cfmmConstantMultiNoV(xReserve, yReserve, wSumSquares) + // fmt.Println(k0, k) + if k0.Equal(zero) || k.Equal(zero) { + panic("k should never be zero") + } kRatio := k0.Quo(k) - - if kRatio.LT(osmomath.OneDec()) { + if kRatio.LT(one) { // k_0 < k. Need to find an upperbound. Worst case assume a linear relationship, gives an upperbound // TODO: In the future, we can derive better bounds via reasoning about coefficients in the cubic // These are quite close when we are in the "stable" part of the curve though. - xHighEst = xReserve.Quo(kRatio).Ceil() - } else if kRatio.GT(osmomath.OneDec()) { + xFinalUpperbound = xReserve.Quo(kRatio).Ceil() + } else if kRatio.GT(one) { // need to find a lowerbound. We could use a cubic relation, but for now we just set it to 0. - xLowEst = osmomath.ZeroDec() - } else { - // k remains unchanged, so xOut = 0 - return osmomath.ZeroDec() + xFinalLowerbound = osmomath.ZeroDec() } + // else + // k remains unchanged. + // So we keep bounds equal to each other + return xFinalLowerbound, xFinalUpperbound +} - maxIterations := 256 - errTolerance := osmoutils.ErrTolerance{AdditiveTolerance: sdk.OneInt(), MultiplicativeTolerance: sdk.Dec{}} - - // create single-input CFMM to pass into binary search - computeFromEst := func(xEst osmomath.BigDec) (osmomath.BigDec, error) { - return cfmmConstantMultiNoV(xEst, yFinal, wSumSquares), nil +// solveCFMMBinarySearch searches the correct dx using binary search over constant K. +func solveCFMMBinarySearchMulti(xReserve, yReserve, wSumSquares, yIn osmomath.BigDec) osmomath.BigDec { + if !xReserve.IsPositive() || !yReserve.IsPositive() || wSumSquares.IsNegative() { + panic("invalid input: reserves and input must be positive") + } else if yIn.Abs().GTE(yReserve) { + panic("cannot input more than pool reserves") } + // fmt.Printf("solve cfmm xreserve %v, yreserve %v, w %v, yin %v\n", xReserve, yReserve, wSumSquares, yIn) + yFinal := yReserve.Add(yIn) + xLowEst, xHighEst := deriveUpperLowerXFinalReserveBounds(xReserve, yReserve, wSumSquares, yFinal) + targetK := targetKCalculator(xReserve, yReserve, wSumSquares, yFinal) + iterKCalc := iterKCalculator(xReserve, wSumSquares, yFinal) + maxIterations := 256 - xEst, err := osmoutils.BinarySearchBigDec(computeFromEst, xLowEst, xHighEst, k, errTolerance, maxIterations) + // we use a geometric error tolerance that guarantees approximately 10^-12 precision on outputs + errTolerance := osmoutils.ErrTolerance{AdditiveTolerance: sdk.Int{}, MultiplicativeTolerance: sdk.NewDecWithPrec(1, 12)} + + // if yIn is positive, we want to under-estimate the amount of xOut. + // This means, we want x_out to be rounded down, as x_out = x_init - x_final, for x_init > x_final. + // Thus we round-up x_final, to make it greater (and therefore ) x_out smaller. + // If yIn is negative, the amount of xOut will also be negative (representing that we must add tokens into the pool) + // this means x_out = x_init - x_final, for x_init < x_final. + // we want to over_estimate |x_out|, which means rounding x_out down as its a negative quantity. + // This means rounding x_final up, to give us a larger negative. + // Therefore we always round up. + roundingDirection := osmomath.RoundUp + errTolerance.RoundingDir = roundingDirection + + xEst, err := osmoutils.BinarySearchBigDec(iterKCalc, xLowEst, xHighEst, targetK, errTolerance, maxIterations) if err != nil { panic(err) } xOut := xReserve.Sub(xEst) - if xOut.GTE(xReserve) { + // fmt.Printf("xOut %v\n", xOut) + + // We check the absolute value of the output against the xReserve amount to ensure that: + // 1. Swaps cannot more than double the input token's pool supply + // 2. Swaps cannot output more than the output token's pool supply + if xOut.Abs().GTE(xReserve) { panic("invalid output: greater than full pool reserves") } return xOut } -func (p Pool) spotPrice(baseDenom, quoteDenom string) (sdk.Dec, error) { - roundMode := osmomath.RoundBankers // TODO: - reserves, err := p.scaledSortedPoolReserves(baseDenom, quoteDenom, roundMode) - if err != nil { - return sdk.Dec{}, err - } - baseReserve, quoteReserve, remReserves := reserves[0], reserves[1], reserves[2:] - // y = baseAsset, x = quoteAsset +func (p Pool) spotPrice(baseDenom, quoteDenom string) (spotPrice sdk.Dec, err error) { // Define f_{y -> x}(a) as the function that outputs the amount of tokens X you'd get by // trading "a" units of Y against the pool, assuming 0 swap fee, at the current liquidity. // The spot price of the pool is then lim a -> 0, f_{y -> x}(a) / a @@ -303,17 +371,19 @@ func (p Pool) spotPrice(baseDenom, quoteDenom string) (sdk.Dec, error) { // We arbitrarily choose a = 1, and anticipate that this is a small value at the scale of // xReserve & yReserve. - a := osmomath.OneDec() - // no need to divide by a, since a = 1. - bigDec := solveCfmm(baseReserve, quoteReserve, remReserves, a) - return bigDec.SDKDec(), nil + a := sdk.OneInt() + + // We swap quoteDenom and baseDenom intentionally, due to the odd issue needed for balancer v1 query compat + res, err := p.calcOutAmtGivenIn(sdk.NewCoin(quoteDenom, a), baseDenom, sdk.ZeroDec()) + // fmt.Println("spot price res", res) + return res, err } func oneMinus(swapFee sdk.Dec) osmomath.BigDec { return osmomath.BigDecFromSDKDec(sdk.OneDec().Sub(swapFee)) } -// returns outAmt as a decimal +// calcOutAmtGivenIn calculate amount of specified denom to output from a pool in sdk.Dec given the input `tokenIn` func (p Pool) calcOutAmtGivenIn(tokenIn sdk.Coin, tokenOutDenom string, swapFee sdk.Dec) (sdk.Dec, error) { // round liquidity down, and round token in down reserves, err := p.scaledSortedPoolReserves(tokenIn.Denom, tokenOutDenom, osmomath.RoundDown) @@ -329,12 +399,14 @@ func (p Pool) calcOutAmtGivenIn(tokenIn sdk.Coin, tokenOutDenom string, swapFee // amm input = tokenIn * (1 - swap fee) ammIn := tokenInDec.Mul(oneMinus(swapFee)) // We are solving for the amount of token out, hence x = tokenOutSupply, y = tokenInSupply + // fmt.Printf("outSupply %s, inSupply %s, remReservs %s, ammIn %s\n ", tokenOutSupply, tokenInSupply, remReserves, ammIn) cfmmOut := solveCfmm(tokenOutSupply, tokenInSupply, remReserves, ammIn) + // fmt.Println("cfmmout ", cfmmOut) outAmt := p.getDescaledPoolAmt(tokenOutDenom, cfmmOut) return outAmt, nil } -// returns inAmt as a decimal +// calcInAmtGivenOut calculates exact input amount given the desired output and return as a decimal func (p *Pool) calcInAmtGivenOut(tokenOut sdk.Coin, tokenInDenom string, swapFee sdk.Dec) (sdk.Dec, error) { // round liquidity down, and round token out up reserves, err := p.scaledSortedPoolReserves(tokenInDenom, tokenOut.Denom, osmomath.RoundDown) @@ -353,30 +425,67 @@ func (p *Pool) calcInAmtGivenOut(tokenOut sdk.Coin, tokenInDenom string, swapFee // returned cfmmIn is negative, representing we need to add this many tokens to pool. // We invert that negative here. cfmmIn = cfmmIn.Neg() - // handle swap fee - inAmt := cfmmIn.QuoRoundUp(oneMinus(swapFee)) // divide by (1 - swapfee) to force a corresponding increase in input asset + inAmt := cfmmIn.QuoRoundUp(oneMinus(swapFee)) inCoinAmt := p.getDescaledPoolAmt(tokenInDenom, inAmt) return inCoinAmt, nil } +// calcSingleAssetJoinShares calculates the number of LP shares that +// should be granted given the passed in single-token input (non-mutative) func (p *Pool) calcSingleAssetJoinShares(tokenIn sdk.Coin, swapFee sdk.Dec) (sdk.Int, error) { poolWithAddedLiquidityAndShares := func(newLiquidity sdk.Coin, newShares sdk.Int) types.PoolI { paCopy := p.Copy() - paCopy.updatePoolForJoin(sdk.NewCoins(tokenIn), newShares) + paCopy.updatePoolForJoin(sdk.NewCoins(newLiquidity), newShares) return &paCopy } - // We apply the swap fee by multiplying by (1 - swapFee) and then truncating to int - oneMinusSwapFee := sdk.OneDec().Sub(swapFee) + // We apply the swap fee by multiplying by: + // 1) getting what % of the input the swap fee should apply to + // 2) multiplying that by swap fee + // 3) oneMinusSwapFee := (1 - swap_fee * swap_fee_applicable_percent) + // 4) Multiplying token in by one minus swap fee. + swapFeeApplicableRatio, err := p.singleAssetJoinSwapFeeRatio(tokenIn.Denom) + if err != nil { + return sdk.Int{}, err + } + oneMinusSwapFee := sdk.OneDec().Sub(swapFee.Mul(swapFeeApplicableRatio)) tokenInAmtAfterFee := tokenIn.Amount.ToDec().Mul(oneMinusSwapFee).TruncateInt() return cfmm_common.BinarySearchSingleAssetJoin(p, sdk.NewCoin(tokenIn.Denom, tokenInAmtAfterFee), poolWithAddedLiquidityAndShares) } -// We can mutate pa here -// TODO: some day switch this to a COW wrapped pa, for better perf -func (p *Pool) joinPoolSharesInternal(ctx sdk.Context, tokensIn sdk.Coins, swapFee sdk.Dec) (numShares sdk.Int, newLiquidity sdk.Coins, err error) { +// returns the ratio of input asset liquidity, to total liquidity in pool, post-scaling. +// We use this as the portion of input liquidity to apply a swap fee too, for single asset joins. +// So if a pool is currently comprised of 80% of asset A, and 20% of asset B (post-scaling), +// and we input asset A, this function will return 20%. +// Note that this will over-estimate swap fee for single asset joins slightly, +// as in the swapping process into the pool, the A to B ratio would decrease the relative supply of B. +func (p *Pool) singleAssetJoinSwapFeeRatio(tokenInDenom string) (sdk.Dec, error) { + // get a second denom in pool + tokenOut := p.PoolLiquidity[0] + if tokenOut.Denom == tokenInDenom { + tokenOut = p.PoolLiquidity[1] + } + // We round bankers scaled liquidity, since we care about the ratio of liquidity. + scaledLiquidity, err := p.scaledSortedPoolReserves(tokenInDenom, tokenOut.Denom, osmomath.RoundDown) + if err != nil { + return sdk.Dec{}, err + } + + totalLiquidityDenominator := osmomath.ZeroDec() + for _, amount := range scaledLiquidity { + totalLiquidityDenominator = totalLiquidityDenominator.Add(amount) + } + ratioOfInputAssetLiquidityToTotalLiquidity := scaledLiquidity[0].Quo(totalLiquidityDenominator) + // SDKDec() rounds down (as it truncates), therefore 1 - term is rounded up, as desired. + nonInternalAssetRatio := sdk.OneDec().Sub(ratioOfInputAssetLiquidityToTotalLiquidity.SDKDec()) + return nonInternalAssetRatio, nil +} + +// Route a pool join attempt to either a single-asset join or all-asset join (mutates pool state) +// Eventually, we intend to switch this to a COW wrapped pa for better performance +func (p *Pool) joinPoolSharesInternal(ctx sdk.Context, tokensIn sdk.Coins, swapFee sdk.Dec) (numShares sdk.Int, tokensJoined sdk.Coins, err error) { if !tokensIn.DenomsSubsetOf(p.GetTotalPoolLiquidity(ctx)) { return sdk.ZeroInt(), sdk.NewCoins(), errors.New("attempted joining pool with assets that do not exist in pool") } @@ -386,15 +495,15 @@ func (p *Pool) joinPoolSharesInternal(ctx sdk.Context, tokensIn sdk.Coins, swapF return sdk.ZeroInt(), sdk.NewCoins(), err } - newLiquidity = tokensIn + tokensJoined = tokensIn - p.updatePoolForJoin(newLiquidity, numShares) + p.updatePoolForJoin(tokensJoined, numShares) - if err = validatePoolAssets(p.PoolLiquidity, p.ScalingFactor); err != nil { + if err = validatePoolLiquidity(p.PoolLiquidity, p.ScalingFactors); err != nil { return sdk.ZeroInt(), sdk.NewCoins(), err } - return numShares, newLiquidity, err + return numShares, tokensJoined, nil } else if len(tokensIn) != p.NumAssets() { return sdk.ZeroInt(), sdk.NewCoins(), errors.New( "stableswap pool only supports LP'ing with one asset, or all assets in pool") @@ -407,9 +516,9 @@ func (p *Pool) joinPoolSharesInternal(ctx sdk.Context, tokensIn sdk.Coins, swapF } p.updatePoolForJoin(tokensIn.Sub(remCoins), numShares) - tokensJoined := tokensIn.Sub(remCoins) + tokensJoined = tokensIn.Sub(remCoins) - if err = validatePoolAssets(p.PoolLiquidity, p.ScalingFactor); err != nil { + if err = validatePoolLiquidity(p.PoolLiquidity, p.ScalingFactors); err != nil { return sdk.ZeroInt(), sdk.NewCoins(), err } diff --git a/x/gamm/pool-models/stableswap/amm_bench_test.go b/x/gamm/pool-models/stableswap/amm_bench_test.go index 4a779a79238..8c5dfc88322 100644 --- a/x/gamm/pool-models/stableswap/amm_bench_test.go +++ b/x/gamm/pool-models/stableswap/amm_bench_test.go @@ -4,7 +4,7 @@ import ( "math/rand" "testing" - "github.com/osmosis-labs/osmosis/v12/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmomath" ) func BenchmarkCFMM(b *testing.B) { diff --git a/x/gamm/pool-models/stableswap/amm_test.go b/x/gamm/pool-models/stableswap/amm_test.go index 3e391bea9d2..304256e6520 100644 --- a/x/gamm/pool-models/stableswap/amm_test.go +++ b/x/gamm/pool-models/stableswap/amm_test.go @@ -3,16 +3,20 @@ package stableswap import ( "fmt" "math/big" + "math/rand" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/osmomath" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/cfmm_common" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/test_helpers" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + sdkrand "github.com/osmosis-labs/osmosis/v13/simulation/simtypes/random" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/cfmm_common" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/test_helpers" + types "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // CFMMTestCase defines a testcase for stableswap pools @@ -523,11 +527,9 @@ func TestCFMMInvariantMultiAssetsBinarySearch(t *testing.T) { func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_InverseRelationship() { type testcase struct { denomOut string - initialPoolOut int64 initialCalcOut int64 - denomIn string - initialPoolIn int64 + denomIn string poolLiquidity sdk.Coins scalingFactors []uint64 @@ -677,26 +679,44 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers scalingFactors: []uint64{100, 76, 33}, }, } + // create randomized test cases + r := rand.New(rand.NewSource(12345)) + coinMax := sdk.NewInt(10).ToDec().Power(30).TruncateInt() + for c := 2; c < 5; c++ { + for i := 0; i < 10; i++ { + coins := sdk.NewCoins() + scalingFactors := []uint64{} + for j := 0; j < c; j++ { + coins = coins.Add(sdkrand.RandExponentialCoin(r, sdk.NewCoin(fmt.Sprintf("token%d", j), coinMax))) + sf := sdkrand.RandIntBetween(r, 1, 1<<60) + scalingFactors = append(scalingFactors, uint64(sf)) + } + initialCalcOut := sdkrand.RandIntBetween(r, 1, 1<<60) + testcases[fmt.Sprintf("rand_case_%d_coins_%d", c, i)] = testcase{ + denomIn: coins[0].Denom, + denomOut: coins[1].Denom, + initialCalcOut: int64(initialCalcOut), + poolLiquidity: coins, + scalingFactors: scalingFactors, + } + } + } swapFeeCases := []string{"0", "0.001", "0.1", "0.5", "0.99"} - getTestCaseName := func(tc testcase, swapFeeCase string) string { - return fmt.Sprintf("tokenOutInitial: %d, tokenInInitial: %d, initialOut: %d, swapFee: %s", - tc.initialPoolOut, - tc.initialPoolIn, + getTestCaseName := func(name string, tc testcase, swapFeeCase string) string { + return fmt.Sprintf("%s: initialOut: %d, swapFee: %s", + name, tc.initialCalcOut, swapFeeCase, ) } - for _, tc := range testcases { + for name, tc := range testcases { for _, swapFee := range swapFeeCases { - suite.Run(getTestCaseName(tc, swapFee), func() { + suite.Run(getTestCaseName(name, tc, swapFee), func() { ctx := suite.CreateTestContext() - poolLiquidityIn := sdk.NewInt64Coin(tc.denomIn, tc.initialPoolIn) - poolLiquidityOut := sdk.NewInt64Coin(tc.denomOut, tc.initialPoolOut) - swapFeeDec, err := sdk.NewDecFromStr(swapFee) suite.Require().NoError(err) @@ -706,12 +726,45 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers // TODO: add scaling factors into inverse relationship tests pool := createTestPool(suite.T(), tc.poolLiquidity, swapFeeDec, exitFeeDec, tc.scalingFactors) suite.Require().NotNil(pool) - test_helpers.TestCalculateAmountOutAndIn_InverseRelationship(suite.T(), ctx, pool, poolLiquidityIn.Denom, poolLiquidityOut.Denom, tc.initialCalcOut, swapFeeDec) + errTolerance := osmoutils.ErrTolerance{ + AdditiveTolerance: sdk.Int{}, MultiplicativeTolerance: sdk.NewDecWithPrec(1, 12)} + test_helpers.TestCalculateAmountOutAndIn_InverseRelationship(suite.T(), ctx, pool, tc.denomIn, tc.denomOut, tc.initialCalcOut, swapFeeDec, errTolerance) }) } } } +func (suite *StableSwapTestSuite) Test_StableSwap_Slippage_LiquidityRelation() { + type testcase struct { + initialLiquidity sdk.Coins + scalingFactors []uint64 + } + testcases := map[string]testcase{ + "1:1 pool, 1:1 SF": { + initialLiquidity: sdk.NewCoins(sdk.NewInt64Coin("bar", 10000), sdk.NewInt64Coin("foo", 10000)), + scalingFactors: []uint64{}, + }, + "10:1 pool, 1:1 SF": { + initialLiquidity: sdk.NewCoins(sdk.NewInt64Coin("bar", 100000), sdk.NewInt64Coin("foo", 10000)), + scalingFactors: []uint64{}, + }, + "10:1 pool, 3:2 SF": { + initialLiquidity: sdk.NewCoins(sdk.NewInt64Coin("bar", 100000), sdk.NewInt64Coin("foo", 10000)), + scalingFactors: []uint64{3, 2}, + }, + } + swapFeeCases := []string{"0", "0.001", "0.1", "0.5", "0.99"} + for name, tc := range testcases { + for _, swapFee := range swapFeeCases { + createPoolFn := func(ctx sdk.Context, liq sdk.Coins) types.PoolI { + return createTestPool(suite.T(), liq, sdk.MustNewDecFromStr(swapFee), sdk.ZeroDec(), tc.scalingFactors) + } + ctx := sdk.Context{} + test_helpers.TestSlippageRelationWithLiquidityIncrease(name, suite.T(), ctx, createPoolFn, tc.initialLiquidity) + } + } +} + func calcUReserve(remReserves []osmomath.BigDec) osmomath.BigDec { uReserve := osmomath.OneDec() for _, assetReserve := range remReserves { @@ -821,14 +874,14 @@ func TestCalcSingleAssetJoinShares(t *testing.T) { shares, err := p.calcSingleAssetJoinShares(tc.tokenIn, tc.swapFee) require.NoError(t, err, "test: %s", name) - p.updatePoolLiquidityForExit(sdk.Coins{tc.tokenIn}) + p.updatePoolForJoin(sdk.Coins{tc.tokenIn}, shares) exitTokens, err := p.ExitPool(ctx, shares, sdk.ZeroDec()) require.NoError(t, err, "test: %s", name) // since each asset swap can have up to sdk.OneInt() error, our expected error bound is 1*numAssets correctnessThreshold := sdk.OneInt().Mul(sdk.NewInt(int64(len(p.PoolLiquidity)))) - tokenOutAmount, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, exitTokens, tc.tokenIn.Denom) + tokenOutAmount, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, exitTokens, tc.tokenIn.Denom, sdk.ZeroDec()) require.True(t, tokenOutAmount.LTE(tc.tokenIn.Amount)) require.True(t, tc.expectedOut.Sub(tokenOutAmount).Abs().LTE(correctnessThreshold)) }) @@ -877,34 +930,34 @@ func TestJoinPoolSharesInternal(t *testing.T) { sdk.NewInt64Coin("bar", 1), ), poolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 10_000_000_000), - sdk.NewInt64Coin("bar", 10_000_000_000), + sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset), ), scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), expNumShare: sdk.ZeroInt(), expTokensJoined: sdk.Coins{}, expPoolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 10_000_000_000), - sdk.NewInt64Coin("bar", 10_000_000_000), + sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset), ), expectPass: false, }, "single-asset pool join exceeds hits max scaled asset amount": { tokensIn: sdk.NewCoins( - sdk.NewInt64Coin("foo", 1), + sdk.NewInt64Coin("foo", 2), ), poolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 10_000_000_000), - sdk.NewInt64Coin("bar", 10_000_000_000), + sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset), ), scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), expNumShare: sdk.ZeroInt(), expTokensJoined: sdk.Coins{}, expPoolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 10_000_000_000), - sdk.NewInt64Coin("bar", 10_000_000_000), + sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset), ), expectPass: false, }, @@ -914,19 +967,19 @@ func TestJoinPoolSharesInternal(t *testing.T) { sdk.NewInt64Coin("bar", 1), ), poolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 9_999_999_999), - sdk.NewInt64Coin("bar", 9_999_999_999), + sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset.Sub(sdk.NewInt(1))), + sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset.Sub(sdk.NewInt(1))), ), scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), - expNumShare: sdk.NewInt(10000000000), + expNumShare: types.InitPoolSharesSupply.Quo(types.StableswapMaxScaledAmtPerAsset), expTokensJoined: sdk.NewCoins( sdk.NewInt64Coin("foo", 1), sdk.NewInt64Coin("bar", 1), ), expPoolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 10_000_000_000), - sdk.NewInt64Coin("bar", 10_000_000_000), + sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset), ), expectPass: true, }, @@ -948,3 +1001,59 @@ func TestJoinPoolSharesInternal(t *testing.T) { }) } } + +func TestSingleAssetJoinSwapFeeRatio(t *testing.T) { + largeInt, ok := sdk.NewIntFromString("123456789012345678") + require.True(t, ok) + type testcase struct { + poolLiquidity sdk.Coins + scalingFactors []uint64 + tokenInDenom string + expectedRatio sdk.Dec + } + tests := map[string]testcase{ + "godoc-example": { + poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), + scalingFactors: []uint64{1, 1}, + tokenInDenom: "tokenA", + expectedRatio: sdk.MustNewDecFromStr("0.2"), + }, + "godoc-example-denom-rev": { + poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), + scalingFactors: []uint64{1, 1}, + tokenInDenom: "tokenB", + expectedRatio: sdk.MustNewDecFromStr("0.8"), + }, + "80:20 -> 1:1 scaling factor": { + poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), + scalingFactors: []uint64{80, 20}, + tokenInDenom: "tokenA", + expectedRatio: sdk.MustNewDecFromStr("0.5"), + }, + "80:20 -> 2:1 scaling factor": { + poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), + scalingFactors: []uint64{40, 20}, + tokenInDenom: "tokenA", + expectedRatio: sdk.MustNewDecFromStr("0.333333333333333334"), + }, + "60:40:40, large numbers": { + poolLiquidity: sdk.NewCoins( + sdk.NewCoin("tokenA", largeInt.MulRaw(6)), + sdk.NewCoin("tokenB", largeInt.MulRaw(4)), + sdk.NewCoin("tokenC", largeInt.MulRaw(4))), + scalingFactors: []uint64{1, 1, 1}, + tokenInDenom: "tokenA", + // 1 - (6 / 14) = 8/14 = 4/7 ~= 0.571428571428571429 + expectedRatio: sdk.MustNewDecFromStr("0.571428571428571429"), + }, + } + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + p := poolStructFromAssets(tc.poolLiquidity, tc.scalingFactors) + + ratio, err := p.singleAssetJoinSwapFeeRatio(tc.tokenInDenom) + require.NoError(t, err) + require.Equal(t, tc.expectedRatio, ratio) + }) + } +} diff --git a/x/gamm/pool-models/stableswap/codec.go b/x/gamm/pool-models/stableswap/codec.go index 72f165e062f..8d45df0c786 100644 --- a/x/gamm/pool-models/stableswap/codec.go +++ b/x/gamm/pool-models/stableswap/codec.go @@ -6,7 +6,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - types "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" + + types "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) // RegisterLegacyAminoCodec registers the necessary x/gamm interfaces and concrete types @@ -46,5 +48,11 @@ var ( func init() { RegisterLegacyAminoCodec(amino) + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + sdk.RegisterLegacyAminoCodec(amino) + RegisterLegacyAminoCodec(authzcodec.Amino) amino.Seal() } + +const PoolTypeName string = "Stableswap" diff --git a/x/gamm/pool-models/stableswap/integration_test.go b/x/gamm/pool-models/stableswap/integration_test.go new file mode 100644 index 00000000000..b00b58ff9cb --- /dev/null +++ b/x/gamm/pool-models/stableswap/integration_test.go @@ -0,0 +1,59 @@ +// This file contains integration tests, using "true" messages. +// We expect tests for: +// * MsgCreatePool creating correct pool as expected +// * MsgStableSwapAdjustScalingFactors works as expected +package stableswap_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" +) + +type TestSuite struct { + apptesting.KeeperTestHelper +} + +func TestTestSuite(t *testing.T) { + suite.Run(t, new(TestSuite)) +} + +func (suite *TestSuite) SetupTest() { + suite.Setup() +} + +func (s *TestSuite) TestSetScalingFactors() { + s.SetupTest() + pk1 := ed25519.GenPrivKey().PubKey() + addr1 := sdk.AccAddress(pk1.Address()) + nextPoolId := s.App.GAMMKeeper.GetNextPoolId(s.Ctx) + defaultCreatePoolMsg := *baseCreatePoolMsgGen(addr1) + defaultCreatePoolMsg.ScalingFactorController = defaultCreatePoolMsg.Sender + defaultAdjustSFMsg := stableswap.NewMsgStableSwapAdjustScalingFactors(defaultCreatePoolMsg.Sender, nextPoolId, []uint64{1, 1}) + + tests := map[string]struct { + createMsg stableswap.MsgCreateStableswapPool + setMsg stableswap.MsgStableSwapAdjustScalingFactors + expectPass bool + }{ + "valid_msg": {defaultCreatePoolMsg, defaultAdjustSFMsg, true}, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + sender := tc.createMsg.GetSigners()[0] + s.FundAcc(sender, s.App.GAMMKeeper.GetParams(s.Ctx).PoolCreationFee) + s.FundAcc(sender, tc.createMsg.InitialPoolLiquidity.Sort()) + _, err := s.RunMsg(&tc.createMsg) + s.Require().NoError(err) + _, err = s.RunMsg(&tc.setMsg) + s.Require().NoError(err) + }) + } +} diff --git a/x/gamm/pool-models/stableswap/msgs.go b/x/gamm/pool-models/stableswap/msgs.go index bf7d1368738..877e6578d90 100644 --- a/x/gamm/pool-models/stableswap/msgs.go +++ b/x/gamm/pool-models/stableswap/msgs.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) const ( @@ -47,16 +47,21 @@ func (msg MsgCreateStableswapPool) ValidateBasic() error { } // validation for scaling factors + scalingFactors := msg.ScalingFactors // The message's scaling factors must be empty or a valid set of scaling factors - if len(msg.ScalingFactors) != 0 { - if err = validateScalingFactors(msg.ScalingFactors, len(msg.InitialPoolLiquidity)); err != nil { + if len(scalingFactors) != 0 { + if err = validateScalingFactors(scalingFactors, len(msg.InitialPoolLiquidity)); err != nil { return err } + } else { + for i := 0; i < len(msg.InitialPoolLiquidity); i += 1 { + scalingFactors = append(scalingFactors, 1) + } } // validation for pool initial liquidity // The message's pool liquidity must have between 2 and 8 assets with at most 10B post-scaled units in each - if err = validatePoolAssets(msg.InitialPoolLiquidity, msg.ScalingFactors); err != nil { + if err = validatePoolLiquidity(msg.InitialPoolLiquidity, scalingFactors); err != nil { return err } @@ -119,10 +124,12 @@ var _ sdk.Msg = &MsgStableSwapAdjustScalingFactors{} func NewMsgStableSwapAdjustScalingFactors( sender string, poolID uint64, + scalingFactors []uint64, ) MsgStableSwapAdjustScalingFactors { return MsgStableSwapAdjustScalingFactors{ - Sender: sender, - PoolID: poolID, + Sender: sender, + PoolID: poolID, + ScalingFactors: scalingFactors, } } diff --git a/x/gamm/pool-models/stableswap/msgs_test.go b/x/gamm/pool-models/stableswap/msgs_test.go index 727e4dc3fa1..935d717c399 100644 --- a/x/gamm/pool-models/stableswap/msgs_test.go +++ b/x/gamm/pool-models/stableswap/msgs_test.go @@ -8,49 +8,50 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" - appParams "github.com/osmosis-labs/osmosis/v12/app/params" - stableswap "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/stableswap" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" + stableswap "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) -func TestMsgCreateStableswapPool(t *testing.T) { - appParams.SetAddressPrefixes() - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()).String() - invalidAddr := sdk.AccAddress("invalid") +func baseCreatePoolMsgGen(sender sdk.AccAddress) *stableswap.MsgCreateStableswapPool { + testPoolAsset := sdk.Coins{ + sdk.NewCoin("atom", sdk.NewInt(100)), + sdk.NewCoin("osmo", sdk.NewInt(100)), + } - createMsg := func(after func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { - testPoolAsset := sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(100)), - sdk.NewCoin("atom", sdk.NewInt(100)), - } + poolParams := &stableswap.PoolParams{ + SwapFee: sdk.NewDecWithPrec(1, 2), + ExitFee: sdk.NewDecWithPrec(1, 2), + } - poolParams := &stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDecWithPrec(1, 2), - } + msg := &stableswap.MsgCreateStableswapPool{ + Sender: sender.String(), + PoolParams: poolParams, + InitialPoolLiquidity: testPoolAsset, + ScalingFactors: []uint64{1, 1}, + FuturePoolGovernor: "", + } - msg := &stableswap.MsgCreateStableswapPool{ - Sender: addr1, - PoolParams: poolParams, - InitialPoolLiquidity: testPoolAsset, - ScalingFactors: []uint64{1, 1}, - FuturePoolGovernor: "", - } + return msg +} - return after(*msg) - } +func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { + appParams.SetAddressPrefixes() + pk1 := ed25519.GenPrivKey().PubKey() + addr1 := sdk.AccAddress(pk1.Address()) + invalidAddr := sdk.AccAddress("invalid") - default_msg := createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { - // Do nothing - return msg - }) + default_msg := baseCreatePoolMsgGen(addr1) + updateMsg := func(f func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + m := *baseCreatePoolMsgGen(addr1) + return f(m) + } require.Equal(t, default_msg.Route(), types.RouterKey) require.Equal(t, default_msg.Type(), "create_stableswap_pool") signers := default_msg.GetSigners() require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1) + require.Equal(t, signers[0].String(), addr1.String()) tests := []struct { name string @@ -59,15 +60,23 @@ func TestMsgCreateStableswapPool(t *testing.T) { }{ { name: "proper msg", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { // Do nothing return msg }), expectPass: true, }, + { + name: "no scaling factors", + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg.ScalingFactors = []uint64{} + return msg + }), + expectPass: true, + }, { name: "invalid sender", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.Sender = invalidAddr.String() return msg }), @@ -75,7 +84,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "has nil InitialPoolLiquidity ", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = nil return msg }), @@ -83,7 +92,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "has one coin in InitialPoolLiquidity", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ sdk.NewCoin("osmo", sdk.NewInt(100)), } @@ -93,17 +102,17 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "have assets in excess of cap", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(100)), - sdk.NewCoin("atom", sdk.NewInt(100)), - sdk.NewCoin("usdt", sdk.NewInt(100)), - sdk.NewCoin("usdc", sdk.NewInt(100)), - sdk.NewCoin("juno", sdk.NewInt(100)), sdk.NewCoin("akt", sdk.NewInt(100)), - sdk.NewCoin("regen", sdk.NewInt(100)), + sdk.NewCoin("atom", sdk.NewInt(100)), sdk.NewCoin("band", sdk.NewInt(100)), sdk.NewCoin("evmos", sdk.NewInt(100)), + sdk.NewCoin("juno", sdk.NewInt(100)), + sdk.NewCoin("osmo", sdk.NewInt(100)), + sdk.NewCoin("regen", sdk.NewInt(100)), + sdk.NewCoin("usdt", sdk.NewInt(100)), + sdk.NewCoin("usdc", sdk.NewInt(100)), } return msg }), @@ -111,7 +120,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "negative swap fee with zero exit fee", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.PoolParams = &stableswap.PoolParams{ SwapFee: sdk.NewDecWithPrec(-1, 2), ExitFee: sdk.NewDecWithPrec(0, 0), @@ -121,8 +130,8 @@ func TestMsgCreateStableswapPool(t *testing.T) { expectPass: false, }, { - name: "scaling factors with invalid lenght", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + name: "scaling factors with invalid length", + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.ScalingFactors = []uint64{1, 2, 3} return msg }), @@ -130,7 +139,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "invalid governor", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.FuturePoolGovernor = "invalid_cosmos_address" return msg }), @@ -138,7 +147,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "invalid governor : len governor > 2", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.FuturePoolGovernor = "lptoken,1000h,invalid_cosmos_address" return msg }), @@ -146,7 +155,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "invalid governor : len governor > 2", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.FuturePoolGovernor = "lptoken,1000h,invalid_cosmos_address" return msg }), @@ -154,7 +163,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "valid governor: err when parse duration ", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.FuturePoolGovernor = "lptoken, invalid_duration" return msg }), @@ -162,7 +171,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "valid governor: just lock duration for pool token", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.FuturePoolGovernor = "1000h" return msg }), @@ -170,7 +179,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "valid governor: address", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.FuturePoolGovernor = "osmo1fqlr98d45v5ysqgp6h56kpujcj4cvsjnjq9nck" return msg }), @@ -178,7 +187,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "valid governor: address", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.FuturePoolGovernor = "" return msg }), @@ -186,7 +195,7 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "zero swap fee, zero exit fee", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.PoolParams = &stableswap.PoolParams{ ExitFee: sdk.NewDecWithPrec(0, 0), SwapFee: sdk.NewDecWithPrec(0, 0), @@ -197,30 +206,44 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "multi assets pool", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(100)), sdk.NewCoin("atom", sdk.NewInt(100)), - sdk.NewCoin("usdt", sdk.NewInt(100)), + sdk.NewCoin("osmo", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(100)), + sdk.NewCoin("usdt", sdk.NewInt(100)), } msg.ScalingFactors = []uint64{1, 1, 1, 1} return msg }), expectPass: true, }, + { + name: "post-scaled asset amount less than 1", + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg.InitialPoolLiquidity = sdk.Coins{ + sdk.NewCoin("osmo", sdk.NewInt(100)), + sdk.NewCoin("atom", sdk.NewInt(100)), + sdk.NewCoin("usdt", sdk.NewInt(100)), + sdk.NewCoin("usdc", sdk.NewInt(100)), + } + msg.ScalingFactors = []uint64{1000, 1, 1, 1} + return msg + }), + expectPass: false, + }, { name: "max asset amounts", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("atom", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("usdt", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("usdc", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("juno", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("akt", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("regen", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("band", sdk.NewInt(10_000_000_000)), + sdk.NewCoin("akt", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("atom", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("band", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("juno", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("osmo", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("regen", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("usdc", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("usdt", types.StableswapMaxScaledAmtPerAsset), } msg.ScalingFactors = []uint64{1, 1, 1, 1, 1, 1, 1, 1} return msg @@ -229,16 +252,16 @@ func TestMsgCreateStableswapPool(t *testing.T) { }, { name: "greater than max post-scaled amount with regular scaling factors", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(1+10_000_000_000)), - sdk.NewCoin("atom", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("usdt", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("usdc", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("juno", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("akt", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("regen", sdk.NewInt(10_000_000_000)), - sdk.NewCoin("band", sdk.NewInt(10_000_000_000)), + sdk.NewCoin("osmo", types.StableswapMaxScaledAmtPerAsset.Add(sdk.OneInt())), + sdk.NewCoin("atom", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("usdt", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("usdc", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("juno", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("akt", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("regen", types.StableswapMaxScaledAmtPerAsset), + sdk.NewCoin("band", types.StableswapMaxScaledAmtPerAsset), } msg.ScalingFactors = []uint64{1, 1, 1, 1, 1, 1, 1, 1} return msg @@ -246,17 +269,17 @@ func TestMsgCreateStableswapPool(t *testing.T) { expectPass: false, }, { - name: "100B token 8-asset pool using large scaling factors", - msg: createMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { + name: "100B token 8-asset pool using large scaling factors (6 decimal precision per asset)", + msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("akt", sdk.NewInt(100_000_000_000_000_000)), sdk.NewCoin("atom", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("usdt", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("usdc", sdk.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("band", sdk.NewInt(100_000_000_000_000_000)), sdk.NewCoin("juno", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("akt", sdk.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("osmo", sdk.NewInt(100_000_000_000_000_000)), sdk.NewCoin("regen", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("band", sdk.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("usdc", sdk.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("usdt", sdk.NewInt(100_000_000_000_000_000)), } msg.ScalingFactors = []uint64{10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000} return msg diff --git a/x/gamm/pool-models/stableswap/pool.go b/x/gamm/pool-models/stableswap/pool.go index 114fc129bc3..62d13f7d67a 100644 --- a/x/gamm/pool-models/stableswap/pool.go +++ b/x/gamm/pool-models/stableswap/pool.go @@ -8,17 +8,33 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/osmomath" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/cfmm_common" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/cfmm_common" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var _ types.PoolI = &Pool{} +type unsortedPoolLiqError struct { + ActualLiquidity sdk.Coins +} + +func (e unsortedPoolLiqError) Error() string { + return fmt.Sprintf(`unsorted initial pool liquidity: %s. + Please sort and make sure scaling factor order matches initial liquidity coin order`, e.ActualLiquidity) +} + +type liquidityAndScalingFactorCountMismatchError struct { + LiquidityCount int + ScalingFactorCount int +} + +func (e liquidityAndScalingFactorCountMismatchError) Error() string { + return fmt.Sprintf("liquidity count (%d) must match scaling factor count (%d)", e.LiquidityCount, e.ScalingFactorCount) +} + // NewStableswapPool returns a stableswap pool // Invariants that are assumed to be satisfied and not checked: -// * len(initialLiquidity) = 2 -// * FutureGovernor is valid // * poolID doesn't already exist func NewStableswapPool(poolId uint64, stableswapPoolParams PoolParams, initialLiquidity sdk.Coins, @@ -32,11 +48,17 @@ func NewStableswapPool(poolId uint64, } } + scalingFactors = applyScalingFactorMultiplier(scalingFactors) + if err := validateScalingFactors(scalingFactors, len(initialLiquidity)); err != nil { return Pool{}, err } - if err := validatePoolAssets(initialLiquidity, scalingFactors); err != nil { + if err := validatePoolLiquidity(initialLiquidity, scalingFactors); err != nil { + return Pool{}, err + } + + if err := types.ValidateFutureGovernor(futureGovernor); err != nil { return Pool{}, err } @@ -46,7 +68,7 @@ func NewStableswapPool(poolId uint64, PoolParams: stableswapPoolParams, TotalShares: sdk.NewCoin(types.GetPoolShareDenom(poolId), types.InitPoolSharesSupply), PoolLiquidity: initialLiquidity, - ScalingFactor: scalingFactors, + ScalingFactors: scalingFactors, ScalingFactorController: scalingFactorController, FuturePoolGovernor: futureGovernor, } @@ -96,19 +118,20 @@ func (p Pool) GetTotalShares() sdk.Int { } func (p Pool) GetScalingFactors() []uint64 { - return p.ScalingFactor + return p.ScalingFactors } // CONTRACT: scaling factors follow the same index with pool liquidity denoms func (p Pool) GetScalingFactorByLiquidityIndex(liquidityIndex int) uint64 { - return p.ScalingFactor[liquidityIndex] + return p.ScalingFactors[liquidityIndex] } func (p Pool) NumAssets() int { return len(p.PoolLiquidity) } -// scaledInput returns scaled input tokens for usage in AMM equations +// scaleCoin returns the BigDec amount of the +// input token after scaling it by the token's scaling factor func (p Pool) scaleCoin(input sdk.Coin, roundingDirection osmomath.RoundingDirection) (osmomath.BigDec, error) { liquidityIndexes := p.getLiquidityIndexMap() scalingFactor := p.GetScalingFactorByLiquidityIndex(liquidityIndexes[input.Denom]) @@ -119,8 +142,8 @@ func (p Pool) scaleCoin(input sdk.Coin, roundingDirection osmomath.RoundingDirec return scaledAmount, nil } -// getDescaledPoolAmts gets descaled amount of given denom and amount -// TODO: Review rounding of this in all contexts +// getDescaledPoolAmt descales the passed in amount +// by the scaling factor of the passed in denom func (p Pool) getDescaledPoolAmt(denom string, amount osmomath.BigDec) sdk.Dec { liquidityIndexes := p.getLiquidityIndexMap() liquidityIndex := liquidityIndexes[denom] @@ -130,8 +153,8 @@ func (p Pool) getDescaledPoolAmt(denom string, amount osmomath.BigDec) sdk.Dec { return amount.MulInt64(int64(scalingFactor)).SDKDec() } -// getLiquidityIndexMap creates a map of denoms to its index in pool liquidity -// TODO: Review all uses of this +// getLiquidityIndexMap creates a map of denoms to its index in pool liquidity. +// As always, the caller must not iterate over the map. func (p Pool) getLiquidityIndexMap() map[string]int { poolLiquidity := p.PoolLiquidity liquidityIndexMap := make(map[string]int, poolLiquidity.Len()) @@ -141,26 +164,37 @@ func (p Pool) getLiquidityIndexMap() map[string]int { return liquidityIndexMap } +// scaledSortedPoolReserves sorts and scales passed in pool reserves such that the denom +// `first` and the denom `second` are ordered first and second, +// respectively. The rest of the ordering is not specified but +// deterministic. +// +// Returns reserve amounts as an array of type BigDec. func (p Pool) scaledSortedPoolReserves(first string, second string, round osmomath.RoundingDirection) ([]osmomath.BigDec, error) { reorderedLiquidity, reorderedScalingFactors, err := p.reorderReservesAndScalingFactors(first, second) if err != nil { return nil, err } + + if err := validateScalingFactors(reorderedScalingFactors, len(reorderedLiquidity)); err != nil { + return nil, err + } + return osmomath.DivCoinAmtsByU64ToBigDec(reorderedLiquidity, reorderedScalingFactors, round) } // reorderReservesAndScalingFactors takes the pool liquidity and scaling factors, and reorders them s.t. // reorderedReserves[0] = p.GetLiquidity().AmountOf(first) // reorderedScalingFactors[0] = p.ScalingFactors[p.getLiquidityIndexMap()[first]] -// and the same for index 1, and second. +// Similarly, reordering happens for second and index 1. // // The remainder of the lists includes every remaining (reserve asset, scaling factor) pair, -// in a deterministic order. +// in a deterministic but unspecified order. // // Returns an error if the pool does not contain either of first or second. func (p Pool) reorderReservesAndScalingFactors(first string, second string) ([]sdk.Coin, []uint64, error) { coins := p.PoolLiquidity - scalingFactors := p.ScalingFactor + scalingFactors := p.ScalingFactors reorderedReserves := make([]sdk.Coin, len(coins)) reorderedScalingFactors := make([]uint64, len(coins)) curIndex := 2 @@ -198,13 +232,17 @@ func (p *Pool) updatePoolLiquidityForSwap(tokensIn sdk.Coins, tokensOut sdk.Coin } } -// updatePoolLiquidityForExit updates the pool liquidity after an exit. +// updatePoolLiquidityForExit updates the pool liquidity and total shares after an exit. // The function sanity checks that not all tokens of a given denom are removed, // and panics if thats the case. -func (p *Pool) updatePoolLiquidityForExit(tokensOut sdk.Coins) { +func (p *Pool) updatePoolLiquidityForExit(tokensOut sdk.Coins, exitingShares sdk.Int) { p.updatePoolLiquidityForSwap(sdk.Coins{}, tokensOut) + p.TotalShares.Amount = p.TotalShares.Amount.Sub(exitingShares) } +// updatePoolForJoin updates the pool liquidity and total shares after a join. +// The function sanity checks that no new denoms were added to the pool +// and panics if this is the case. func (p *Pool) updatePoolForJoin(tokensIn sdk.Coins, newShares sdk.Int) { numTokens := p.NumAssets() p.PoolLiquidity = p.PoolLiquidity.Add(tokensIn...) @@ -215,6 +253,7 @@ func (p *Pool) updatePoolForJoin(tokensIn sdk.Coins, newShares sdk.Int) { } // TODO: These should all get moved to amm.go +// CalcOutAmtGivenIn calculates expected output amount given input token func (p Pool) CalcOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, swapFee sdk.Dec) (tokenOut sdk.Coin, err error) { if tokenIn.Len() != 1 { return sdk.Coin{}, errors.New("stableswap CalcOutAmtGivenIn: tokenIn is of wrong length") @@ -227,13 +266,15 @@ func (p Pool) CalcOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDeno // we ignore the decimal component, as token out amount must round down tokenOutAmt := outAmtDec.TruncateInt() if !tokenOutAmt.IsPositive() { - return sdk.Coin{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, "token amount must be positive") + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrInvalidMathApprox, + fmt.Sprintf("token amount must be positive, got %v", tokenOutAmt)) } return sdk.NewCoin(tokenOutDenom, tokenOutAmt), nil } +// SwapOutAmtGivenIn executes a swap given a desired input amount func (p *Pool) SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, swapFee sdk.Dec) (tokenOut sdk.Coin, err error) { - if err = validatePoolAssets(p.PoolLiquidity.Add(tokenIn...), p.ScalingFactor); err != nil { + if err = validatePoolLiquidity(p.PoolLiquidity.Add(tokenIn...), p.ScalingFactors); err != nil { return sdk.Coin{}, err } @@ -247,11 +288,12 @@ func (p *Pool) SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDen return tokenOut, nil } +// CalcInAmtGivenOut calculates input amount needed to receive given output func (p Pool) CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, swapFee sdk.Dec) (tokenIn sdk.Coin, err error) { if tokenOut.Len() != 1 { return sdk.Coin{}, errors.New("stableswap CalcInAmtGivenOut: tokenOut is of wrong length") } - // TODO: Refactor this later to handle scaling factors + amt, err := p.calcInAmtGivenOut(tokenOut[0], tokenInDenom, swapFee) if err != nil { return sdk.Coin{}, err @@ -267,13 +309,14 @@ func (p Pool) CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDeno return sdk.NewCoin(tokenInDenom, tokenInAmt), nil } +// SwapInAmtGivenOut executes a swap given a desired output amount func (p *Pool) SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, swapFee sdk.Dec) (tokenIn sdk.Coin, err error) { tokenIn, err = p.CalcInAmtGivenOut(ctx, tokenOut, tokenInDenom, swapFee) if err != nil { return sdk.Coin{}, err } - if err = validatePoolAssets(p.PoolLiquidity.Add(tokenIn), p.ScalingFactor); err != nil { + if err = validatePoolLiquidity(p.PoolLiquidity.Add(tokenIn), p.ScalingFactors); err != nil { return sdk.Coin{}, err } @@ -282,6 +325,8 @@ func (p *Pool) SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDen return tokenIn, nil } +// SpotPrice calculates the approximate amount of `baseDenom` one would receive for +// an input dx of `quoteDenom` (to simplify calculations, we approximate dx = 1) func (p Pool) SpotPrice(ctx sdk.Context, baseAssetDenom string, quoteAssetDenom string) (sdk.Dec, error) { return p.spotPrice(baseAssetDenom, quoteAssetDenom) } @@ -347,8 +392,12 @@ func (p *Pool) ExitPool(ctx sdk.Context, exitingShares sdk.Int, exitFee sdk.Dec) return sdk.Coins{}, err } - p.TotalShares.Amount = p.TotalShares.Amount.Sub(exitingShares) - p.updatePoolLiquidityForExit(exitingCoins) + postExitLiquidity := p.PoolLiquidity.Sub(exitingCoins) + if err := validatePoolLiquidity(postExitLiquidity, p.ScalingFactors); err != nil { + return sdk.Coins{}, err + } + + p.updatePoolLiquidityForExit(exitingCoins, exitingShares) return exitingCoins, nil } @@ -357,23 +406,25 @@ func (p Pool) CalcExitPoolCoinsFromShares(ctx sdk.Context, exitingShares sdk.Int return cfmm_common.CalcExitPool(ctx, &p, exitingShares, exitFee) } -// SetStableSwapScalingFactors sets scaling factors for pool to the given amount +// SetScalingFactors sets scaling factors for pool to the given amount // It should only be able to be successfully called by the pool's ScalingFactorGovernor // TODO: move commented test for this function from x/gamm/keeper/pool_service_test.go once a pool_test.go file has been created for stableswap -func (p *Pool) SetStableSwapScalingFactors(ctx sdk.Context, scalingFactors []uint64, sender string) error { +func (p *Pool) SetScalingFactors(ctx sdk.Context, scalingFactors []uint64, sender string) error { if sender != p.ScalingFactorController { return types.ErrNotScalingFactorGovernor } + scalingFactors = applyScalingFactorMultiplier(scalingFactors) + if err := validateScalingFactors(scalingFactors, p.PoolLiquidity.Len()); err != nil { return err } - if err := validatePoolAssets(p.PoolLiquidity, scalingFactors); err != nil { + if err := validatePoolLiquidity(p.PoolLiquidity, scalingFactors); err != nil { return err } - p.ScalingFactor = scalingFactors + p.ScalingFactors = scalingFactors return nil } @@ -387,30 +438,57 @@ func validateScalingFactorController(scalingFactorController string) error { func validateScalingFactors(scalingFactors []uint64, numAssets int) error { if len(scalingFactors) != numAssets { - return types.ErrInvalidStableswapScalingFactors + return types.ErrInvalidScalingFactorLength } for _, scalingFactor := range scalingFactors { if scalingFactor == 0 || int64(scalingFactor) <= 0 { - return types.ErrInvalidStableswapScalingFactors + return types.ErrInvalidScalingFactors } } return nil } -func validatePoolAssets(initialAssets sdk.Coins, scalingFactors []uint64) error { - if len(initialAssets) < types.MinPoolAssets { +// assumes liquidity is all pool liquidity, in correct sorted order +func validatePoolLiquidity(liquidity sdk.Coins, scalingFactors []uint64) error { + liquidityCount := len(liquidity) + scalingFactorCount := len(scalingFactors) + if liquidityCount != scalingFactorCount { + return liquidityAndScalingFactorCountMismatchError{LiquidityCount: liquidityCount, ScalingFactorCount: scalingFactorCount} + } + + if liquidityCount < types.MinPoolAssets { return types.ErrTooFewPoolAssets - } else if len(initialAssets) > types.MaxPoolAssets { + } else if liquidityCount > types.MaxPoolAssets { return types.ErrTooManyPoolAssets } - for i, asset := range initialAssets { - if asset.Amount.Quo(sdk.NewInt(int64(scalingFactors[i]))).GT(sdk.NewInt(types.StableswapMaxScaledAmtPerAsset)) { + liquidityCopy := make(sdk.Coins, liquidityCount) + copy(liquidityCopy, liquidity) + liquidityCopy.Sort() + + for i, asset := range liquidity { + if asset != liquidityCopy[i] { + return unsortedPoolLiqError{ActualLiquidity: liquidity} + } + + scaledAmount := asset.Amount.Quo(sdk.NewInt(int64(scalingFactors[i]))) + if scaledAmount.GT(types.StableswapMaxScaledAmtPerAsset) { return types.ErrHitMaxScaledAssets + } else if scaledAmount.LT(sdk.NewInt(types.StableswapMinScaledAmtPerAsset)) { + return types.ErrHitMinScaledAssets } } return nil } + +func applyScalingFactorMultiplier(scalingFactors []uint64) []uint64 { + newScalingFactors := make([]uint64, len(scalingFactors)) + for i := range scalingFactors { + newScalingFactors[i] = scalingFactors[i] * types.ScalingFactorMultiplier + } + + return newScalingFactors +} diff --git a/x/gamm/pool-models/stableswap/pool_params.go b/x/gamm/pool-models/stableswap/pool_params.go index 61deda6b7c1..15446b2ad7f 100644 --- a/x/gamm/pool-models/stableswap/pool_params.go +++ b/x/gamm/pool-models/stableswap/pool_params.go @@ -3,7 +3,7 @@ package stableswap import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func (params PoolParams) Validate() error { diff --git a/x/gamm/pool-models/stableswap/pool_test.go b/x/gamm/pool-models/stableswap/pool_test.go index c408b9b180d..439b6c23a63 100644 --- a/x/gamm/pool-models/stableswap/pool_test.go +++ b/x/gamm/pool-models/stableswap/pool_test.go @@ -2,16 +2,15 @@ package stableswap import ( - "math/big" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/osmomath" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/internal/cfmm_common" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/internal/cfmm_common" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var ( @@ -28,12 +27,12 @@ var ( defaultFutureGovernor = "" twoEvenStablePoolAssets = sdk.NewCoins( - sdk.NewInt64Coin("foo", 1000000000), sdk.NewInt64Coin("bar", 1000000000), + sdk.NewInt64Coin("foo", 1000000000), ) twoUnevenStablePoolAssets = sdk.NewCoins( - sdk.NewInt64Coin("foo", 2000000000), sdk.NewInt64Coin("bar", 1000000000), + sdk.NewInt64Coin("foo", 2000000000), ) threeEvenStablePoolAssets = sdk.NewCoins( sdk.NewInt64Coin("asset/a", 1000000), @@ -69,7 +68,7 @@ func poolStructFromAssets(assets sdk.Coins, scalingFactors []uint64) Pool { PoolParams: defaultStableswapPoolParams, TotalShares: sdk.NewCoin(types.GetPoolShareDenom(defaultPoolId), types.InitPoolSharesSupply), PoolLiquidity: assets, - ScalingFactor: scalingFactors, + ScalingFactors: applyScalingFactorMultiplier(scalingFactors), FuturePoolGovernor: defaultFutureGovernor, } return p @@ -95,7 +94,7 @@ func TestReorderReservesAndScalingFactors(t *testing.T) { sdk.NewInt64Coin("asset/d", 4000000000), sdk.NewInt64Coin("asset/e", 5000000000), }, - reordedScalingFactors: []uint64{3, 2, 1, 4, 5}, + reordedScalingFactors: []uint64{3 * types.ScalingFactorMultiplier, 2 * types.ScalingFactorMultiplier, 1 * types.ScalingFactorMultiplier, 4 * types.ScalingFactorMultiplier, 5 * types.ScalingFactorMultiplier}, }, "two of 5 assets in pool v2": { denoms: [2]string{"asset/e", "asset/b"}, @@ -108,7 +107,7 @@ func TestReorderReservesAndScalingFactors(t *testing.T) { sdk.NewInt64Coin("asset/c", 3000000000), sdk.NewInt64Coin("asset/d", 4000000000), }, - reordedScalingFactors: []uint64{5, 2, 1, 3, 4}, + reordedScalingFactors: []uint64{5 * types.ScalingFactorMultiplier, 2 * types.ScalingFactorMultiplier, 1 * types.ScalingFactorMultiplier, 3 * types.ScalingFactorMultiplier, 4 * types.ScalingFactorMultiplier}, }, "asset 1 doesn't exist": { denoms: [2]string{"foo", "asset/b"}, @@ -140,6 +139,7 @@ func TestReorderReservesAndScalingFactors(t *testing.T) { func TestScaledSortedPoolReserves(t *testing.T) { baseEvenAmt := osmomath.NewBigDec(1000000000) + bigDecScalingMultiplier := osmomath.NewBigDec(types.ScalingFactorMultiplier) tests := map[string]struct { denoms [2]string roundMode osmomath.RoundingDirection @@ -153,44 +153,44 @@ func TestScaledSortedPoolReserves(t *testing.T) { denoms: [2]string{"foo", "bar"}, poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expReserves: []osmomath.BigDec{baseEvenAmt, baseEvenAmt}, + expReserves: []osmomath.BigDec{baseEvenAmt.Quo(bigDecScalingMultiplier), baseEvenAmt.Quo(bigDecScalingMultiplier)}, }, "uneven two-asset pool with default scaling factors": { denoms: [2]string{"foo", "bar"}, poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expReserves: []osmomath.BigDec{baseEvenAmt.MulInt64(2), baseEvenAmt}, + expReserves: []osmomath.BigDec{baseEvenAmt.MulInt64(2).Quo(bigDecScalingMultiplier), baseEvenAmt.Quo(bigDecScalingMultiplier)}, }, "even two-asset pool with even scaling factors greater than 1": { denoms: [2]string{"foo", "bar"}, poolAssets: twoEvenStablePoolAssets, scalingFactors: []uint64{10, 10}, - expReserves: []osmomath.BigDec{baseEvenAmt.QuoInt64(10), baseEvenAmt.QuoInt64(10)}, + expReserves: []osmomath.BigDec{(baseEvenAmt.Quo(bigDecScalingMultiplier)).QuoInt64(10), (baseEvenAmt.Quo(bigDecScalingMultiplier)).QuoInt64(10)}, }, "even two-asset pool with uneven scaling factors greater than 1": { denoms: [2]string{"foo", "bar"}, poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, expReserves: []osmomath.BigDec{ - osmomath.NewBigDec(2000000000 / 5), osmomath.NewBigDec(1000000000 / 10), + osmomath.NewBigDec(2000000000 / 5).Quo(bigDecScalingMultiplier), osmomath.NewBigDec(1000000000 / 10).Quo(bigDecScalingMultiplier), }, }, "even two-asset pool with even, massive scaling factors greater than 1": { denoms: [2]string{"foo", "bar"}, poolAssets: twoEvenStablePoolAssets, scalingFactors: []uint64{10000000000, 10000000000}, - expReserves: []osmomath.BigDec{osmomath.NewDecWithPrec(1, 1), osmomath.NewDecWithPrec(1, 1)}, + expReserves: []osmomath.BigDec{osmomath.NewDecWithPrec(1, 1).Quo(bigDecScalingMultiplier), osmomath.NewDecWithPrec(1, 1).Quo(bigDecScalingMultiplier)}, }, "five asset pool, scaling factors = 1": { denoms: [2]string{"asset/c", "asset/d"}, poolAssets: fiveUnevenStablePoolAssets, scalingFactors: []uint64{1, 1, 1, 1, 1}, expReserves: []osmomath.BigDec{ - baseEvenAmt.MulInt64(3), - baseEvenAmt.MulInt64(4), - baseEvenAmt, - baseEvenAmt.MulInt64(2), - baseEvenAmt.MulInt64(5), + baseEvenAmt.MulInt64(3).Quo(bigDecScalingMultiplier), + baseEvenAmt.MulInt64(4).Quo(bigDecScalingMultiplier), + baseEvenAmt.Quo(bigDecScalingMultiplier), + baseEvenAmt.MulInt64(2).Quo(bigDecScalingMultiplier), + baseEvenAmt.MulInt64(5).Quo(bigDecScalingMultiplier), }, }, "five asset pool, scaling factors = 1,2,3,4,5": { @@ -198,20 +198,20 @@ func TestScaledSortedPoolReserves(t *testing.T) { poolAssets: fiveUnevenStablePoolAssets, scalingFactors: []uint64{1, 2, 3, 4, 5}, expReserves: []osmomath.BigDec{ - baseEvenAmt, - baseEvenAmt, - baseEvenAmt, - baseEvenAmt, - baseEvenAmt, + baseEvenAmt.Quo(bigDecScalingMultiplier), + baseEvenAmt.Quo(bigDecScalingMultiplier), + baseEvenAmt.Quo(bigDecScalingMultiplier), + baseEvenAmt.Quo(bigDecScalingMultiplier), + baseEvenAmt.Quo(bigDecScalingMultiplier), }, }, "max scaling factors": { denoms: [2]string{"foo", "bar"}, poolAssets: twoEvenStablePoolAssets, - scalingFactors: []uint64{(1 << 62), (1 << 62)}, + scalingFactors: []uint64{(1 << 62) / types.ScalingFactorMultiplier, (1 << 62) / types.ScalingFactorMultiplier}, expReserves: []osmomath.BigDec{ - osmomath.NewBigDec(1000000000).QuoInt64(int64(1 << 62)), - osmomath.NewBigDec(1000000000).QuoInt64(int64(1 << 62)), + (osmomath.NewBigDec(1000000000).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier))).Quo(osmomath.NewBigDec(int64(1<<62) / types.ScalingFactorMultiplier)), + (osmomath.NewBigDec(1000000000).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier))).Quo(osmomath.NewBigDec(int64(1<<62) / types.ScalingFactorMultiplier)), }, }, "zero scaling factor": { @@ -239,6 +239,42 @@ func TestScaledSortedPoolReserves(t *testing.T) { } } +func TestGetLiquidityIndexMap(t *testing.T) { + tests := map[string]struct { + poolAssets sdk.Coins + }{ + "2 asset pool": { + twoEvenStablePoolAssets, + }, + "3 asset pool": { + threeEvenStablePoolAssets, + }, + "4 asset pool": { + sdk.NewCoins( + sdk.NewInt64Coin("asset/a", 1000000000), + sdk.NewInt64Coin("asset/b", 1000000000), + sdk.NewInt64Coin("asset/c", 1000000000), + sdk.NewInt64Coin("asset/d", 1000000000), + ), + }, + "5 asset pool": { + fiveEvenStablePoolAssets, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + pool := poolStructFromAssets(tc.poolAssets, []uint64{}) + + indexMap := pool.getLiquidityIndexMap() + require.Equal(t, len(indexMap), len(tc.poolAssets)) + for ind := 0; ind < len(tc.poolAssets); ind++ { + actual_ind := indexMap[tc.poolAssets[ind].Denom] + require.Equal(t, actual_ind, ind) + } + }) + } +} func TestGetDescaledPoolAmts(t *testing.T) { tests := map[string]struct { denom string @@ -258,129 +294,112 @@ func TestGetDescaledPoolAmts(t *testing.T) { // sanity checks, default scaling factors "get exact supply of one asset, even two-asset pool with default scaling factors": { denom: "foo", - amount: osmomath.NewBigDec(1000000000), + amount: osmomath.NewBigDec(100000000), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(1000000000), + expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), }, "get less than supply of one asset, even two-asset pool with default scaling factors": { denom: "foo", amount: osmomath.NewBigDec(500000000), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(500000000), + expResult: sdk.NewDec(500000000 * types.ScalingFactorMultiplier), }, "get more than supply of one asset, even two-asset pool with default scaling factors": { denom: "foo", - amount: osmomath.NewBigDec(10000000000000), + amount: osmomath.NewBigDec(100000000), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(10000000000000), + expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), }, // uneven pools "get exact supply of first asset, uneven two-asset pool with default scaling factors": { denom: "foo", - amount: osmomath.NewBigDec(2000000000), + amount: osmomath.NewBigDec(200000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(2000000000), + expResult: sdk.NewDec(200000000 * types.ScalingFactorMultiplier), }, "get less than supply of first asset, uneven two-asset pool with default scaling factors": { denom: "foo", amount: osmomath.NewBigDec(500000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(500000000), + expResult: sdk.NewDec(500000000 * types.ScalingFactorMultiplier), }, "get more than supply of first asset, uneven two-asset pool with default scaling factors": { denom: "foo", - amount: osmomath.NewBigDec(10000000000000), + amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(10000000000000), + expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), }, "get exact supply of second asset, uneven two-asset pool with default scaling factors": { denom: "bar", - amount: osmomath.NewBigDec(1000000000), + amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(1000000000), + expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), }, "get less than supply of second asset, uneven two-asset pool with default scaling factors": { denom: "bar", amount: osmomath.NewBigDec(500000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(500000000), + expResult: sdk.NewDec(500000000 * types.ScalingFactorMultiplier), }, "get more than supply of second asset, uneven two-asset pool with default scaling factors": { denom: "bar", - amount: osmomath.NewBigDec(10000000000000), + amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(10000000000000), + expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), }, // uneven scaling factors (note: denoms are ordered lexicographically, not by pool asset input) "get exact supply of first asset, uneven two-asset pool with uneven scaling factors": { denom: "foo", - amount: osmomath.NewBigDec(2000000000), + amount: osmomath.NewBigDec(20000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(2000000000 * 5), + expResult: sdk.NewDec(20000000 * 5 * types.ScalingFactorMultiplier), }, "get less than supply of first asset, uneven two-asset pool with uneven scaling factors": { denom: "foo", - amount: osmomath.NewBigDec(500000000), + amount: osmomath.NewBigDec(50000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(500000000 * 5), + expResult: sdk.NewDec(50000000 * 5 * types.ScalingFactorMultiplier), }, "get more than supply of first asset, uneven two-asset pool with uneven scaling factors": { denom: "foo", - amount: osmomath.NewBigDec(10000000000000), + amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(10000000000000 * 5), + expResult: sdk.NewDec(100000000 * 5 * types.ScalingFactorMultiplier), }, "get exact supply of second asset, uneven two-asset pool with uneven scaling factors": { denom: "bar", - amount: osmomath.NewBigDec(2000000000), + amount: osmomath.NewBigDec(20000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(2000000000 * 10), + expResult: sdk.NewDec(20000000 * 10 * types.ScalingFactorMultiplier), }, "get less than supply of second asset, uneven two-asset pool with uneven scaling factors": { denom: "bar", - amount: osmomath.NewBigDec(500000000), + amount: osmomath.NewBigDec(50000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(500000000 * 10), + expResult: sdk.NewDec(50000000 * 10 * types.ScalingFactorMultiplier), }, "get more than supply of second asset, uneven two-asset pool with uneven scaling factors": { denom: "bar", - amount: osmomath.NewBigDec(10000000000000), + amount: osmomath.NewBigDec(10000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(10000000000000 * 10), - }, - - // panic catching - "scaled asset overflows": { - denom: "foo", - amount: overflowDec, - poolAssets: twoEvenStablePoolAssets, - scalingFactors: []uint64{(1 << 62), (1 << 62)}, - expPanic: true, - }, - "descaled asset overflows": { - denom: "foo", - // 2^1000, should not overflow until descaled - amount: osmomath.NewDecFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(1000), nil), big.NewInt(1))), - poolAssets: twoEvenStablePoolAssets, - scalingFactors: []uint64{(1 << 62), (1 << 62)}, - expPanic: true, + expResult: sdk.NewDec(10000000 * 10 * types.ScalingFactorMultiplier), }, } @@ -388,16 +407,7 @@ func TestGetDescaledPoolAmts(t *testing.T) { t.Run(name, func(t *testing.T) { // system under test sut := func() { - // we create the pool directly to bypass checks in NewStableswapPool() - p := Pool{ - Address: types.NewPoolAddress(defaultPoolId).String(), - Id: defaultPoolId, - PoolParams: defaultStableswapPoolParams, - TotalShares: sdk.NewCoin(types.GetPoolShareDenom(defaultPoolId), types.InitPoolSharesSupply), - PoolLiquidity: tc.poolAssets, - ScalingFactor: tc.scalingFactors, - FuturePoolGovernor: defaultFutureGovernor, - } + p := poolStructFromAssets(tc.poolAssets, tc.scalingFactors) result := p.getDescaledPoolAmt(tc.denom, tc.amount) require.Equal(t, tc.expResult, result) @@ -422,7 +432,7 @@ func TestScaleCoin(t *testing.T) { rounding: osmomath.RoundDown, poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expOutput: osmomath.NewBigDec(100), + expOutput: osmomath.NewBigDec(100).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), expError: false, }, "uneven two-asset pool with default scaling factors": { @@ -430,7 +440,7 @@ func TestScaleCoin(t *testing.T) { rounding: osmomath.RoundDown, poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expOutput: osmomath.NewBigDec(200), + expOutput: osmomath.NewBigDec(200).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), expError: false, }, "even two-asset pool with uneven scaling factors greater than 1": { @@ -438,7 +448,7 @@ func TestScaleCoin(t *testing.T) { rounding: osmomath.RoundDown, poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expOutput: osmomath.NewBigDec(10), + expOutput: osmomath.NewBigDec(10).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), expError: false, }, "even two-asset pool with even, massive scaling factors greater than 1": { @@ -446,7 +456,7 @@ func TestScaleCoin(t *testing.T) { rounding: osmomath.RoundDown, poolAssets: twoEvenStablePoolAssets, scalingFactors: []uint64{10000000000, 10_000_000_000}, - expOutput: osmomath.NewDecWithPrec(100, 10), + expOutput: osmomath.NewDecWithPrec(100, 10).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), expError: false, }, "five asset pool scaling factors = 1": { @@ -454,7 +464,7 @@ func TestScaleCoin(t *testing.T) { rounding: osmomath.RoundDown, poolAssets: fiveUnevenStablePoolAssets, scalingFactors: []uint64{1, 1, 1, 1, 1}, - expOutput: osmomath.NewBigDec(100), + expOutput: osmomath.NewBigDec(100).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), expError: false, }, "five asset pool scaling factors = 1,2,3,4,5": { @@ -462,15 +472,15 @@ func TestScaleCoin(t *testing.T) { rounding: osmomath.RoundDown, poolAssets: fiveUnevenStablePoolAssets, scalingFactors: []uint64{1, 2, 3, 4, 5}, - expOutput: osmomath.NewBigDec(25), + expOutput: osmomath.NewBigDec(25).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), expError: false, }, "max scaling factors on small token inputs": { input: sdk.NewCoin("foo", sdk.NewInt(10)), rounding: osmomath.RoundDown, poolAssets: twoEvenStablePoolAssets, - scalingFactors: []uint64{(1 << 62), (1 << 62)}, - expOutput: osmomath.NewBigDec(10).QuoInt64(1 << 62), + scalingFactors: []uint64{(1 << 62) / types.ScalingFactorMultiplier, (1 << 62) / types.ScalingFactorMultiplier}, + expOutput: (osmomath.NewBigDec(10).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier))).Quo(osmomath.NewBigDec((1 << 62) / types.ScalingFactorMultiplier)), expError: false, }, "zero scaling factor": { @@ -484,16 +494,7 @@ func TestScaleCoin(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - // we create the pool directly to bypass checks in NewStableswapPool() - p := Pool{ - Address: types.NewPoolAddress(defaultPoolId).String(), - Id: defaultPoolId, - PoolParams: defaultStableswapPoolParams, - TotalShares: sdk.NewCoin(types.GetPoolShareDenom(defaultPoolId), types.InitPoolSharesSupply), - PoolLiquidity: tc.poolAssets, - ScalingFactor: tc.scalingFactors, - FuturePoolGovernor: defaultFutureGovernor, - } + p := poolStructFromAssets(tc.poolAssets, tc.scalingFactors) scaledInput, err := p.scaleCoin(tc.input, tc.rounding) @@ -690,29 +691,47 @@ func TestSwapOutAmtGivenIn(t *testing.T) { expError bool }{ "even pool basic trade": { - poolAssets: twoEvenStablePoolAssets, - scalingFactors: defaultTwoAssetScalingFactors, - tokenIn: sdk.NewCoins(sdk.NewInt64Coin("foo", 100)), - // we expect at least a 1 token difference since output is truncated + poolAssets: twoEvenStablePoolAssets, + scalingFactors: defaultTwoAssetScalingFactors, + tokenIn: sdk.NewCoins(sdk.NewInt64Coin("foo", 100)), expectedTokenOut: sdk.NewInt64Coin("bar", 99), expectedPoolLiquidity: twoEvenStablePoolAssets.Add(sdk.NewInt64Coin("foo", 100)).Sub(sdk.NewCoins(sdk.NewInt64Coin("bar", 99))), swapFee: sdk.ZeroDec(), expError: false, }, + "100:1 scaling factor ratio, even swap": { + poolAssets: sdk.NewCoins( + sdk.NewInt64Coin("bar", 1000000000), + sdk.NewInt64Coin("foo", 10000000), + ), + scalingFactors: []uint64{100, 1}, + tokenIn: sdk.NewCoins(sdk.NewInt64Coin("foo", 100)), + expectedTokenOut: sdk.NewInt64Coin("bar", 9999), + expectedPoolLiquidity: sdk.NewCoins( + sdk.NewInt64Coin("bar", 1000000000).SubAmount(sdk.NewIntFromUint64(9999)), + sdk.NewInt64Coin("foo", 10000000).AddAmount(sdk.NewIntFromUint64(100)), + ), + swapFee: sdk.ZeroDec(), + expError: false, + }, + // TODO: Add test cases here, where they're off 1-1 ratio + // * (we just need to verify that the further off they are, further slippage is) + // * Add test cases with non-zero swap fee. + // looks like its really an error due to slippage at limit "trade hits max pool capacity for asset": { poolAssets: sdk.NewCoins( sdk.NewInt64Coin("foo", 9_999_999_998), - sdk.NewInt64Coin("bar", 9_999_999_999), + sdk.NewInt64Coin("bar", 9_999_999_998), ), scalingFactors: defaultTwoAssetScalingFactors, tokenIn: sdk.NewCoins(sdk.NewInt64Coin("foo", 1)), - expectedTokenOut: sdk.NewInt64Coin("bar", 1), + expectedTokenOut: sdk.Coin{}, expectedPoolLiquidity: sdk.NewCoins( sdk.NewInt64Coin("foo", 9_999_999_999), - sdk.NewInt64Coin("bar", 9_999_999_998), + sdk.NewInt64Coin("bar", 9_999_999_997), ), swapFee: sdk.ZeroDec(), - expError: false, + expError: true, }, "trade exceeds max pool capacity for asset": { poolAssets: sdk.NewCoins( @@ -737,11 +756,13 @@ func TestSwapOutAmtGivenIn(t *testing.T) { p := poolStructFromAssets(tc.poolAssets, tc.scalingFactors) tokenOut, err := p.SwapOutAmtGivenIn(ctx, tc.tokenIn, tc.expectedTokenOut.Denom, tc.swapFee) + osmoassert.ConditionalError(t, tc.expError, err) if !tc.expError { - require.Equal(t, tc.expectedTokenOut, tokenOut) - require.Equal(t, tc.expectedPoolLiquidity, p.PoolLiquidity) + require.Equal(t, tc.expectedTokenOut.Amount, tokenOut.Amount) + require.True(t, p.PoolLiquidity.IsAllGTE(tc.expectedPoolLiquidity), + "p.PoolLiquidity.IsAllGTE(tc.expectedPoolLiquidity) failed. Pool liq %v, expected %v", + p.PoolLiquidity, tc.expectedPoolLiquidity) } - osmoassert.ConditionalError(t, tc.expError, err) }) } } @@ -757,41 +778,40 @@ func TestSwapInAmtGivenOut(t *testing.T) { expError bool }{ "even pool basic trade": { - poolAssets: twoEvenStablePoolAssets, - scalingFactors: defaultTwoAssetScalingFactors, - tokenOut: sdk.NewCoins(sdk.NewInt64Coin("bar", 99)), - // we expect at least a 1 token difference from our true expected output since it is truncated - expectedTokenIn: sdk.NewInt64Coin("foo", 99), - expectedPoolLiquidity: twoEvenStablePoolAssets.Add(sdk.NewInt64Coin("foo", 99)).Sub(sdk.NewCoins(sdk.NewInt64Coin("bar", 99))), + poolAssets: twoEvenStablePoolAssets, + scalingFactors: defaultTwoAssetScalingFactors, + tokenOut: sdk.NewCoins(sdk.NewInt64Coin("bar", 100)), + expectedTokenIn: sdk.NewInt64Coin("foo", 100), + expectedPoolLiquidity: twoEvenStablePoolAssets.Add(sdk.NewInt64Coin("foo", 100)).Sub(sdk.NewCoins(sdk.NewInt64Coin("bar", 100))), swapFee: sdk.ZeroDec(), expError: false, }, "trade hits max pool capacity for asset": { poolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 9_999_999_998), - sdk.NewInt64Coin("bar", 9_999_999_999), + sdk.NewInt64Coin("foo", 9_999_999_997*types.ScalingFactorMultiplier), + sdk.NewInt64Coin("bar", 9_999_999_997*types.ScalingFactorMultiplier), ), scalingFactors: defaultTwoAssetScalingFactors, - tokenOut: sdk.NewCoins(sdk.NewInt64Coin("bar", 1)), - expectedTokenIn: sdk.NewInt64Coin("foo", 1), + tokenOut: sdk.NewCoins(sdk.NewInt64Coin("bar", 1*types.ScalingFactorMultiplier)), + expectedTokenIn: sdk.NewInt64Coin("foo", 1*types.ScalingFactorMultiplier), expectedPoolLiquidity: sdk.NewCoins( - sdk.NewInt64Coin("foo", 9_999_999_999), - sdk.NewInt64Coin("bar", 9_999_999_998), + sdk.NewInt64Coin("foo", 9_999_999_998*types.ScalingFactorMultiplier), + sdk.NewInt64Coin("bar", 9_999_999_996*types.ScalingFactorMultiplier), ), swapFee: sdk.ZeroDec(), expError: false, }, "trade exceeds max pool capacity for asset": { poolAssets: sdk.NewCoins( - sdk.NewInt64Coin("foo", 10_000_000_000), - sdk.NewInt64Coin("bar", 10_000_000_000), + sdk.NewInt64Coin("foo", 10_000_000_000*types.ScalingFactorMultiplier), + sdk.NewInt64Coin("bar", 10_000_000_000*types.ScalingFactorMultiplier), ), scalingFactors: defaultTwoAssetScalingFactors, tokenOut: sdk.NewCoins(sdk.NewInt64Coin("bar", 1)), expectedTokenIn: sdk.Coin{}, expectedPoolLiquidity: sdk.NewCoins( - sdk.NewInt64Coin("foo", 10_000_000_000), - sdk.NewInt64Coin("bar", 10_000_000_000), + sdk.NewInt64Coin("foo", 10_000_000_000*types.ScalingFactorMultiplier), + sdk.NewInt64Coin("bar", 10_000_000_000*types.ScalingFactorMultiplier), ), swapFee: sdk.ZeroDec(), expError: true, @@ -805,8 +825,8 @@ func TestSwapInAmtGivenOut(t *testing.T) { tokenIn, err := p.SwapInAmtGivenOut(ctx, tc.tokenOut, tc.expectedTokenIn.Denom, tc.swapFee) if !tc.expError { - require.Equal(t, tc.expectedTokenIn, tokenIn) - require.Equal(t, tc.expectedPoolLiquidity, p.PoolLiquidity) + require.True(t, tokenIn.Amount.GTE(tc.expectedTokenIn.Amount)) + require.True(t, p.PoolLiquidity.IsAllGTE(tc.expectedPoolLiquidity)) } osmoassert.ConditionalError(t, tc.expError, err) }) @@ -824,7 +844,6 @@ func TestInverseJoinPoolExitPool(t *testing.T) { unevenJoinedTokens sdk.Coins scalingFactors []uint64 swapFee sdk.Dec - expectPass bool } tests := map[string]testcase{ @@ -833,70 +852,60 @@ func TestInverseJoinPoolExitPool(t *testing.T) { poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), - expectPass: true, }, "[single asset join] uneven two asset pool, no swap fee": { tokensIn: hundredFoo, poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), - expectPass: true, }, "[single asset join] even 3-asset pool, no swap fee": { tokensIn: thousandAssetA, poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, swapFee: sdk.ZeroDec(), - expectPass: true, }, "[single asset join] uneven 3-asset pool, no swap fee": { tokensIn: thousandAssetA, poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, swapFee: sdk.ZeroDec(), - expectPass: true, }, "[single asset join] even two asset pool, default swap fee": { tokensIn: hundredFoo, poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: defaultSwapFee, - expectPass: true, }, "[single asset join] uneven two asset pool, default swap fee": { tokensIn: hundredFoo, poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: defaultSwapFee, - expectPass: true, }, "[single asset join] even 3-asset pool, default swap fee": { tokensIn: thousandAssetA, poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, swapFee: defaultSwapFee, - expectPass: true, }, "[single asset join] uneven 3-asset pool, default swap fee": { tokensIn: thousandAssetA, poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, swapFee: defaultSwapFee, - expectPass: true, }, "[single asset join] even 3-asset pool, 0.03 swap fee": { tokensIn: thousandAssetA, poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, swapFee: sdk.MustNewDecFromStr("0.03"), - expectPass: true, }, "[single asset join] uneven 3-asset pool, 0.03 swap fee": { tokensIn: thousandAssetA, poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, swapFee: sdk.MustNewDecFromStr("0.03"), - expectPass: true, }, "[all asset join] even two asset pool, same tokenIn ratio": { @@ -904,28 +913,24 @@ func TestInverseJoinPoolExitPool(t *testing.T) { poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), - expectPass: true, }, "[all asset join] even two asset pool, different tokenIn ratio with pool": { tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", sdk.NewInt(10+tenPercentOfTwoPoolRaw))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), - expectPass: true, }, "[all asset join] even two asset pool, different tokenIn ratio with pool, nonzero swap fee": { tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", sdk.NewInt(10+tenPercentOfTwoPoolRaw))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: defaultSwapFee, - expectPass: true, }, "[all asset join] even two asset pool, no tokens in": { tokensIn: sdk.NewCoins(), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, swapFee: sdk.ZeroDec(), - expectPass: true, }, } @@ -934,32 +939,384 @@ func TestInverseJoinPoolExitPool(t *testing.T) { ctx := sdk.Context{} p := poolStructFromAssets(tc.poolAssets, tc.scalingFactors) + // only for single asset join case + var swapRatio sdk.Dec + var err error + if len(tc.tokensIn) == 1 { + swapRatio, err = p.singleAssetJoinSwapFeeRatio(tc.tokensIn[0].Denom) + require.NoError(t, err) + } + // we join then exit the pool shares, err := p.JoinPool(ctx, tc.tokensIn, tc.swapFee) tokenOut, err := p.ExitPool(ctx, shares, defaultExitFee) // if single asset join, we swap output tokens to input denom to test the full inverse relationship if len(tc.tokensIn) == 1 { - tokenOutAmt, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, tokenOut, tc.tokensIn[0].Denom) + tokenOutAmt, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, tokenOut, tc.tokensIn[0].Denom, sdk.ZeroDec()) require.NoError(t, err) tokenOut = sdk.NewCoins(sdk.NewCoin(tc.tokensIn[0].Denom, tokenOutAmt)) } - // if single asset join, we expect output token swapped into the input denom to be input minus swap fee + // if single asset join, we expect output token swapped into the input denom + // to be smaller by swap ratio * 2 var expectedTokenOut sdk.Coins if len(tc.tokensIn) == 1 { - expectedAmt := (tc.tokensIn[0].Amount.ToDec().Mul(sdk.OneDec().Sub(tc.swapFee))).TruncateInt() + oneMinusSingleSwapFee := sdk.OneDec().Sub((swapRatio.Mul(tc.swapFee))) + expectedAmt := (tc.tokensIn[0].Amount.ToDec().Mul(oneMinusSingleSwapFee)).TruncateInt() expectedTokenOut = sdk.NewCoins(sdk.NewCoin(tc.tokensIn[0].Denom, expectedAmt)) } else { expectedTokenOut = tc.tokensIn } + finalPoolLiquidity := p.GetTotalPoolLiquidity(ctx) + require.True(t, tokenOut.IsAllLTE(expectedTokenOut), "token out %v, expected <= %v", tokenOut, expectedTokenOut) + require.True(t, finalPoolLiquidity.IsAllGTE(tc.poolAssets)) + require.NoError(t, err) + }) + } +} + +func TestExitPool(t *testing.T) { + tenPercentOfTwoPoolCoins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(int64(1000000000/10))), sdk.NewCoin("bar", sdk.NewInt(int64(1000000000/10)))) + tenPercentOfThreePoolCoins := sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(1000000/10)), sdk.NewCoin("asset/b", sdk.NewInt(1000000/10)), sdk.NewCoin("asset/c", sdk.NewInt(1000000/10))) + tenPercentOfUnevenThreePoolCoins := sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(1000000/10)), sdk.NewCoin("asset/b", sdk.NewInt(2000000/10)), sdk.NewCoin("asset/c", sdk.NewInt(3000000/10))) + type testcase struct { + sharesIn sdk.Int + initialPoolLiquidity sdk.Coins + scalingFactors []uint64 + expectedPoolLiquidity sdk.Coins + expectedTokenOut sdk.Coins + expectPass bool + } + tests := map[string]testcase{ + "basic two-asset pool exit on even pool": { + sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(10)), + initialPoolLiquidity: twoEvenStablePoolAssets, + scalingFactors: defaultTwoAssetScalingFactors, + expectedPoolLiquidity: twoEvenStablePoolAssets.Sub(tenPercentOfTwoPoolCoins), + expectedTokenOut: tenPercentOfTwoPoolCoins, + expectPass: true, + }, + "basic three-asset pool exit on even pool": { + sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(10)), + initialPoolLiquidity: threeEvenStablePoolAssets, + scalingFactors: defaultThreeAssetScalingFactors, + expectedPoolLiquidity: threeEvenStablePoolAssets.Sub(tenPercentOfThreePoolCoins), + expectedTokenOut: tenPercentOfThreePoolCoins, + expectPass: true, + }, + "basic three-asset pool exit on uneven pool": { + sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(10)), + initialPoolLiquidity: threeUnevenStablePoolAssets, + scalingFactors: defaultThreeAssetScalingFactors, + expectedPoolLiquidity: threeUnevenStablePoolAssets.Sub(tenPercentOfUnevenThreePoolCoins), + expectedTokenOut: tenPercentOfUnevenThreePoolCoins, + expectPass: true, + }, + "pool exit pushes post-scaled asset below 1": { + // attempt to exit one token when post-scaled amount is already 1 for each asset + sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(1000000)), + initialPoolLiquidity: threeEvenStablePoolAssets, + scalingFactors: []uint64{1000000 / types.ScalingFactorMultiplier, 100000 / types.ScalingFactorMultiplier, 100000 / types.ScalingFactorMultiplier}, + expectedPoolLiquidity: threeEvenStablePoolAssets, + expectedTokenOut: sdk.Coins{}, + expectPass: false, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + ctx := sdk.Context{} + p := poolStructFromAssets(tc.initialPoolLiquidity, tc.scalingFactors) + tokenOut, err := p.ExitPool(ctx, tc.sharesIn, defaultExitFee) + if tc.expectPass { finalPoolLiquidity := p.GetTotalPoolLiquidity(ctx) - require.True(t, tokenOut.IsAllLTE(expectedTokenOut)) - require.True(t, finalPoolLiquidity.IsAllGTE(tc.poolAssets)) + require.True(t, tokenOut.IsAllLTE(tc.expectedTokenOut)) + require.True(t, finalPoolLiquidity.IsAllGTE(tc.expectedPoolLiquidity)) } osmoassert.ConditionalError(t, !tc.expectPass, err) }) } } + +func TestValidatePoolLiquidity(t *testing.T) { + const ( + a = "aaa" + b = "bbb" + c = "ccc" + d = "ddd" + ) + + var ( + ten = sdk.NewInt(10) + + coinA = sdk.NewCoin(a, ten) + coinB = sdk.NewCoin(b, ten) + coinC = sdk.NewCoin(c, ten) + coinD = sdk.NewCoin(d, ten) + ) + + tests := map[string]struct { + liquidity sdk.Coins + scalingFactors []uint64 + expectError error + }{ + "sorted": { + liquidity: sdk.Coins{ + coinA, + coinB, + coinC, + coinD, + }, + scalingFactors: []uint64{10, 10, 10, 10}, + }, + "unsorted - error": { + liquidity: sdk.Coins{ + coinD, + coinA, + coinC, + coinB, + }, + scalingFactors: []uint64{10, 10, 10, 10}, + expectError: unsortedPoolLiqError{ActualLiquidity: sdk.Coins{ + coinD, + coinA, + coinC, + coinB, + }}, + }, + "denoms don't match scaling factors": { + liquidity: sdk.Coins{ + coinA, + coinB, + coinC, + coinD, + }, + scalingFactors: []uint64{10, 10}, + expectError: liquidityAndScalingFactorCountMismatchError{ + LiquidityCount: 4, + ScalingFactorCount: 2, + }, + }, + // TODO: cover remaining edge cases by referring to the function implementation. + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + err := validatePoolLiquidity(tc.liquidity, tc.scalingFactors) + + if tc.expectError != nil { + require.Error(t, err) + return + } + + require.NoError(t, err) + }) + } +} + +func TestStableswapSpotPrice(t *testing.T) { + type testcase struct { + baseDenom string + quoteDenom string + poolAssets sdk.Coins + scalingFactors []uint64 + expectPass bool + expectedPrice sdk.Dec + } + tests := map[string]testcase{ + "even two-asset pool": { + baseDenom: "foo", + quoteDenom: "bar", + poolAssets: twoEvenStablePoolAssets, + scalingFactors: defaultTwoAssetScalingFactors, + expectPass: true, + }, + "even two-asset pool with large scaling factors": { + baseDenom: "foo", + quoteDenom: "bar", + poolAssets: twoEvenStablePoolAssets, + scalingFactors: []uint64{10000, 10000}, + expectPass: true, + }, + "even two-asset pool with different scaling factors (foo -> bar)": { + baseDenom: "foo", + quoteDenom: "bar", + poolAssets: twoUnevenStablePoolAssets, + scalingFactors: []uint64{10000, 20000}, + expectedPrice: sdk.NewDec(2), + expectPass: true, + }, + "even two-asset pool with different scaling factors (bar -> foo)": { + baseDenom: "bar", + quoteDenom: "foo", + poolAssets: twoUnevenStablePoolAssets, + scalingFactors: []uint64{10000, 20000}, + expectedPrice: sdk.NewDecWithPrec(5, 1), + expectPass: true, + }, + "uneven two-asset pool": { + baseDenom: "foo", + quoteDenom: "bar", + poolAssets: twoUnevenStablePoolAssets, + scalingFactors: defaultTwoAssetScalingFactors, + expectPass: true, + }, + "even three-asset pool": { + baseDenom: "asset/a", + quoteDenom: "asset/b", + poolAssets: threeEvenStablePoolAssets, + scalingFactors: defaultThreeAssetScalingFactors, + expectPass: true, + }, + "even three-asset pool with large scaling factors": { + baseDenom: "asset/a", + quoteDenom: "asset/b", + poolAssets: threeEvenStablePoolAssets, + scalingFactors: []uint64{10000, 10000, 10000}, + expectPass: true, + }, + "even three-asset pool with different scaling factors": { + baseDenom: "asset/a", + quoteDenom: "asset/b", + poolAssets: threeEvenStablePoolAssets, + scalingFactors: []uint64{500, 700, 200}, + expectPass: true, + }, + "uneven three-asset pool (a -> b)": { + baseDenom: "asset/a", + quoteDenom: "asset/b", + poolAssets: sdk.NewCoins( + sdk.NewInt64Coin("asset/a", 10_000_000_000), + sdk.NewInt64Coin("asset/b", 20_000_000_000), + sdk.NewInt64Coin("asset/c", 30_000_000_000), + ), + scalingFactors: defaultThreeAssetScalingFactors, + expectPass: true, + }, + "uneven three-asset pool (b -> a)": { + baseDenom: "asset/b", + quoteDenom: "asset/a", + poolAssets: sdk.NewCoins( + sdk.NewInt64Coin("asset/a", 10_000_000_000), + sdk.NewInt64Coin("asset/b", 20_000_000_000), + sdk.NewInt64Coin("asset/c", 30_000_000_000), + ), + scalingFactors: defaultThreeAssetScalingFactors, + expectPass: true, + }, + "uneven three-asset pool large scaling factors (a -> b)": { + baseDenom: "asset/a", + quoteDenom: "asset/b", + poolAssets: sdk.NewCoins( + sdk.NewInt64Coin("asset/a", 10_000_000_000), + sdk.NewInt64Coin("asset/b", 20_000_000_000), + sdk.NewInt64Coin("asset/c", 30_000_000_000), + ), + scalingFactors: []uint64{10000, 10000, 10000}, + expectPass: true, + }, + "uneven three-asset pool large scaling factors (b -> a)": { + baseDenom: "asset/b", + quoteDenom: "asset/a", + poolAssets: sdk.NewCoins( + sdk.NewInt64Coin("asset/a", 10_000_000_000), + sdk.NewInt64Coin("asset/b", 20_000_000_000), + sdk.NewInt64Coin("asset/c", 30_000_000_000), + ), + scalingFactors: []uint64{10000, 10000, 10000}, + expectPass: true, + }, + "uneven 3-asset pool with uneven scaling factors (a -> b)": { + baseDenom: "asset/a", + quoteDenom: "asset/b", + poolAssets: sdk.NewCoins( + sdk.NewInt64Coin("asset/a", 12_345_678_910), + sdk.NewInt64Coin("asset/b", 10_987_654_321), + sdk.NewInt64Coin("asset/c", 8_452_398_713), + ), + scalingFactors: []uint64{36, 578, 253}, + expectPass: true, + }, + "uneven 3-asset pool with uneven scaling factors (b -> a)": { + baseDenom: "asset/a", + quoteDenom: "asset/b", + poolAssets: sdk.NewCoins( + sdk.NewInt64Coin("asset/a", 12_345_678_910), + sdk.NewInt64Coin("asset/b", 10_987_654_321), + sdk.NewInt64Coin("asset/c", 8_452_398_713), + ), + scalingFactors: []uint64{36, 578, 253}, + expectPass: true, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + ctx := sdk.Context{} + p := poolStructFromAssets(tc.poolAssets, tc.scalingFactors) + spotPrice, err := p.SpotPrice(ctx, tc.baseDenom, tc.quoteDenom) + + if tc.expectPass { + require.NoError(t, err) + + var expectedSpotPrice sdk.Dec + if (tc.expectedPrice != sdk.Dec{}) { + expectedSpotPrice = tc.expectedPrice + } else { + expectedSpotPrice, err = p.calcOutAmtGivenIn(sdk.NewInt64Coin(tc.quoteDenom, 1), tc.baseDenom, sdk.ZeroDec()) + require.NoError(t, err) + } + + // We allow for a small geometric error due to our spot price being an approximation + diff := (expectedSpotPrice.Sub(spotPrice)).Abs() + errTerm := diff.Quo(sdk.MinDec(expectedSpotPrice, spotPrice)) + require.True(t, errTerm.LT(sdk.NewDecWithPrec(1, 8)), "Expected: %d, Actual: %d", expectedSpotPrice, spotPrice) + + // Pool liquidity should remain unchanged + require.Equal(t, tc.poolAssets, p.GetTotalPoolLiquidity(ctx)) + } + osmoassert.ConditionalError(t, !tc.expectPass, err) + }) + } +} + +func TestValidateScalingFactors(t *testing.T) { + + tests := map[string]struct { + scalingFactors []uint64 + numAssets int + expectError bool + }{ + "number of scaling factors match number of assets": { + numAssets: 4, + scalingFactors: []uint64{10, 10, 10, 10}, + expectError: false, + }, + "number of scaling factors and assets mismatch": { + numAssets: 3, + scalingFactors: []uint64{10, 10, 10, 10}, + expectError: true, + }, + "all scaling factors equal to zero": { + numAssets: 3, + scalingFactors: []uint64{0, 0, 0}, + expectError: true, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + err := validateScalingFactors(tc.scalingFactors, tc.numAssets) + + if tc.expectError != false { + require.Error(t, err) + return + } + + require.NoError(t, err) + }) + } +} diff --git a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go index 967e1232b4f..a0d33b22513 100644 --- a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go +++ b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go @@ -89,7 +89,7 @@ type Pool struct { // assets in the pool PoolLiquidity github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=pool_liquidity,json=poolLiquidity,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_liquidity"` // for calculation amognst assets with different precisions - ScalingFactor []uint64 `protobuf:"varint,7,rep,packed,name=scaling_factor,json=scalingFactor,proto3" json:"scaling_factor,omitempty" yaml:"stableswap_scaling_factor"` + ScalingFactors []uint64 `protobuf:"varint,7,rep,packed,name=scaling_factors,json=scalingFactors,proto3" json:"scaling_factors,omitempty" yaml:"stableswap_scaling_factors"` // scaling_factor_controller is the address can adjust pool scaling factors ScalingFactorController string `protobuf:"bytes,8,opt,name=scaling_factor_controller,json=scalingFactorController,proto3" json:"scaling_factor_controller,omitempty" yaml:"scaling_factor_controller"` } @@ -136,47 +136,48 @@ func init() { } var fileDescriptor_ae0f054436f9999a = []byte{ - // 637 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x4f, 0xd4, 0x40, - 0x14, 0xdf, 0xc2, 0xc2, 0xe2, 0x20, 0x6b, 0xac, 0x24, 0x16, 0x88, 0xed, 0xa6, 0x51, 0xb3, 0x31, - 0x6e, 0x2b, 0x98, 0x98, 0xc8, 0x8d, 0xc5, 0x60, 0x8c, 0x1e, 0xb0, 0x9e, 0xfc, 0x93, 0xac, 0xd3, - 0x76, 0xb6, 0x4c, 0x9c, 0xee, 0xd4, 0x99, 0x29, 0xc2, 0xc5, 0xb3, 0x47, 0x8f, 0x1e, 0x39, 0x1a, - 0xcf, 0x7e, 0x08, 0xe2, 0x89, 0xa3, 0xf1, 0x50, 0x0d, 0x7c, 0x83, 0xfd, 0x04, 0x66, 0xa6, 0x53, - 0xd8, 0x45, 0x25, 0x24, 0x9e, 0x76, 0xde, 0x7b, 0xbf, 0xf7, 0x7b, 0xef, 0xf7, 0xde, 0xdb, 0x82, - 0xfb, 0x94, 0xa7, 0x94, 0x63, 0xee, 0x27, 0x30, 0x4d, 0xfd, 0x8c, 0x52, 0xd2, 0x49, 0x69, 0x8c, - 0x08, 0xf7, 0xb9, 0x80, 0x21, 0x41, 0xfc, 0x1d, 0xcc, 0x46, 0x9e, 0x3d, 0x89, 0xf0, 0x32, 0x46, - 0x05, 0x35, 0x6f, 0xe9, 0x54, 0x4f, 0xa6, 0x7a, 0x32, 0x50, 0x66, 0x7a, 0x27, 0x70, 0x6f, 0x7b, - 0x39, 0x44, 0x02, 0x2e, 0x2f, 0x2e, 0x44, 0x0a, 0xdc, 0x53, 0x99, 0x7e, 0x69, 0x94, 0x34, 0x8b, - 0xf3, 0x09, 0x4d, 0x68, 0xe9, 0x97, 0x2f, 0xed, 0xb5, 0x13, 0x4a, 0x13, 0x82, 0x7c, 0x65, 0x85, - 0x79, 0xdf, 0x8f, 0x73, 0x06, 0x05, 0xa6, 0x03, 0x1d, 0x77, 0x4e, 0xc7, 0x05, 0x4e, 0x11, 0x17, - 0x30, 0xcd, 0x2a, 0x82, 0xb2, 0x88, 0x0f, 0x73, 0xb1, 0xe5, 0xeb, 0x36, 0x94, 0x71, 0x2a, 0x1e, - 0x42, 0x8e, 0x8e, 0xe3, 0x11, 0xc5, 0xba, 0x80, 0xbb, 0x6f, 0x00, 0xb0, 0x49, 0x29, 0xd9, 0x84, - 0x0c, 0xa6, 0xdc, 0x7c, 0x05, 0x66, 0x94, 0xfe, 0x3e, 0x42, 0x96, 0xd1, 0x32, 0xda, 0x17, 0xba, - 0x6b, 0xfb, 0x85, 0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x19, 0xfe, 0xf6, 0xf2, 0x8a, 0xbf, 0x73, 0xd6, 0x67, 0x2c, 0x9c, 0x56, 0xff, 0xec, 0xbb, 0xbf, - 0x03, 0x00, 0x00, 0xff, 0xff, 0x3a, 0xa0, 0xff, 0x13, 0xf4, 0x04, 0x00, 0x00, + // 642 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0xdb, 0xb4, 0x29, 0x5b, 0x48, 0x85, 0xa9, 0x84, 0xdb, 0x0a, 0x6f, 0xb0, 0x28, 0x8a, + 0x10, 0xb1, 0x29, 0x95, 0x90, 0xe8, 0xad, 0x29, 0x2a, 0x42, 0x42, 0xa8, 0x98, 0x13, 0x3f, 0x52, + 0x58, 0xdb, 0x1b, 0x77, 0x85, 0x9d, 0x35, 0xbb, 0xeb, 0xd2, 0x5e, 0x38, 0x73, 0xe4, 0xc8, 0xb1, + 0x67, 0xb8, 0xf2, 0x10, 0x15, 0xa7, 0x1e, 0x11, 0x07, 0x83, 0xda, 0x37, 0xc8, 0x13, 0xa0, 0x5d, + 0xaf, 0xfb, 0x13, 0xa0, 0xaa, 0xc4, 0x29, 0x3b, 0x33, 0xdf, 0x7c, 0x33, 0xdf, 0xcc, 0xc4, 0xe0, + 0x3e, 0xe5, 0x29, 0xe5, 0x84, 0x7b, 0x31, 0x4a, 0x53, 0x2f, 0xa3, 0x34, 0xe9, 0xa4, 0x34, 0xc2, + 0x09, 0xf7, 0xb8, 0x40, 0x41, 0x82, 0xf9, 0x3b, 0x94, 0x9d, 0x78, 0xf6, 0x24, 0xc2, 0xcd, 0x18, + 0x15, 0xd4, 0xbc, 0xa5, 0x53, 0x5d, 0x99, 0xea, 0xca, 0x40, 0x99, 0xe9, 0x1e, 0xc3, 0xdd, 0xad, + 0xa5, 0x00, 0x0b, 0xb4, 0x34, 0x3f, 0x17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e2, 0xb0, 0x80, 0xd7, 0xff, 0x98, 0xf4, 0x08, 0xd6, 0xf1, 0x9b, 0xda, 0xb3, 0x5e, + 0x3a, 0xcc, 0xd7, 0x60, 0xee, 0x34, 0xa6, 0x17, 0xd2, 0x81, 0x60, 0x34, 0x49, 0x30, 0xb3, 0xa6, + 0xd4, 0xd8, 0x6f, 0x0c, 0x0b, 0xd8, 0xd2, 0xcc, 0xff, 0x82, 0x3a, 0xfe, 0xd5, 0x53, 0xc4, 0x6b, + 0x47, 0x91, 0x95, 0xcb, 0x1f, 0x76, 0x61, 0xed, 0xd3, 0x2e, 0xac, 0x7d, 0xfb, 0xda, 0x99, 0x90, + 0xab, 0x79, 0xd4, 0x7d, 0xb9, 0x77, 0x60, 0x1b, 0xfb, 0x07, 0xb6, 0xf1, 0xeb, 0xc0, 0x36, 0x3e, + 0x1e, 0xda, 0xb5, 0xfd, 0x43, 0xbb, 0xf6, 0xfd, 0xd0, 0xae, 0xbd, 0x58, 0x3d, 0x31, 0x17, 0x7d, + 0x75, 0x9d, 0x04, 0x05, 0xbc, 0x32, 0xbc, 0xad, 0xa5, 0x65, 0x6f, 0xfb, 0xac, 0x2f, 0x59, 0x30, + 0xa9, 0xfe, 0xdc, 0xcb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xeb, 0xf7, 0x52, 0xb8, 0xf7, 0x04, + 0x00, 0x00, } func (m *PoolParams) Marshal() (dAtA []byte, err error) { @@ -249,10 +250,10 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x42 } - if len(m.ScalingFactor) > 0 { - dAtA2 := make([]byte, len(m.ScalingFactor)*10) + if len(m.ScalingFactors) > 0 { + dAtA2 := make([]byte, len(m.ScalingFactors)*10) var j1 int - for _, num := range m.ScalingFactor { + for _, num := range m.ScalingFactors { for num >= 1<<7 { dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 @@ -374,9 +375,9 @@ func (m *Pool) Size() (n int) { n += 1 + l + sovStableswapPool(uint64(l)) } } - if len(m.ScalingFactor) > 0 { + if len(m.ScalingFactors) > 0 { l = 0 - for _, e := range m.ScalingFactor { + for _, e := range m.ScalingFactors { l += sovStableswapPool(uint64(e)) } n += 1 + sovStableswapPool(uint64(l)) + l @@ -741,7 +742,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { break } } - m.ScalingFactor = append(m.ScalingFactor, v) + m.ScalingFactors = append(m.ScalingFactors, v) } else if wireType == 2 { var packedLen int for shift := uint(0); ; shift += 7 { @@ -776,8 +777,8 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } } elementCount = count - if elementCount != 0 && len(m.ScalingFactor) == 0 { - m.ScalingFactor = make([]uint64, 0, elementCount) + if elementCount != 0 && len(m.ScalingFactors) == 0 { + m.ScalingFactors = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -795,10 +796,10 @@ func (m *Pool) Unmarshal(dAtA []byte) error { break } } - m.ScalingFactor = append(m.ScalingFactor, v) + m.ScalingFactors = append(m.ScalingFactors, v) } } else { - return fmt.Errorf("proto: wrong wireType = %d for field ScalingFactor", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScalingFactors", wireType) } case 8: if wireType != 2 { diff --git a/x/gamm/pool-models/stableswap/tx.pb.go b/x/gamm/pool-models/stableswap/tx.pb.go index 1a1386999e2..a4a3ce1612f 100644 --- a/x/gamm/pool-models/stableswap/tx.pb.go +++ b/x/gamm/pool-models/stableswap/tx.pb.go @@ -274,46 +274,46 @@ func init() { } var fileDescriptor_46b7c8a0f24de97c = []byte{ - // 623 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0x9b, 0x7c, 0xf9, 0xc4, 0x54, 0x80, 0xb0, 0xa2, 0xd6, 0x0d, 0x92, 0x1d, 0x0c, 0x8b, - 0x14, 0xa8, 0x87, 0x06, 0x09, 0x09, 0x76, 0x75, 0x50, 0x51, 0x05, 0x91, 0x8a, 0x2b, 0x36, 0xb0, - 0x08, 0x63, 0x7b, 0x6a, 0x06, 0x6c, 0x8f, 0xf1, 0x4c, 0xd2, 0x66, 0xc9, 0x1b, 0xf0, 0x18, 0x88, - 0x77, 0x60, 0xc3, 0x02, 0x75, 0xd9, 0x25, 0x2b, 0x83, 0x92, 0x37, 0xc8, 0x8e, 0x1d, 0xb2, 0xc7, - 0xf9, 0x93, 0x92, 0xb6, 0x41, 0x5d, 0x79, 0x7c, 0xe7, 0xdc, 0x73, 0xee, 0x3d, 0x77, 0x66, 0xc0, - 0x7d, 0xca, 0x02, 0xca, 0x08, 0x83, 0x1e, 0x0a, 0x02, 0x18, 0x51, 0xea, 0x6f, 0x05, 0xd4, 0xc5, - 0x3e, 0x83, 0x8c, 0x23, 0xdb, 0xc7, 0xec, 0x08, 0x45, 0x90, 0x1f, 0x1b, 0x51, 0x4c, 0x39, 0x95, - 0xef, 0xe6, 0x68, 0x23, 0x45, 0x1b, 0x29, 0x5a, 0x80, 0x8d, 0x09, 0xd8, 0xe8, 0x6e, 0xdb, 0x98, - 0xa3, 0xed, 0xaa, 0xea, 0x64, 0x60, 0x68, 0x23, 0x86, 0x61, 0x1e, 0x84, 0x0e, 0x25, 0xa1, 0xe0, - 0xaa, 0x56, 0x3c, 0xea, 0xd1, 0x6c, 0x09, 0xd3, 0x55, 0x1e, 0x7d, 0x7c, 0x91, 0x7a, 0x26, 0xcb, - 0x76, 0x8a, 0x10, 0xa9, 0xfa, 0xb7, 0x12, 0x58, 0x6f, 0x31, 0xaf, 0x19, 0x63, 0xc4, 0xf1, 0xc1, - 0x18, 0xb2, 0x4f, 0xa9, 0x2f, 0x6f, 0x82, 0x32, 0xc3, 0xa1, 0x8b, 0x63, 0x45, 0xaa, 0x49, 0xf5, - 0x2b, 0xe6, 0x8d, 0x61, 0xa2, 0x5d, 0xed, 0xa1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, 0x3f, 0x07, 0x6a, 0xe1, 0xf5, 0xce, 0xd4, 0x9b, 0x90, 0x4b, 0x6f, 0xf9, - 0xc8, 0x66, 0xa3, 0x1f, 0xd8, 0xdd, 0x6e, 0xc0, 0xe3, 0xb3, 0x1e, 0x5a, 0xbb, 0x9c, 0xbd, 0xac, - 0x0f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x50, 0xb6, 0xbb, 0x26, 0x06, 0x00, 0x00, + // 622 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6f, 0xd3, 0x30, + 0x14, 0x6f, 0xd6, 0x52, 0x84, 0x27, 0x40, 0x44, 0xd5, 0x96, 0x15, 0x29, 0x29, 0x81, 0x43, 0x07, + 0x2c, 0x66, 0x9b, 0x84, 0x04, 0xb7, 0xa5, 0x68, 0x68, 0x82, 0x4a, 0x23, 0x13, 0x17, 0x38, 0x14, + 0x27, 0xf1, 0x82, 0x21, 0x89, 0x43, 0xec, 0x76, 0xeb, 0x91, 0x6f, 0xc0, 0xc7, 0x40, 0x7c, 0x07, + 0x2e, 0x1c, 0xd0, 0x8e, 0x3b, 0x72, 0x0a, 0xa8, 0xfd, 0x06, 0xbd, 0x71, 0x43, 0x89, 0xd3, 0x7f, + 0x52, 0xbb, 0xad, 0x68, 0xa7, 0x38, 0xcf, 0xbf, 0xf7, 0xfb, 0xbd, 0xf7, 0x7b, 0xb6, 0xc1, 0x43, + 0xca, 0x02, 0xca, 0x08, 0x83, 0x1e, 0x0a, 0x02, 0x18, 0x51, 0xea, 0x6f, 0x04, 0xd4, 0xc5, 0x3e, + 0x83, 0x8c, 0x23, 0xdb, 0xc7, 0xec, 0x08, 0x45, 0x90, 0x1f, 0x1b, 0x51, 0x4c, 0x39, 0x95, 0xef, + 0xe7, 0x68, 0x23, 0x45, 0x1b, 0x29, 0x5a, 0x80, 0x8d, 0x31,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0x2c, 0xfe, 0xff, 0x04, 0xf5, 0x07, 0x60, 0xfd, 0xdc, + 0x1e, 0x86, 0xb6, 0x6c, 0xfd, 0x5d, 0x02, 0xc5, 0x26, 0xf3, 0xe4, 0xaf, 0x12, 0xa8, 0xcc, 0xbc, + 0x7e, 0x8d, 0x45, 0xae, 0xcf, 0x9c, 0x21, 0x54, 0x5f, 0x5c, 0x02, 0xc9, 0x68, 0x92, 0x3f, 0x25, + 0xa0, 0x9e, 0x33, 0xa1, 0xe6, 0x82, 0x7a, 0x67, 0xd3, 0x55, 0x5f, 0x5f, 0x2a, 0xdd, 0xb0, 0x11, + 0xf3, 0xed, 0x49, 0x4f, 0x95, 0x4e, 0x7b, 0xaa, 0xf4, 0xa7, 0xa7, 0x4a, 0x5f, 0xfa, 0x6a, 0xe1, + 0xb4, 0xaf, 0x16, 0x7e, 0xf5, 0xd5, 0xc2, 0x9b, 0x9d, 0x89, 0x37, 0x21, 0x97, 0xde, 0xf0, 0x91, + 0xcd, 0x86, 0x3f, 0xb0, 0xb3, 0xb9, 0x0d, 0x8f, 0xcf, 0x7a, 0x68, 0xed, 0x72, 0xf6, 0xb2, 0x6e, + 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xc6, 0x5b, 0x3f, 0xf5, 0x26, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/gamm/pool-models/stableswap/util_test.go b/x/gamm/pool-models/stableswap/util_test.go index 61d9dc47c05..6c05cce8c10 100644 --- a/x/gamm/pool-models/stableswap/util_test.go +++ b/x/gamm/pool-models/stableswap/util_test.go @@ -6,14 +6,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func createTestPool(t *testing.T, poolLiquidity sdk.Coins, swapFee, exitFee sdk.Dec, scalingFactors []uint64) types.PoolI { pool, err := NewStableswapPool(1, PoolParams{ SwapFee: swapFee, ExitFee: exitFee, - }, poolLiquidity, scalingFactors, "", "") + }, poolLiquidity, applyScalingFactorMultiplier(scalingFactors), "", "") require.NoError(t, err) diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index 7ceebefe190..12052ae1c63 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -8,11 +8,11 @@ import ( legacysimulationtype "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" - balancertypes "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + balancertypes "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var PoolCreationFee = sdk.NewInt64Coin("stake", 10_000_000) diff --git a/x/gamm/simulation/sim_setup.go b/x/gamm/simulation/sim_setup.go index c7a3497aa0f..96b91eb920c 100644 --- a/x/gamm/simulation/sim_setup.go +++ b/x/gamm/simulation/sim_setup.go @@ -1,8 +1,8 @@ package gammsimulation import ( - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - "github.com/osmosis-labs/osmosis/v12/x/gamm/keeper" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" ) func DefaultActions(keeper keeper.Keeper) []simtypes.Action { diff --git a/x/gamm/types/constants.go b/x/gamm/types/constants.go index 4152661d7a8..823548129a8 100644 --- a/x/gamm/types/constants.go +++ b/x/gamm/types/constants.go @@ -14,7 +14,9 @@ const ( SigFigsExponent = 8 BalancerGasFeeForSwap = 10_000 - StableswapMaxScaledAmtPerAsset = 10_000_000_000 + StableswapMinScaledAmtPerAsset = 1 + // We keep this multiplier at 1, but can increase if needed in the unlikely scenario where default scaling factors of 1 cannot accommodate enough assets + ScalingFactorMultiplier = 1 ) var ( @@ -31,4 +33,7 @@ var ( // MultihopSwapFeeMultiplierForOsmoPools if a swap fees multiplier for trades consists of just two OSMO pools during a single transaction. MultihopSwapFeeMultiplierForOsmoPools = sdk.NewDecWithPrec(5, 1) // 0.5 + + // Maximum amount per asset after the application of scaling factors should be 10e34. + StableswapMaxScaledAmtPerAsset = sdk.NewDec(10).Power(34).TruncateInt() ) diff --git a/x/gamm/types/errors.go b/x/gamm/types/errors.go index ce1828e5982..5457f3ede84 100644 --- a/x/gamm/types/errors.go +++ b/x/gamm/types/errors.go @@ -20,7 +20,7 @@ var ( ErrPoolAlreadyExist = sdkerrors.Register(ModuleName, 2, "pool already exist") ErrPoolLocked = sdkerrors.Register(ModuleName, 3, "pool is locked") ErrTooFewPoolAssets = sdkerrors.Register(ModuleName, 4, "pool should have at least 2 assets, as they must be swapping between at least two assets") - ErrTooManyPoolAssets = sdkerrors.Register(ModuleName, 5, "pool has too many assets (currently capped at 8 assets per pool)") + ErrTooManyPoolAssets = sdkerrors.Register(ModuleName, 5, "pool has too many assets (currently capped at 8 assets for both balancer and stableswap)") ErrLimitMaxAmount = sdkerrors.Register(ModuleName, 6, "calculated amount is larger than max amount") ErrLimitMinAmount = sdkerrors.Register(ModuleName, 7, "calculated amount is lesser than min amount") ErrInvalidMathApprox = sdkerrors.Register(ModuleName, 8, "invalid calculated result") @@ -48,9 +48,10 @@ var ( ErrNotImplemented = sdkerrors.Register(ModuleName, 60, "function not implemented") - ErrNotStableSwapPool = sdkerrors.Register(ModuleName, 61, "not stableswap pool") - ErrInvalidStableswapScalingFactors = sdkerrors.Register(ModuleName, 62, "length between liquidity and scaling factors mismatch") - ErrNotScalingFactorGovernor = sdkerrors.Register(ModuleName, 63, "not scaling factor governor") - ErrInvalidScalingFactors = sdkerrors.Register(ModuleName, 64, "invalid scaling factor") - ErrHitMaxScaledAssets = sdkerrors.Register(ModuleName, 65, "post-scaled pool assets can not exceed 10B") + ErrNotStableSwapPool = sdkerrors.Register(ModuleName, 61, "not stableswap pool") + ErrInvalidScalingFactorLength = sdkerrors.Register(ModuleName, 62, "pool liquidity and scaling factors must have same length") + ErrNotScalingFactorGovernor = sdkerrors.Register(ModuleName, 63, "not scaling factor governor") + ErrInvalidScalingFactors = sdkerrors.Register(ModuleName, 64, "scaling factors cannot be 0 or use more than 63 bits") + ErrHitMaxScaledAssets = sdkerrors.Register(ModuleName, 65, "post-scaled pool assets can not exceed 10^34") + ErrHitMinScaledAssets = sdkerrors.Register(ModuleName, 66, "post-scaled pool assets can not be less than 1") ) diff --git a/x/gamm/types/expected_keepers.go b/x/gamm/types/expected_keepers.go index 14cfd72fdf5..ba0ddc0ab28 100644 --- a/x/gamm/types/expected_keepers.go +++ b/x/gamm/types/expected_keepers.go @@ -41,3 +41,7 @@ type BankKeeper interface { type CommunityPoolKeeper interface { FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error } + +type PoolIncentivesKeeper interface { + IsPoolIncentivized(ctx sdk.Context, poolId uint64) bool +} diff --git a/x/gamm/types/genesis.pb.go b/x/gamm/types/genesis.pb.go index 7b9500b26e6..cae16eab32e 100644 --- a/x/gamm/types/genesis.pb.go +++ b/x/gamm/types/genesis.pb.go @@ -147,29 +147,29 @@ var fileDescriptor_5a324eb7f1dd793e = []byte{ // 401 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xcf, 0xaa, 0xd3, 0x40, 0x18, 0xc5, 0x33, 0xde, 0x7b, 0x0b, 0xe6, 0x8a, 0x7f, 0x42, 0x17, 0xb9, 0x17, 0x49, 0x4b, 0x56, - 0xd9, 0x74, 0xc6, 0x56, 0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5f, 0x27, 0x17, 0x4b, 0x80, 0xea, 0x79, + 0x62, 0x68, 0x2f, 0x72, 0xef, 0x73, 0xb6, 0x95, 0xa9, 0xce, 0xc7, 0xd7, 0x75, 0xc6, 0x5a, 0xff, + 0xd6, 0x18, 0x45, 0xe7, 0xc9, 0x5d, 0x75, 0xae, 0xd8, 0x57, 0xfa, 0xd4, 0x9b, 0xbb, 0x83, 0x46, + 0x37, 0xe2, 0x9f, 0x8d, 0x51, 0x74, 0x79, 0xf3, 0x10, 0xff, 0xef, 0x2b, 0x61, 0xd3, 0x5a, 0x7c, + 0xae, 0xae, 0x9f, 0x58, 0x45, 0xfc, 0x62, 0x77, 0x0c, 0xd0, 0xfe, 0x18, 0xa0, 0x9f, 0xc7, 0x00, + 0x7d, 0x38, 0x05, 0xce, 0xfe, 0x14, 0x38, 0xdf, 0x4f, 0x81, 0xf3, 0xe6, 0xd1, 0x5f, 0x15, 0x58, + 0xbf, 0x49, 0x45, 0x33, 0xd1, 0x0f, 0x64, 0x33, 0x9d, 0x91, 0xad, 0xf9, 0x59, 0x74, 0x21, 0xd9, + 0x40, 0xdf, 0x68, 0xf6, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x43, 0x18, 0x92, 0x53, 0x49, 0x02, 0x00, 0x00, } diff --git a/x/gamm/types/msgs_test.go b/x/gamm/types/msgs_test.go index e988795ba1e..325aa5f0f8c 100644 --- a/x/gamm/types/msgs_test.go +++ b/x/gamm/types/msgs_test.go @@ -7,10 +7,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - appParams "github.com/osmosis-labs/osmosis/v12/app/params" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" ) func TestMsgSwapExactAmountIn(t *testing.T) { @@ -956,6 +957,14 @@ func TestAuthzMsg(t *testing.T) { TokenInMaxAmount: sdk.NewInt(1), }, }, + { + name: "MsgCreateStableswapPool", + gammMsg: &stableswap.MsgCreateStableswapPool{ + Sender: addr1, + PoolParams: &stableswap.PoolParams{}, + InitialPoolLiquidity: sdk.NewCoins(coin), + }, + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { diff --git a/x/gamm/types/params.go b/x/gamm/types/params.go index 426840257b3..82f3f04353e 100644 --- a/x/gamm/types/params.go +++ b/x/gamm/types/params.go @@ -3,7 +3,7 @@ package types import ( "fmt" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" diff --git a/x/gamm/types/query.pb.go b/x/gamm/types/query.pb.go index 12889076df2..0cadd1e2c48 100644 --- a/x/gamm/types/query.pb.go +++ b/x/gamm/types/query.pb.go @@ -392,6 +392,198 @@ func (m *QueryPoolTypeResponse) GetPoolType() string { return "" } +// =============================== CalcJoinPoolShares +type QueryCalcJoinPoolSharesRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokensIn github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=tokens_in,json=tokensIn,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_in"` +} + +func (m *QueryCalcJoinPoolSharesRequest) Reset() { *m = QueryCalcJoinPoolSharesRequest{} } +func (m *QueryCalcJoinPoolSharesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCalcJoinPoolSharesRequest) ProtoMessage() {} +func (*QueryCalcJoinPoolSharesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{8} +} +func (m *QueryCalcJoinPoolSharesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCalcJoinPoolSharesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCalcJoinPoolSharesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCalcJoinPoolSharesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCalcJoinPoolSharesRequest.Merge(m, src) +} +func (m *QueryCalcJoinPoolSharesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCalcJoinPoolSharesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCalcJoinPoolSharesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCalcJoinPoolSharesRequest proto.InternalMessageInfo + +func (m *QueryCalcJoinPoolSharesRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QueryCalcJoinPoolSharesRequest) GetTokensIn() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TokensIn + } + return nil +} + +type QueryCalcJoinPoolSharesResponse struct { + ShareOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_out_amount" yaml:"share_out_amount"` + TokensOut github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=tokens_out,json=tokensOut,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_out"` +} + +func (m *QueryCalcJoinPoolSharesResponse) Reset() { *m = QueryCalcJoinPoolSharesResponse{} } +func (m *QueryCalcJoinPoolSharesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCalcJoinPoolSharesResponse) ProtoMessage() {} +func (*QueryCalcJoinPoolSharesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{9} +} +func (m *QueryCalcJoinPoolSharesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCalcJoinPoolSharesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCalcJoinPoolSharesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCalcJoinPoolSharesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCalcJoinPoolSharesResponse.Merge(m, src) +} +func (m *QueryCalcJoinPoolSharesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCalcJoinPoolSharesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCalcJoinPoolSharesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCalcJoinPoolSharesResponse proto.InternalMessageInfo + +func (m *QueryCalcJoinPoolSharesResponse) GetTokensOut() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TokensOut + } + return nil +} + +// =============================== CalcExitPoolCoinsFromShares +type QueryCalcExitPoolCoinsFromSharesRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + ShareInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_in_amount"` +} + +func (m *QueryCalcExitPoolCoinsFromSharesRequest) Reset() { + *m = QueryCalcExitPoolCoinsFromSharesRequest{} +} +func (m *QueryCalcExitPoolCoinsFromSharesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCalcExitPoolCoinsFromSharesRequest) ProtoMessage() {} +func (*QueryCalcExitPoolCoinsFromSharesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{10} +} +func (m *QueryCalcExitPoolCoinsFromSharesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCalcExitPoolCoinsFromSharesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCalcExitPoolCoinsFromSharesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesRequest.Merge(m, src) +} +func (m *QueryCalcExitPoolCoinsFromSharesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCalcExitPoolCoinsFromSharesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesRequest proto.InternalMessageInfo + +func (m *QueryCalcExitPoolCoinsFromSharesRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +type QueryCalcExitPoolCoinsFromSharesResponse struct { + TokensOut github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=tokens_out,json=tokensOut,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_out"` +} + +func (m *QueryCalcExitPoolCoinsFromSharesResponse) Reset() { + *m = QueryCalcExitPoolCoinsFromSharesResponse{} +} +func (m *QueryCalcExitPoolCoinsFromSharesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCalcExitPoolCoinsFromSharesResponse) ProtoMessage() {} +func (*QueryCalcExitPoolCoinsFromSharesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{11} +} +func (m *QueryCalcExitPoolCoinsFromSharesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCalcExitPoolCoinsFromSharesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCalcExitPoolCoinsFromSharesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesResponse.Merge(m, src) +} +func (m *QueryCalcExitPoolCoinsFromSharesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCalcExitPoolCoinsFromSharesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCalcExitPoolCoinsFromSharesResponse proto.InternalMessageInfo + +func (m *QueryCalcExitPoolCoinsFromSharesResponse) GetTokensOut() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TokensOut + } + return nil +} + // =============================== PoolParams type QueryPoolParamsRequest struct { PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` @@ -401,7 +593,7 @@ func (m *QueryPoolParamsRequest) Reset() { *m = QueryPoolParamsRequest{} func (m *QueryPoolParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPoolParamsRequest) ProtoMessage() {} func (*QueryPoolParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{8} + return fileDescriptor_d9a717df9ca609ef, []int{12} } func (m *QueryPoolParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -445,7 +637,7 @@ func (m *QueryPoolParamsResponse) Reset() { *m = QueryPoolParamsResponse func (m *QueryPoolParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPoolParamsResponse) ProtoMessage() {} func (*QueryPoolParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{9} + return fileDescriptor_d9a717df9ca609ef, []int{13} } func (m *QueryPoolParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -490,7 +682,7 @@ func (m *QueryTotalPoolLiquidityRequest) Reset() { *m = QueryTotalPoolLi func (m *QueryTotalPoolLiquidityRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalPoolLiquidityRequest) ProtoMessage() {} func (*QueryTotalPoolLiquidityRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{10} + return fileDescriptor_d9a717df9ca609ef, []int{14} } func (m *QueryTotalPoolLiquidityRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -534,7 +726,7 @@ func (m *QueryTotalPoolLiquidityResponse) Reset() { *m = QueryTotalPoolL func (m *QueryTotalPoolLiquidityResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalPoolLiquidityResponse) ProtoMessage() {} func (*QueryTotalPoolLiquidityResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{11} + return fileDescriptor_d9a717df9ca609ef, []int{15} } func (m *QueryTotalPoolLiquidityResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -579,7 +771,7 @@ func (m *QueryTotalSharesRequest) Reset() { *m = QueryTotalSharesRequest func (m *QueryTotalSharesRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalSharesRequest) ProtoMessage() {} func (*QueryTotalSharesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{12} + return fileDescriptor_d9a717df9ca609ef, []int{16} } func (m *QueryTotalSharesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -623,7 +815,7 @@ func (m *QueryTotalSharesResponse) Reset() { *m = QueryTotalSharesRespon func (m *QueryTotalSharesResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalSharesResponse) ProtoMessage() {} func (*QueryTotalSharesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{13} + return fileDescriptor_d9a717df9ca609ef, []int{17} } func (m *QueryTotalSharesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -659,8 +851,108 @@ func (m *QueryTotalSharesResponse) GetTotalShares() types1.Coin { return types1.Coin{} } +// =============================== CalcJoinPoolNoSwapShares +type QueryCalcJoinPoolNoSwapSharesRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokensIn github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=tokens_in,json=tokensIn,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_in"` +} + +func (m *QueryCalcJoinPoolNoSwapSharesRequest) Reset() { *m = QueryCalcJoinPoolNoSwapSharesRequest{} } +func (m *QueryCalcJoinPoolNoSwapSharesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCalcJoinPoolNoSwapSharesRequest) ProtoMessage() {} +func (*QueryCalcJoinPoolNoSwapSharesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{18} +} +func (m *QueryCalcJoinPoolNoSwapSharesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCalcJoinPoolNoSwapSharesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCalcJoinPoolNoSwapSharesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesRequest.Merge(m, src) +} +func (m *QueryCalcJoinPoolNoSwapSharesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCalcJoinPoolNoSwapSharesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesRequest proto.InternalMessageInfo + +func (m *QueryCalcJoinPoolNoSwapSharesRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QueryCalcJoinPoolNoSwapSharesRequest) GetTokensIn() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TokensIn + } + return nil +} + +type QueryCalcJoinPoolNoSwapSharesResponse struct { + TokensOut github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=tokens_out,json=tokensOut,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_out" yaml:"tokens_out"` + SharesOut github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=shares_out,json=sharesOut,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"shares_out"` +} + +func (m *QueryCalcJoinPoolNoSwapSharesResponse) Reset() { *m = QueryCalcJoinPoolNoSwapSharesResponse{} } +func (m *QueryCalcJoinPoolNoSwapSharesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCalcJoinPoolNoSwapSharesResponse) ProtoMessage() {} +func (*QueryCalcJoinPoolNoSwapSharesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{19} +} +func (m *QueryCalcJoinPoolNoSwapSharesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCalcJoinPoolNoSwapSharesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCalcJoinPoolNoSwapSharesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesResponse.Merge(m, src) +} +func (m *QueryCalcJoinPoolNoSwapSharesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCalcJoinPoolNoSwapSharesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCalcJoinPoolNoSwapSharesResponse proto.InternalMessageInfo + +func (m *QueryCalcJoinPoolNoSwapSharesResponse) GetTokensOut() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TokensOut + } + return nil +} + // QuerySpotPriceRequest defines the gRPC request structure for a SpotPrice // query. +// +// Deprecated: Do not use. type QuerySpotPriceRequest struct { PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` BaseAssetDenom string `protobuf:"bytes,2,opt,name=base_asset_denom,json=baseAssetDenom,proto3" json:"base_asset_denom,omitempty" yaml:"base_asset_denom"` @@ -671,7 +963,7 @@ func (m *QuerySpotPriceRequest) Reset() { *m = QuerySpotPriceRequest{} } func (m *QuerySpotPriceRequest) String() string { return proto.CompactTextString(m) } func (*QuerySpotPriceRequest) ProtoMessage() {} func (*QuerySpotPriceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{14} + return fileDescriptor_d9a717df9ca609ef, []int{20} } func (m *QuerySpotPriceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -721,25 +1013,24 @@ func (m *QuerySpotPriceRequest) GetQuoteAssetDenom() string { return "" } -// QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice -// query. -type QuerySpotPriceResponse struct { - // String of the Dec. Ex) 10.203uatom - SpotPrice string `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3" json:"spot_price,omitempty" yaml:"spot_price"` +type QueryPoolsWithFilterRequest struct { + MinLiquidity github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=min_liquidity,json=minLiquidity,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"min_liquidity" yaml:"min_liquidity"` + PoolType string `protobuf:"bytes,2,opt,name=pool_type,json=poolType,proto3" json:"pool_type,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QuerySpotPriceResponse) Reset() { *m = QuerySpotPriceResponse{} } -func (m *QuerySpotPriceResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySpotPriceResponse) ProtoMessage() {} -func (*QuerySpotPriceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{15} +func (m *QueryPoolsWithFilterRequest) Reset() { *m = QueryPoolsWithFilterRequest{} } +func (m *QueryPoolsWithFilterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolsWithFilterRequest) ProtoMessage() {} +func (*QueryPoolsWithFilterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{21} } -func (m *QuerySpotPriceResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPoolsWithFilterRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySpotPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPoolsWithFilterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySpotPriceResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPoolsWithFilterRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -749,45 +1040,57 @@ func (m *QuerySpotPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *QuerySpotPriceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySpotPriceResponse.Merge(m, src) +func (m *QueryPoolsWithFilterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolsWithFilterRequest.Merge(m, src) } -func (m *QuerySpotPriceResponse) XXX_Size() int { +func (m *QueryPoolsWithFilterRequest) XXX_Size() int { return m.Size() } -func (m *QuerySpotPriceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySpotPriceResponse.DiscardUnknown(m) +func (m *QueryPoolsWithFilterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolsWithFilterRequest.DiscardUnknown(m) } -var xxx_messageInfo_QuerySpotPriceResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPoolsWithFilterRequest proto.InternalMessageInfo -func (m *QuerySpotPriceResponse) GetSpotPrice() string { +func (m *QueryPoolsWithFilterRequest) GetMinLiquidity() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.SpotPrice + return m.MinLiquidity + } + return nil +} + +func (m *QueryPoolsWithFilterRequest) GetPoolType() string { + if m != nil { + return m.PoolType } return "" } -// =============================== EstimateSwapExactAmountIn -type QuerySwapExactAmountInRequest struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - TokenIn string `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty" yaml:"token_in"` - Routes []SwapAmountInRoute `protobuf:"bytes,4,rep,name=routes,proto3" json:"routes" yaml:"routes"` +func (m *QueryPoolsWithFilterRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func (m *QuerySwapExactAmountInRequest) Reset() { *m = QuerySwapExactAmountInRequest{} } -func (m *QuerySwapExactAmountInRequest) String() string { return proto.CompactTextString(m) } -func (*QuerySwapExactAmountInRequest) ProtoMessage() {} -func (*QuerySwapExactAmountInRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{16} +type QueryPoolsWithFilterResponse struct { + Pools []*types.Any `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QuerySwapExactAmountInRequest) XXX_Unmarshal(b []byte) error { + +func (m *QueryPoolsWithFilterResponse) Reset() { *m = QueryPoolsWithFilterResponse{} } +func (m *QueryPoolsWithFilterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPoolsWithFilterResponse) ProtoMessage() {} +func (*QueryPoolsWithFilterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{22} +} +func (m *QueryPoolsWithFilterResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySwapExactAmountInRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPoolsWithFilterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySwapExactAmountInRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPoolsWithFilterResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -797,28 +1100,133 @@ func (m *QuerySwapExactAmountInRequest) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QuerySwapExactAmountInRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySwapExactAmountInRequest.Merge(m, src) +func (m *QueryPoolsWithFilterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolsWithFilterResponse.Merge(m, src) } -func (m *QuerySwapExactAmountInRequest) XXX_Size() int { +func (m *QueryPoolsWithFilterResponse) XXX_Size() int { return m.Size() } -func (m *QuerySwapExactAmountInRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySwapExactAmountInRequest.DiscardUnknown(m) +func (m *QueryPoolsWithFilterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolsWithFilterResponse.DiscardUnknown(m) } -var xxx_messageInfo_QuerySwapExactAmountInRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPoolsWithFilterResponse proto.InternalMessageInfo -func (m *QuerySwapExactAmountInRequest) GetSender() string { +func (m *QueryPoolsWithFilterResponse) GetPools() []*types.Any { if m != nil { - return m.Sender + return m.Pools } - return "" + return nil } -func (m *QuerySwapExactAmountInRequest) GetPoolId() uint64 { +func (m *QueryPoolsWithFilterResponse) GetPagination() *query.PageResponse { if m != nil { - return m.PoolId + return m.Pagination + } + return nil +} + +// QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice +// query. +// +// Deprecated: Do not use. +type QuerySpotPriceResponse struct { + // String of the Dec. Ex) 10.203uatom + SpotPrice string `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3" json:"spot_price,omitempty" yaml:"spot_price"` +} + +func (m *QuerySpotPriceResponse) Reset() { *m = QuerySpotPriceResponse{} } +func (m *QuerySpotPriceResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySpotPriceResponse) ProtoMessage() {} +func (*QuerySpotPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{23} +} +func (m *QuerySpotPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpotPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpotPriceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySpotPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpotPriceResponse.Merge(m, src) +} +func (m *QuerySpotPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySpotPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpotPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpotPriceResponse proto.InternalMessageInfo + +func (m *QuerySpotPriceResponse) GetSpotPrice() string { + if m != nil { + return m.SpotPrice + } + return "" +} + +// =============================== EstimateSwapExactAmountIn +type QuerySwapExactAmountInRequest struct { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenIn string `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty" yaml:"token_in"` + Routes []SwapAmountInRoute `protobuf:"bytes,4,rep,name=routes,proto3" json:"routes" yaml:"routes"` +} + +func (m *QuerySwapExactAmountInRequest) Reset() { *m = QuerySwapExactAmountInRequest{} } +func (m *QuerySwapExactAmountInRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySwapExactAmountInRequest) ProtoMessage() {} +func (*QuerySwapExactAmountInRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d9a717df9ca609ef, []int{24} +} +func (m *QuerySwapExactAmountInRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySwapExactAmountInRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySwapExactAmountInRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySwapExactAmountInRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySwapExactAmountInRequest.Merge(m, src) +} +func (m *QuerySwapExactAmountInRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySwapExactAmountInRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySwapExactAmountInRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySwapExactAmountInRequest proto.InternalMessageInfo + +func (m *QuerySwapExactAmountInRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *QuerySwapExactAmountInRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId } return 0 } @@ -845,7 +1253,7 @@ func (m *QuerySwapExactAmountInResponse) Reset() { *m = QuerySwapExactAm func (m *QuerySwapExactAmountInResponse) String() string { return proto.CompactTextString(m) } func (*QuerySwapExactAmountInResponse) ProtoMessage() {} func (*QuerySwapExactAmountInResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{17} + return fileDescriptor_d9a717df9ca609ef, []int{25} } func (m *QuerySwapExactAmountInResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -876,6 +1284,7 @@ var xxx_messageInfo_QuerySwapExactAmountInResponse proto.InternalMessageInfo // =============================== EstimateSwapExactAmountOut type QuerySwapExactAmountOutRequest struct { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` Routes []SwapAmountOutRoute `protobuf:"bytes,3,rep,name=routes,proto3" json:"routes" yaml:"routes"` @@ -886,7 +1295,7 @@ func (m *QuerySwapExactAmountOutRequest) Reset() { *m = QuerySwapExactAm func (m *QuerySwapExactAmountOutRequest) String() string { return proto.CompactTextString(m) } func (*QuerySwapExactAmountOutRequest) ProtoMessage() {} func (*QuerySwapExactAmountOutRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{18} + return fileDescriptor_d9a717df9ca609ef, []int{26} } func (m *QuerySwapExactAmountOutRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -951,7 +1360,7 @@ func (m *QuerySwapExactAmountOutResponse) Reset() { *m = QuerySwapExactA func (m *QuerySwapExactAmountOutResponse) String() string { return proto.CompactTextString(m) } func (*QuerySwapExactAmountOutResponse) ProtoMessage() {} func (*QuerySwapExactAmountOutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{19} + return fileDescriptor_d9a717df9ca609ef, []int{27} } func (m *QuerySwapExactAmountOutResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -987,7 +1396,7 @@ func (m *QueryTotalLiquidityRequest) Reset() { *m = QueryTotalLiquidityR func (m *QueryTotalLiquidityRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalLiquidityRequest) ProtoMessage() {} func (*QueryTotalLiquidityRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{20} + return fileDescriptor_d9a717df9ca609ef, []int{28} } func (m *QueryTotalLiquidityRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1024,7 +1433,7 @@ func (m *QueryTotalLiquidityResponse) Reset() { *m = QueryTotalLiquidity func (m *QueryTotalLiquidityResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalLiquidityResponse) ProtoMessage() {} func (*QueryTotalLiquidityResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{21} + return fileDescriptor_d9a717df9ca609ef, []int{29} } func (m *QueryTotalLiquidityResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1069,13 +1478,21 @@ func init() { proto.RegisterType((*QueryNumPoolsResponse)(nil), "osmosis.gamm.v1beta1.QueryNumPoolsResponse") proto.RegisterType((*QueryPoolTypeRequest)(nil), "osmosis.gamm.v1beta1.QueryPoolTypeRequest") proto.RegisterType((*QueryPoolTypeResponse)(nil), "osmosis.gamm.v1beta1.QueryPoolTypeResponse") + proto.RegisterType((*QueryCalcJoinPoolSharesRequest)(nil), "osmosis.gamm.v1beta1.QueryCalcJoinPoolSharesRequest") + proto.RegisterType((*QueryCalcJoinPoolSharesResponse)(nil), "osmosis.gamm.v1beta1.QueryCalcJoinPoolSharesResponse") + proto.RegisterType((*QueryCalcExitPoolCoinsFromSharesRequest)(nil), "osmosis.gamm.v1beta1.QueryCalcExitPoolCoinsFromSharesRequest") + proto.RegisterType((*QueryCalcExitPoolCoinsFromSharesResponse)(nil), "osmosis.gamm.v1beta1.QueryCalcExitPoolCoinsFromSharesResponse") proto.RegisterType((*QueryPoolParamsRequest)(nil), "osmosis.gamm.v1beta1.QueryPoolParamsRequest") proto.RegisterType((*QueryPoolParamsResponse)(nil), "osmosis.gamm.v1beta1.QueryPoolParamsResponse") proto.RegisterType((*QueryTotalPoolLiquidityRequest)(nil), "osmosis.gamm.v1beta1.QueryTotalPoolLiquidityRequest") proto.RegisterType((*QueryTotalPoolLiquidityResponse)(nil), "osmosis.gamm.v1beta1.QueryTotalPoolLiquidityResponse") proto.RegisterType((*QueryTotalSharesRequest)(nil), "osmosis.gamm.v1beta1.QueryTotalSharesRequest") proto.RegisterType((*QueryTotalSharesResponse)(nil), "osmosis.gamm.v1beta1.QueryTotalSharesResponse") + proto.RegisterType((*QueryCalcJoinPoolNoSwapSharesRequest)(nil), "osmosis.gamm.v1beta1.QueryCalcJoinPoolNoSwapSharesRequest") + proto.RegisterType((*QueryCalcJoinPoolNoSwapSharesResponse)(nil), "osmosis.gamm.v1beta1.QueryCalcJoinPoolNoSwapSharesResponse") proto.RegisterType((*QuerySpotPriceRequest)(nil), "osmosis.gamm.v1beta1.QuerySpotPriceRequest") + proto.RegisterType((*QueryPoolsWithFilterRequest)(nil), "osmosis.gamm.v1beta1.QueryPoolsWithFilterRequest") + proto.RegisterType((*QueryPoolsWithFilterResponse)(nil), "osmosis.gamm.v1beta1.QueryPoolsWithFilterResponse") proto.RegisterType((*QuerySpotPriceResponse)(nil), "osmosis.gamm.v1beta1.QuerySpotPriceResponse") proto.RegisterType((*QuerySwapExactAmountInRequest)(nil), "osmosis.gamm.v1beta1.QuerySwapExactAmountInRequest") proto.RegisterType((*QuerySwapExactAmountInResponse)(nil), "osmosis.gamm.v1beta1.QuerySwapExactAmountInResponse") @@ -1088,94 +1505,120 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/query.proto", fileDescriptor_d9a717df9ca609ef) } var fileDescriptor_d9a717df9ca609ef = []byte{ - // 1382 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x97, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xc0, 0xb3, 0xa9, 0x93, 0xda, 0x13, 0x9a, 0x26, 0xd3, 0xb4, 0x75, 0x9d, 0xd6, 0x5b, 0x06, - 0xd1, 0xa4, 0x6d, 0xb2, 0xdb, 0xa4, 0xe9, 0xa5, 0x02, 0x4a, 0xdd, 0x26, 0x6d, 0x2a, 0x68, 0xc3, - 0xb6, 0x02, 0x01, 0x07, 0x6b, 0x93, 0x2c, 0xee, 0xaa, 0xf6, 0xce, 0xc6, 0x33, 0xdb, 0xd4, 0x42, - 0x15, 0x12, 0x42, 0x9c, 0x38, 0x20, 0x15, 0x38, 0x55, 0x82, 0x03, 0x07, 0xc4, 0x99, 0x03, 0xff, - 0x00, 0x52, 0x85, 0x84, 0x54, 0xc4, 0x05, 0x71, 0x30, 0xa8, 0xe1, 0xc0, 0xd9, 0xff, 0x00, 0x68, - 0x66, 0xde, 0x7e, 0xd8, 0xd9, 0xd8, 0x4e, 0x10, 0x12, 0xa7, 0xd8, 0xf3, 0xbe, 0x7e, 0xef, 0x63, - 0x3c, 0x2f, 0xe8, 0x24, 0x65, 0x35, 0xca, 0x5c, 0x66, 0x56, 0xec, 0x5a, 0xcd, 0xbc, 0x3f, 0xb7, - 0xea, 0x70, 0x7b, 0xce, 0xdc, 0x08, 0x9c, 0x7a, 0xc3, 0xf0, 0xeb, 0x94, 0x53, 0x3c, 0x01, 0x1a, - 0x86, 0xd0, 0x30, 0x40, 0xa3, 0x30, 0x51, 0xa1, 0x15, 0x2a, 0x15, 0x4c, 0xf1, 0x49, 0xe9, 0x16, - 0x4e, 0xa4, 0x7a, 0xe3, 0x0f, 0x40, 0x5c, 0x5c, 0x93,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0x45, 0x89, 0x7f, 0x09, 0xbf, - 0x9c, 0x8e, 0x1f, 0x83, 0x3b, 0x40, 0x6b, 0xb2, 0x4d, 0xdb, 0x2f, 0x3b, 0xc2, 0x19, 0x3c, 0x98, - 0x65, 0xd7, 0xc3, 0x3f, 0x6b, 0xa8, 0xb0, 0x43, 0x3e, 0xb7, 0x02, 0x8e, 0x77, 0xc1, 0x16, 0xaf, - 0x3c, 0x5d, 0x27, 0x7d, 0xe7, 0x0d, 0x81, 0x2c, 0xc9, 0x94, 0x5e, 0xc5, 0xaf, 0xfc, 0x8b, 0x94, - 0x68, 0xc0, 0x4b, 0x37, 0x9e, 0x3c, 0x2b, 0x6a, 0x4f, 0x9f, 0x15, 0xb5, 0x3f, 0x9e, 0x15, 0xb5, - 0x4f, 0xb7, 0x8a, 0x03, 0x4f, 0xb7, 0x8a, 0x03, 0xbf, 0x6e, 0x15, 0x07, 0xde, 0x39, 0x97, 0x78, - 0x89, 0x21, 0xc6, 0x6c, 0xd5, 0x5e, 0x65, 0x51, 0xc0, 0xfb, 0x73, 0xf3, 0xe6, 0x03, 0x15, 0x56, - 0xbe, 0xcb, 0xab, 0xc3, 0xf2, 0x9f, 0xcf, 0xf3, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xcb, - 0xa3, 0x26, 0x80, 0x12, 0x00, 0x00, + // 1795 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x4b, 0x6c, 0x1c, 0x49, + 0x19, 0x76, 0x8d, 0x1f, 0xeb, 0x29, 0xaf, 0x5f, 0xb5, 0x4e, 0x32, 0x19, 0x3b, 0x33, 0xa1, 0xd8, + 0xb5, 0xbd, 0x1b, 0xbb, 0x27, 0x7e, 0xac, 0x40, 0x86, 0xdd, 0xac, 0x9d, 0xb5, 0xe3, 0xb1, 0xd8, + 0xb5, 0xe9, 0x44, 0x89, 0x80, 0xc3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35, 0x49, 0x7e, 0xdc, 0xad, 0x39, 0x04, 0x78, 0x4d, 0x06, 0xb8, 0x4a, 0xae, + 0xb4, 0x17, 0xa0, 0x79, 0x6c, 0x71, 0x15, 0xa0, 0x7a, 0x92, 0x51, 0xdf, 0x26, 0x11, 0xe7, 0x4f, + 0x11, 0xc6, 0xe1, 0x4b, 0x03, 0x99, 0x6b, 0x51, 0xb4, 0x15, 0xef, 0x1a, 0xc9, 0xf9, 0x36, 0xb5, + 0x01, 0xf4, 0xb2, 0x04, 0xad, 0x91, 0xb9, 0xf6, 0x40, 0xab, 0x67, 0x0c, 0xf2, 0x3b, 0x84, 0x49, + 0xed, 0x93, 0x43, 0xd3, 0x7a, 0x6a, 0xf8, 0xe2, 0xd1, 0xb4, 0x9e, 0x1a, 0xbf, 0x6b, 0xd0, 0x35, + 0x89, 0xfc, 0xab, 0x64, 0xa5, 0x3d, 0xe4, 0xaa, 0xeb, 0xca, 0x9f, 0x61, 0xeb, 0xfd, 0x25, 0xc2, + 0x43, 0x91, 0x07, 0x05, 0x32, 0xdf, 0x0a, 0x4a, 0x65, 0xc5, 0x68, 0xed, 0xaa, 0x03, 0xe4, 0x15, + 0x09, 0x79, 0x99, 0x2c, 0x76, 0x02, 0x59, 0xdd, 0x68, 0x45, 0x51, 0xc4, 0x83, 0xab, 0x02, 0x69, + 0xd6, 0xc8, 0xaa, 0xef, 0xbb, 0xc9, 0xb9, 0xf6, 0x94, 0x01, 0xe4, 0x97, 0x3a, 0xac, 0x08, 0x61, + 0xec, 0x3e, 0x8a, 0x21, 0xf2, 0x07, 0x84, 0xcf, 0xaf, 0xbb, 0xdc, 0x2a, 0x1a, 0xdc, 0xac, 0x99, + 0xbe, 0xc9, 0x52, 0x33, 0x10, 0x0d, 0x6e, 0x2b, 0xc9, 0xe5, 0xce, 0x8c, 0x20, 0x82, 0x75, 0x19, + 0xc1, 0x15, 0xf2, 0x51, 0xfd, 0x08, 0x22, 0x47, 0x10, 0xd0, 0x66, 0x22, 0x7d, 0x26, 0x3c, 0x86, + 0x7f, 0x44, 0x38, 0xd9, 0x20, 0x9e, 0x6d, 0x8f, 0x93, 0x0e, 0xb0, 0x85, 0x43, 0x7e, 0xd3, 0x62, + 0x6f, 0x3c, 0x13, 0xd3, 0x0d, 0x19, 0xd2, 0x27, 0xe4, 0xe3, 0xff, 0x22, 0x24, 0xe6, 0xf1, 0xb5, + 0xad, 0xe7, 0x2f, 0x53, 0xe8, 0xc5, 0xcb, 0x14, 0xfa, 0xdb, 0xcb, 0x14, 0xfa, 0xc1, 0xab, 0x54, + 0xcf, 0x8b, 0x57, 0xa9, 0x9e, 0x3f, 0xbf, 0x4a, 0xf5, 0x7c, 0xf3, 0x72, 0x64, 0xf6, 0x84, 0x3d, + 0xe6, 0x0b, 0xc6, 0xae, 0x1b, 0x6c, 0x78, 0x6f, 0x61, 0x29, 0x73, 0xac, 0xb6, 0x95, 0x93, 0xe8, + 0xee, 0x80, 0xbc, 0x29, 0x2f, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xce, 0x32, 0x25, 0xda, + 0x1b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1193,12 +1636,20 @@ type QueryClient interface { Pools(ctx context.Context, in *QueryPoolsRequest, opts ...grpc.CallOption) (*QueryPoolsResponse, error) NumPools(ctx context.Context, in *QueryNumPoolsRequest, opts ...grpc.CallOption) (*QueryNumPoolsResponse, error) TotalLiquidity(ctx context.Context, in *QueryTotalLiquidityRequest, opts ...grpc.CallOption) (*QueryTotalLiquidityResponse, error) + // PoolsWithFilter allows you to query specific pools with requested + // parameters + PoolsWithFilter(ctx context.Context, in *QueryPoolsWithFilterRequest, opts ...grpc.CallOption) (*QueryPoolsWithFilterResponse, error) // Per Pool gRPC Endpoints Pool(ctx context.Context, in *QueryPoolRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) // PoolType returns the type of the pool. // Returns "Balancer" as a string literal when the pool is a balancer pool. // Errors if the pool is failed to be type caseted. PoolType(ctx context.Context, in *QueryPoolTypeRequest, opts ...grpc.CallOption) (*QueryPoolTypeResponse, error) + // Simulates joining pool without a swap. Returns the amount of shares you'd + // get and tokens needed to provide + CalcJoinPoolNoSwapShares(ctx context.Context, in *QueryCalcJoinPoolNoSwapSharesRequest, opts ...grpc.CallOption) (*QueryCalcJoinPoolNoSwapSharesResponse, error) + CalcJoinPoolShares(ctx context.Context, in *QueryCalcJoinPoolSharesRequest, opts ...grpc.CallOption) (*QueryCalcJoinPoolSharesResponse, error) + CalcExitPoolCoinsFromShares(ctx context.Context, in *QueryCalcExitPoolCoinsFromSharesRequest, opts ...grpc.CallOption) (*QueryCalcExitPoolCoinsFromSharesResponse, error) PoolParams(ctx context.Context, in *QueryPoolParamsRequest, opts ...grpc.CallOption) (*QueryPoolParamsResponse, error) TotalPoolLiquidity(ctx context.Context, in *QueryTotalPoolLiquidityRequest, opts ...grpc.CallOption) (*QueryTotalPoolLiquidityResponse, error) TotalShares(ctx context.Context, in *QueryTotalSharesRequest, opts ...grpc.CallOption) (*QueryTotalSharesResponse, error) @@ -1245,6 +1696,15 @@ func (c *queryClient) TotalLiquidity(ctx context.Context, in *QueryTotalLiquidit return out, nil } +func (c *queryClient) PoolsWithFilter(ctx context.Context, in *QueryPoolsWithFilterRequest, opts ...grpc.CallOption) (*QueryPoolsWithFilterResponse, error) { + out := new(QueryPoolsWithFilterResponse) + err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/PoolsWithFilter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) Pool(ctx context.Context, in *QueryPoolRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) { out := new(QueryPoolResponse) err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/Pool", in, out, opts...) @@ -1263,6 +1723,33 @@ func (c *queryClient) PoolType(ctx context.Context, in *QueryPoolTypeRequest, op return out, nil } +func (c *queryClient) CalcJoinPoolNoSwapShares(ctx context.Context, in *QueryCalcJoinPoolNoSwapSharesRequest, opts ...grpc.CallOption) (*QueryCalcJoinPoolNoSwapSharesResponse, error) { + out := new(QueryCalcJoinPoolNoSwapSharesResponse) + err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CalcJoinPoolShares(ctx context.Context, in *QueryCalcJoinPoolSharesRequest, opts ...grpc.CallOption) (*QueryCalcJoinPoolSharesResponse, error) { + out := new(QueryCalcJoinPoolSharesResponse) + err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/CalcJoinPoolShares", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CalcExitPoolCoinsFromShares(ctx context.Context, in *QueryCalcExitPoolCoinsFromSharesRequest, opts ...grpc.CallOption) (*QueryCalcExitPoolCoinsFromSharesResponse, error) { + out := new(QueryCalcExitPoolCoinsFromSharesResponse) + err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) PoolParams(ctx context.Context, in *QueryPoolParamsRequest, opts ...grpc.CallOption) (*QueryPoolParamsResponse, error) { out := new(QueryPoolParamsResponse) err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/PoolParams", in, out, opts...) @@ -1290,6 +1777,7 @@ func (c *queryClient) TotalShares(ctx context.Context, in *QueryTotalSharesReque return out, nil } +// Deprecated: Do not use. func (c *queryClient) SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, opts ...grpc.CallOption) (*QuerySpotPriceResponse, error) { out := new(QuerySpotPriceResponse) err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/SpotPrice", in, out, opts...) @@ -1322,12 +1810,20 @@ type QueryServer interface { Pools(context.Context, *QueryPoolsRequest) (*QueryPoolsResponse, error) NumPools(context.Context, *QueryNumPoolsRequest) (*QueryNumPoolsResponse, error) TotalLiquidity(context.Context, *QueryTotalLiquidityRequest) (*QueryTotalLiquidityResponse, error) + // PoolsWithFilter allows you to query specific pools with requested + // parameters + PoolsWithFilter(context.Context, *QueryPoolsWithFilterRequest) (*QueryPoolsWithFilterResponse, error) // Per Pool gRPC Endpoints Pool(context.Context, *QueryPoolRequest) (*QueryPoolResponse, error) // PoolType returns the type of the pool. // Returns "Balancer" as a string literal when the pool is a balancer pool. // Errors if the pool is failed to be type caseted. PoolType(context.Context, *QueryPoolTypeRequest) (*QueryPoolTypeResponse, error) + // Simulates joining pool without a swap. Returns the amount of shares you'd + // get and tokens needed to provide + CalcJoinPoolNoSwapShares(context.Context, *QueryCalcJoinPoolNoSwapSharesRequest) (*QueryCalcJoinPoolNoSwapSharesResponse, error) + CalcJoinPoolShares(context.Context, *QueryCalcJoinPoolSharesRequest) (*QueryCalcJoinPoolSharesResponse, error) + CalcExitPoolCoinsFromShares(context.Context, *QueryCalcExitPoolCoinsFromSharesRequest) (*QueryCalcExitPoolCoinsFromSharesResponse, error) PoolParams(context.Context, *QueryPoolParamsRequest) (*QueryPoolParamsResponse, error) TotalPoolLiquidity(context.Context, *QueryTotalPoolLiquidityRequest) (*QueryTotalPoolLiquidityResponse, error) TotalShares(context.Context, *QueryTotalSharesRequest) (*QueryTotalSharesResponse, error) @@ -1352,12 +1848,24 @@ func (*UnimplementedQueryServer) NumPools(ctx context.Context, req *QueryNumPool func (*UnimplementedQueryServer) TotalLiquidity(ctx context.Context, req *QueryTotalLiquidityRequest) (*QueryTotalLiquidityResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalLiquidity not implemented") } +func (*UnimplementedQueryServer) PoolsWithFilter(ctx context.Context, req *QueryPoolsWithFilterRequest) (*QueryPoolsWithFilterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolsWithFilter not implemented") +} func (*UnimplementedQueryServer) Pool(ctx context.Context, req *QueryPoolRequest) (*QueryPoolResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Pool not implemented") } func (*UnimplementedQueryServer) PoolType(ctx context.Context, req *QueryPoolTypeRequest) (*QueryPoolTypeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PoolType not implemented") } +func (*UnimplementedQueryServer) CalcJoinPoolNoSwapShares(ctx context.Context, req *QueryCalcJoinPoolNoSwapSharesRequest) (*QueryCalcJoinPoolNoSwapSharesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CalcJoinPoolNoSwapShares not implemented") +} +func (*UnimplementedQueryServer) CalcJoinPoolShares(ctx context.Context, req *QueryCalcJoinPoolSharesRequest) (*QueryCalcJoinPoolSharesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CalcJoinPoolShares not implemented") +} +func (*UnimplementedQueryServer) CalcExitPoolCoinsFromShares(ctx context.Context, req *QueryCalcExitPoolCoinsFromSharesRequest) (*QueryCalcExitPoolCoinsFromSharesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CalcExitPoolCoinsFromShares not implemented") +} func (*UnimplementedQueryServer) PoolParams(ctx context.Context, req *QueryPoolParamsRequest) (*QueryPoolParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PoolParams not implemented") } @@ -1435,6 +1943,24 @@ func _Query_TotalLiquidity_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Query_PoolsWithFilter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolsWithFilterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolsWithFilter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.gamm.v1beta1.Query/PoolsWithFilter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolsWithFilter(ctx, req.(*QueryPoolsWithFilterRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_Pool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryPoolRequest) if err := dec(in); err != nil { @@ -1471,6 +1997,60 @@ func _Query_PoolType_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Query_CalcJoinPoolNoSwapShares_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCalcJoinPoolNoSwapSharesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CalcJoinPoolNoSwapShares(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CalcJoinPoolNoSwapShares(ctx, req.(*QueryCalcJoinPoolNoSwapSharesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CalcJoinPoolShares_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCalcJoinPoolSharesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CalcJoinPoolShares(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.gamm.v1beta1.Query/CalcJoinPoolShares", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CalcJoinPoolShares(ctx, req.(*QueryCalcJoinPoolSharesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CalcExitPoolCoinsFromShares_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCalcExitPoolCoinsFromSharesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CalcExitPoolCoinsFromShares(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CalcExitPoolCoinsFromShares(ctx, req.(*QueryCalcExitPoolCoinsFromSharesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_PoolParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryPoolParamsRequest) if err := dec(in); err != nil { @@ -1595,6 +2175,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TotalLiquidity", Handler: _Query_TotalLiquidity_Handler, }, + { + MethodName: "PoolsWithFilter", + Handler: _Query_PoolsWithFilter_Handler, + }, { MethodName: "Pool", Handler: _Query_Pool_Handler, @@ -1603,6 +2187,18 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PoolType", Handler: _Query_PoolType_Handler, }, + { + MethodName: "CalcJoinPoolNoSwapShares", + Handler: _Query_CalcJoinPoolNoSwapShares_Handler, + }, + { + MethodName: "CalcJoinPoolShares", + Handler: _Query_CalcJoinPoolShares_Handler, + }, + { + MethodName: "CalcExitPoolCoinsFromShares", + Handler: _Query_CalcExitPoolCoinsFromShares_Handler, + }, { MethodName: "PoolParams", Handler: _Query_PoolParams_Handler, @@ -1888,7 +2484,7 @@ func (m *QueryPoolTypeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryPoolParamsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryCalcJoinPoolSharesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1898,16 +2494,30 @@ func (m *QueryPoolParamsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPoolParamsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolSharesRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPoolParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolSharesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.TokensIn) > 0 { + for iNdEx := len(m.TokensIn) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokensIn[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } if m.PoolId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) i-- @@ -1916,7 +2526,7 @@ func (m *QueryPoolParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryPoolParamsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryCalcJoinPoolSharesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1926,32 +2536,44 @@ func (m *QueryPoolParamsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPoolParamsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolSharesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPoolParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolSharesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Params != nil { - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.TokensOut) > 0 { + for iNdEx := len(m.TokensOut) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokensOut[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0xa } + { + size := m.ShareOutAmount.Size() + i -= size + if _, err := m.ShareOutAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *QueryTotalPoolLiquidityRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryCalcExitPoolCoinsFromSharesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1961,16 +2583,26 @@ func (m *QueryTotalPoolLiquidityRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryTotalPoolLiquidityRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCalcExitPoolCoinsFromSharesRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryTotalPoolLiquidityRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCalcExitPoolCoinsFromSharesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + { + size := m.ShareInAmount.Size() + i -= size + if _, err := m.ShareInAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if m.PoolId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) i-- @@ -1979,7 +2611,7 @@ func (m *QueryTotalPoolLiquidityRequest) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryTotalPoolLiquidityResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryCalcExitPoolCoinsFromSharesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1989,20 +2621,20 @@ func (m *QueryTotalPoolLiquidityResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryTotalPoolLiquidityResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCalcExitPoolCoinsFromSharesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryTotalPoolLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCalcExitPoolCoinsFromSharesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Liquidity) > 0 { - for iNdEx := len(m.Liquidity) - 1; iNdEx >= 0; iNdEx-- { + if len(m.TokensOut) > 0 { + for iNdEx := len(m.TokensOut) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Liquidity[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.TokensOut[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2016,7 +2648,7 @@ func (m *QueryTotalPoolLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } -func (m *QueryTotalSharesRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPoolParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2026,12 +2658,12 @@ func (m *QueryTotalSharesRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryTotalSharesRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPoolParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryTotalSharesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPoolParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2044,7 +2676,7 @@ func (m *QueryTotalSharesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryTotalSharesResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPoolParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2054,30 +2686,32 @@ func (m *QueryTotalSharesResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryTotalSharesResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPoolParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryTotalSharesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPoolParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.TotalShares.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *QuerySpotPriceRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalPoolLiquidityRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2087,30 +2721,16 @@ func (m *QuerySpotPriceRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySpotPriceRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalPoolLiquidityRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySpotPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalPoolLiquidityRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.QuoteAssetDenom) > 0 { - i -= len(m.QuoteAssetDenom) - copy(dAtA[i:], m.QuoteAssetDenom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteAssetDenom))) - i-- - dAtA[i] = 0x1a - } - if len(m.BaseAssetDenom) > 0 { - i -= len(m.BaseAssetDenom) - copy(dAtA[i:], m.BaseAssetDenom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseAssetDenom))) - i-- - dAtA[i] = 0x12 - } if m.PoolId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) i-- @@ -2119,7 +2739,7 @@ func (m *QuerySpotPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QuerySpotPriceResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalPoolLiquidityResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2129,27 +2749,34 @@ func (m *QuerySpotPriceResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySpotPriceResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalPoolLiquidityResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySpotPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalPoolLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.SpotPrice) > 0 { - i -= len(m.SpotPrice) - copy(dAtA[i:], m.SpotPrice) - i = encodeVarintQuery(dAtA, i, uint64(len(m.SpotPrice))) - i-- - dAtA[i] = 0xa + if len(m.Liquidity) > 0 { + for iNdEx := len(m.Liquidity) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Liquidity[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } -func (m *QuerySwapExactAmountInRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalSharesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2159,53 +2786,25 @@ func (m *QuerySwapExactAmountInRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySwapExactAmountInRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalSharesRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySwapExactAmountInRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalSharesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Routes) > 0 { - for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.TokenIn) > 0 { - i -= len(m.TokenIn) - copy(dAtA[i:], m.TokenIn) - i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenIn))) - i-- - dAtA[i] = 0x1a - } if m.PoolId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) i-- - dAtA[i] = 0x10 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QuerySwapExactAmountInResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalSharesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2215,22 +2814,22 @@ func (m *QuerySwapExactAmountInResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySwapExactAmountInResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalSharesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySwapExactAmountInResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalSharesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size := m.TokenOutAmount.Size() - i -= size - if _, err := m.TokenOutAmount.MarshalTo(dAtA[i:]); err != nil { + size, err := m.TotalShares.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- @@ -2238,7 +2837,7 @@ func (m *QuerySwapExactAmountInResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QuerySwapExactAmountOutRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryCalcJoinPoolNoSwapSharesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2248,27 +2847,20 @@ func (m *QuerySwapExactAmountOutRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySwapExactAmountOutRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolNoSwapSharesRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySwapExactAmountOutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolNoSwapSharesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.TokenOut) > 0 { - i -= len(m.TokenOut) - copy(dAtA[i:], m.TokenOut) - i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenOut))) - i-- - dAtA[i] = 0x22 - } - if len(m.Routes) > 0 { - for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + if len(m.TokensIn) > 0 { + for iNdEx := len(m.TokensIn) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.TokensIn[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2276,25 +2868,18 @@ func (m *QuerySwapExactAmountOutRequest) MarshalToSizedBuffer(dAtA []byte) (int, i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } } if m.PoolId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) i-- - dAtA[i] = 0x10 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QuerySwapExactAmountOutResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryCalcJoinPoolNoSwapSharesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2304,30 +2889,44 @@ func (m *QuerySwapExactAmountOutResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySwapExactAmountOutResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolNoSwapSharesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySwapExactAmountOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCalcJoinPoolNoSwapSharesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size := m.TokenInAmount.Size() + size := m.SharesOut.Size() i -= size - if _, err := m.TokenInAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.SharesOut.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + if len(m.TokensOut) > 0 { + for iNdEx := len(m.TokensOut) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokensOut[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } return len(dAtA) - i, nil } -func (m *QueryTotalLiquidityRequest) Marshal() (dAtA []byte, err error) { +func (m *QuerySpotPriceRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2337,20 +2936,39 @@ func (m *QueryTotalLiquidityRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryTotalLiquidityRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QuerySpotPriceRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryTotalLiquidityRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QuerySpotPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.QuoteAssetDenom) > 0 { + i -= len(m.QuoteAssetDenom) + copy(dAtA[i:], m.QuoteAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteAssetDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseAssetDenom) > 0 { + i -= len(m.BaseAssetDenom) + copy(dAtA[i:], m.BaseAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseAssetDenom))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func (m *QueryTotalLiquidityResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPoolsWithFilterRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2360,20 +2978,39 @@ func (m *QueryTotalLiquidityResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryTotalLiquidityResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPoolsWithFilterRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryTotalLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPoolsWithFilterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Liquidity) > 0 { - for iNdEx := len(m.Liquidity) - 1; iNdEx >= 0; iNdEx-- { + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.PoolType) > 0 { + i -= len(m.PoolType) + copy(dAtA[i:], m.PoolType) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PoolType))) + i-- + dAtA[i] = 0x12 + } + if len(m.MinLiquidity) > 0 { + for iNdEx := len(m.MinLiquidity) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Liquidity[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.MinLiquidity[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2387,333 +3024,1422 @@ func (m *QueryTotalLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryPoolRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) +func (m *QueryPoolsWithFilterResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return n + return dAtA[:n], nil } -func (m *QueryPoolResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pool != nil { - l = m.Pool.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryPoolsWithFilterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPoolsRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryPoolsWithFilterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryPoolsResponse) Size() (n int) { - if m == nil { - return 0 + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - var l int - _ = l if len(m.Pools) > 0 { - for _, e := range m.Pools { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + for iNdEx := len(m.Pools) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Pools[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + return len(dAtA) - i, nil } -func (m *QueryNumPoolsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QuerySpotPriceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *QueryNumPoolsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.NumPools != 0 { - n += 1 + sovQuery(uint64(m.NumPools)) - } - return n +func (m *QuerySpotPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPoolTypeRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QuerySpotPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) + if len(m.SpotPrice) > 0 { + i -= len(m.SpotPrice) + copy(dAtA[i:], m.SpotPrice) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SpotPrice))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryPoolTypeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PoolType) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) +func (m *QuerySwapExactAmountInRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return n + return dAtA[:n], nil } -func (m *QueryPoolParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) - } - return n +func (m *QuerySwapExactAmountInRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPoolParamsResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QuerySwapExactAmountInRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.Params != nil { - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.Routes) > 0 { + for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } } - return n -} - -func (m *QueryTotalPoolLiquidityRequest) Size() (n int) { - if m == nil { - return 0 + if len(m.TokenIn) > 0 { + i -= len(m.TokenIn) + copy(dAtA[i:], m.TokenIn) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenIn))) + i-- + dAtA[i] = 0x1a } - var l int - _ = l if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 } - return n + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryTotalPoolLiquidityResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QuerySwapExactAmountInResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *QuerySwapExactAmountInResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySwapExactAmountInResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Liquidity) > 0 { - for _, e := range m.Liquidity { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size := m.TokenOutAmount.Size() + i -= size + if _, err := m.TokenOutAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - return n + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (m *QueryTotalSharesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) +func (m *QuerySwapExactAmountOutRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return n + return dAtA[:n], nil } -func (m *QueryTotalSharesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.TotalShares.Size() - n += 1 + l + sovQuery(uint64(l)) - return n +func (m *QuerySwapExactAmountOutRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySpotPriceRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QuerySwapExactAmountOutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) + if len(m.TokenOut) > 0 { + i -= len(m.TokenOut) + copy(dAtA[i:], m.TokenOut) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenOut))) + i-- + dAtA[i] = 0x22 } - l = len(m.BaseAssetDenom) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.Routes) > 0 { + for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } } - l = len(m.QuoteAssetDenom) - if l > 0 { + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySwapExactAmountOutResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySwapExactAmountOutResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySwapExactAmountOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TokenInAmount.Size() + i -= size + if _, err := m.TokenInAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTotalLiquidityRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalLiquidityRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalLiquidityRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryTotalLiquidityResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalLiquidityResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Liquidity) > 0 { + for iNdEx := len(m.Liquidity) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Liquidity[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryPoolRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pool != nil { + l = m.Pool.Size() n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QuerySpotPriceResponse) Size() (n int) { +func (m *QueryPoolsRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.SpotPrice) - if l > 0 { + if m.Pagination != nil { + l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QuerySwapExactAmountInRequest) Size() (n int) { +func (m *QueryPoolsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Sender) - if l > 0 { + if len(m.Pools) > 0 { + for _, e := range m.Pools { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) } + return n +} + +func (m *QueryNumPoolsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryNumPoolsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NumPools != 0 { + n += 1 + sovQuery(uint64(m.NumPools)) + } + return n +} + +func (m *QueryPoolTypeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l if m.PoolId != 0 { n += 1 + sovQuery(uint64(m.PoolId)) } - l = len(m.TokenIn) + return n +} + +func (m *QueryPoolTypeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PoolType) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if len(m.Routes) > 0 { - for _, e := range m.Routes { + return n +} + +func (m *QueryCalcJoinPoolSharesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + if len(m.TokensIn) > 0 { + for _, e := range m.TokensIn { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryCalcJoinPoolSharesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ShareOutAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + if len(m.TokensOut) > 0 { + for _, e := range m.TokensOut { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } - return n -} + return n +} + +func (m *QueryCalcExitPoolCoinsFromSharesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = m.ShareInAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryCalcExitPoolCoinsFromSharesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TokensOut) > 0 { + for _, e := range m.TokensOut { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryPoolParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryPoolParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTotalPoolLiquidityRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryTotalPoolLiquidityResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Liquidity) > 0 { + for _, e := range m.Liquidity { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryTotalSharesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryTotalSharesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TotalShares.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryCalcJoinPoolNoSwapSharesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + if len(m.TokensIn) > 0 { + for _, e := range m.TokensIn { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryCalcJoinPoolNoSwapSharesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TokensOut) > 0 { + for _, e := range m.TokensOut { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + l = m.SharesOut.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QuerySpotPriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.BaseAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPoolsWithFilterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.MinLiquidity) > 0 { + for _, e := range m.MinLiquidity { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + l = len(m.PoolType) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPoolsWithFilterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Pools) > 0 { + for _, e := range m.Pools { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySpotPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpotPrice) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySwapExactAmountInRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.TokenIn) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Routes) > 0 { + for _, e := range m.Routes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QuerySwapExactAmountInResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TokenOutAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QuerySwapExactAmountOutRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + if len(m.Routes) > 0 { + for _, e := range m.Routes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + l = len(m.TokenOut) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySwapExactAmountOutResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TokenInAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTotalLiquidityRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryTotalLiquidityResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Liquidity) > 0 { + for _, e := range m.Liquidity { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPoolRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pool == nil { + m.Pool = &types.Any{} + } + if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPoolsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPoolsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pools", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pools = append(m.Pools, &types.Any{}) + if err := m.Pools[len(m.Pools)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNumPoolsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryNumPoolsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNumPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNumPoolsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryNumPoolsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNumPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumPools", wireType) + } + m.NumPools = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumPools |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func (m *QuerySwapExactAmountInResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - l = m.TokenOutAmount.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + return nil } - -func (m *QuerySwapExactAmountOutRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) - } - if len(m.Routes) > 0 { - for _, e := range m.Routes { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryPoolTypeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPoolTypeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolTypeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - l = len(m.TokenOut) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QuerySwapExactAmountOutResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.TokenInAmount.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} -func (m *QueryTotalLiquidityRequest) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n + return nil } - -func (m *QueryTotalLiquidityResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Liquidity) > 0 { - for _, e := range m.Liquidity { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryPoolTypeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPoolTypeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolTypeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PoolType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { +func (m *QueryCalcJoinPoolSharesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2736,10 +4462,10 @@ func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCalcJoinPoolSharesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCalcJoinPoolSharesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2761,6 +4487,40 @@ func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { break } } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokensIn", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokensIn = append(m.TokensIn, types1.Coin{}) + if err := m.TokensIn[len(m.TokensIn)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2782,7 +4542,7 @@ func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { +func (m *QueryCalcJoinPoolSharesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2805,15 +4565,49 @@ func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCalcJoinPoolSharesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCalcJoinPoolSharesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ShareOutAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ShareOutAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokensOut", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2840,10 +4634,8 @@ func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pool == nil { - m.Pool = &types.Any{} - } - if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TokensOut = append(m.TokensOut, types1.Coin{}) + if err := m.TokensOut[len(m.TokensOut)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2868,7 +4660,7 @@ func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryCalcExitPoolCoinsFromSharesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2891,17 +4683,36 @@ func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCalcExitPoolCoinsFromSharesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCalcExitPoolCoinsFromSharesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ShareInAmount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2911,25 +4722,23 @@ func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ShareInAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2954,7 +4763,7 @@ func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryCalcExitPoolCoinsFromSharesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2977,49 +4786,15 @@ func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCalcExitPoolCoinsFromSharesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCalcExitPoolCoinsFromSharesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pools", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pools = append(m.Pools, &types.Any{}) - if err := m.Pools[len(m.Pools)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TokensOut", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3046,10 +4821,8 @@ func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TokensOut = append(m.TokensOut, types1.Coin{}) + if err := m.TokensOut[len(m.TokensOut)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3074,7 +4847,7 @@ func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryNumPoolsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPoolParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3097,12 +4870,31 @@ func (m *QueryNumPoolsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryNumPoolsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryNumPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3124,7 +4916,7 @@ func (m *QueryNumPoolsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryNumPoolsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPoolParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3147,17 +4939,17 @@ func (m *QueryNumPoolsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryNumPoolsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryNumPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumPools", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - m.NumPools = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3167,11 +4959,28 @@ func (m *QueryNumPoolsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumPools |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &types.Any{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3193,7 +5002,7 @@ func (m *QueryNumPoolsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolTypeRequest) Unmarshal(dAtA []byte) error { +func (m *QueryTotalPoolLiquidityRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3216,10 +5025,10 @@ func (m *QueryPoolTypeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolTypeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalPoolLiquidityRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolTypeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalPoolLiquidityRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3262,7 +5071,7 @@ func (m *QueryPoolTypeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolTypeResponse) Unmarshal(dAtA []byte) error { +func (m *QueryTotalPoolLiquidityResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3285,17 +5094,17 @@ func (m *QueryPoolTypeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolTypeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalPoolLiquidityResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolTypeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalPoolLiquidityResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Liquidity", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3305,23 +5114,25 @@ func (m *QueryPoolTypeResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.PoolType = string(dAtA[iNdEx:postIndex]) + m.Liquidity = append(m.Liquidity, types1.Coin{}) + if err := m.Liquidity[len(m.Liquidity)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -3344,7 +5155,7 @@ func (m *QueryPoolTypeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolParamsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryTotalSharesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3367,10 +5178,10 @@ func (m *QueryPoolParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalSharesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalSharesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3413,7 +5224,7 @@ func (m *QueryPoolParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolParamsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryTotalSharesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3436,15 +5247,15 @@ func (m *QueryPoolParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalSharesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalSharesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalShares", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3471,10 +5282,7 @@ func (m *QueryPoolParamsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Params == nil { - m.Params = &types.Any{} - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3499,7 +5307,7 @@ func (m *QueryPoolParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryTotalPoolLiquidityRequest) Unmarshal(dAtA []byte) error { +func (m *QueryCalcJoinPoolNoSwapSharesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3522,17 +5330,36 @@ func (m *QueryTotalPoolLiquidityRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryTotalPoolLiquidityRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCalcJoinPoolNoSwapSharesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryTotalPoolLiquidityRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCalcJoinPoolNoSwapSharesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) } - m.PoolId = 0 + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokensIn", wireType) + } + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3542,11 +5369,26 @@ func (m *QueryTotalPoolLiquidityRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokensIn = append(m.TokensIn, types1.Coin{}) + if err := m.TokensIn[len(m.TokensIn)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3568,7 +5410,7 @@ func (m *QueryTotalPoolLiquidityRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryTotalPoolLiquidityResponse) Unmarshal(dAtA []byte) error { +func (m *QueryCalcJoinPoolNoSwapSharesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3591,15 +5433,15 @@ func (m *QueryTotalPoolLiquidityResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryTotalPoolLiquidityResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCalcJoinPoolNoSwapSharesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryTotalPoolLiquidityResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCalcJoinPoolNoSwapSharesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Liquidity", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TokensOut", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3626,8 +5468,42 @@ func (m *QueryTotalPoolLiquidityResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Liquidity = append(m.Liquidity, types1.Coin{}) - if err := m.Liquidity[len(m.Liquidity)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TokensOut = append(m.TokensOut, types1.Coin{}) + if err := m.TokensOut[len(m.TokensOut)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SharesOut", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SharesOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3652,7 +5528,7 @@ func (m *QueryTotalPoolLiquidityResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryTotalSharesRequest) Unmarshal(dAtA []byte) error { +func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3675,10 +5551,10 @@ func (m *QueryTotalSharesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryTotalSharesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySpotPriceRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryTotalSharesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySpotPriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3700,6 +5576,70 @@ func (m *QueryTotalSharesRequest) Unmarshal(dAtA []byte) error { break } } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseAssetDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseAssetDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteAssetDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.QuoteAssetDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3721,7 +5661,7 @@ func (m *QueryTotalSharesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryTotalSharesResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPoolsWithFilterRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3744,15 +5684,15 @@ func (m *QueryTotalSharesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryTotalSharesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolsWithFilterRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryTotalSharesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolsWithFilterRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalShares", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinLiquidity", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3779,7 +5719,76 @@ func (m *QueryTotalSharesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TotalShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.MinLiquidity = append(m.MinLiquidity, types1.Coin{}) + if err := m.MinLiquidity[len(m.MinLiquidity)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PoolType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3804,7 +5813,7 @@ func (m *QueryTotalSharesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPoolsWithFilterResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3827,36 +5836,17 @@ func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QuerySpotPriceRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolsWithFilterResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySpotPriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolsWithFilterResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) - } - m.PoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BaseAssetDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pools", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3866,29 +5856,31 @@ func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.BaseAssetDenom = string(dAtA[iNdEx:postIndex]) + m.Pools = append(m.Pools, &types.Any{}) + if err := m.Pools[len(m.Pools)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QuoteAssetDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3898,23 +5890,27 @@ func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.QuoteAssetDenom = string(dAtA[iNdEx:postIndex]) + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/gamm/types/query.pb.gw.go b/x/gamm/types/query.pb.gw.go index dda499c40fc..c1b4f7c7b20 100644 --- a/x/gamm/types/query.pb.gw.go +++ b/x/gamm/types/query.pb.gw.go @@ -105,6 +105,42 @@ func local_request_Query_TotalLiquidity_0(ctx context.Context, marshaler runtime } +var ( + filter_Query_PoolsWithFilter_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PoolsWithFilter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolsWithFilterRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PoolsWithFilter_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PoolsWithFilter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolsWithFilter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolsWithFilterRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PoolsWithFilter_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PoolsWithFilter(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_Pool_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryPoolRequest var metadata runtime.ServerMetadata @@ -213,6 +249,150 @@ func local_request_Query_PoolType_0(ctx context.Context, marshaler runtime.Marsh } +var ( + filter_Query_CalcJoinPoolShares_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_CalcJoinPoolShares_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCalcJoinPoolSharesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CalcJoinPoolShares_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CalcJoinPoolShares(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CalcJoinPoolShares_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCalcJoinPoolSharesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CalcJoinPoolShares_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CalcJoinPoolShares(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_CalcExitPoolCoinsFromShares_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_CalcExitPoolCoinsFromShares_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCalcExitPoolCoinsFromSharesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CalcExitPoolCoinsFromShares_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CalcExitPoolCoinsFromShares(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CalcExitPoolCoinsFromShares_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCalcExitPoolCoinsFromSharesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CalcExitPoolCoinsFromShares_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CalcExitPoolCoinsFromShares(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_PoolParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryPoolParamsRequest var metadata runtime.ServerMetadata @@ -666,6 +846,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PoolsWithFilter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PoolsWithFilter_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolsWithFilter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Pool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -712,6 +915,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_CalcJoinPoolShares_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CalcJoinPoolShares_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CalcJoinPoolShares_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CalcExitPoolCoinsFromShares_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CalcExitPoolCoinsFromShares_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CalcExitPoolCoinsFromShares_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PoolParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -951,6 +1200,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PoolsWithFilter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PoolsWithFilter_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolsWithFilter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Pool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -991,6 +1260,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_CalcJoinPoolShares_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_CalcJoinPoolShares_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CalcJoinPoolShares_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CalcExitPoolCoinsFromShares_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_CalcExitPoolCoinsFromShares_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CalcExitPoolCoinsFromShares_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_PoolParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1121,10 +1430,16 @@ var ( pattern_Query_TotalLiquidity_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "gamm", "v1beta1", "total_liquidity"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PoolsWithFilter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "gamm", "v1beta1", "filtered_pools"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Pool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"osmosis", "gamm", "v1beta1", "pools", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PoolType_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"osmosis", "gamm", "v1beta1", "pool_type", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_CalcJoinPoolShares_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pools", "pool_id", "join_swap_exact_in"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_CalcExitPoolCoinsFromShares_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pools", "pool_id", "exit_swap_share_amount_in"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PoolParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pools", "pool_id", "params"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_TotalPoolLiquidity_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pools", "pool_id", "total_pool_liquidity"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1145,10 +1460,16 @@ var ( forward_Query_TotalLiquidity_0 = runtime.ForwardResponseMessage + forward_Query_PoolsWithFilter_0 = runtime.ForwardResponseMessage + forward_Query_Pool_0 = runtime.ForwardResponseMessage forward_Query_PoolType_0 = runtime.ForwardResponseMessage + forward_Query_CalcJoinPoolShares_0 = runtime.ForwardResponseMessage + + forward_Query_CalcExitPoolCoinsFromShares_0 = runtime.ForwardResponseMessage + forward_Query_PoolParams_0 = runtime.ForwardResponseMessage forward_Query_TotalPoolLiquidity_0 = runtime.ForwardResponseMessage diff --git a/x/gamm/types/route.go b/x/gamm/types/route.go index 2107e0a95f3..5d3da08f6ba 100644 --- a/x/gamm/types/route.go +++ b/x/gamm/types/route.go @@ -2,15 +2,10 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" ) type SwapAmountInRoutes []SwapAmountInRoute -func (routes SwapAmountInRoutes) IsOsmoRoutedMultihop() bool { - return len(routes) == 2 && (routes[0].TokenOutDenom == appparams.BaseCoinUnit) -} - func (routes SwapAmountInRoutes) Validate() error { if len(routes) == 0 { return ErrEmptyRoutes @@ -26,12 +21,32 @@ func (routes SwapAmountInRoutes) Validate() error { return nil } -type SwapAmountOutRoutes []SwapAmountOutRoute +func (routes SwapAmountInRoutes) IntermediateDenoms() []string { + if len(routes) < 2 { + return nil + } + intermediateDenoms := make([]string, 0, len(routes)-1) + for _, route := range routes[:len(routes)-1] { + intermediateDenoms = append(intermediateDenoms, route.TokenOutDenom) + } -func (routes SwapAmountOutRoutes) IsOsmoRoutedMultihop() bool { - return len(routes) == 2 && (routes[1].TokenInDenom == appparams.BaseCoinUnit) + return intermediateDenoms } +func (routes SwapAmountInRoutes) PoolIds() []uint64 { + poolIds := make([]uint64, 0, len(routes)) + for _, route := range routes { + poolIds = append(poolIds, route.PoolId) + } + return poolIds +} + +func (routes SwapAmountInRoutes) Length() int { + return len(routes) +} + +type SwapAmountOutRoutes []SwapAmountOutRoute + func (routes SwapAmountOutRoutes) Validate() error { if len(routes) == 0 { return ErrEmptyRoutes @@ -46,3 +61,33 @@ func (routes SwapAmountOutRoutes) Validate() error { return nil } + +func (routes SwapAmountOutRoutes) IntermediateDenoms() []string { + if len(routes) < 2 { + return nil + } + intermediateDenoms := make([]string, 0, len(routes)-1) + for _, route := range routes[1:] { + intermediateDenoms = append(intermediateDenoms, route.TokenInDenom) + } + + return intermediateDenoms +} + +func (routes SwapAmountOutRoutes) PoolIds() []uint64 { + poolIds := make([]uint64, 0, len(routes)) + for _, route := range routes { + poolIds = append(poolIds, route.PoolId) + } + return poolIds +} + +func (routes SwapAmountOutRoutes) Length() int { + return len(routes) +} + +type MultihopRoute interface { + Length() int + PoolIds() []uint64 + IntermediateDenoms() []string +} diff --git a/x/gamm/types/tx.pb.go b/x/gamm/types/tx.pb.go index 95df9db55cc..a7580571473 100644 --- a/x/gamm/types/tx.pb.go +++ b/x/gamm/types/tx.pb.go @@ -969,78 +969,78 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/tx.proto", fileDescriptor_cfc8fd3ac7df3247) } var fileDescriptor_cfc8fd3ac7df3247 = []byte{ - // 1122 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x4d, 0x6f, 0x1b, 0xc5, - 0x1b, 0xcf, 0xd8, 0x6e, 0x5e, 0x26, 0xcd, 0xdb, 0x36, 0x69, 0x9c, 0x6d, 0x6b, 0xa7, 0xf3, 0xff, - 0x0b, 0x52, 0xaa, 0xee, 0x36, 0xa9, 0x04, 0x88, 0x0b, 0x60, 0x08, 0xc2, 0x15, 0x96, 0xab, 0xed, - 0xa5, 0xe2, 0x62, 0xad, 0xe3, 0x95, 0xbb, 0x6a, 0x76, 0xc6, 0xf2, 0xcc, 0x06, 0x57, 0x48, 0x20, - 0xf1, 0x72, 0x07, 0x21, 0x5e, 0x3e, 0x01, 0xe2, 0x2b, 0x70, 0x80, 0x03, 0x5c, 0x7a, 0xec, 0x0d, - 0xca, 0xc1, 0x42, 0xc9, 0x37, 0xf0, 0x27, 0x40, 0xbb, 0x33, 0xfb, 0xea, 0xdd,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0x15, 0x12, 0x83, 0x88, - 0xed, 0x23, 0xa3, 0x83, 0x88, 0x2a, 0x8c, 0x11, 0x44, 0xca, 0x20, 0xfd, 0x1a, 0xc0, 0xcd, 0x34, - 0x3a, 0xba, 0x7b, 0x2a, 0x7a, 0x12, 0x34, 0xe4, 0x37, 0xb3, 0x6a, 0xf8, 0x71, 0x7c, 0x0e, 0x37, - 0x92, 0x47, 0xab, 0x32, 0xd2, 0x64, 0x44, 0x5e, 0x7e, 0x3d, 0x9b, 0xbc, 0x17, 0x40, 0xe5, 0xfe, - 0xb3, 0xe3, 0x12, 0x78, 0x7e, 0x5c, 0x02, 0xff, 0x1e, 0x97, 0xc0, 0x37, 0x27, 0xa5, 0x99, 0xe7, - 0x27, 0xa5, 0x99, 0xbf, 0x4f, 0x4a, 0x33, 0x1f, 0xdf, 0x0d, 0xd1, 0x84, 0xb0, 0x7d, 0xe7, 0x50, - 0x6f, 0x52, 0xef, 0x87, 0x7a, 0xb4, 0xbb, 0xa7, 0xf6, 0xf8, 0x67, 0x55, 0x97, 0x34, 0x9a, 0xb3, - 0xee, 0x67, 0xd0, 0x7b, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xa6, 0xf5, 0x0b, 0xf1, 0x73, 0x15, - 0x00, 0x00, + // 1121 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x4b, 0x6f, 0x1b, 0x45, + 0x1c, 0xcf, 0xd8, 0x6e, 0x1e, 0x93, 0xe6, 0xb5, 0x4d, 0x1a, 0x67, 0xdb, 0xda, 0xe9, 0x80, 0x20, + 0xa5, 0xea, 0x6e, 0x93, 0x48, 0x80, 0xb8, 0x00, 0x86, 0x20, 0x5c, 0x61, 0xa5, 0xda, 0x5e, 0x2a, + 0x2e, 0xd6, 0x3a, 0x5e, 0xb9, 0xab, 0x66, 0x67, 0x2c, 0xcf, 0x6c, 0x70, 0x85, 0x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x00, + 0xf0, 0x7a, 0x52, 0x65, 0xc3, 0x7c, 0x13, 0x18, 0x1b, 0x0f, 0xdf, 0xc4, 0xed, 0x21, 0x6d, 0xd1, + 0x0b, 0x4c, 0x44, 0xf5, 0x35, 0x80, 0x52, 0xd0, 0x88, 0x7d, 0x9b, 0x9d, 0x01, 0x77, 0xef, 0x79, + 0x57, 0xd1, 0xc4, 0x23, 0xc3, 0xee, 0xb2, 0x68, 0x0b, 0x47, 0xdd, 0xf3, 0x1c, 0x5c, 0x1b, 0xac, + 0xcd, 0xbe, 0xcd, 0xb2, 0xc0, 0xee, 0xa3, 0x18, 0xec, 0xb6, 0x86, 0xc1, 0xce, 0xcb, 0x36, 0x86, + 0xbb, 0xcf, 0xe1, 0x95, 0x84, 0xa9, 0x21, 0xf8, 0xec, 0x93, 0xcc, 0xad, 0x90, 0x53, 0x07, 0x11, + 0xd2, 0x96, 0x83, 0x39, 0x24, 0x68, 0x2d, 0x42, 0x2c, 0x85, 0x61, 0xa8, 0x1f, 0x85, 0x58, 0xbe, + 0x07, 0xf0, 0x46, 0x62, 0x6d, 0x7d, 0xe0, 0xb5, 0x3d, 0xde, 0x08, 0x2e, 0x05, 0x38, 0x1f, 0x79, + 0xc7, 0xcc, 0x79, 0x2c, 0xe3, 0x91, 0x37, 0xfa, 0x2b, 0x07, 0x37, 0xc4, 0xc8, 0xe5, 0x71, 0x31, + 0xa3, 0x83, 0xcf, 0x42, 0x35, 0x99, 0x86, 0xd4, 0xf8, 0x09, 0x25, 0x98, 0xe7, 0xe3, 0x23, 0x94, + 0x24, 0x9b, 0x48, 0x5b, 0xf1, 0xf6, 0x84, 0x80, 0x50, 0x7e, 0x01, 0xf0, 0x66, 0x6a, 0x11, 0x2f, + 0x74, 0x8b, 0x41, 0xbf, 0xe6, 0x23, 0xfd, 0x7d, 0xe0, 0x9c, 0x9e, 0xe9, 0x4e, 0x67, 0xea, 0xef, + 0xbb, 0x03, 0x3c, 0xc4, 0xef, 0xec, 0x46, 0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0x86, + 0x7d, 0x7b, 0x54, 0x4b, 0xfb, 0x36, 0x93, 0x77, 0x33, 0x08, 0xfb, 0x7e, 0xbf, 0x02, 0xf0, 0x6a, + 0xca, 0xaa, 0xa7, 0x9e, 0xda, 0x8c, 0x41, 0x05, 0xf9, 0xad, 0x8c, 0x0a, 0x89, 0x41, 0xc4, 0xf6, + 0x91, 0xe1, 0x41, 0x44, 0x15, 0x46, 0x08, 0x22, 0x65, 0x90, 0x7e, 0x0b, 0xe0, 0x7a, 0x1a, 0x1d, + 0xdd, 0x3d, 0x15, 0x3d, 0x09, 0x1a, 0xf2, 0xdb, 0x59, 0x35, 0xfc, 0x38, 0xbe, 0x84, 0x6b, 0xc9, + 0xa3, 0x55, 0x19, 0x6a, 0x32, 0x22, 0x2f, 0xbf, 0x99, 0x4d, 0xde, 0x0b, 0xa0, 0x72, 0xef, 0xe9, + 0x71, 0x09, 0x3c, 0x3b, 0x2e, 0x81, 0xff, 0x8f, 0x4b, 0xe0, 0xbb, 0x93, 0xd2, 0xd4, 0xb3, 0x93, + 0xd2, 0xd4, 0xbf, 0x27, 0xa5, 0xa9, 0x4f, 0xef, 0x86, 0x68, 0x42, 0xd8, 0xbe, 0x73, 0xa8, 0x37, + 0xa8, 0xf7, 0x43, 0x3d, 0xda, 0xde, 0x55, 0xbb, 0xfc, 0xb3, 0xaa, 0x4b, 0x1a, 0x8d, 0x69, 0xf7, + 0x33, 0xe8, 0xee, 0x8b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x66, 0x91, 0x23, 0xe6, 0x73, 0x15, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/gamm/v2types/query.pb.go b/x/gamm/v2types/query.pb.go new file mode 100644 index 00000000000..370c892b1a4 --- /dev/null +++ b/x/gamm/v2types/query.pb.go @@ -0,0 +1,690 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/gamm/v2/query.proto + +package v2types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QuerySpotPriceRequest defines the gRPC request structure for a SpotPrice +// query. +type QuerySpotPriceRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + BaseAssetDenom string `protobuf:"bytes,2,opt,name=base_asset_denom,json=baseAssetDenom,proto3" json:"base_asset_denom,omitempty" yaml:"base_asset_denom"` + QuoteAssetDenom string `protobuf:"bytes,3,opt,name=quote_asset_denom,json=quoteAssetDenom,proto3" json:"quote_asset_denom,omitempty" yaml:"quote_asset_denom"` +} + +func (m *QuerySpotPriceRequest) Reset() { *m = QuerySpotPriceRequest{} } +func (m *QuerySpotPriceRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySpotPriceRequest) ProtoMessage() {} +func (*QuerySpotPriceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_49ff000e88fc374c, []int{0} +} +func (m *QuerySpotPriceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpotPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpotPriceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySpotPriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpotPriceRequest.Merge(m, src) +} +func (m *QuerySpotPriceRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySpotPriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpotPriceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpotPriceRequest proto.InternalMessageInfo + +func (m *QuerySpotPriceRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QuerySpotPriceRequest) GetBaseAssetDenom() string { + if m != nil { + return m.BaseAssetDenom + } + return "" +} + +func (m *QuerySpotPriceRequest) GetQuoteAssetDenom() string { + if m != nil { + return m.QuoteAssetDenom + } + return "" +} + +// QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice +// query. +type QuerySpotPriceResponse struct { + // String of the Dec. Ex) 10.203uatom + SpotPrice string `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3" json:"spot_price,omitempty" yaml:"spot_price"` +} + +func (m *QuerySpotPriceResponse) Reset() { *m = QuerySpotPriceResponse{} } +func (m *QuerySpotPriceResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySpotPriceResponse) ProtoMessage() {} +func (*QuerySpotPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_49ff000e88fc374c, []int{1} +} +func (m *QuerySpotPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpotPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpotPriceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySpotPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpotPriceResponse.Merge(m, src) +} +func (m *QuerySpotPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySpotPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpotPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpotPriceResponse proto.InternalMessageInfo + +func (m *QuerySpotPriceResponse) GetSpotPrice() string { + if m != nil { + return m.SpotPrice + } + return "" +} + +func init() { + proto.RegisterType((*QuerySpotPriceRequest)(nil), "osmosis.gamm.v2.QuerySpotPriceRequest") + proto.RegisterType((*QuerySpotPriceResponse)(nil), "osmosis.gamm.v2.QuerySpotPriceResponse") +} + +func init() { proto.RegisterFile("osmosis/gamm/v2/query.proto", fileDescriptor_49ff000e88fc374c) } + +var fileDescriptor_49ff000e88fc374c = []byte{ + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x41, 0x8b, 0x13, 0x31, + 0x14, 0xc7, 0x9b, 0x55, 0x57, 0x9a, 0xc3, 0xae, 0x1b, 0x5c, 0xad, 0xdd, 0x75, 0xba, 0xcc, 0xc1, + 0x5d, 0x15, 0x27, 0xb4, 0xeb, 0xc9, 0x9b, 0x45, 0x41, 0x41, 0x44, 0xc7, 0x9b, 0x97, 0x21, 0xd3, + 0xc6, 0x71, 0xa0, 0x33, 0x2f, 0xed, 0xcb, 0x94, 0x2d, 0xe2, 0xc5, 0xbb, 0x20, 0x78, 0xf0, 0x2b, + 0x79, 0x5c, 0x10, 0xc1, 0x53, 0x91, 0xd6, 0x4f, 0xd0, 0x4f, 0x20, 0x49, 0x66, 0xba, 0xee, 0x28, + 0x78, 0x4b, 0xde, 0xef, 0x9f, 0x5f, 0x92, 0xc7, 0xa3, 0x7b, 0x80, 0x19, 0x60, 0x8a, 0x3c, 0x11, + 0x59, 0xc6, 0xa7, 0x3d, 0x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ors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // SpotPrice defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, opts ...grpc.CallOption) (*QuerySpotPriceResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, opts ...grpc.CallOption) (*QuerySpotPriceResponse, error) { + out := new(QuerySpotPriceResponse) + err := c.cc.Invoke(ctx, "/osmosis.gamm.v2.Query/SpotPrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // SpotPrice defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + SpotPrice(context.Context, *QuerySpotPriceRequest) (*QuerySpotPriceResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) SpotPrice(ctx context.Context, req *QuerySpotPriceRequest) (*QuerySpotPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SpotPrice not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_SpotPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySpotPriceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SpotPrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.gamm.v2.Query/SpotPrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SpotPrice(ctx, req.(*QuerySpotPriceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.gamm.v2.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SpotPrice", + Handler: _Query_SpotPrice_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/gamm/v2/query.proto", +} + +func (m *QuerySpotPriceRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySpotPriceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpotPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.QuoteAssetDenom) > 0 { + i -= len(m.QuoteAssetDenom) + copy(dAtA[i:], m.QuoteAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteAssetDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseAssetDenom) > 0 { + i -= len(m.BaseAssetDenom) + copy(dAtA[i:], m.BaseAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseAssetDenom))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QuerySpotPriceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySpotPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpotPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpotPrice) > 0 { + i -= len(m.SpotPrice) + copy(dAtA[i:], m.SpotPrice) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SpotPrice))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QuerySpotPriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.BaseAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySpotPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpotPrice) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySpotPriceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpotPriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseAssetDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseAssetDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteAssetDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.QuoteAssetDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySpotPriceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySpotPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpotPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpotPrice = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/gamm/v2types/query.pb.gw.go b/x/gamm/v2types/query.pb.gw.go new file mode 100644 index 00000000000..2195093b816 --- /dev/null +++ b/x/gamm/v2types/query.pb.gw.go @@ -0,0 +1,207 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/gamm/v2/query.proto + +/* +Package v2types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v2types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Query_SpotPrice_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_SpotPrice_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpotPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpotPrice_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SpotPrice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SpotPrice_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpotPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpotPrice_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SpotPrice(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_SpotPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_SpotPrice_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SpotPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_SpotPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_SpotPrice_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SpotPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_SpotPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v2", "pools", "pool_id", "prices"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_SpotPrice_0 = runtime.ForwardResponseMessage +) diff --git a/x/ibc-hooks/README.md b/x/ibc-hooks/README.md new file mode 100644 index 00000000000..3434f20afbb --- /dev/null +++ b/x/ibc-hooks/README.md @@ -0,0 +1,119 @@ +# IBC-hooks + +## Wasm Hooks + +The wasm hook is an IBC middleware which is used to allow ICS-20 token transfers to initiate contract calls. +This allows cross-chain contract calls, that involve token movement. +This is useful for a variety of usecases. +One of primary importance is cross-chain swaps, which is an extremely powerful primitive. + +The mechanism enabling this is a `memo` field on every ICS20 transfer packet as of [IBC v3.4.0](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b). +Wasm hooks is an IBC middleware that parses an ICS20 transfer, and if the `memo` field is of a particular form, executes a wasm contract call. We now detail the `memo` format for `wasm` contract calls, and the execution guarantees provided. + +### Cosmwasm Contract Execution Format + +Before we dive into the IBC metadata format, we show the cosmwasm execute message format, so the reader has a sense of what are the fields we need to be setting in. +The cosmwasm `MsgExecuteContract` is defined [here](https://github.com/CosmWasm/wasmd/blob/4fe2fbc8f322efdaf187e2e5c99ce32fd1df06f0/x/wasm/types/tx.pb.go#L340-L349 +) as the following type: + +```go +type MsgExecuteContract struct { + // Sender is the that actor that signed the messages + Sender string + // Contract is the address of the smart contract + Contract string + // Msg json encoded message to be passed to the contract + Msg RawContractMessage + // Funds coins that are transferred to the contract on execution + Funds sdk.Coins +} +``` + +So we detail where we want to get each of these fields from: + +* Sender: We cannot trust the sender of an IBC packet, the counterparty chain has full ability to lie about it. +We cannot risk this sender being confused for a particular user or module address on Osmosis. +So we hardcode the sender to be a particular module account made in IBC. +* Contract: This field should be directly obtained from the ICS-20 packet metadata +* Msg: This field should be directly obtained from the ICS-20 packet metadata. +* Funds: This field is set to the amount of funds being sent over in the ICS 20 packet. One detail is that the denom in the packet is the counterparty chains representation of the denom, so we have to translate it to Osmosis' representation. + +So our constructed cosmwasm message that we execute will look like: + +```go +msg := MsgExecuteContract{ + // Sender is the that actor that signed the messages + Sender: "osmo1-hardcoded-moduleAccount", + // Contract is the address of the smart contract + Contract: packet.data.memo["wasm"]["ContractAddress"], + // Msg json encoded message to be passed to the contract + Msg: packet.data.memo["wasm"]["Msg"], + // Funds coins that are transferred to the contract on execution + Funds: sdk.NewCoin{Denom: ibc.ConvertSenderDenomToLocalDenom(packet.data.Denom), Amount: packet.data.Amount} +``` + +### ICS20 packet structure + +So given the details above, we propogate the implied ICS20 packet data structure. +ICS20 is JSON native, so we use JSON for the memo format. + +```json +{ + //... other ibc fields that we don't care about + "data":{ + "denom": "denom on counterparty chain (e.g. uatom)", + "amount": "1000", + "sender": "...", // ignored + "receiver": "contract addr or blank", + "memo": { + "wasm": { + "contract": "osmo1contractAddr", + "msg": { + "raw_message_fields": "raw_message_data", + } + } + } + } +} +``` + +An ICS20 packet is formatted correctly for wasmhooks iff the following all hold: + +* `memo` is not blank +* `memo` is valid JSON +* `memo` has at least one key, with value `"wasm"` +* `memo["wasm"]` has exactly two entries, `"contract"` and `"msg"` +* `memo["wasm"]["msg"]` is a valid JSON object +* `receiver == "" || receiver == memo["wasm"]["contract"]` + +We consider an ICS20 packet as directed towards wasmhooks iff all of the following hold: + +* `memo` is not blank +* `memo` is valid JSON +* `memo` has at least one key, with name `"wasm"` + +If an ICS20 packet is not directed towards wasmhooks, wasmhooks doesn't do anything. +If an ICS20 packet is directed towards wasmhooks, and is formated incorrectly, then wasmhooks returns an error. + +### Execution flow + +Pre wasm hooks: + +* Ensure the incoming IBC packet is cryptogaphically valid +* Ensure the incoming IBC packet is not timed out. + +In Wasm hooks, pre packet execution: + +* Ensure the packet is correctly formatted (as defined above) +* Edit the receiver to be the hardcoded IBC module account + +In wasm hooks, post packet execution: + +* Construct wasm message as defined before +* Execute wasm message +* if wasm message has error, return ErrAck +* otherwise continue through middleware + + + +### Testing strategy \ No newline at end of file diff --git a/x/ibc-hooks/bytecode/counter.wasm b/x/ibc-hooks/bytecode/counter.wasm new file mode 100644 index 00000000000..55f18df6dd3 Binary files /dev/null and b/x/ibc-hooks/bytecode/counter.wasm differ diff --git a/x/ibc-hooks/bytecode/echo.wasm b/x/ibc-hooks/bytecode/echo.wasm new file mode 100644 index 00000000000..4feb4554e7c Binary files /dev/null and b/x/ibc-hooks/bytecode/echo.wasm differ diff --git a/x/ibc-hooks/genesis.go b/x/ibc-hooks/genesis.go new file mode 100644 index 00000000000..57d26b37477 --- /dev/null +++ b/x/ibc-hooks/genesis.go @@ -0,0 +1,17 @@ +package ibc_hooks + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + + "github.com/osmosis-labs/osmosis/v13/osmoutils" +) + +var WasmHookModuleAccountAddr sdk.AccAddress = address.Module(ModuleName, []byte("wasm-hook intermediary account")) + +func IbcHooksInitGenesis(ctx sdk.Context, ak osmoutils.AccountKeeper) { + err := osmoutils.CreateModuleAccount(ctx, ak, WasmHookModuleAccountAddr) + if err != nil { + panic(err) + } +} diff --git a/x/ibc-hooks/hooks.go b/x/ibc-hooks/hooks.go new file mode 100644 index 00000000000..14557cd1dcd --- /dev/null +++ b/x/ibc-hooks/hooks.go @@ -0,0 +1,144 @@ +package ibc_hooks + +import ( + // external libraries + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + // ibc-go + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" +) + +type Hooks interface{} + +type OnChanOpenInitOverrideHooks interface { + OnChanOpenInitOverride(im IBCMiddleware, ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) error +} +type OnChanOpenInitBeforeHooks interface { + OnChanOpenInitBeforeHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) +} +type OnChanOpenInitAfterHooks interface { + OnChanOpenInitAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string, err error) +} + +// OnChanOpenTry Hooks +type OnChanOpenTryOverrideHooks interface { + OnChanOpenTryOverride(im IBCMiddleware, ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string) (string, error) +} +type OnChanOpenTryBeforeHooks interface { + OnChanOpenTryBeforeHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string) +} +type OnChanOpenTryAfterHooks interface { + OnChanOpenTryAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string, version string, err error) +} + +// OnChanOpenAck Hooks +type OnChanOpenAckOverrideHooks interface { + OnChanOpenAckOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string) error +} +type OnChanOpenAckBeforeHooks interface { + OnChanOpenAckBeforeHook(ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string) +} +type OnChanOpenAckAfterHooks interface { + OnChanOpenAckAfterHook(ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string, err error) +} + +// OnChanOpenConfirm Hooks +type OnChanOpenConfirmOverrideHooks interface { + OnChanOpenConfirmOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string) error +} +type OnChanOpenConfirmBeforeHooks interface { + OnChanOpenConfirmBeforeHook(ctx sdk.Context, portID, channelID string) +} +type OnChanOpenConfirmAfterHooks interface { + OnChanOpenConfirmAfterHook(ctx sdk.Context, portID, channelID string, err error) +} + +// OnChanCloseInit Hooks +type OnChanCloseInitOverrideHooks interface { + OnChanCloseInitOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string) error +} +type OnChanCloseInitBeforeHooks interface { + OnChanCloseInitBeforeHook(ctx sdk.Context, portID, channelID string) +} +type OnChanCloseInitAfterHooks interface { + OnChanCloseInitAfterHook(ctx sdk.Context, portID, channelID string, err error) +} + +// OnChanCloseConfirm Hooks +type OnChanCloseConfirmOverrideHooks interface { + OnChanCloseConfirmOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string) error +} +type OnChanCloseConfirmBeforeHooks interface { + OnChanCloseConfirmBeforeHook(ctx sdk.Context, portID, channelID string) +} +type OnChanCloseConfirmAfterHooks interface { + OnChanCloseConfirmAfterHook(ctx sdk.Context, portID, channelID string, err error) +} + +// OnRecvPacket Hooks +type OnRecvPacketOverrideHooks interface { + OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement +} +type OnRecvPacketBeforeHooks interface { + OnRecvPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) +} +type OnRecvPacketAfterHooks interface { + OnRecvPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ack ibcexported.Acknowledgement) +} + +// OnAcknowledgementPacket Hooks +type OnAcknowledgementPacketOverrideHooks interface { + OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error +} +type OnAcknowledgementPacketBeforeHooks interface { + OnAcknowledgementPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) +} +type OnAcknowledgementPacketAfterHooks interface { + OnAcknowledgementPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, err error) +} + +// OnTimeoutPacket Hooks +type OnTimeoutPacketOverrideHooks interface { + OnTimeoutPacketOverride(im IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error +} +type OnTimeoutPacketBeforeHooks interface { + OnTimeoutPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) +} +type OnTimeoutPacketAfterHooks interface { + OnTimeoutPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, err error) +} + +// SendPacket Hooks +type SendPacketOverrideHooks interface { + SendPacketOverride(i ICS4Middleware, ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error +} +type SendPacketBeforeHooks interface { + SendPacketBeforeHook(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) +} +type SendPacketAfterHooks interface { + SendPacketAfterHook(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, err error) +} + +// WriteAcknowledgement Hooks +type WriteAcknowledgementOverrideHooks interface { + WriteAcknowledgementOverride(i ICS4Middleware, ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error +} +type WriteAcknowledgementBeforeHooks interface { + WriteAcknowledgementBeforeHook(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) +} +type WriteAcknowledgementAfterHooks interface { + WriteAcknowledgementAfterHook(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, err error) +} + +// GetAppVersion Hooks +type GetAppVersionOverrideHooks interface { + GetAppVersionOverride(i ICS4Middleware, ctx sdk.Context, portID, channelID string) (string, bool) +} +type GetAppVersionBeforeHooks interface { + GetAppVersionBeforeHook(ctx sdk.Context, portID, channelID string) +} +type GetAppVersionAfterHooks interface { + GetAppVersionAfterHook(ctx sdk.Context, portID, channelID string, result string, success bool) +} diff --git a/x/ibc-hooks/ibc_middleware_test.go b/x/ibc-hooks/ibc_middleware_test.go new file mode 100644 index 00000000000..5d722cf3582 --- /dev/null +++ b/x/ibc-hooks/ibc_middleware_test.go @@ -0,0 +1,348 @@ +package ibc_hooks_test + +import ( + "encoding/json" + "fmt" + ibc_hooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks" + "testing" + + "github.com/osmosis-labs/osmosis/v13/osmoutils" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + + "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" + + osmosisibctesting "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/testutil" + + "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks/testutils" +) + +type HooksTestSuite struct { + apptesting.KeeperTestHelper + + coordinator *ibctesting.Coordinator + + chainA *osmosisibctesting.TestChain + chainB *osmosisibctesting.TestChain + + path *ibctesting.Path +} + +func (suite *HooksTestSuite) SetupTest() { + suite.Setup() + ibctesting.DefaultTestingAppInit = osmosisibctesting.SetupTestingApp + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.chainA = &osmosisibctesting.TestChain{ + TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(1)), + } + suite.chainB = &osmosisibctesting.TestChain{ + TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(2)), + } + suite.path = NewTransferPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(suite.path) +} + +func TestIBCHooksTestSuite(t *testing.T) { + suite.Run(t, new(HooksTestSuite)) +} + +// ToDo: Move this to osmosistesting to avoid repetition +func NewTransferPath(chainA, chainB *osmosisibctesting.TestChain) *ibctesting.Path { + path := ibctesting.NewPath(chainA.TestChain, chainB.TestChain) + path.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort + path.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort + path.EndpointA.ChannelConfig.Version = transfertypes.Version + path.EndpointB.ChannelConfig.Version = transfertypes.Version + + return path +} + +func (suite *HooksTestSuite) TestOnRecvPacketHooks() { + var ( + trace transfertypes.DenomTrace + amount sdk.Int + receiver string + status testutils.Status + ) + + testCases := []struct { + msg string + malleate func(*testutils.Status) + expPass bool + }{ + {"override", func(status *testutils.Status) { + suite.chainB.GetOsmosisApp().TransferStack. + ICS4Middleware.Hooks = testutils.TestRecvOverrideHooks{Status: status} + }, true}, + {"before and after", func(status *testutils.Status) { + suite.chainB.GetOsmosisApp().TransferStack. + ICS4Middleware.Hooks = testutils.TestRecvBeforeAfterHooks{Status: status} + }, true}, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.msg, func() { + suite.SetupTest() // reset + + path := NewTransferPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(path) + receiver = suite.chainB.SenderAccount.GetAddress().String() // must be explicitly changed in malleate + status = testutils.Status{} + + amount = sdk.NewInt(100) // must be explicitly changed in malleate + seq := uint64(1) + + trace = transfertypes.ParseDenomTrace(sdk.DefaultBondDenom) + + // send coin from chainA to chainB + transferMsg := transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoin(trace.IBCDenom(), amount), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0) + _, err := suite.chainA.SendMsgs(transferMsg) + suite.Require().NoError(err) // message committed + + tc.malleate(&status) + + data := transfertypes.NewFungibleTokenPacketData(trace.GetFullDenomPath(), amount.String(), suite.chainA.SenderAccount.GetAddress().String(), receiver) + packet := channeltypes.NewPacket(data.GetBytes(), seq, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0) + + ack := suite.chainB.GetOsmosisApp().TransferStack. + OnRecvPacket(suite.chainB.GetContext(), packet, suite.chainA.SenderAccount.GetAddress()) + + if tc.expPass { + suite.Require().True(ack.Success()) + } else { + suite.Require().False(ack.Success()) + } + + if _, ok := suite.chainB.GetOsmosisApp().TransferStack. + ICS4Middleware.Hooks.(testutils.TestRecvOverrideHooks); ok { + suite.Require().True(status.OverrideRan) + suite.Require().False(status.BeforeRan) + suite.Require().False(status.AfterRan) + } + + if _, ok := suite.chainB.GetOsmosisApp().TransferStack. + ICS4Middleware.Hooks.(testutils.TestRecvBeforeAfterHooks); ok { + suite.Require().False(status.OverrideRan) + suite.Require().True(status.BeforeRan) + suite.Require().True(status.AfterRan) + } + }) + } +} + +func (suite *HooksTestSuite) makeMockPacket(receiver, memo string, prevSequence uint64) channeltypes.Packet { + packetData := transfertypes.FungibleTokenPacketData{ + Denom: sdk.DefaultBondDenom, + Amount: "1", + Sender: suite.chainB.SenderAccount.GetAddress().String(), + Receiver: receiver, + Memo: memo, + } + + return channeltypes.NewPacket( + packetData.GetBytes(), + prevSequence+1, + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID, + suite.path.EndpointA.ChannelConfig.PortID, + suite.path.EndpointA.ChannelID, + clienttypes.NewHeight(0, 100), + 0, + ) +} + +func (suite *HooksTestSuite) receivePacket(receiver, memo string) []byte { + return suite.receivePacketWithSequence(receiver, memo, 0) +} + +func (suite *HooksTestSuite) receivePacketWithSequence(receiver, memo string, prevSequence uint64) []byte { + channelCap := suite.chainB.GetChannelCapability( + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID) + + packet := suite.makeMockPacket(receiver, memo, prevSequence) + + err := suite.chainB.GetOsmosisApp().HooksICS4Wrapper.SendPacket( + suite.chainB.GetContext(), channelCap, packet) + suite.Require().NoError(err, "IBC send failed. Expected success. %s", err) + + // Update both clients + err = suite.path.EndpointB.UpdateClient() + suite.Require().NoError(err) + err = suite.path.EndpointA.UpdateClient() + suite.Require().NoError(err) + + // recv in chain a + res, err := suite.path.EndpointA.RecvPacketWithResult(packet) + + // get the ack from the chain a's response + ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) + suite.Require().NoError(err) + + // manually send the acknowledgement to chain b + err = suite.path.EndpointA.AcknowledgePacket(packet, ack) + suite.Require().NoError(err) + return ack +} + +func (suite *HooksTestSuite) TestRecvTransferWithMetadata() { + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/echo.wasm") + addr := suite.chainA.InstantiateContract(&suite.Suite, "{}") + + ackBytes := suite.receivePacket(addr.String(), fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"echo": {"msg": "test"} } } }`, addr)) + ackStr := string(ackBytes) + fmt.Println(ackStr) + var ack map[string]string // This can't be unmarshalled to Acknowledgement because it's fetched from the events + err := json.Unmarshal(ackBytes, &ack) + suite.Require().NoError(err) + suite.Require().NotContains(ack, "error") + suite.Require().Equal(ack["result"], "eyJjb250cmFjdF9yZXN1bHQiOiJkR2hwY3lCemFHOTFiR1FnWldOb2J3PT0iLCJpYmNfYWNrIjoiZXlKeVpYTjFiSFFpT2lKQlVUMDlJbjA9In0=") +} + +// After successfully executing a wasm call, the contract should have the funds sent via IBC +func (suite *HooksTestSuite) TestFundsAreTransferredToTheContract() { + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/echo.wasm") + addr := suite.chainA.InstantiateContract(&suite.Suite, "{}") + + // Check that the contract has no funds + localDenom := osmoutils.MustExtractDenomFromPacketOnRecv(suite.makeMockPacket("", "", 0)) + balance := suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) + suite.Require().Equal(sdk.NewInt(0), balance.Amount) + + // Execute the contract via IBC + ackBytes := suite.receivePacket(addr.String(), fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"echo": {"msg": "test"} } } }`, addr)) + ackStr := string(ackBytes) + fmt.Println(ackStr) + var ack map[string]string // This can't be unmarshalled to Acknowledgement because it's fetched from the events + err := json.Unmarshal(ackBytes, &ack) + suite.Require().NoError(err) + suite.Require().NotContains(ack, "error") + suite.Require().Equal(ack["result"], "eyJjb250cmFjdF9yZXN1bHQiOiJkR2hwY3lCemFHOTFiR1FnWldOb2J3PT0iLCJpYmNfYWNrIjoiZXlKeVpYTjFiSFFpT2lKQlVUMDlJbjA9In0=") + + // Check that the token has now been transferred to the contract + balance = suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) + suite.Require().Equal(sdk.NewInt(1), balance.Amount) +} + +// If the wasm call wails, the contract acknowledgement should be an error and the funds returned +func (suite *HooksTestSuite) TestFundsAreReturnedOnFailedContractExec() { + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/echo.wasm") + addr := suite.chainA.InstantiateContract(&suite.Suite, "{}") + + // Check that the contract has no funds + localDenom := osmoutils.MustExtractDenomFromPacketOnRecv(suite.makeMockPacket("", "", 0)) + balance := suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) + suite.Require().Equal(sdk.NewInt(0), balance.Amount) + + // Execute the contract via IBC with a message that the contract will reject + ackBytes := suite.receivePacket(addr.String(), fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"not_echo": {"msg": "test"} } } }`, addr)) + ackStr := string(ackBytes) + fmt.Println(ackStr) + var ack map[string]string // This can't be unmarshalled to Acknowledgement because it's fetched from the events + err := json.Unmarshal(ackBytes, &ack) + suite.Require().NoError(err) + suite.Require().Contains(ack, "error") + + // Check that the token has now been transferred to the contract + balance = suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) + fmt.Println(balance) + suite.Require().Equal(sdk.NewInt(0), balance.Amount) +} + +func (suite *HooksTestSuite) TestPacketsThatShouldBeSkipped() { + var sequence uint64 + receiver := suite.chainB.SenderAccount.GetAddress().String() + + testCases := []struct { + memo string + expPassthrough bool + }{ + {"", true}, + {"{01]", true}, // bad json + {"{}", true}, + {`{"something": ""}`, true}, + {`{"wasm": "test"}`, false}, + {`{"wasm": []`, true}, // invalid top level JSON + {`{"wasm": {}`, true}, // invalid top level JSON + {`{"wasm": []}`, false}, + {`{"wasm": {}}`, false}, + {`{"wasm": {"contract": "something"}}`, false}, + {`{"wasm": {"contract": "osmo1clpqr4nrk4khgkxj78fcwwh6dl3uw4epasmvnj"}}`, false}, + {`{"wasm": {"msg": "something"}}`, false}, + // invalid receiver + {`{"wasm": {"contract": "osmo1clpqr4nrk4khgkxj78fcwwh6dl3uw4epasmvnj", "msg": {}}}`, false}, + // msg not an object + {fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": 1}}`, receiver), false}, + } + + for _, tc := range testCases { + ackBytes := suite.receivePacketWithSequence(receiver, tc.memo, sequence) + ackStr := string(ackBytes) + fmt.Println(ackStr) + var ack map[string]string // This can't be unmarshalled to Acknowledgement because it's fetched from the events + err := json.Unmarshal(ackBytes, &ack) + suite.Require().NoError(err) + if tc.expPassthrough { + suite.Require().Equal("AQ==", ack["result"], tc.memo) + } else { + suite.Require().Contains(ackStr, "error", tc.memo) + } + sequence += 1 + } +} + +// After successfully executing a wasm call, the contract should have the funds sent via IBC +func (suite *HooksTestSuite) TestFundTracking() { + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/counter.wasm") + addr := suite.chainA.InstantiateContract(&suite.Suite, `{"count": 0}`) + + // Check that the contract has no funds + localDenom := osmoutils.MustExtractDenomFromPacketOnRecv(suite.makeMockPacket("", "", 0)) + balance := suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) + suite.Require().Equal(sdk.NewInt(0), balance.Amount) + + // Execute the contract via IBC + suite.receivePacket( + addr.String(), + fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"increment": {} } } }`, addr)) + + state := suite.chainA.QueryContract( + &suite.Suite, addr, + []byte(fmt.Sprintf(`{"get_count": {"addr": "%s"}}`, ibc_hooks.WasmHookModuleAccountAddr))) + suite.Require().Equal(`{"count":0}`, state) + + state = suite.chainA.QueryContract( + &suite.Suite, addr, + []byte(fmt.Sprintf(`{"get_total_funds": {"addr": "%s"}}`, ibc_hooks.WasmHookModuleAccountAddr))) + suite.Require().Equal(`{"total_funds":[]}`, state) + + suite.receivePacketWithSequence( + addr.String(), + fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"increment": {} } } }`, addr), 1) + + state = suite.chainA.QueryContract( + &suite.Suite, addr, + []byte(fmt.Sprintf(`{"get_count": {"addr": "%s"}}`, ibc_hooks.WasmHookModuleAccountAddr))) + suite.Require().Equal(`{"count":1}`, state) + + state = suite.chainA.QueryContract( + &suite.Suite, addr, + []byte(fmt.Sprintf(`{"get_total_funds": {"addr": "%s"}}`, ibc_hooks.WasmHookModuleAccountAddr))) + suite.Require().Equal(`{"total_funds":[{"denom":"ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878","amount":"1"}]}`, state) + + // Check that the token has now been transferred to the contract + balance = suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) + suite.Require().Equal(sdk.NewInt(2), balance.Amount) +} diff --git a/x/ibc-hooks/ibc_module.go b/x/ibc-hooks/ibc_module.go new file mode 100644 index 00000000000..b7646274a02 --- /dev/null +++ b/x/ibc-hooks/ibc_module.go @@ -0,0 +1,257 @@ +package ibc_hooks + +import ( + // external libraries + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + // ibc-go + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" +) + +var _ porttypes.Middleware = &IBCMiddleware{} + +type IBCMiddleware struct { + App porttypes.IBCModule + ICS4Middleware *ICS4Middleware +} + +func NewIBCMiddleware(app porttypes.IBCModule, ics4 *ICS4Middleware) IBCMiddleware { + return IBCMiddleware{ + App: app, + ICS4Middleware: ics4, + } +} + +// OnChanOpenInit implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) error { + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenInitOverrideHooks); ok { + return hook.OnChanOpenInitOverride(im, ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenInitBeforeHooks); ok { + hook.OnChanOpenInitBeforeHook(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version) + } + + err := im.App.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version) + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenInitAfterHooks); ok { + hook.OnChanOpenInitAfterHook(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version, err) + } + return err +} + +// OnChanOpenTry implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenTryOverrideHooks); ok { + return hook.OnChanOpenTryOverride(im, ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenTryBeforeHooks); ok { + hook.OnChanOpenTryBeforeHook(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion) + } + + version, err := im.App.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion) + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenTryAfterHooks); ok { + hook.OnChanOpenTryAfterHook(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion, version, err) + } + return version, err +} + +// OnChanOpenAck implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyChannelID string, + counterpartyVersion string, +) error { + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenAckOverrideHooks); ok { + return hook.OnChanOpenAckOverride(im, ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenAckBeforeHooks); ok { + hook.OnChanOpenAckBeforeHook(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) + } + err := im.App.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenAckAfterHooks); ok { + hook.OnChanOpenAckAfterHook(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion, err) + } + + return err +} + +// OnChanOpenConfirm implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenConfirmOverrideHooks); ok { + return hook.OnChanOpenConfirmOverride(im, ctx, portID, channelID) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenConfirmBeforeHooks); ok { + hook.OnChanOpenConfirmBeforeHook(ctx, portID, channelID) + } + err := im.App.OnChanOpenConfirm(ctx, portID, channelID) + if hook, ok := im.ICS4Middleware.Hooks.(OnChanOpenConfirmAfterHooks); ok { + hook.OnChanOpenConfirmAfterHook(ctx, portID, channelID, err) + } + return err +} + +// OnChanCloseInit implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // Here we can remove the limits when a new channel is closed. For now, they can remove them manually on the contract + if hook, ok := im.ICS4Middleware.Hooks.(OnChanCloseInitOverrideHooks); ok { + return hook.OnChanCloseInitOverride(im, ctx, portID, channelID) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanCloseInitBeforeHooks); ok { + hook.OnChanCloseInitBeforeHook(ctx, portID, channelID) + } + err := im.App.OnChanCloseInit(ctx, portID, channelID) + if hook, ok := im.ICS4Middleware.Hooks.(OnChanCloseInitAfterHooks); ok { + hook.OnChanCloseInitAfterHook(ctx, portID, channelID, err) + } + + return err +} + +// OnChanCloseConfirm implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + // Here we can remove the limits when a new channel is closed. For now, they can remove them manually on the contract + if hook, ok := im.ICS4Middleware.Hooks.(OnChanCloseConfirmOverrideHooks); ok { + return hook.OnChanCloseConfirmOverride(im, ctx, portID, channelID) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnChanCloseConfirmBeforeHooks); ok { + hook.OnChanCloseConfirmBeforeHook(ctx, portID, channelID) + } + err := im.App.OnChanCloseConfirm(ctx, portID, channelID) + if hook, ok := im.ICS4Middleware.Hooks.(OnChanCloseConfirmAfterHooks); ok { + hook.OnChanCloseConfirmAfterHook(ctx, portID, channelID, err) + } + + return err +} + +// OnRecvPacket implements the IBCMiddleware interface +func (im IBCMiddleware) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + if hook, ok := im.ICS4Middleware.Hooks.(OnRecvPacketOverrideHooks); ok { + return hook.OnRecvPacketOverride(im, ctx, packet, relayer) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnRecvPacketBeforeHooks); ok { + hook.OnRecvPacketBeforeHook(ctx, packet, relayer) + } + + ack := im.App.OnRecvPacket(ctx, packet, relayer) + + if hook, ok := im.ICS4Middleware.Hooks.(OnRecvPacketAfterHooks); ok { + hook.OnRecvPacketAfterHook(ctx, packet, relayer, ack) + } + + return ack +} + +// OnAcknowledgementPacket implements the IBCMiddleware interface +func (im IBCMiddleware) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + if hook, ok := im.ICS4Middleware.Hooks.(OnAcknowledgementPacketOverrideHooks); ok { + return hook.OnAcknowledgementPacketOverride(im, ctx, packet, acknowledgement, relayer) + } + if hook, ok := im.ICS4Middleware.Hooks.(OnAcknowledgementPacketBeforeHooks); ok { + hook.OnAcknowledgementPacketBeforeHook(ctx, packet, acknowledgement, relayer) + } + + err := im.App.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) + + if hook, ok := im.ICS4Middleware.Hooks.(OnAcknowledgementPacketAfterHooks); ok { + hook.OnAcknowledgementPacketAfterHook(ctx, packet, acknowledgement, relayer, err) + } + + return err +} + +// OnTimeoutPacket implements the IBCMiddleware interface +func (im IBCMiddleware) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + if hook, ok := im.ICS4Middleware.Hooks.(OnTimeoutPacketOverrideHooks); ok { + return hook.OnTimeoutPacketOverride(im, ctx, packet, relayer) + } + + if hook, ok := im.ICS4Middleware.Hooks.(OnTimeoutPacketBeforeHooks); ok { + hook.OnTimeoutPacketBeforeHook(ctx, packet, relayer) + } + err := im.App.OnTimeoutPacket(ctx, packet, relayer) + if hook, ok := im.ICS4Middleware.Hooks.(OnTimeoutPacketAfterHooks); ok { + hook.OnTimeoutPacketAfterHook(ctx, packet, relayer, err) + } + + return err +} + +// SendPacket implements the ICS4 Wrapper interface +func (im IBCMiddleware) SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet ibcexported.PacketI, +) error { + return im.ICS4Middleware.SendPacket(ctx, chanCap, packet) +} + +// WriteAcknowledgement implements the ICS4 Wrapper interface +func (im IBCMiddleware) WriteAcknowledgement( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet ibcexported.PacketI, + ack ibcexported.Acknowledgement, +) error { + return im.ICS4Middleware.WriteAcknowledgement(ctx, chanCap, packet, ack) +} + +//func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { +// return im.ICS4Middleware.GetAppVersion(ctx, portID, channelID) +//} diff --git a/x/ibc-hooks/ics4_middleware.go b/x/ibc-hooks/ics4_middleware.go new file mode 100644 index 00000000000..6ec2b54b2d4 --- /dev/null +++ b/x/ibc-hooks/ics4_middleware.go @@ -0,0 +1,77 @@ +package ibc_hooks + +import ( + // external libraries + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + // ibc-go + porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" +) + +var _ porttypes.ICS4Wrapper = &ICS4Middleware{} + +type ICS4Middleware struct { + channel porttypes.ICS4Wrapper + + // Hooks + Hooks Hooks +} + +func NewICS4Middleware(channel porttypes.ICS4Wrapper, hooks Hooks) ICS4Middleware { + return ICS4Middleware{ + channel: channel, + Hooks: hooks, + } +} + +func (i ICS4Middleware) SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet ibcexported.PacketI) error { + if hook, ok := i.Hooks.(SendPacketOverrideHooks); ok { + return hook.SendPacketOverride(i, ctx, channelCap, packet) + } + + if hook, ok := i.Hooks.(SendPacketBeforeHooks); ok { + hook.SendPacketBeforeHook(ctx, channelCap, packet) + } + + err := i.channel.SendPacket(ctx, channelCap, packet) + + if hook, ok := i.Hooks.(SendPacketAfterHooks); ok { + hook.SendPacketAfterHook(ctx, channelCap, packet, err) + } + + return err +} + +func (i ICS4Middleware) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error { + if hook, ok := i.Hooks.(WriteAcknowledgementOverrideHooks); ok { + return hook.WriteAcknowledgementOverride(i, ctx, chanCap, packet, ack) + } + + if hook, ok := i.Hooks.(WriteAcknowledgementBeforeHooks); ok { + hook.WriteAcknowledgementBeforeHook(ctx, chanCap, packet, ack) + } + err := i.channel.WriteAcknowledgement(ctx, chanCap, packet, ack) + if hook, ok := i.Hooks.(WriteAcknowledgementAfterHooks); ok { + hook.WriteAcknowledgementAfterHook(ctx, chanCap, packet, ack, err) + } + + return err +} + +//func (i ICS4Middleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { +// if hook, ok := i.Hooks.(GetAppVersionOverrideHooks); ok { +// return hook.GetAppVersionOverride(i, ctx, portID, channelID) +// } +// +// if hook, ok := i.Hooks.(GetAppVersionBeforeHooks); ok { +// hook.GetAppVersionBeforeHook(ctx, portID, channelID) +// } +// version, err := (*i.channel).GetAppVersion(ctx, portID, channelID) +// if hook, ok := i.Hooks.(GetAppVersionAfterHooks); ok { +// hook.GetAppVersionAfterHook(ctx, portID, channelID, version, err) +// } +// +// return version, err +//} diff --git a/x/ibc-hooks/sdkmodule.go b/x/ibc-hooks/sdkmodule.go new file mode 100644 index 00000000000..61611869e37 --- /dev/null +++ b/x/ibc-hooks/sdkmodule.go @@ -0,0 +1,141 @@ +package ibc_hooks + +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + + "github.com/osmosis-labs/osmosis/v13/osmoutils" + + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +type Ibcmodule struct{} + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + ModuleName = "ibchooks" +) + +// AppModuleBasic defines the basic application module used by the mint module. +type AppModuleBasic struct{} + +var _ module.AppModuleBasic = AppModuleBasic{} + +// Name returns the mint module's name. +func (AppModuleBasic) Name() string { + return ModuleName +} + +// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types. +func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} + +// DefaultGenesis returns default genesis state as raw bytes for the +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + emptyString := "{}" + return []byte(emptyString) +} + +// ValidateGenesis performs genesis state validation for the mint module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + return nil +} + +// RegisterRESTRoutes registers the REST routes for the mint module. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {} + +// GetTxCmd returns no root tx command for the mint module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } + +// GetQueryCmd returns the root query command for the mint module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return nil +} + +// ___________________________________________________________________________ + +// AppModule implements an application module for the mint module. +type AppModule struct { + AppModuleBasic + + authKeeper osmoutils.AccountKeeper +} + +// NewAppModule creates a new AppModule object. +func NewAppModule(ak osmoutils.AccountKeeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + authKeeper: ak, + } +} + +// Name returns the mint module's name. +func (AppModule) Name() string { + return ModuleName +} + +// RegisterInvariants registers the mint module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// Route returns the message routing key for the mint module. +func (AppModule) Route() sdk.Route { return sdk.Route{} } + +// QuerierRoute returns the module's querier route name. +func (AppModule) QuerierRoute() string { + return "" +} + +// LegacyQuerierHandler returns the x/mint module's sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { + return nil, fmt.Errorf("legacy querier not supported for the x/%s module", ModuleName) + } +} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { +} + +// InitGenesis performs genesis initialization for the ibc-hooks module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + IbcHooksInitGenesis(ctx, am.authKeeper) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the mint +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + return json.RawMessage{} +} + +// BeginBlock returns the begin blocker for the mint module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +} + +// EndBlock returns the end blocker for the mint module. It returns no validator +// updates. +func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } diff --git a/x/ibc-hooks/testutils/Cargo.toml b/x/ibc-hooks/testutils/Cargo.toml new file mode 100644 index 00000000000..9e4bf04d415 --- /dev/null +++ b/x/ibc-hooks/testutils/Cargo.toml @@ -0,0 +1,16 @@ +[workspace] + +members = [ + 'contracts/*', +] + +[profile.release] +codegen-units = 1 +debug = false +debug-assertions = false +incremental = false +lto = true +opt-level = 3 +overflow-checks = true +panic = 'abort' +rpath = false diff --git a/x/ibc-hooks/testutils/contracts/counter/Cargo.toml b/x/ibc-hooks/testutils/contracts/counter/Cargo.toml new file mode 100644 index 00000000000..f164afc0e66 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "counter" +description = "Cosmwasm counter dapp, with permissions for testing Osmosis wasmhooks" +version = "0.1.0" +authors = ["osmosis contributors"] +edition = "2021" + +exclude = [ + # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. + "contract.wasm", + "hash.txt", +] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib", "rlib"] + +[features] +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +# use library feature to disable all instantiate/execute/query exports +library = [] + +[package.metadata.scripts] +optimize = """docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/rust-optimizer:0.12.6 +""" + +[dependencies] +cosmwasm-schema = "1.1.3" +cosmwasm-std = "1.1.3" +cosmwasm-storage = "1.1.3" +cw-storage-plus = "0.16.0" +cw2 = "0.16.0" +schemars = "0.8.10" +serde = { version = "1.0.145", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.31" } + +[dev-dependencies] +cw-multi-test = "0.16.0" diff --git a/x/ibc-hooks/testutils/contracts/counter/README.md b/x/ibc-hooks/testutils/contracts/counter/README.md new file mode 100644 index 00000000000..18de2ea5590 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/README.md @@ -0,0 +1,11 @@ +# Counter + +This contract is a modification of the standard cosmwasm `counter` contract. +Namely it tracks a counter, _by sender_. +This is done to let us be able to test wasmhooks in Osmosis better. + +This contract tracks any funds sent to it by adding it to the state under the `sender` key. + +This way we can verify that, independently of the sender, the funds will end up under the +`WasmHooksModuleAccount` address when the contract is executed via an IBC send that goes +through the wasmhooks module. diff --git a/x/ibc-hooks/testutils/contracts/counter/src/contract.rs b/x/ibc-hooks/testutils/contracts/counter/src/contract.rs new file mode 100644 index 00000000000..be67b59302b --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/src/contract.rs @@ -0,0 +1,287 @@ +use std::collections::HashMap; + +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cosmwasm_std::{ + to_binary, Binary, Coin, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint128, +}; +use cw2::set_contract_version; + +use crate::error::ContractError; +use crate::msg::*; +use crate::state::{Counter, COUNTERS}; + +// version info for migration info +const CONTRACT_NAME: &str = "osmosis:permissioned_counter"; +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn instantiate( + deps: DepsMut, + _env: Env, + info: MessageInfo, + msg: InstantiateMsg, +) -> Result { + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + let initial_counter = Counter { + count: msg.count, + total_funds: vec![], + owner: info.sender.clone(), + }; + COUNTERS.save(deps.storage, info.sender.clone(), &initial_counter)?; + + Ok(Response::new() + .add_attribute("method", "instantiate") + .add_attribute("owner", info.sender) + .add_attribute("count", msg.count.to_string())) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps: DepsMut, + _env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::Increment {} => execute::increment(deps, info), + ExecuteMsg::Reset { count } => execute::reset(deps, info, count), + } +} + +pub mod execute { + use super::*; + + pub fn increment(deps: DepsMut, info: MessageInfo) -> Result { + COUNTERS.update( + deps.storage, + info.sender.clone(), + |state| -> Result<_, ContractError> { + match state { + None => Ok(Counter { + count: 0, + total_funds: vec![], + owner: info.sender.clone(), + }), + Some(counter) => Ok(Counter { + count: counter.count + 1, + total_funds: naive_add_coins(&info.funds, &counter.total_funds), + owner: info.sender.clone(), + }), + } + }, + )?; + + Ok(Response::new().add_attribute("action", "increment")) + } + + pub fn reset(deps: DepsMut, info: MessageInfo, count: i32) -> Result { + COUNTERS.update( + deps.storage, + info.sender.clone(), + |state| -> Result<_, ContractError> { + match state { + None => Err(ContractError::Unauthorized {}), + Some(state) if state.owner != info.sender.clone() => { + Err(ContractError::Unauthorized {}) + } + _ => Ok(Counter { + count, + total_funds: vec![], + owner: info.sender.clone(), + }), + } + }, + )?; + Ok(Response::new().add_attribute("action", "reset")) + } +} + +pub fn naive_add_coins(lhs: &Vec, rhs: &Vec) -> Vec { + // This is a naive, inneficient implementation of Vec addition. + // This shouldn't be used in production but serves our purpose for this + // testing contract + let mut coins: HashMap = HashMap::new(); + for coin in lhs { + coins.insert(coin.denom.clone(), coin.amount); + } + + + for coin in rhs { + coins + .entry(coin.denom.clone()) + .and_modify(|e| *e += coin.amount) + .or_insert(coin.amount); + } + coins.iter().map(|(d, &a)| Coin::new(a.into(), d)).collect() +} + +#[test] +fn coin_addition() { + let c1 = vec![Coin::new(1, "a"), Coin::new(2, "b")]; + let c2 = vec![Coin::new(7, "a"), Coin::new(2, "c")]; + + let mut sum = naive_add_coins(&c1, &c1); + sum.sort_by(|a, b| a.denom.cmp(&b.denom)); + assert_eq!(sum, vec![Coin::new(2, "a"), Coin::new(4, "b")]); + + let mut sum = naive_add_coins(&c1, &c2); + sum.sort_by(|a, b| a.denom.cmp(&b.denom)); + assert_eq!( + sum, + vec![Coin::new(8, "a"), Coin::new(2, "b"), Coin::new(2, "c"),] + ); + + let mut sum = naive_add_coins(&c2, &c2); + sum.sort_by(|a, b| a.denom.cmp(&b.denom)); + assert_eq!(sum, vec![Coin::new(14, "a"), Coin::new(4, "c"),]); + + let mut sum = naive_add_coins(&c2, &c1); + sum.sort_by(|a, b| a.denom.cmp(&b.denom)); + assert_eq!( + sum, + vec![Coin::new(8, "a"), Coin::new(2, "b"), Coin::new(2, "c"),] + ); + + let mut sum = naive_add_coins(&vec![], &c2); + sum.sort_by(|a, b| a.denom.cmp(&b.denom)); + assert_eq!(sum, c2); + + let mut sum = naive_add_coins(&c2, &vec![]); + sum.sort_by(|a, b| a.denom.cmp(&b.denom)); + assert_eq!(sum, c2); +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::GetCount { addr } => to_binary(&query::count(deps, addr)?), + QueryMsg::GetTotalFunds { addr } => to_binary(&query::total_funds(deps, addr)?), + } +} + +pub mod query { + use cosmwasm_std::Addr; + + use super::*; + + pub fn count(deps: Deps, addr: Addr) -> StdResult { + let state = COUNTERS.load(deps.storage, addr)?; + Ok(GetCountResponse { count: state.count }) + } + + pub fn total_funds(deps: Deps, addr: Addr) -> StdResult { + let state = COUNTERS.load(deps.storage, addr)?; + Ok(GetTotalFundsResponse { + total_funds: state.total_funds, + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; + use cosmwasm_std::Addr; + use cosmwasm_std::{coins, from_binary}; + + #[test] + fn proper_initialization() { + let mut deps = mock_dependencies(); + + let msg = InstantiateMsg { count: 17 }; + let info = mock_info("creator", &coins(1000, "earth")); + + // we can just call .unwrap() to assert this was a success + let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + assert_eq!(0, res.messages.len()); + + // it worked, let's query the state + let res = query( + deps.as_ref(), + mock_env(), + QueryMsg::GetCount { + addr: Addr::unchecked("creator"), + }, + ) + .unwrap(); + let value: GetCountResponse = from_binary(&res).unwrap(); + assert_eq!(17, value.count); + } + + #[test] + fn increment() { + let mut deps = mock_dependencies(); + + let msg = InstantiateMsg { count: 17 }; + let info = mock_info("creator", &coins(2, "token")); + let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + + let msg = InstantiateMsg { count: 17 }; + let info = mock_info("someone-else", &coins(2, "token")); + let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + + let info = mock_info("creator", &coins(2, "token")); + let msg = ExecuteMsg::Increment {}; + let _res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + + // should increase counter by 1 + let res = query( + deps.as_ref(), + mock_env(), + QueryMsg::GetCount { + addr: Addr::unchecked("creator"), + }, + ) + .unwrap(); + let value: GetCountResponse = from_binary(&res).unwrap(); + assert_eq!(18, value.count); + + // Counter for someone else is not incremented + let res = query( + deps.as_ref(), + mock_env(), + QueryMsg::GetCount { + addr: Addr::unchecked("someone-else"), + }, + ) + .unwrap(); + let value: GetCountResponse = from_binary(&res).unwrap(); + assert_eq!(17, value.count); + } + + #[test] + fn reset() { + let mut deps = mock_dependencies(); + + let msg = InstantiateMsg { count: 17 }; + let info = mock_info("creator", &coins(2, "token")); + let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + + // beneficiary can release it + let unauth_info = mock_info("anyone", &coins(2, "token")); + let msg = ExecuteMsg::Reset { count: 5 }; + let res = execute(deps.as_mut(), mock_env(), unauth_info, msg); + match res { + Err(ContractError::Unauthorized {}) => {} + _ => panic!("Must return unauthorized error"), + } + + // only the original creator can reset the counter + let auth_info = mock_info("creator", &coins(2, "token")); + let msg = ExecuteMsg::Reset { count: 5 }; + let _res = execute(deps.as_mut(), mock_env(), auth_info, msg).unwrap(); + + // should now be 5 + let res = query( + deps.as_ref(), + mock_env(), + QueryMsg::GetCount { + addr: Addr::unchecked("creator"), + }, + ) + .unwrap(); + let value: GetCountResponse = from_binary(&res).unwrap(); + assert_eq!(5, value.count); + } +} diff --git a/x/ibc-hooks/testutils/contracts/counter/src/error.rs b/x/ibc-hooks/testutils/contracts/counter/src/error.rs new file mode 100644 index 00000000000..3caf0c5c5bc --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/src/error.rs @@ -0,0 +1,16 @@ +use cosmwasm_std::StdError; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ContractError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("Unauthorized")] + Unauthorized {}, + + #[error("Custom Error val: {val:?}")] + CustomError { val: String }, + // Add any other custom errors you like here. + // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details. +} diff --git a/x/ibc-hooks/testutils/contracts/counter/src/helpers.rs b/x/ibc-hooks/testutils/contracts/counter/src/helpers.rs new file mode 100644 index 00000000000..c943c136584 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/src/helpers.rs @@ -0,0 +1,48 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use cosmwasm_std::{ + to_binary, Addr, Coin, CosmosMsg, CustomQuery, Querier, QuerierWrapper, StdResult, WasmMsg, + WasmQuery, +}; + +use crate::msg::{ExecuteMsg, GetCountResponse, QueryMsg}; + +/// CwTemplateContract is a wrapper around Addr that provides a lot of helpers +/// for working with this. +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct CwTemplateContract(pub Addr); + +impl CwTemplateContract { + pub fn addr(&self) -> Addr { + self.0.clone() + } + + pub fn call>(&self, msg: T) -> StdResult { + let msg = to_binary(&msg.into())?; + Ok(WasmMsg::Execute { + contract_addr: self.addr().into(), + msg, + funds: vec![], + } + .into()) + } + + /// Get Count + pub fn count(&self, querier: &Q, addr: Addr) -> StdResult + where + Q: Querier, + T: Into, + CQ: CustomQuery, + { + let msg = QueryMsg::GetCount { addr }; + let query = WasmQuery::Smart { + contract_addr: self.addr().into(), + msg: to_binary(&msg)?, + } + .into(); + let res: GetCountResponse = QuerierWrapper::::new(querier).query(&query)?; + Ok(res) + } +} + diff --git a/x/ibc-hooks/testutils/contracts/counter/src/integration_tests.rs b/x/ibc-hooks/testutils/contracts/counter/src/integration_tests.rs new file mode 100644 index 00000000000..4c507846521 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/src/integration_tests.rs @@ -0,0 +1,71 @@ +#[cfg(test)] +mod tests { + use crate::helpers::CwTemplateContract; + use crate::msg::InstantiateMsg; + use cosmwasm_std::{Addr, Coin, Empty, Uint128}; + use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor}; + + pub fn contract_template() -> Box> { + let contract = ContractWrapper::new( + crate::contract::execute, + crate::contract::instantiate, + crate::contract::query, + ); + Box::new(contract) + } + + const USER: &str = "USER"; + const ADMIN: &str = "ADMIN"; + const NATIVE_DENOM: &str = "denom"; + + fn mock_app() -> App { + AppBuilder::new().build(|router, _, storage| { + router + .bank + .init_balance( + storage, + &Addr::unchecked(USER), + vec![Coin { + denom: NATIVE_DENOM.to_string(), + amount: Uint128::new(1), + }], + ) + .unwrap(); + }) + } + + fn proper_instantiate() -> (App, CwTemplateContract) { + let mut app = mock_app(); + let cw_template_id = app.store_code(contract_template()); + + let msg = InstantiateMsg { count: 1i32 }; + let cw_template_contract_addr = app + .instantiate_contract( + cw_template_id, + Addr::unchecked(ADMIN), + &msg, + &[], + "test", + None, + ) + .unwrap(); + + let cw_template_contract = CwTemplateContract(cw_template_contract_addr); + + (app, cw_template_contract) + } + + mod count { + use super::*; + use crate::msg::ExecuteMsg; + + #[test] + fn count() { + let (mut app, cw_template_contract) = proper_instantiate(); + + let msg = ExecuteMsg::Increment {}; + let cosmos_msg = cw_template_contract.call(msg).unwrap(); + app.execute(Addr::unchecked(USER), cosmos_msg).unwrap(); + } + } +} diff --git a/x/ibc-hooks/testutils/contracts/counter/src/lib.rs b/x/ibc-hooks/testutils/contracts/counter/src/lib.rs new file mode 100644 index 00000000000..ffd1f6ac440 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/src/lib.rs @@ -0,0 +1,9 @@ +#![allow(unused_imports)] +pub mod contract; +mod error; +pub mod helpers; +pub mod integration_tests; +pub mod msg; +pub mod state; + +pub use crate::error::ContractError; diff --git a/x/ibc-hooks/testutils/contracts/counter/src/msg.rs b/x/ibc-hooks/testutils/contracts/counter/src/msg.rs new file mode 100644 index 00000000000..6c29fdf2508 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/src/msg.rs @@ -0,0 +1,34 @@ +use cosmwasm_schema::{cw_serde, QueryResponses}; +use cosmwasm_std::{Addr, Coin}; + +#[cw_serde] +pub struct InstantiateMsg { + pub count: i32, +} + +#[cw_serde] +pub enum ExecuteMsg { + Increment {}, + Reset { count: i32 }, +} + +#[cw_serde] +#[derive(QueryResponses)] +pub enum QueryMsg { + // GetCount returns the current count as a json-encoded number + #[returns(GetCountResponse)] + GetCount { addr: Addr }, + #[returns(GetTotalFundsResponse)] + GetTotalFunds { addr: Addr }, +} + +// We define a custom struct for each query response +#[cw_serde] +pub struct GetCountResponse { + pub count: i32, +} + +#[cw_serde] +pub struct GetTotalFundsResponse { + pub total_funds: Vec, +} diff --git a/x/ibc-hooks/testutils/contracts/counter/src/state.rs b/x/ibc-hooks/testutils/contracts/counter/src/state.rs new file mode 100644 index 00000000000..4b8002fc4f7 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/counter/src/state.rs @@ -0,0 +1,14 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use cosmwasm_std::{Addr, Coin}; +use cw_storage_plus::{Item, Map}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct Counter { + pub count: i32, + pub total_funds: Vec, + pub owner: Addr, +} + +pub const COUNTERS: Map = Map::new("state"); diff --git a/x/ibc-hooks/testutils/contracts/echo/Cargo.toml b/x/ibc-hooks/testutils/contracts/echo/Cargo.toml new file mode 100644 index 00000000000..6980ce8cb24 --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/echo/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "echo" +description = "Cosmwasm contract that always returns the same response" +version = "0.1.0" +authors = ["osmosis contributors"] +edition = "2021" + +exclude = [ + # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. + "contract.wasm", + "hash.txt", +] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib", "rlib"] + +[features] +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +# use library feature to disable all instantiate/execute/query exports +library = [] + +[package.metadata.scripts] +optimize = """docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/rust-optimizer:0.12.6 +""" + +[dependencies] +cosmwasm-schema = "1.1.3" +cosmwasm-std = "1.1.3" +cosmwasm-storage = "1.1.3" +cw-storage-plus = "0.16.0" +schemars = "0.8.10" +serde = { version = "1.0.145", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.31" } + +[dev-dependencies] +cw-multi-test = "0.16.0" diff --git a/x/ibc-hooks/testutils/contracts/echo/src/lib.rs b/x/ibc-hooks/testutils/contracts/echo/src/lib.rs new file mode 100644 index 00000000000..ab1d16a3aef --- /dev/null +++ b/x/ibc-hooks/testutils/contracts/echo/src/lib.rs @@ -0,0 +1,42 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cosmwasm_std::{DepsMut, Env, MessageInfo, Response, StdError}; +use cosmwasm_schema::{cw_serde}; + +// Messages +#[cw_serde] +pub struct InstantiateMsg {} + +#[cw_serde] +pub enum ExecuteMsg { + Echo { msg: String }, +} + +// Instantiate +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn instantiate( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: InstantiateMsg, +) -> Result { + Ok(Response::new()) +} + +// Execute +fn simple_response(msg: String) -> Response { + Response::new() + .add_attribute("echo", msg) + .set_data(b"this should echo") +} +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::Echo { msg } => Ok(simple_response(msg)), + } +} diff --git a/x/ibc-hooks/testutils/testing_hooks.go b/x/ibc-hooks/testutils/testing_hooks.go new file mode 100644 index 00000000000..3b9671c03fc --- /dev/null +++ b/x/ibc-hooks/testutils/testing_hooks.go @@ -0,0 +1,42 @@ +package testutils + +import ( + // external libraries + sdk "github.com/cosmos/cosmos-sdk/types" + + // ibc-go + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" + + ibchooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks" +) + +var ( + _ ibchooks.Hooks = TestRecvOverrideHooks{} + _ ibchooks.Hooks = TestRecvBeforeAfterHooks{} +) + +type Status struct { + OverrideRan bool + BeforeRan bool + AfterRan bool +} + +// Recv +type TestRecvOverrideHooks struct{ Status *Status } + +func (t TestRecvOverrideHooks) OnRecvPacketOverride(im ibchooks.IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement { + t.Status.OverrideRan = true + ack := im.App.OnRecvPacket(ctx, packet, relayer) + return ack +} + +type TestRecvBeforeAfterHooks struct{ Status *Status } + +func (t TestRecvBeforeAfterHooks) OnRecvPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) { + t.Status.BeforeRan = true +} + +func (t TestRecvBeforeAfterHooks) OnRecvPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ack ibcexported.Acknowledgement) { + t.Status.AfterRan = true +} diff --git a/x/ibc-hooks/types/errors.go b/x/ibc-hooks/types/errors.go new file mode 100644 index 00000000000..2c05d7fcce4 --- /dev/null +++ b/x/ibc-hooks/types/errors.go @@ -0,0 +1,8 @@ +package types + +var ( + ErrBadPacketMetadataMsg = "cannot unmarshal metadata: '%v'. %s" + ErrBadMetadataFormatMsg = "wasm metadata not properly formatted for: '%v'. %s" + ErrBadExecutionMsg = "cannot execute contract: %v" + ErrBadResponse = "cannot create response: %v" +) diff --git a/x/ibc-hooks/wasm_hook.go b/x/ibc-hooks/wasm_hook.go new file mode 100644 index 00000000000..4eca8bf1bc5 --- /dev/null +++ b/x/ibc-hooks/wasm_hook.go @@ -0,0 +1,204 @@ +package ibc_hooks + +import ( + "encoding/json" + "fmt" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + + "github.com/osmosis-labs/osmosis/v13/osmoutils" + + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" + + "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks/types" +) + +type ContractAck struct { + ContractResult []byte `json:"contract_result"` + IbcAck []byte `json:"ibc_ack"` +} + +type WasmHooks struct { + ContractKeeper *wasmkeeper.PermissionedKeeper +} + +func NewWasmHooks(contractKeeper *wasmkeeper.PermissionedKeeper) WasmHooks { + return WasmHooks{ContractKeeper: contractKeeper} +} + +func (h WasmHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement { + if h.ContractKeeper == nil { + // Not configured + return im.App.OnRecvPacket(ctx, packet, relayer) + } + + isIcs20, data := isIcs20Packet(packet) + if !isIcs20 { + return im.App.OnRecvPacket(ctx, packet, relayer) + } + + // Validate the memo + isWasmRouted, contractAddr, msgBytes, err := ValidateAndParseMemo(data.GetMemo(), data.Receiver) + if !isWasmRouted { + return im.App.OnRecvPacket(ctx, packet, relayer) + } + if err != nil { + return channeltypes.NewErrorAcknowledgement(err.Error()) + } + if msgBytes == nil || contractAddr == nil { // This should never happen + return channeltypes.NewErrorAcknowledgement("error in wasmhook message validation") + } + + // The funds sent on this packet need to be transferred to the wasm hooks module address/ + // For this, we override the ICS20 packet's Receiver (essentially hijacking the funds for the module) + // and execute the underlying OnRecvPacket() call (which should eventually land on the transfer app's + // relay.go and send the sunds to the module. + // + // If that succeeds, we make the contract call + data.Receiver = WasmHookModuleAccountAddr.String() + bz, err := json.Marshal(data) + if err != nil { + return channeltypes.NewErrorAcknowledgement(fmt.Sprintf("cannot marshal the ICS20 packet: %s", err.Error())) + } + packet.Data = bz + + // Execute the receive + ack := im.App.OnRecvPacket(ctx, packet, relayer) + if !ack.Success() { + return ack + } + + amount, ok := sdk.NewIntFromString(data.GetAmount()) + if !ok { + // This should never happen, as it should've been caught in the underlaying call to OnRecvPacket, + // but returning here for completeness + return channeltypes.NewErrorAcknowledgement("Invalid packet data: Amount is not an int") + } + + // The packet's denom is the denom in the sender chain. This needs to be converted to the local denom. + denom := osmoutils.MustExtractDenomFromPacketOnRecv(packet) + funds := sdk.NewCoins(sdk.NewCoin(denom, amount)) + + execMsg := wasmtypes.MsgExecuteContract{ + Sender: WasmHookModuleAccountAddr.String(), + Contract: contractAddr.String(), + Msg: msgBytes, + Funds: funds, + } + response, err := h.execWasmMsg(ctx, &execMsg) + if err != nil { + return channeltypes.NewErrorAcknowledgement(err.Error()) + } + + fullAck := ContractAck{ContractResult: response.Data, IbcAck: ack.Acknowledgement()} + bz, err = json.Marshal(fullAck) + if err != nil { + return channeltypes.NewErrorAcknowledgement(fmt.Sprintf(types.ErrBadResponse, err.Error())) + } + + return channeltypes.NewResultAcknowledgement(bz) +} + +func (h WasmHooks) execWasmMsg(ctx sdk.Context, execMsg *wasmtypes.MsgExecuteContract) (*wasmtypes.MsgExecuteContractResponse, error) { + if err := execMsg.ValidateBasic(); err != nil { + return nil, fmt.Errorf(types.ErrBadExecutionMsg, err.Error()) + } + wasmMsgServer := wasmkeeper.NewMsgServerImpl(h.ContractKeeper) + return wasmMsgServer.ExecuteContract(sdk.WrapSDKContext(ctx), execMsg) +} + +func isIcs20Packet(packet channeltypes.Packet) (isIcs20 bool, ics20data transfertypes.FungibleTokenPacketData) { + var data transfertypes.FungibleTokenPacketData + if err := json.Unmarshal(packet.GetData(), &data); err != nil { + return false, data + } + return true, data +} + +func isMemoWasmRouted(memo string) (isWasmRouted bool, metadata map[string]interface{}) { + metadata = make(map[string]interface{}) + + // If there is no memo, the packet was either sent with an earlier version of IBC, or the memo was + // intentionally left blank. Nothing to do here. Ignore the packet and pass it down the stack. + if len(memo) == 0 { + return false, metadata + } + + // the metadata must be a valid JSON object + err := json.Unmarshal([]byte(memo), &metadata) + if err != nil { + return false, metadata + } + + // If the key "wasm" doesn't exist, there's nothing to do on this hook. Continue by passing the packet + // down the stack + _, ok := metadata["wasm"] + if !ok { + return false, metadata + } + + return true, metadata +} + +func ValidateAndParseMemo(memo string, receiver string) (isWasmRouted bool, contractAddr sdk.AccAddress, msgBytes []byte, err error) { + isWasmRouted, metadata := isMemoWasmRouted(memo) + if !isWasmRouted { + return isWasmRouted, sdk.AccAddress{}, nil, nil + } + + wasmRaw := metadata["wasm"] + + // Make sure the wasm key is a map. If it isn't, ignore this packet + wasm, ok := wasmRaw.(map[string]interface{}) + if !ok { + return isWasmRouted, sdk.AccAddress{}, nil, + fmt.Errorf(types.ErrBadMetadataFormatMsg, memo, "wasm metadata is not a valid JSON map object") + } + + // Get the contract + contract, ok := wasm["contract"].(string) + if !ok { + // The tokens will be returned + return isWasmRouted, sdk.AccAddress{}, nil, + fmt.Errorf(types.ErrBadMetadataFormatMsg, memo, `Could not find key wasm["contract"]`) + } + + contractAddr, err = sdk.AccAddressFromBech32(contract) + if err != nil { + return isWasmRouted, sdk.AccAddress{}, nil, + fmt.Errorf(types.ErrBadMetadataFormatMsg, memo, `wasm["contract"] is not a valid bech32 address`) + } + + // The contract and the receiver should be the same for the packet to be valid + if contract != receiver { + return isWasmRouted, sdk.AccAddress{}, nil, + fmt.Errorf(types.ErrBadMetadataFormatMsg, memo, `wasm["contract"] should be the same as the receiver of the packet`) + } + + // Ensure the message key is provided + if wasm["msg"] == nil { + return isWasmRouted, sdk.AccAddress{}, nil, + fmt.Errorf(types.ErrBadMetadataFormatMsg, memo, `Could not find key wasm["msg"]`) + } + + // Make sure the msg key is a map. If it isn't, return an error + _, ok = wasm["msg"].(map[string]interface{}) + if !ok { + return isWasmRouted, sdk.AccAddress{}, nil, + fmt.Errorf(types.ErrBadMetadataFormatMsg, memo, `wasm["msg"] is not a map object`) + } + + // Get the message string by serializing the map + msgBytes, err = json.Marshal(wasm["msg"]) + if err != nil { + // The tokens will be returned + return isWasmRouted, sdk.AccAddress{}, nil, + fmt.Errorf(types.ErrBadMetadataFormatMsg, memo, err.Error()) + } + + return isWasmRouted, contractAddr, msgBytes, nil +} diff --git a/x/ibc-rate-limit/Cargo.lock b/x/ibc-rate-limit/Cargo.lock new file mode 100644 index 00000000000..07e4f7e4a10 --- /dev/null +++ b/x/ibc-rate-limit/Cargo.lock @@ -0,0 +1,914 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "const-oid" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" + +[[package]] +name = "cosmwasm-crypto" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28376836c7677e1ea6d6656a754582e88b91e544ce22fae42956d5fe5549a958" +dependencies = [ + "digest 0.10.5", + "ed25519-zebra", + "k256", + "rand_core 0.6.4", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb69f4f7a8a4bce68c8fbd3646238fede1e77056e4ea31c5b6bfc37b709eec3" +dependencies = [ + "syn", +] + +[[package]] +name = "cosmwasm-schema" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a227cfeb9a7152b26a354b1c990e930e962f75fd68f57ab5ae2ef888c8524292" +dependencies = [ + "cosmwasm-schema-derive", + "schemars", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3626cb42eef870de67f791e873711255325224d86f281bf628c42abd295f3a14" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cosmwasm-std" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bf9157d060abbc55152aeadcace799d03dc630575daa66604079a1206cb060" +dependencies = [ + "base64", + "cosmwasm-crypto", + "cosmwasm-derive", + "derivative", + "forward_ref", + "hex", + "schemars", + "serde", + "serde-json-wasm", + "thiserror", + "uint", +] + +[[package]] +name = "cosmwasm-storage" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b61fcfef87d15af0263e2e4d792af80355929674a3b4e29ffb3c898ec6e25852" +dependencies = [ + "cosmwasm-std", + "serde", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "cw-multi-test" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f9a8ab7c3c29ec93cb7a39ce4b14a05e053153b4a17ef7cf2246af1b7c087e" +dependencies = [ + "anyhow", + "cosmwasm-std", + "cosmwasm-storage", + "cw-storage-plus 0.13.4", + "cw-utils", + "derivative", + "itertools", + "prost 0.9.0", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw-storage-plus" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + +[[package]] +name = "cw-storage-plus" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b6f91c0b94481a3e9ef1ceb183c37d00764f8751e39b45fc09f4d9b970d469" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + +[[package]] +name = "cw-utils" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dbaecb78c8e8abfd6b4258c7f4fbeb5c49a5e45ee4d910d3240ee8e1d714e1b" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw2" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus 0.13.4", + "schemars", + "serde", +] + +[[package]] +name = "der" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek", + "hashbrown", + "hex", + "rand_core 0.6.4", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.5", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "forward_ref" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.5", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "libc" +version = "0.2.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "osmosis-std" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b3792977036dc49cfc9af9fd7a6c021fd48dfffc8ebf09324201506c65a47a" +dependencies = [ + "chrono", + "cosmwasm-std", + "osmosis-std-derive", + "prost 0.11.2", + "prost-types", + "schemars", + "serde", + "serde-cw-value", +] + +[[package]] +name = "osmosis-std-derive" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c501f2b8ff88b1c60ab671d7b808e947f384fa2524fe4ec8c06f63ef4be29979" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" +dependencies = [ + "bytes", + "prost-derive 0.9.0", +] + +[[package]] +name = "prost" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0841812012b2d4a6145fae9a6af1534873c32aa67fff26bd09f8fa42c83f95a" +dependencies = [ + "bytes", + "prost-derive 0.11.2", +] + +[[package]] +name = "prost-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164ae68b6587001ca506d3bf7f1000bfa248d0e1217b618108fba4ec1d0cc306" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747761bc3dc48f9a34553bf65605cf6cb6288ba219f3450b4275dbd81539551a" +dependencies = [ + "bytes", + "prost 0.11.2", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rate-limiter" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-multi-test", + "cw-storage-plus 0.16.0", + "cw2", + "hex", + "osmosis-std", + "osmosis-std-derive", + "prost 0.11.2", + "schemars", + "serde", + "serde-json-wasm", + "sha2 0.10.6", + "thiserror", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "schemars" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "serde" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-cw-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75d32da6b8ed758b7d850b6c3c08f1d7df51a4df3cb201296e63e34a78e99d4" +dependencies = [ + "serde", +] + +[[package]] +name = "serde-json-wasm" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.5", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.5", + "rand_core 0.6.4", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "uint" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/x/ibc-rate-limit/README.md b/x/ibc-rate-limit/README.md index f9a91cb8c1c..f8a0b91bdad 100644 --- a/x/ibc-rate-limit/README.md +++ b/x/ibc-rate-limit/README.md @@ -1,26 +1,119 @@ -# # IBC Rate Limit +# IBC Rate Limit -The ``IBC Rate Limit`` middleware implements an [IBC Middleware](https://github.com/cosmos/ibc-go/blob/f57170b1d4dd202a3c6c1c61dcf302b6a9546405/docs/ibc/middleware/develop.md) -that wraps a [transfer](https://ibc.cosmos.network/main/apps/transfer/overview.html) app to regulate how much value can -flow in and out of the chain for a specific denom and channel. +The IBC Rate Limit module is responsible for adding a governance-configurable rate limit to IBC transfers. +This is a safety control, intended to protect assets on osmosis in event of: -## Contents +* a bug/hack on osmosis +* a bug/hack on the counter-party chain +* a bug/hack in IBC itself -1. **[Concepts](#concepts)** -2. **[Parameters](#parameters)** -3. **[Contract](#contract)** -4. **[Integration](#integration)** +This is done in exchange for a potential (one-way) bridge liveness tradeoff, in periods of high deposits or withdrawals. -## Concepts +The architecture of this package is a minimal go package which implements an [IBC Middleware](https://github.com/cosmos/ibc-go/blob/f57170b1d4dd202a3c6c1c61dcf302b6a9546405/docs/ibc/middleware/develop.md) that wraps the [ICS20 transfer](https://ibc.cosmos.network/main/apps/transfer/overview.html) app, and calls into a cosmwasm contract. +The cosmwasm contract then has all of the actual IBC rate limiting logic. +The Cosmwasm code can be found in the [`contracts`](./contracts/) package, with bytecode findable in the [`bytecode`](./bytecode/) folder. The cosmwasm VM usage allows Osmosis chain governance to choose to change this safety control with no hard forks, via a parameter change proposal, a great mitigation for faster threat adaptavity. -### Overview +The status of the module is being in a state suitable for some initial governance settable rate limits for high value bridged assets. +Its not in its long term / end state for all channels by any means, but does act as a strong protection we +can instantiate today for high value IBC connections. -The `x/ibc-rate-limit` module implements an IBC middleware and a transfer app wrapper. The middleware checks if the -amount of value of a specific denom transferred through a channel has exceeded a quota defined by governance for -that channel/denom. These checks are handled through a CosmWasm contract. The contract to be used for this is -configured via a parameter. +## Motivation -### Middleware +The motivation of IBC-rate-limit comes from the empirical observations of blockchain bridge hacks that a rate limit would have massively reduced the stolen amount of assets in: + +- [Polynetwork Bridge Hack ($611 million)](https://rekt.news/polynetwork-rekt/) +- [BNB Bridge Hack ($586 million)](https://rekt.news/bnb-bridge-rekt/) +- [Wormhole Bridge Hack ($326 million)](https://rekt.news/wormhole-rekt/) +- [Nomad Bridge Hack ($190 million)](https://rekt.news/nomad-rekt/) +- [Harmony Bridge Hack ($100 million)](https://rekt.news/harmony-rekt/) - (Would require rate limit + monitoring) +- [Dragonberry IBC bug](https://forum.cosmos.network/t/ibc-security-advisory-dragonberry/7702) (can't yet disclose amount at risk, but was saved due to being found first by altruistic Osmosis core developers) + +In the presence of a software bug on Osmosis, IBC itself, or on a counterparty chain, we would like to prevent the bridge from being fully depegged. +This stems from the idea that a 30% asset depeg is ~infinitely better than a 100% depeg. +Its _crazy_ that today these complex bridged assets can instantly go to 0 in event of bug. +The goal of a rate limit is to raise an alert that something has potentially gone wrong, allowing validators and developers to have time to analyze, react, and protect larger portions of user funds. + +The thesis of this is that, it is worthwile to sacrifice liveness in the case of legitimate demand to send extreme amounts of funds, to prevent the terrible long-tail full fund risks. +Rate limits aren't the end-all of safety controls, they're merely the simplest automated one. More should be explored and added onto IBC! + +## Rate limit types + +We express rate limits in time-based periods. +This means, we set rate limits for (say) 6-hour, daily, and weekly intervals. +The rate limit for a given time period stores the relevant amount of assets at the start of the rate limit. +Rate limits are then defined on percentage terms of the asset. +The time windows for rate limits are currently _not_ rolling, they have discrete start/end times. + +We allow setting separate rate limits for the inflow and outflow of assets. +We do all of our rate limits based on the _net flow_ of assets on a channel pair. This prevents DOS issues, of someone repeatedly sending assets back and forth, to trigger rate limits and break liveness. + +We currently envision creating two kinds of rate limits: + +* Per denomination rate limits + - allows safety statements like "Only 30% of Stars on Osmosis can flow out in one day" or "The amount of Atom on Osmosis can at most double per day". +* Per channel rate limits + - Limit the total inflow and outflow on a given IBC channel, based on "USDC" equivalent, using Osmosis as the price oracle. + +We currently only implement per denomination rate limits for non-native assets. We do not yet implement channel based rate limits. + +Currently these rate limits automatically "expire" at the end of the quota duration. TODO: Think of better designs here. E.g. can we have a constant number of subsequent quotas start filled? Or perhaps harmonically decreasing amounts of next few quotas pre-filled? Halted until DAO override seems not-great. + +## Instantiating rate limits + +Today all rate limit quotas must be set manually by governance. +In the future, we should design towards some conservative rate limit to add as a safety-backstop automatically for channels. +Ideas for how this could look: + +* One month after a channel has been created, automatically add in some USDC-based rate limit +* One month after governance incentivizes an asset, add on a per-denomination rate limit. + +Definitely needs far more ideation and iteration! + +## Parameterizing the rate limit + +One element is we don't want any rate limit timespan thats too short, e.g. not enough time for humans to react to. So we wouldn't want a 1 hour rate limit, unless we think that if its hit, it could be assessed within an hour. + +### Handling rate limit boundaries + +We want to be safe against the case where say we have a daily rate limit ending at a given time, and an adversary attempts to attack near the boundary window. +We would not like them to be able to "double extract funds" by timing their extraction near a window boundary. + +Admittedly, not a lot of thought has been put into how to deal with this well. +Right now we envision simply handling this by saying if you want a quota of duration D, instead include two quotas of duration D, but offset by `D/2` from each other. + +Ideally we can change windows to be more 'rolling' in the future, to avoid this overhead and more cleanly handle the problem. (Perhaps rolling ~1 hour at a time) + +### Inflow parameterization + +The "Inflow" side of a rate limit is essentially protection against unforeseen bug on a counterparty chain. +This can be quite conservative (e.g. bridged amount doubling in one week). This covers a few cases: + +* Counter-party chain B having a token theft attack + - TODO: description of how this looks +* Counter-party chain B runaway mint + - TODO: description of how this looks +* IBC theft + - TODO: description of how this looks + +It does get more complex when the counterparty chain is itself a DEX, but this is still much more protection than nothing. + +### Outflow parameterization + +The "Outflow" side of a rate limit is protection against a bug on Osmosis OR IBC. +This has potential for much more user-frustrating issues, if set too low. +E.g. if theres some event that causes many people to suddenly withdraw many STARS or many USDC. + +So this parameterization has to contend with being a tradeoff of withdrawal liveness in high volatility periods vs being a crucial safety rail, in event of on-Osmosis bug. + +TODO: Better fill out + +### Example suggested parameterization + +## Code structure + +As mentioned at the beginning of the README, the go code is a relatively minimal ICS 20 wrapper, that dispatches relevant calls to a cosmwasm contract that implements the rate limiting functionality. + +### Go Middleware To achieve this, the middleware needs to implement the `porttypes.Middleware` interface and the `porttypes.ICS4Wrapper` interface. This allows the middleware to send and receive IBC messages by wrapping @@ -28,23 +121,14 @@ any IBC module, and be used as an ICS4 wrapper by a transfer module (for sending Of those interfaces, just the following methods have custom logic: -* `ICS4Wrapper.SendPacket` adds tracking of value sent via an ibc channel -* `Middleware.OnRecvPacket` adds tracking of value received via an ibc channel -* `Middleware.OnAcknowledgementPacket` undos the tracking of a sent packet if the acknowledgment is not a success -* `OnTimeoutPacket` undos the tracking of a sent packet if the packet times out (is not relayed) +* `ICS4Wrapper.SendPacket` forwards to contract, with intent of tracking of value sent via an ibc channel +* `Middleware.OnRecvPacket` forwards to contract, with intent of tracking of value received via an ibc channel +* `Middleware.OnAcknowledgementPacket` forwards to contract, with intent of undoing the tracking of a sent packet if the acknowledgment is not a success +* `OnTimeoutPacket` forwards to contract, with intent of undoing the tracking of a sent packet if the packet times out (is not relayed) All other methods from those interfaces are passthroughs to the underlying implementations. -### Contract Concepts - -The tracking contract uses the following concepts - -1. **RateLimit** - tracks the value flow transferred and the quota for a path. -2. **Path** - is a (denom, channel) pair. -3. **Flow** - tracks the value that has moved through a path during the current time window. -4. **Quota** - is the percentage of the denom's total value that can be transferred through the path in a given period of time (duration) - -## Parameters +#### Parameters The middleware uses the following parameters: @@ -55,23 +139,45 @@ The middleware uses the following parameters: 1. **ContractAddress** - The contract address is the address of an instantiated version of the contract provided under `./contracts/` -## Contract +### Cosmwasm Contract Concepts + +Something to keep in mind with all of the code, is that we have to reason separately about every item in the following matrix: + +| Native Token | Non-Native Token | +|----------------------|--------------------------| +| Send Native Token | Send Non-Native Token | +| Receive Native Token | Receive Non-Native Token | +| Timeout Native Send | Timeout Non-native Send | + +(Error ACK can reuse the same code as timeout) + +TODO: Spend more time on sudo messages in the following description. We need to better describe how we map the quota concepts onto the code. +Need to describe how we get the quota beginning balance, and that its different for sends and receives. +Explain intracacies of tracking that a timeout and/or ErrorAck must appear from the same quota, else we ignore its update to the quotas. + + +The tracking contract uses the following concepts -### Messages +1. **RateLimit** - tracks the value flow transferred and the quota for a path. +2. **Path** - is a (denom, channel) pair. +3. **Flow** - tracks the value that has moved through a path during the current time window. +4. **Quota** - is the percentage of the denom's total value that can be transferred through the path in a given period of time (duration) + +#### Messages The contract specifies the following messages: -#### Query +##### Query * GetQuotas - Returns the quotas for a path -#### Exec +##### Exec * AddPath - Adds a list of quotas for a path * RemovePath - Removes a path * ResetPathQuota - If a rate limit has been reached, the contract's governance address can reset the quota so that transfers are allowed again -#### Sudo +##### Sudo Sudo messages can only be executed by the chain. @@ -79,7 +185,73 @@ Sudo messages can only be executed by the chain. * RecvPacket - Increments the amount used out of the receive quota and checks that the receive is allowed. If it isn't, it will return a RateLimitExceeded error * UndoSend - If a send has failed, the undo message is used to remove its cost from the send quota -## Integration +All of these messages receive the packet from the chain and extract the necessary information to process the packet and determine if it should be the rate limited. + +### Necessary information + +To determine if a packet should be rate limited, we need: + +* Channel: The channel on the Osmosis side: `packet.SourceChannel` for sends, and `packet.DestinationChannel` for receives. +* Denom: The denom of the token being transferred as known on the Osmosis side (more on that bellow) +* Channel Value: The total value of the chanel denominated in `Denom` (i.e.: channel-17 is worth 10k osmo). +* Funds: the amount being transferred + +#### Notes on Channel +The contract also supports quotas on a custom channel called "any" that is checked on every transfer. If either the +transfer channel or the "any" channel have a quota that has been filled, the transaction will be rate limited. + +#### Notes on Denom +We always use the the denom as represented on Osmosis. For native assets that is the local denom, and for non-native +assets it's the "ibc" prefix and the sha256 hash of the denom trace (`ibc/...`). + +##### Sends + +For native denoms, we can just use the denom in the packet. If the denom is invalid, it will fail somewhere else along the chain. Example result: `uosmo` + +For non-native denoms, the contract needs to hash the denom trace and append it to the `ibc/` prefix. The +contract always receives the parsed denom (i.e.: `transfer/channel-32/uatom` instead of +`ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2`). This is because of the order in which +the middleware is called. When sending a non-native denom, the packet contains `transfer/source-channel/denom` as it +is built on the `relay.SendTransfer()` in the transfer module and then passed to the middleware. Example result: `ibc/` + +##### Receives + +This behaves slightly different if the asset is an osmosis asset that was sent to the counterparty and is being +returned to the chain, or if the asset is being received by the chain and originates on the counterparty. In ibc this +is called being a "source" or a "sink" respectively. + +If the chain is a sink for the denom, we build the local denom by prefixing the port and the channel +(`transfer/local-channel`) and hashing that denom. Example result: `ibc/` + +If the chain is the source for the denom, there are two possibilities: + +* The token is a native token, in which case we just remove the prefix added by the counterparty. Example result: `uosmo` +* The token is a non-native token, in which case we remove the extra prefix and hash it. Example result `ibc/` + +#### Notes on Channel Value +We have iterated on different strategies for calculating the channel value. Our preferred strategy is the following: +* For non-native tokens (`ibc/...`), the channel value should be the supply of those tokens in Osmosis +* For native tokens, the channel value should be the total amount of tokens in escrow across all ibc channels + +The later ensures the limits are lower and represent the amount of native tokens that exist outside Osmosis. This is +beneficial as we assume the majority of native tokens exist on the native chain and the amount "normal" ibc transfers is +proportional to the tokens that have left the chain. + +This strategy cannot be implemented at the moment because IBC does not track the amount of tokens in escrow across +all channels ([github issue](https://github.com/cosmos/ibc-go/issues/2664)). Instead, we use the current supply on +Osmosis for all denoms (i.e.: treat native and non-native tokens the same way). Once that ticket is fixed, we will +update this strategy. + +##### Caching + +The channel value varies constantly. To have better predictability, and avoid issues of the value growing if there is +a potential infinite mint bug, we cache the channel value at the beginning of the period for every quota. + +This means that if we have a daily quota of 1% of the osmo supply, and the channel value is 1M osmo at the beginning of +the quota, no more than 100k osmo can transferred during that day. If 10M osmo were to be minted or IBC'd in during that +period, the quota will not increase until the period expired. Then it will be 1% of the new channel value (~11M) + +### Integration The rate limit middleware wraps the `transferIBCModule` and is added as the entry route for IBC transfers. @@ -87,3 +259,49 @@ The module is also provided to the underlying `transferIBCModule` as its `ICS4Wr pointed to a channel, which also implements the `ICS4Wrapper` interface. This integration can be seen in [osmosis/app/keepers/keepers.go](https://github.com/osmosis-labs/osmosis/blob/main/app/keepers/keepers.go) + +## Testing strategy + + +A general testing strategy is as follows: + +* Setup two chains. +* Send some tokens from A->B and some from B->A (so that there are IBC tokens to play with in both sides) +* Add the rate limiter on A with low limits (i.e. 1% of supply) +* Test Function for chains A' and B' and denom d + * Send some d tokens from A' to B' and get close to the limit. + * Do the same transfer making sure the amount is above the quota and verify it fails with the rate limit error + * Wait until the reset time has passed, and send again. The transfer should now succeed +* Repeat the above test for the following combination of chains and tokens: `(A,B,a)`, `(B,A,a)`, `(A,B,b)`, `(B,A,b)`, + where `a` and `b` are native tokens to chains A and B respectively. + +For more comprehensive tests we can also: +* Add a third chain C and make sure everything works properly for C tokens that have been transferred to A and to B +* Test that the contracts gov address can reset rate limits if the quota has been hit +* Test the queries for getting information about the state of the quotas +* Test that rate limit symmetries hold (i.e.: sending the a token through a rate-limited channel and then sending back + reduces the rate limits by the same amount that it was increased during the first send) +* Ensure that the channels between the test chains have different names (A->B="channel-0", B->A="channel-1", for example) + +## Known Future work + +Items that have been highlighted above: + +* Making automated rate limits get added for channels, instead of manual configuration only +* Improving parameterization strategies / data analysis +* Adding the USDC based rate limits +* We need better strategies for how rate limits "expire". + +Not yet highlighted + +* Making monitoring tooling to know when approaching rate limiting and when they're hit +* Making tooling to easily give us summaries we can use, to reason about "bug or not bug" in event of rate limit being hit +* Enabling ways to pre-declare large transfers so as to not hit rate limits. + * Perhaps you can on-chain declare intent to send these assets with a large delay, that raises monitoring but bypasses rate limits? + * Maybe contract-based tooling to split up the transfer suffices? +* Strategies to account for high volatility periods without hitting rate limits + * Can imagine "Hop network" style markets emerging + * Could imagine tieng it into looking at AMM volatility, or off-chain oracles + * but these are both things we should be wary of security bugs in. + * Maybe [constraint based programming with tracking of provenance](https://youtu.be/HB5TrK7A4pI?t=2852) as a solution +* Analyze changing denom-based rate limits, to just overall withdrawal amount for Osmosis \ No newline at end of file diff --git a/x/ibc-rate-limit/bytecode/rate_limiter.wasm b/x/ibc-rate-limit/bytecode/rate_limiter.wasm new file mode 100644 index 00000000000..30b545e0612 Binary files /dev/null and b/x/ibc-rate-limit/bytecode/rate_limiter.wasm differ diff --git a/x/ibc-rate-limit/client/cli/query.go b/x/ibc-rate-limit/client/cli/query.go new file mode 100644 index 00000000000..db4ee8e2d96 --- /dev/null +++ b/x/ibc-rate-limit/client/cli/query.go @@ -0,0 +1,68 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + // Group lockup queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetCmdParams(), + ) + + return cmd +} + +// GetCmdParams returns module params. +func GetCmdParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query module params", + Long: strings.TrimSpace( + fmt.Sprintf(`Query module params. + +Example: +$ %s query lockup params +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/ibc-rate-limit/contracts/rate-limiter/.gitignore b/x/ibc-rate-limit/contracts/rate-limiter/.gitignore deleted file mode 100644 index dfdaaa6bcda..00000000000 --- a/x/ibc-rate-limit/contracts/rate-limiter/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# Build results -/target - -# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) -.cargo-ok - -# Text file backups -**/*.rs.bk - -# macOS -.DS_Store - -# IDEs -*.iml -.idea diff --git a/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml b/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml index 4c78fcf37fb..9a82ff8d95a 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml +++ b/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml @@ -32,14 +32,20 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-std = "1.1.0" -cosmwasm-storage = "1.1.0" -cosmwasm-schema = "1.1.0" -cw-storage-plus = "0.13.2" +cosmwasm-std = { version = "1.1.5", features = ["stargate", "cosmwasm_1_1"]} +cosmwasm-schema = "1.1.5" +cosmwasm-storage = "1.1.5" +cw-storage-plus = "0.16.0" cw2 = "0.13.2" schemars = "0.8.8" serde = { version = "1.0.137", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } +prost = {version = "0.11.2", default-features = false, features = ["prost-derive"]} +osmosis-std-derive = {version = "0.12.0"} +osmosis-std = "0.12.0" +sha2 = "0.10.6" +hex = "0.4.3" [dev-dependencies] cw-multi-test = "0.13.2" +serde-json-wasm = "0.4.1" diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/contract.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/contract.rs index 95458d4c464..30bae5b33e9 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/contract.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/contract.rs @@ -5,7 +5,7 @@ use cw2::set_contract_version; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg}; -use crate::state::{FlowType, Path, GOVMODULE, IBCMODULE}; +use crate::state::{FlowType, GOVMODULE, IBCMODULE}; use crate::{execute, query, sudo}; // version info for migration info @@ -62,40 +62,34 @@ pub fn execute( } } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> Result { match msg { SudoMsg::SendPacket { - channel_id, - channel_value, - funds, - denom, - } => sudo::try_transfer( + packet, + #[cfg(test)] + channel_value_mock, + } => sudo::process_packet( deps, - &Path::new(&channel_id, &denom), - channel_value, - funds, + packet, FlowType::Out, env.block.time, + #[cfg(test)] + channel_value_mock, ), SudoMsg::RecvPacket { - channel_id, - channel_value, - funds, - denom, - } => sudo::try_transfer( + packet, + #[cfg(test)] + channel_value_mock, + } => sudo::process_packet( deps, - &Path::new(&channel_id, &denom), - channel_value, - funds, + packet, FlowType::In, env.block.time, + #[cfg(test)] + channel_value_mock, ), - SudoMsg::UndoSend { - channel_id, - denom, - funds, - } => sudo::undo_send(deps, &Path::new(&channel_id, &denom), funds), + SudoMsg::UndoSend { packet } => sudo::undo_send(deps, packet), } } diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs index fa5b99e49da..b51009c0605 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs @@ -1,6 +1,7 @@ #![cfg(test)] -use crate::{contract::*, ContractError}; +use crate::packet::Packet; +use crate::{contract::*, test_msg_recv, test_msg_send, ContractError}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{from_binary, Addr, Attribute, Uint256}; @@ -41,7 +42,7 @@ fn consume_allowance() { gov_module: Addr::unchecked(GOV_ADDR), ibc_module: Addr::unchecked(IBC_ADDR), paths: vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![quota], }], @@ -49,24 +50,24 @@ fn consume_allowance() { let info = mock_info(GOV_ADDR, &vec![]); let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), - denom: format!("denom"), + denom: format!("denom") , channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; + funds: 300_u32.into() + ); let res = sudo(deps.as_mut(), mock_env(), msg).unwrap(); let Attribute { key, value } = &res.attributes[4]; assert_eq!(key, "weekly_used_out"); assert_eq!(value, "300"); - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; + funds: 300_u32.into() + ); let err = sudo(deps.as_mut(), mock_env(), msg).unwrap_err(); assert!(matches!(err, ContractError::RateLimitExceded { .. })); } @@ -80,7 +81,7 @@ fn symetric_flows_dont_consume_allowance() { gov_module: Addr::unchecked(GOV_ADDR), ibc_module: Addr::unchecked(IBC_ADDR), paths: vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![quota], }], @@ -88,18 +89,18 @@ fn symetric_flows_dont_consume_allowance() { let info = mock_info(GOV_ADDR, &vec![]); let _res = instantiate(deps.as_mut(), mock_env(), info.clone(), msg).unwrap(); - let send_msg = SudoMsg::SendPacket { + let send_msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; - let recv_msg = SudoMsg::RecvPacket { + funds: 300_u32.into() + ); + let recv_msg = test_msg_recv!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_000_u32.into(), - funds: 300_u32.into(), - }; + funds: 300_u32.into() + ); let res = sudo(deps.as_mut(), mock_env(), send_msg.clone()).unwrap(); let Attribute { key, value } = &res.attributes[3]; @@ -142,7 +143,7 @@ fn asymetric_quotas() { gov_module: Addr::unchecked(GOV_ADDR), ibc_module: Addr::unchecked(IBC_ADDR), paths: vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![quota], }], @@ -151,38 +152,37 @@ fn asymetric_quotas() { let _res = instantiate(deps.as_mut(), mock_env(), info.clone(), msg).unwrap(); // Sending 2% - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_060_u32.into(), - funds: 60_u32.into(), - }; + funds: 60_u32.into() + ); let res = sudo(deps.as_mut(), mock_env(), msg).unwrap(); let Attribute { key, value } = &res.attributes[4]; assert_eq!(key, "weekly_used_out"); assert_eq!(value, "60"); // Sending 2% more. Allowed, as sending has a 4% allowance - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_060_u32.into(), - funds: 60_u32.into(), - }; + funds: 60_u32.into() + ); let res = sudo(deps.as_mut(), mock_env(), msg).unwrap(); - println!("{res:?}"); let Attribute { key, value } = &res.attributes[4]; assert_eq!(key, "weekly_used_out"); assert_eq!(value, "120"); // Receiving 1% should still work. 4% *sent* through the path, but we can still receive. - let recv_msg = SudoMsg::RecvPacket { + let recv_msg = test_msg_recv!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_000_u32.into(), - funds: 30_u32.into(), - }; + funds: 30_u32.into() + ); let res = sudo(deps.as_mut(), mock_env(), recv_msg).unwrap(); let Attribute { key, value } = &res.attributes[3]; assert_eq!(key, "weekly_used_in"); @@ -192,22 +192,22 @@ fn asymetric_quotas() { assert_eq!(value, "90"); // Sending 2%. Should fail. In balance, we've sent 4% and received 1%, so only 1% left to send. - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_060_u32.into(), - funds: 60_u32.into(), - }; + funds: 60_u32.into() + ); let err = sudo(deps.as_mut(), mock_env(), msg.clone()).unwrap_err(); assert!(matches!(err, ContractError::RateLimitExceded { .. })); // Sending 1%: Allowed; because sending has a 4% allowance. We've sent 4% already, but received 1%, so there's send cappacity again - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_060_u32.into(), - funds: 30_u32.into(), - }; + funds: 30_u32.into() + ); let res = sudo(deps.as_mut(), mock_env(), msg.clone()).unwrap(); let Attribute { key, value } = &res.attributes[3]; assert_eq!(key, "weekly_used_in"); @@ -226,7 +226,7 @@ fn query_state() { gov_module: Addr::unchecked(GOV_ADDR), ibc_module: Addr::unchecked(IBC_ADDR), paths: vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![quota], }], @@ -236,7 +236,7 @@ fn query_state() { let _res = instantiate(deps.as_mut(), env.clone(), info, msg).unwrap(); let query_msg = QueryMsg::GetQuotas { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), }; @@ -253,20 +253,20 @@ fn query_state() { env.block.time.plus_seconds(RESET_TIME_WEEKLY) ); - let send_msg = SudoMsg::SendPacket { + let send_msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; + funds: 300_u32.into() + ); sudo(deps.as_mut(), mock_env(), send_msg.clone()).unwrap(); - let recv_msg = SudoMsg::RecvPacket { + let recv_msg = test_msg_recv!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_000_u32.into(), - funds: 30_u32.into(), - }; + funds: 30_u32.into() + ); sudo(deps.as_mut(), mock_env(), recv_msg.clone()).unwrap(); // Query @@ -291,7 +291,7 @@ fn bad_quotas() { gov_module: Addr::unchecked(GOV_ADDR), ibc_module: Addr::unchecked(IBC_ADDR), paths: vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![QuotaMsg { name: "bad_quota".to_string(), @@ -307,7 +307,7 @@ fn bad_quotas() { // If a quota is higher than 100%, we set it to 100% let query_msg = QueryMsg::GetQuotas { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), }; let res = query(deps.as_ref(), env.clone(), query_msg).unwrap(); @@ -332,7 +332,7 @@ fn undo_send() { gov_module: Addr::unchecked(GOV_ADDR), ibc_module: Addr::unchecked(IBC_ADDR), paths: vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![quota], }], @@ -340,22 +340,25 @@ fn undo_send() { let info = mock_info(GOV_ADDR, &vec![]); let _res = instantiate(deps.as_mut(), mock_env(), info.clone(), msg).unwrap(); - let send_msg = SudoMsg::SendPacket { + let send_msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; + funds: 300_u32.into() + ); let undo_msg = SudoMsg::UndoSend { - channel_id: format!("channel"), - denom: format!("denom"), - funds: 300_u32.into(), + packet: Packet::mock( + format!("channel"), + format!("channel"), + format!("denom"), + 300_u32.into(), + ), }; sudo(deps.as_mut(), mock_env(), send_msg.clone()).unwrap(); let trackers = RATE_LIMIT_TRACKERS - .load(&deps.storage, ("channel".to_string(), "denom".to_string())) + .load(&deps.storage, ("any".to_string(), "denom".to_string())) .unwrap(); assert_eq!( trackers.first().unwrap().flow.outflow, @@ -367,9 +370,30 @@ fn undo_send() { sudo(deps.as_mut(), mock_env(), undo_msg.clone()).unwrap(); let trackers = RATE_LIMIT_TRACKERS - .load(&deps.storage, ("channel".to_string(), "denom".to_string())) + .load(&deps.storage, ("any".to_string(), "denom".to_string())) .unwrap(); assert_eq!(trackers.first().unwrap().flow.outflow, Uint256::from(0_u32)); assert_eq!(trackers.first().unwrap().flow.period_end, period_end); assert_eq!(trackers.first().unwrap().quota.channel_value, channel_value); } + +#[test] +fn test_basic_message() { + let json = r#"{"send_packet":{"packet":{"sequence":2,"source_port":"transfer","source_channel":"channel-0","destination_port":"transfer","destination_channel":"channel-0","data":{"denom":"stake","amount":"125000000000011250","sender":"osmo1dwtagd6xzl4eutwtyv6mewra627lkg3n3w26h6","receiver":"osmo1yvjkt8lnpxucjmspaj5ss4aa8562gx0a3rks8s"},"timeout_height":{"revision_height":100}}}}"#; + let _parsed: SudoMsg = serde_json_wasm::from_str(json).unwrap(); + //println!("{parsed:?}"); +} + +#[test] +fn test_testnet_message() { + let json = r#"{"send_packet":{"packet":{"sequence":4,"source_port":"transfer","source_channel":"channel-0","destination_port":"transfer","destination_channel":"channel-1491","data":{"denom":"uosmo","amount":"100","sender":"osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks","receiver":"osmo1c584m4lq25h83yp6ag8hh4htjr92d954vklzja"},"timeout_height":{},"timeout_timestamp":1668024637477293371}}}"#; + let _parsed: SudoMsg = serde_json_wasm::from_str(json).unwrap(); + //println!("{parsed:?}"); +} + +#[test] +fn test_tokenfactory_message() { + let json = r#"{"send_packet":{"packet":{"sequence":4,"source_port":"transfer","source_channel":"channel-0","destination_port":"transfer","destination_channel":"channel-1491","data":{"denom":"transfer/channel-0/factory/osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj/czar","amount":"100000000000000000","sender":"osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks","receiver":"osmo1c584m4lq25h83yp6ag8hh4htjr92d954vklzja"},"timeout_height":{},"timeout_timestamp":1668024476848430980}}}"#; + let _parsed: SudoMsg = serde_json_wasm::from_str(json).unwrap(); + //println!("{parsed:?}"); +} diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs index 367180baf59..f5dcda94688 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{StdError, Timestamp, Uint256}; use thiserror::Error; -#[derive(Error, Debug)] +#[derive(Error, Debug, PartialEq)] pub enum ContractError { #[error("{0}")] Std(#[from] StdError), diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs index d5d76acb0e8..bd9befeb83c 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs @@ -1,10 +1,10 @@ #![cfg(test)] -use crate::{helpers::RateLimitingContract, msg::ExecuteMsg}; -use cosmwasm_std::{Addr, Coin, Empty, Uint128}; +use crate::{helpers::RateLimitingContract, msg::ExecuteMsg, test_msg_send, ContractError}; +use cosmwasm_std::{Addr, Coin, Empty, Timestamp, Uint128, Uint256}; use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor}; use crate::{ - msg::{InstantiateMsg, PathMsg, QuotaMsg, SudoMsg}, + msg::{InstantiateMsg, PathMsg, QuotaMsg}, state::tests::{RESET_TIME_DAILY, RESET_TIME_MONTHLY, RESET_TIME_WEEKLY}, }; @@ -73,18 +73,18 @@ fn expiration() { let quota = QuotaMsg::new("weekly", RESET_TIME_WEEKLY, 10, 10); let (mut app, cw_rate_limit_contract) = proper_instantiate(vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![quota], }]); // Using all the allowance - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; + channel_value: 3_000_u32.into(), + funds: 300_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); let res = app.sudo(cosmos_msg).unwrap(); @@ -102,16 +102,27 @@ fn expiration() { assert_eq!(value, "300"); // Another packet is rate limited - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; + channel_value: 3_000_u32.into(), + funds: 300_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); - let _err = app.sudo(cosmos_msg).unwrap_err(); - - // TODO: how do we check the error type here? + let err = app.sudo(cosmos_msg).unwrap_err(); + + assert_eq!( + err.downcast_ref::().unwrap(), + &ContractError::RateLimitExceded { + channel: "channel".to_string(), + denom: "denom".to_string(), + amount: Uint256::from_u128(300), + quota_name: "weekly".to_string(), + used: Uint256::from_u128(300), + max: Uint256::from_u128(300), + reset: Timestamp::from_nanos(1572402219879305533), + } + ); // ... Time passes app.update_block(|b| { @@ -120,12 +131,12 @@ fn expiration() { }); // Sending the packet should work now - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_300_u32.into(), - funds: 300_u32.into(), - }; + channel_value: 3_000_u32.into(), + funds: 300_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); let res = app.sudo(cosmos_msg).unwrap(); @@ -153,28 +164,28 @@ fn multiple_quotas() { ]; let (mut app, cw_rate_limit_contract) = proper_instantiate(vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas, }]); // Sending 1% to use the daily allowance - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); // Another packet is rate limited - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -185,12 +196,12 @@ fn multiple_quotas() { }); // Sending the packet should work now - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); @@ -204,12 +215,12 @@ fn multiple_quotas() { }); // Sending the packet should work now - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); } @@ -221,12 +232,12 @@ fn multiple_quotas() { }); // We now have exceeded the weekly limit! Even if the daily limit allows us, the weekly doesn't - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -237,12 +248,12 @@ fn multiple_quotas() { }); // We can still can't send because the weekly and monthly limits are the same - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -254,12 +265,12 @@ fn multiple_quotas() { }); // We can still can't send because the monthly limit hasn't passed - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -269,12 +280,12 @@ fn multiple_quotas() { b.time = b.time.plus_seconds((RESET_TIME_WEEKLY * 2) + 1) // Two weeks }); - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 101_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); } @@ -287,38 +298,38 @@ fn channel_value_cached() { ]; let (mut app, cw_rate_limit_contract) = proper_instantiate(vec![PathMsg { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas, }]); // Sending 1% (half of the daily allowance) - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 100_u32.into(), - funds: 1_u32.into(), - }; + funds: 1_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); // Sending 3% is now rate limited - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 100_u32.into(), - funds: 3_u32.into(), - }; + funds: 3_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); // Even if the channel value increases, the percentage is calculated based on the value at period start - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 100000_u32.into(), - funds: 3_u32.into(), - }; + funds: 3_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -333,12 +344,12 @@ fn channel_value_cached() { // Sending 1% of a new value (10_000) passes the daily check, cause it // has expired, but not the weekly check (The value for last week is // sitll 100, as only 1 day has passed) - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 10_000_u32.into(), - funds: 100_u32.into(), - }; + funds: 100_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -350,23 +361,23 @@ fn channel_value_cached() { }); // Sending 1% of a new value should work and set the value for the day at 10_000 - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 10_000_u32.into(), - funds: 100_u32.into(), - }; + funds: 100_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); // If the value magically decreasses. We can still send up to 100 more (1% of 10k) - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 1_u32.into(), - funds: 75_u32.into(), - }; + funds: 75_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); @@ -377,21 +388,22 @@ fn add_paths_later() { let (mut app, cw_rate_limit_contract) = proper_instantiate(vec![]); // All sends are allowed - let msg = SudoMsg::SendPacket { + let msg = test_msg_send!( channel_id: format!("channel"), denom: format!("denom"), channel_value: 3_000_u32.into(), - funds: 300_u32.into(), - }; + funds: 300_u32.into() + ); let cosmos_msg = cw_rate_limit_contract.sudo(msg.clone()); let res = app.sudo(cosmos_msg).unwrap(); + let Attribute { key, value } = &res.custom_attrs(1)[3]; assert_eq!(key, "quota"); assert_eq!(value, "none"); // Add a weekly limit of 1% let management_msg = ExecuteMsg::AddPath { - channel_id: format!("channel"), + channel_id: format!("any"), denom: format!("denom"), quotas: vec![QuotaMsg::new("weekly", RESET_TIME_WEEKLY, 1, 1)], }; diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/lib.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/lib.rs index 0b7ddb6b66f..6fcd1c32cec 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/lib.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/lib.rs @@ -1,9 +1,13 @@ +#![allow(clippy::result_large_err)] + // Contract pub mod contract; mod error; pub mod msg; mod state; +pub mod packet; + // Functions mod execute; mod query; diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs index 0f1f0c4b061..57279c0ad67 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs @@ -1,8 +1,13 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{Addr, Uint256}; +use cosmwasm_std::Addr; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +#[cfg(test)] +use cosmwasm_std::Uint256; + +use crate::packet::Packet; + // PathMsg contains a channel_id and denom to represent a unique identifier within ibc-go, and a list of rate limit quotas #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct PathMsg { @@ -82,21 +87,17 @@ pub enum QueryMsg { #[cw_serde] pub enum SudoMsg { SendPacket { - channel_id: String, - denom: String, - channel_value: Uint256, - funds: Uint256, + packet: Packet, + #[cfg(test)] + channel_value_mock: Option, }, RecvPacket { - channel_id: String, - denom: String, - channel_value: Uint256, - funds: Uint256, + packet: Packet, + #[cfg(test)] + channel_value_mock: Option, }, UndoSend { - channel_id: String, - denom: String, - funds: Uint256, + packet: Packet, }, } diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/packet.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/packet.rs index 6bc5b8cfed1..6e53754bbc3 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/packet.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/packet.rs @@ -1,7 +1,11 @@ -use cosmwasm_std::{Addr, Deps, Timestamp}; +use crate::state::FlowType; +use cosmwasm_std::{Addr, Deps, StdError, Uint256}; +use osmosis_std_derive::CosmwasmExt; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct Height { /// Previously known as "epoch" revision_number: Option, @@ -10,15 +14,17 @@ pub struct Height { revision_height: Option, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +// IBC transfer data +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct FungibleTokenData { - denom: String, - amount: u128, + pub denom: String, + amount: Uint256, sender: Addr, receiver: Addr, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +// An IBC packet +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct Packet { pub sequence: u64, pub source_port: String, @@ -27,38 +33,450 @@ pub struct Packet { pub destination_channel: String, pub data: FungibleTokenData, pub timeout_height: Height, - pub timeout_timestamp: Option, + pub timeout_timestamp: Option, +} + +// SupplyOf query message definition. +// osmosis-std doesn't currently support the SupplyOf query, so I'm defining it localy so it can be used to obtain the channel value +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + serde::Serialize, + serde::Deserialize, + schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.bank.v1beta1.QuerySupplyOfRequest")] +#[proto_query( + path = "/cosmos.bank.v1beta1.Query/SupplyOf", + response_type = QuerySupplyOfResponse +)] +pub struct QuerySupplyOfRequest { + #[prost(string, tag = "1")] + pub denom: ::prost::alloc::string::String, +} + +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + serde::Serialize, + serde::Deserialize, + schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.bank.v1beta1.QuerySupplyOf")] +pub struct QuerySupplyOfResponse { + #[prost(message, optional, tag = "1")] + pub amount: ::core::option::Option, +} +// End of SupplyOf query message definition + +use std::str::FromStr; // Needed to parse the coin's String as Uint256 + +fn hash_denom(denom: &str) -> String { + let mut hasher = Sha256::new(); + hasher.update(denom.as_bytes()); + let result = hasher.finalize(); + let hash = hex::encode(result); + format!("ibc/{}", hash.to_uppercase()) } impl Packet { - pub fn channel_value(&self, _deps: Deps) -> u128 { - // let balance = deps.querier.query_all_balances("address", self.data.denom); - // deps.querier.sup - return 125000000000011250 * 2; + pub fn mock( + source_channel: String, + dest_channel: String, + denom: String, + funds: Uint256, + ) -> Packet { + Packet { + sequence: 0, + source_port: "transfer".to_string(), + source_channel, + destination_port: "transfer".to_string(), + destination_channel: dest_channel, + data: crate::packet::FungibleTokenData { + denom, + amount: funds, + sender: Addr::unchecked("sender"), + receiver: Addr::unchecked("receiver"), + }, + timeout_height: crate::packet::Height { + revision_number: None, + revision_height: None, + }, + timeout_timestamp: None, + } } - pub fn get_funds(&self) -> u128 { - return self.data.amount; + pub fn channel_value(&self, deps: Deps, direction: &FlowType) -> Result { + let res = QuerySupplyOfRequest { + denom: self.local_denom(direction), + } + .query(&deps.querier)?; + Uint256::from_str(&res.amount.unwrap_or_default().amount) } - fn local_channel(&self) -> String { + pub fn get_funds(&self) -> Uint256 { + self.data.amount + } + + fn local_channel(&self, direction: &FlowType) -> String { // Pick the appropriate channel depending on whether this is a send or a recv - return self.destination_channel.clone(); + match direction { + FlowType::In => self.destination_channel.clone(), + FlowType::Out => self.source_channel.clone(), + } + } + + fn receiver_chain_is_source(&self) -> bool { + self.data + .denom + .starts_with(&format!("transfer/{}", self.source_channel)) } - fn local_demom(&self) -> String { - // This should actually convert the denom from the packet to the osmosis denom, but for now, just returning this - return self.data.denom.clone(); + fn handle_denom_for_sends(&self) -> String { + if !self.data.denom.starts_with("transfer/") { + // For native tokens we just use what's on the packet + return self.data.denom.clone(); + } + // For non-native tokens, we need to generate the IBCDenom + hash_denom(&self.data.denom) } - pub fn path_data(&self) -> (String, String) { - let denom = self.local_demom(); - let channel = if denom.starts_with("ibc/") { - self.local_channel() + fn handle_denom_for_recvs(&self) -> String { + if self.receiver_chain_is_source() { + // These are tokens that have been sent to the counterparty and are returning + let unprefixed = self + .data + .denom + .strip_prefix(&format!("transfer/{}/", self.source_channel)) + .unwrap_or_default(); + let split: Vec<&str> = unprefixed.split('/').collect(); + if split[0] == unprefixed { + // This is a native token. Return the unprefixed token + unprefixed.to_string() + } else { + // This is a non-native that was sent to the counterparty. + // We need to hash it. + // The ibc-go implementation checks that the denom has been built correctly. We + // don't need to do that here because if it hasn't, the transfer module will catch it. + hash_denom(unprefixed) + } } else { - "any".to_string() // native tokens are rate limited globally - }; + // Tokens that come directly from the counterparty. + // Since the sender didn't prefix them, we need to do it here. + let prefixed = format!("transfer/{}/", self.destination_channel) + &self.data.denom; + hash_denom(&prefixed) + } + } + + fn local_denom(&self, direction: &FlowType) -> String { + match direction { + FlowType::In => self.handle_denom_for_recvs(), + FlowType::Out => self.handle_denom_for_sends(), + } + } + + pub fn path_data(&self, direction: &FlowType) -> (String, String) { + (self.local_channel(direction), self.local_denom(direction)) + } +} + +// Helpers + +// Create a new packet for testing +#[cfg(test)] +#[macro_export] +macro_rules! test_msg_send { + (channel_id: $channel_id:expr, denom: $denom:expr, channel_value: $channel_value:expr, funds: $funds:expr) => { + $crate::msg::SudoMsg::SendPacket { + packet: $crate::packet::Packet::mock($channel_id, $channel_id, $denom, $funds), + channel_value_mock: Some($channel_value), + } + }; +} + +#[cfg(test)] +#[macro_export] +macro_rules! test_msg_recv { + (channel_id: $channel_id:expr, denom: $denom:expr, channel_value: $channel_value:expr, funds: $funds:expr) => { + $crate::msg::SudoMsg::RecvPacket { + packet: $crate::packet::Packet::mock( + $channel_id, + $channel_id, + format!("transfer/{}/{}", $channel_id, $denom), + $funds, + ), + channel_value_mock: Some($channel_value), + } + }; +} + +#[cfg(test)] +pub mod tests { + use crate::msg::SudoMsg; + + use super::*; + + #[test] + fn send_native() { + let packet = Packet::mock( + format!("channel-17-local"), + format!("channel-42-counterparty"), + format!("uosmo"), + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::Out), "uosmo"); + } + + #[test] + fn send_non_native() { + // The transfer module "unhashes" the denom from + // ibc/09E4864A262249507925831FBAD69DAD08F66FAAA0640714E765912A0751289A + // to port/channel/denom before passing it along to the contrace + let packet = Packet::mock( + format!("channel-17-local"), + format!("channel-42-counterparty"), + format!("transfer/channel-17-local/ujuno"), + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::Out), + "ibc/09E4864A262249507925831FBAD69DAD08F66FAAA0640714E765912A0751289A" + ); + } + + #[test] + fn receive_non_native() { + // The counterparty chain sends their own native token to us + let packet = Packet::mock( + format!("channel-42-counterparty"), // The counterparty's channel is the source here + format!("channel-17-local"), // Our channel is the dest channel + format!("ujuno"), // This is unwrapped. It is our job to wrap it + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::In), + "ibc/09E4864A262249507925831FBAD69DAD08F66FAAA0640714E765912A0751289A" + ); + } + + #[test] + fn receive_native() { + // The counterparty chain sends us back our native token that they had wrapped + let packet = Packet::mock( + format!("channel-42-counterparty"), // The counterparty's channel is the source here + format!("channel-17-local"), // Our channel is the dest channel + format!("transfer/channel-42-counterparty/uosmo"), + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::In), "uosmo"); + } + + // Let's assume we have two chains A and B (local and counterparty) connected in the following way: + // + // Chain A <---> channel-17-local <---> channel-42-counterparty <---> Chain B + // + // The following tests should pass + // + + const WRAPPED_OSMO_ON_HUB_TRACE: &str = "transfer/channel-141/uosmo"; + const WRAPPED_ATOM_ON_OSMOSIS_TRACE: &str = "transfer/channel-0/uatom"; + const WRAPPED_ATOM_ON_OSMOSIS_HASH: &str = + "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; + const WRAPPED_OSMO_ON_HUB_HASH: &str = + "ibc/14F9BC3E44B8A9C1BE1FB08980FAB87034C9905EF17CF2F5008FC085218811CC"; + + #[test] + fn sanity_check() { + // Examples using the official channels as of Nov 2022. + + // uatom sent to osmosis + let packet = Packet::mock( + format!("channel-141"), // from: hub + format!("channel-0"), // to: osmosis + format!("uatom"), + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::In), + WRAPPED_ATOM_ON_OSMOSIS_HASH.clone() + ); + + // uatom on osmosis sent back to the hub + let packet = Packet::mock( + format!("channel-0"), // from: osmosis + format!("channel-141"), // to: hub + WRAPPED_ATOM_ON_OSMOSIS_TRACE.to_string(), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::In), "uatom"); + + // osmo sent to the hub + let packet = Packet::mock( + format!("channel-0"), // from: osmosis + format!("channel-141"), // to: hub + format!("uosmo"), + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::Out), "uosmo"); + + // osmo on the hub sent back to osmosis + // send + let packet = Packet::mock( + format!("channel-141"), // from: hub + format!("channel-0"), // to: osmosis + WRAPPED_OSMO_ON_HUB_TRACE.to_string(), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::Out), WRAPPED_OSMO_ON_HUB_HASH); + + // receive + let packet = Packet::mock( + format!("channel-141"), // from: hub + format!("channel-0"), // to: osmosis + WRAPPED_OSMO_ON_HUB_TRACE.to_string(), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::In), "uosmo"); + + // Now let's pretend we're the hub. + // The following tests are from perspective of the the hub (i.e.: if this contract were deployed there) + // + // osmo sent to the hub + let packet = Packet::mock( + format!("channel-0"), // from: osmosis + format!("channel-141"), // to: hub + format!("uosmo"), + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::In), WRAPPED_OSMO_ON_HUB_HASH); + + // uosmo on the hub sent back to the osmosis + let packet = Packet::mock( + format!("channel-141"), // from: hub + format!("channel-0"), // to: osmosis + WRAPPED_OSMO_ON_HUB_TRACE.to_string(), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::In), "uosmo"); + + // uatom sent to osmosis + let packet = Packet::mock( + format!("channel-141"), // from: hub + format!("channel-0"), // to: osmosis + format!("uatom"), + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::Out), "uatom"); + + // utaom on the osmosis sent back to the hub + // send + let packet = Packet::mock( + format!("channel-0"), // from: osmosis + format!("channel-141"), // to: hub + WRAPPED_ATOM_ON_OSMOSIS_TRACE.to_string(), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::Out), + WRAPPED_ATOM_ON_OSMOSIS_HASH + ); + + // receive + let packet = Packet::mock( + format!("channel-0"), // from: osmosis + format!("channel-141"), // to: hub + WRAPPED_ATOM_ON_OSMOSIS_TRACE.to_string(), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::In), "uatom"); + } + + #[test] + fn sanity_double() { + // Now let's deal with double wrapping + + let juno_wrapped_osmosis_wrapped_atom_hash = + "ibc/6CDD4663F2F09CD62285E2D45891FC149A3568E316CE3EBBE201A71A78A69388"; + + // Send uatom on stored on osmosis to juno + // send + let packet = Packet::mock( + format!("channel-42"), // from: osmosis + format!("channel-0"), // to: juno + WRAPPED_ATOM_ON_OSMOSIS_TRACE.to_string(), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::Out), + WRAPPED_ATOM_ON_OSMOSIS_HASH + ); + + // receive + let packet = Packet::mock( + format!("channel-42"), // from: osmosis + format!("channel-0"), // to: juno + WRAPPED_ATOM_ON_OSMOSIS_TRACE.to_string(), + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::In), + juno_wrapped_osmosis_wrapped_atom_hash + ); + + // Send back that multi-wrapped token to osmosis + // send + let packet = Packet::mock( + format!("channel-0"), // from: juno + format!("channel-42"), // to: osmosis + format!("{}{}", "transfer/channel-0/", WRAPPED_ATOM_ON_OSMOSIS_TRACE), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::Out), + juno_wrapped_osmosis_wrapped_atom_hash + ); + + // receive + let packet = Packet::mock( + format!("channel-0"), // from: juno + format!("channel-42"), // to: osmosis + format!("{}{}", "transfer/channel-0/", WRAPPED_ATOM_ON_OSMOSIS_TRACE), // unwrapped before reaching the contract + 0_u128.into(), + ); + assert_eq!( + packet.local_denom(&FlowType::In), + WRAPPED_ATOM_ON_OSMOSIS_HASH + ); + } + + #[test] + fn tokenfactory_packet() { + let json = r#"{"send_packet":{"packet":{"sequence":4,"source_port":"transfer","source_channel":"channel-0","destination_port":"transfer","destination_channel":"channel-1491","data":{"denom":"transfer/channel-0/factory/osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj/czar","amount":"100000000000000000","sender":"osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks","receiver":"osmo1c584m4lq25h83yp6ag8hh4htjr92d954vklzja"},"timeout_height":{},"timeout_timestamp":1668024476848430980}}}"#; + let parsed: SudoMsg = serde_json_wasm::from_str(json).unwrap(); + //println!("{parsed:?}"); + + match parsed { + SudoMsg::SendPacket { packet, .. } => { + assert_eq!( + packet.local_denom(&FlowType::Out), + "ibc/07A1508F49D0753EDF95FA18CA38C0D6974867D793EB36F13A2AF1A5BB148B22" + ); + } + _ => panic!("parsed into wrong variant"), + } + } - return (channel, denom); + #[test] + fn packet_with_memo() { + // extra fields (like memo) get ignored. + let json = r#"{"recv_packet":{"packet":{"sequence":1,"source_port":"transfer","source_channel":"channel-0","destination_port":"transfer","destination_channel":"channel-0","data":{"denom":"stake","amount":"1","sender":"osmo177uaalkhra6wth6hc9hu79f72eq903kwcusx4r","receiver":"osmo1fj6yt4pwfea4865z763fvhwktlpe020ef93dlq","memo":"some info"},"timeout_height":{"revision_height":100}}}}"#; + let _parsed: SudoMsg = serde_json_wasm::from_str(json).unwrap(); + //println!("{parsed:?}"); } } diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs index e28fc1004b7..e699936d812 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs @@ -243,7 +243,9 @@ fn calculate_channel_value( if denom.contains("ibc") { channel_value + funds // Non-Native tokens get removed from the supply on send. Add that amount back } else { - channel_value - funds // Native tokens increase escrow amount on send. Remove that amount here + // The commented-out code in the golang calculate channel value is what we want, but we're currently using the whole supply temporarily for efficiency. see rate_limit.go/CalculateChannelValue(..) + //channel_value - funds // Native tokens increase escrow amount on send. Remove that amount here + channel_value } } FlowType::In => channel_value, diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs index 0a8ae8e5161..36a16f638d4 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs @@ -1,10 +1,42 @@ use cosmwasm_std::{DepsMut, Response, Timestamp, Uint256}; use crate::{ + packet::Packet, state::{FlowType, Path, RateLimit, RATE_LIMIT_TRACKERS}, ContractError, }; +// This function will process a packet and extract the paths information, funds, +// and channel value from it. This is will have to interact with the chain via grpc queries to properly +// obtain this information. +// +// For backwards compatibility, we're teporarily letting the chain override the +// denom and channel value, but these should go away in favour of the contract +// extracting these from the packet +pub fn process_packet( + deps: DepsMut, + packet: Packet, + direction: FlowType, + now: Timestamp, + #[cfg(test)] channel_value_mock: Option, +) -> Result { + let (channel_id, denom) = packet.path_data(&direction); + let path = &Path::new(&channel_id, &denom); + let funds = packet.get_funds(); + + #[cfg(test)] + // When testing we override the channel value with the mock since we can't get it from the chain + let channel_value = match channel_value_mock { + Some(channel_value) => channel_value, + None => packet.channel_value(deps.as_ref(), &direction)?, // This should almost never be used, but left for completeness in case we want to send an empty channel_value from the test + }; + + #[cfg(not(test))] + let channel_value = packet.channel_value(deps.as_ref(), &direction)?; + + try_transfer(deps, path, channel_value, funds, direction, now) +} + /// This function checks the rate limit and, if successful, stores the updated data about the value /// that has been transfered through the channel for a specific denom. /// If the period for a RateLimit has ended, the Flow information is reset. @@ -20,15 +52,20 @@ pub fn try_transfer( now: Timestamp, ) -> Result { // Sudo call. Only go modules should be allowed to access this - let trackers = RATE_LIMIT_TRACKERS.may_load(deps.storage, path.into())?; - let configured = match trackers { - None => false, - Some(ref x) if x.is_empty() => false, - _ => true, - }; + // Fetch potential trackers for "any" channel of the required token + let any_path = Path::new("any", path.denom.clone()); + let mut any_trackers = RATE_LIMIT_TRACKERS + .may_load(deps.storage, any_path.clone().into())? + .unwrap_or_default(); + // Fetch trackers for the requested path + let mut trackers = RATE_LIMIT_TRACKERS + .may_load(deps.storage, path.into())? + .unwrap_or_default(); + + let not_configured = trackers.is_empty() && any_trackers.is_empty(); - if !configured { + if not_configured { // No Quota configured for the current path. Allowing all messages. return Ok(Response::new() .add_attribute("method", "try_transfer") @@ -37,16 +74,20 @@ pub fn try_transfer( .add_attribute("quota", "none")); } - let mut rate_limits = trackers.unwrap(); - // If any of the RateLimits fails, allow_transfer() will return // ContractError::RateLimitExceded, which we'll propagate out - let results: Vec = rate_limits + let results: Vec = trackers + .iter_mut() + .map(|limit| limit.allow_transfer(path, &direction, funds, channel_value, now)) + .collect::>()?; + + let any_results: Vec = any_trackers .iter_mut() .map(|limit| limit.allow_transfer(path, &direction, funds, channel_value, now)) .collect::>()?; RATE_LIMIT_TRACKERS.save(deps.storage, path.into(), &results)?; + RATE_LIMIT_TRACKERS.save(deps.storage, any_path.into(), &any_results)?; let response = Response::new() .add_attribute("method", "try_transfer") @@ -55,7 +96,11 @@ pub fn try_transfer( // Adds the attributes for each path to the response. In prod, the // addtribute add_rate_limit_attributes is a noop - results.iter().fold(Ok(response), |acc, result| { + let response: Result = + any_results.iter().fold(Ok(response), |acc, result| { + Ok(add_rate_limit_attributes(acc?, result)) + }); + results.iter().fold(Ok(response?), |acc, result| { Ok(add_rate_limit_attributes(acc?, result)) }) } @@ -96,17 +141,23 @@ fn add_rate_limit_attributes(response: Response, result: &RateLimit) -> Response // This function manually injects an inflow. This is used when reverting a // packet that failed ack or timed-out. -pub fn undo_send(deps: DepsMut, path: &Path, funds: Uint256) -> Result { +pub fn undo_send(deps: DepsMut, packet: Packet) -> Result { // Sudo call. Only go modules should be allowed to access this - let trackers = RATE_LIMIT_TRACKERS.may_load(deps.storage, path.into())?; + let (channel_id, denom) = packet.path_data(&FlowType::Out); // Sends have direction out. + let path = &Path::new(&channel_id, &denom); + let any_path = Path::new("any", &denom); + let funds = packet.get_funds(); - let configured = match trackers { - None => false, - Some(ref x) if x.is_empty() => false, - _ => true, - }; + let mut any_trackers = RATE_LIMIT_TRACKERS + .may_load(deps.storage, any_path.clone().into())? + .unwrap_or_default(); + let mut trackers = RATE_LIMIT_TRACKERS + .may_load(deps.storage, path.into())? + .unwrap_or_default(); + + let not_configured = trackers.is_empty() && any_trackers.is_empty(); - if !configured { + if not_configured { // No Quota configured for the current path. Allowing all messages. return Ok(Response::new() .add_attribute("method", "try_transfer") @@ -115,10 +166,15 @@ pub fn undo_send(deps: DepsMut, path: &Path, funds: Uint256) -> Result = rate_limits + let results: Vec = trackers + .iter_mut() + .map(|limit| { + limit.flow.undo_flow(FlowType::Out, funds); + limit.to_owned() + }) + .collect(); + let any_results: Vec = any_trackers .iter_mut() .map(|limit| { limit.flow.undo_flow(FlowType::Out, funds); @@ -127,9 +183,11 @@ pub fn undo_send(deps: DepsMut, path: &Path, funds: Uint256) -> ResultB. Rate limit receives "stake" in the packet. Nothing to do in the contract suite.fullSendTest(true) } // Test rate limiting on sends func (suite *MiddlewareTestSuite) TestSendTransferWithRateLimitingNonNative() { + // Sends denom=ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878 from A->B. + // Rate limit receives "transfer/channel-0/stake" in the packet (because transfer.relay.SendTransfer is called before the middleware) + // and should hash it before calculating the value suite.fullSendTest(false) } @@ -339,55 +360,66 @@ func (suite *MiddlewareTestSuite) TestSendTransferReset() { // Test rate limiting on receives func (suite *MiddlewareTestSuite) fullRecvTest(native bool) { - quotaPercentage := 5 + quotaPercentage := 4 suite.initializeEscrow() // Get the denom and amount to send - denom := sdk.DefaultBondDenom - if !native { - denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", denom)) - denom = denomTrace.IBCDenom() + sendDenom := sdk.DefaultBondDenom + localDenom := sdk.DefaultBondDenom + channel := "channel-0" + if native { + denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", localDenom)) + localDenom = denomTrace.IBCDenom() + } else { + denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", sendDenom)) + sendDenom = denomTrace.IBCDenom() } osmosisApp := suite.chainA.GetOsmosisApp() - // This is the first one. Inside the tests. It works as expected. - channelValue := ibc_rate_limit.CalculateChannelValue(suite.chainA.GetContext(), denom, "transfer", "channel-0", osmosisApp.BankKeeper) + channelValue := CalculateChannelValue(suite.chainA.GetContext(), localDenom, osmosisApp.BankKeeper) - // The amount to be sent is send 2.5% (quota is 5%) + // The amount to be sent is 2% (quota is 4%) quota := channelValue.QuoRaw(int64(100 / quotaPercentage)) sendAmount := quota.QuoRaw(2) - fmt.Printf("Testing recv rate limiting for denom=%s, channelValue=%s, quota=%s, sendAmount=%s\n", denom, channelValue, quota, sendAmount) + fmt.Printf("Testing recv rate limiting for denom=%s, channelValue=%s, quota=%s, sendAmount=%s\n", localDenom, channelValue, quota, sendAmount) // Setup contract - suite.chainA.StoreContractCode(&suite.Suite) - quotas := suite.BuildChannelQuota("weekly", denom, 604800, 5, 5) - addr := suite.chainA.InstantiateContract(&suite.Suite, quotas) + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/rate_limiter.wasm") + quotas := suite.BuildChannelQuota("weekly", channel, localDenom, 604800, 4, 4) + addr := suite.chainA.InstantiateRLContract(&suite.Suite, quotas) suite.chainA.RegisterRateLimitingContract(addr) // receive 2.5% (quota is 5%) - suite.AssertReceive(true, suite.MessageFromBToA(denom, sendAmount)) + fmt.Printf("Sending %s from B to A. Represented in chain A as wrapped? %v\n", sendDenom, native) + suite.AssertReceive(true, suite.MessageFromBToA(sendDenom, sendAmount)) // receive 2.5% (quota is 5%) - suite.AssertReceive(true, suite.MessageFromBToA(denom, sendAmount)) + suite.AssertReceive(true, suite.MessageFromBToA(sendDenom, sendAmount)) // Sending above the quota should fail. We send 2 instead of 1 to account for rounding errors - suite.AssertReceive(false, suite.MessageFromBToA(denom, sdk.NewInt(2))) + suite.AssertReceive(false, suite.MessageFromBToA(sendDenom, sdk.NewInt(2))) } func (suite *MiddlewareTestSuite) TestRecvTransferWithRateLimitingNative() { + // Sends denom=stake from B->A. + // Rate limit receives "stake" in the packet and should wrap it before calculating the value + // types.ReceiverChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), data.Denom) should return false => Wrap the token suite.fullRecvTest(true) } func (suite *MiddlewareTestSuite) TestRecvTransferWithRateLimitingNonNative() { + // Sends denom=ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878 from B->A. + // Rate limit receives "transfer/channel-0/stake" in the packet and should turn it into "stake" + // types.ReceiverChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), data.Denom) should return true => unprefix. If unprefixed is not local, hash. suite.fullRecvTest(false) } // Test no rate limiting occurs when the contract is set, but not quotas are condifured for the path func (suite *MiddlewareTestSuite) TestSendTransferNoQuota() { // Setup contract - suite.chainA.StoreContractCode(&suite.Suite) - addr := suite.chainA.InstantiateContract(&suite.Suite, ``) + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/rate_limiter.wasm") + addr := suite.chainA.InstantiateRLContract(&suite.Suite, ``) suite.chainA.RegisterRateLimitingContract(addr) // send 1 token. @@ -399,16 +431,17 @@ func (suite *MiddlewareTestSuite) TestSendTransferNoQuota() { func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { suite.initializeEscrow() // Setup contract - suite.chainA.StoreContractCode(&suite.Suite) - quotas := suite.BuildChannelQuota("weekly", sdk.DefaultBondDenom, 604800, 1, 1) - addr := suite.chainA.InstantiateContract(&suite.Suite, quotas) + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/rate_limiter.wasm") + quotas := suite.BuildChannelQuota("weekly", "channel-0", sdk.DefaultBondDenom, 604800, 1, 1) + addr := suite.chainA.InstantiateRLContract(&suite.Suite, quotas) suite.chainA.RegisterRateLimitingContract(addr) // Get the escrowed amount osmosisApp := suite.chainA.GetOsmosisApp() - escrowAddress := transfertypes.GetEscrowAddress("transfer", "channel-0") - escrowed := osmosisApp.BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, sdk.DefaultBondDenom) - + // ToDo: This is what we eventually want here, but using the full supply temporarily for performance reasons. See CalculateChannelValue + // escrowAddress := transfertypes.GetEscrowAddress("transfer", "channel-0") + // escrowed := osmosisApp.BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, sdk.DefaultBondDenom) + escrowed := osmosisApp.BankKeeper.GetSupplyWithOffset(suite.chainA.GetContext(), sdk.DefaultBondDenom) quota := escrowed.Amount.QuoRaw(100) // 1% of the escrowed amount // Use the whole quota @@ -460,3 +493,19 @@ func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { // We should be able to send again because the packet that exceeded the quota failed and has been reverted suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) } + +func (suite *MiddlewareTestSuite) TestUnsetRateLimitingContract() { + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite, "./bytecode/rate_limiter.wasm") + addr := suite.chainA.InstantiateRLContract(&suite.Suite, "") + suite.chainA.RegisterRateLimitingContract(addr) + + // Unset the contract param + params, err := types.NewParams("") + suite.Require().NoError(err) + osmosisApp := suite.chainA.GetOsmosisApp() + paramSpace, ok := osmosisApp.AppKeepers.ParamsKeeper.GetSubspace(types.ModuleName) + suite.Require().True(ok) + // N.B.: this panics if validation fails. + paramSpace.SetParamSet(suite.chainA.GetContext(), ¶ms) +} diff --git a/x/ibc-rate-limit/ibc_module.go b/x/ibc-rate-limit/ibc_module.go index 433826dddac..f93b24997c9 100644 --- a/x/ibc-rate-limit/ibc_module.go +++ b/x/ibc-rate-limit/ibc_module.go @@ -2,6 +2,9 @@ package ibc_rate_limit import ( "encoding/json" + "strings" + + "github.com/osmosis-labs/osmosis/v13/osmoutils" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -10,7 +13,8 @@ import ( channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + + "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" ) type IBCModule struct { @@ -103,7 +107,7 @@ func (im *IBCModule) OnChanCloseConfirm( return im.app.OnChanCloseConfirm(ctx, portID, channelID) } -func ValidateReceiverAddress(packet channeltypes.Packet) error { +func ValidateReceiverAddress(packet exported.PacketI) error { var packetData transfertypes.FungibleTokenPacketData if err := json.Unmarshal(packet.GetData(), &packetData); err != nil { return err @@ -129,25 +133,14 @@ func (im *IBCModule) OnRecvPacket( // The contract has not been configured. Continue as usual return im.app.OnRecvPacket(ctx, packet, relayer) } - amount, denom, err := GetFundsFromPacket(packet) - if err != nil { - return channeltypes.NewErrorAcknowledgement("bad packet in rate limit's OnRecvPacket") - } - channelValue := im.ics4Middleware.CalculateChannelValue(ctx, denom, packet) - - err = CheckAndUpdateRateLimits( - ctx, - im.ics4Middleware.ContractKeeper, - "recv_packet", - contract, - channelValue, - packet.GetDestChannel(), - denom, // We always use the packet's denom here, as we want the limits to be the same on both directions - amount, - ) + err := CheckAndUpdateRateLimits(ctx, im.ics4Middleware.ContractKeeper, "recv_packet", contract, packet) if err != nil { - return channeltypes.NewErrorAcknowledgement(types.ErrRateLimitExceeded.Error()) + if strings.Contains(err.Error(), "rate limit exceeded") { + return channeltypes.NewErrorAcknowledgement(types.ErrRateLimitExceeded.Error()) + } + fullError := sdkerrors.Wrap(types.ErrContractError, err.Error()) + return channeltypes.NewErrorAcknowledgement(fullError.Error()) } // if this returns an Acknowledgement that isn't successful, all state changes are discarded @@ -166,7 +159,7 @@ func (im *IBCModule) OnAcknowledgementPacket( return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal ICS-20 transfer packet acknowledgement: %v", err) } - if !ack.Success() { + if osmoutils.IsAckError(acknowledgement) { err := im.RevertSentPacket(ctx, packet) // If there is an error here we should still handle the ack if err != nil { ctx.EventManager().EmitEvent( @@ -207,12 +200,8 @@ func (im *IBCModule) OnTimeoutPacket( // RevertSentPacket Notifies the contract that a sent packet wasn't properly received func (im *IBCModule) RevertSentPacket( ctx sdk.Context, - packet channeltypes.Packet, + packet exported.PacketI, ) error { - var data transfertypes.FungibleTokenPacketData - if err := json.Unmarshal(packet.GetData(), &data); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal ICS-20 transfer packet data: %s", err.Error()) - } contract := im.ics4Middleware.GetParams(ctx) if contract == "" { // The contract has not been configured. Continue as usual @@ -223,9 +212,7 @@ func (im *IBCModule) RevertSentPacket( ctx, im.ics4Middleware.ContractKeeper, contract, - packet.GetSourceChannel(), - data.Denom, - data.Amount, + packet, ); err != nil { return err } diff --git a/x/ibc-rate-limit/ics4_wrapper.go b/x/ibc-rate-limit/ics4_wrapper.go index 453de40a4fc..ad53bea30ec 100644 --- a/x/ibc-rate-limit/ics4_wrapper.go +++ b/x/ibc-rate-limit/ics4_wrapper.go @@ -8,6 +8,7 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" ) @@ -51,25 +52,17 @@ func (i *ICS4Wrapper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capab return i.channel.SendPacket(ctx, chanCap, packet) } - amount, denom, err := GetFundsFromPacket(packet) - if err != nil { - return sdkerrors.Wrap(err, "Rate limit SendPacket") + // We need the full packet so the contract can process it. If it can't be cast to a channeltypes.Packet, this + // should fail. The only reason that would happen is if another middleware is modifying the packet, though. In + // that case we can modify the middleware order or change this cast so we have all the data we need. + fullPacket, ok := packet.(channeltypes.Packet) + if !ok { + return sdkerrors.ErrInvalidRequest } - channelValue := i.CalculateChannelValue(ctx, denom, packet) - - err = CheckAndUpdateRateLimits( - ctx, - i.ContractKeeper, - "send_packet", - contract, - channelValue, - packet.GetSourceChannel(), - denom, // We always use the packet's denom here, as we want the limits to be the same on both directions - amount, - ) + err := CheckAndUpdateRateLimits(ctx, i.ContractKeeper, "send_packet", contract, fullPacket) if err != nil { - return sdkerrors.Wrap(err, "bad packet in rate limit's SendPacket") + return sdkerrors.Wrap(err, "rate limit SendPacket failed to authorize transfer") } return i.channel.SendPacket(ctx, chanCap, packet) @@ -83,10 +76,3 @@ func (i *ICS4Wrapper) GetParams(ctx sdk.Context) (contract string) { i.paramSpace.GetIfExists(ctx, []byte("contract"), &contract) return contract } - -// CalculateChannelValue The value of an IBC channel. This is calculated using the denom supplied by the sender. -// if the denom is not correct, the transfer should fail somewhere else on the call chain -func (i *ICS4Wrapper) CalculateChannelValue(ctx sdk.Context, denom string, packet exported.PacketI) sdk.Int { - // The logic is etracted into a function here so that it can be used within the tests - return CalculateChannelValue(ctx, denom, packet.GetSourcePort(), packet.GetSourceChannel(), i.bankKeeper) -} diff --git a/x/ibc-rate-limit/module.go b/x/ibc-rate-limit/module.go new file mode 100644 index 00000000000..1776ff8cc6c --- /dev/null +++ b/x/ibc-rate-limit/module.go @@ -0,0 +1,60 @@ +package ibc_rate_limit + +import ( + "context" + "encoding/json" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + + ibcratelimitcli "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" +) + +var ( + _ module.AppModuleBasic = AppModuleBasic{} +) + +type AppModuleBasic struct{} + +func (AppModuleBasic) Name() string { return types.ModuleName } + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return nil +} + +// ValidateGenesis performs genesis state validation for the ibc-rate-limit module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + return nil +} + +// --------------------------------------- +// Interfaces. +func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) { +} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return ibcratelimitcli.GetQueryCmd() +} + +// RegisterInterfaces registers interfaces and implementations of the ibc-rate-limit module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +} diff --git a/x/ibc-rate-limit/rate_limit.go b/x/ibc-rate-limit/rate_limit.go index 5c91e5ffeed..6dfd2ec9713 100644 --- a/x/ibc-rate-limit/rate_limit.go +++ b/x/ibc-rate-limit/rate_limit.go @@ -2,15 +2,14 @@ package ibc_rate_limit import ( "encoding/json" - "strings" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" ) var ( @@ -19,9 +18,7 @@ var ( ) func CheckAndUpdateRateLimits(ctx sdk.Context, contractKeeper *wasmkeeper.PermissionedKeeper, - msgType, contract string, - channelValue sdk.Int, sourceChannel, denom string, - amount string, + msgType, contract string, packet exported.PacketI, ) error { contractAddr, err := sdk.AccAddressFromBech32(contract) if err != nil { @@ -30,10 +27,7 @@ func CheckAndUpdateRateLimits(ctx sdk.Context, contractKeeper *wasmkeeper.Permis sendPacketMsg, err := BuildWasmExecMsg( msgType, - sourceChannel, - denom, - channelValue, - amount, + packet, ) if err != nil { return err @@ -49,25 +43,28 @@ func CheckAndUpdateRateLimits(ctx sdk.Context, contractKeeper *wasmkeeper.Permis } type UndoSendMsg struct { - UndoSend UndoSendMsgContent `json:"undo_send"` + UndoSend UndoPacketMsg `json:"undo_send"` } -type UndoSendMsgContent struct { - ChannelId string `json:"channel_id"` - Denom string `json:"denom"` - Funds string `json:"funds"` +type UndoPacketMsg struct { + Packet UnwrappedPacket `json:"packet"` } func UndoSendRateLimit(ctx sdk.Context, contractKeeper *wasmkeeper.PermissionedKeeper, contract string, - sourceChannel, denom string, - amount string, + packet exported.PacketI, ) error { contractAddr, err := sdk.AccAddressFromBech32(contract) if err != nil { return err } - msg := UndoSendMsg{UndoSend: UndoSendMsgContent{ChannelId: sourceChannel, Denom: denom, Funds: amount}} + + unwrapped, err := unwrapPacket(packet) + if err != nil { + return err + } + + msg := UndoSendMsg{UndoSend: UndoPacketMsg{Packet: unwrapped}} asJson, err := json.Marshal(msg) if err != nil { return err @@ -82,38 +79,67 @@ func UndoSendRateLimit(ctx sdk.Context, contractKeeper *wasmkeeper.PermissionedK } type SendPacketMsg struct { - SendPacket RateLimitExecMsg `json:"send_packet"` + SendPacket PacketMsg `json:"send_packet"` } type RecvPacketMsg struct { - RecvPacket RateLimitExecMsg `json:"recv_packet"` + RecvPacket PacketMsg `json:"recv_packet"` +} + +type PacketMsg struct { + Packet UnwrappedPacket `json:"packet"` } -type RateLimitExecMsg struct { - ChannelId string `json:"channel_id"` - Denom string `json:"denom"` - ChannelValue sdk.Int `json:"channel_value"` - Funds string `json:"funds"` +type UnwrappedPacket struct { + Sequence uint64 `json:"sequence"` + SourcePort string `json:"source_port"` + SourceChannel string `json:"source_channel"` + DestinationPort string `json:"destination_port"` + DestinationChannel string `json:"destination_channel"` + Data transfertypes.FungibleTokenPacketData `json:"data"` + TimeoutHeight clienttypes.Height `json:"timeout_height"` + TimeoutTimestamp uint64 `json:"timeout_timestamp,omitempty"` } -func BuildWasmExecMsg(msgType, sourceChannel, denom string, channelValue sdk.Int, amount string) ([]byte, error) { - content := RateLimitExecMsg{ - ChannelId: sourceChannel, - Denom: denom, - ChannelValue: channelValue, - Funds: amount, +func unwrapPacket(packet exported.PacketI) (UnwrappedPacket, error) { + var packetData transfertypes.FungibleTokenPacketData + err := json.Unmarshal(packet.GetData(), &packetData) + if err != nil { + return UnwrappedPacket{}, err } + height, ok := packet.GetTimeoutHeight().(clienttypes.Height) + if !ok { + return UnwrappedPacket{}, types.ErrBadMessage + } + return UnwrappedPacket{ + Sequence: packet.GetSequence(), + SourcePort: packet.GetSourcePort(), + SourceChannel: packet.GetSourceChannel(), + DestinationPort: packet.GetDestPort(), + DestinationChannel: packet.GetDestChannel(), + Data: packetData, + TimeoutHeight: height, + TimeoutTimestamp: packet.GetTimeoutTimestamp(), + }, nil +} - var ( - asJson []byte - err error - ) +func BuildWasmExecMsg(msgType string, packet exported.PacketI) ([]byte, error) { + unwrapped, err := unwrapPacket(packet) + if err != nil { + return []byte{}, err + } + + var asJson []byte switch { case msgType == msgSend: - msg := SendPacketMsg{SendPacket: content} + msg := SendPacketMsg{SendPacket: PacketMsg{ + Packet: unwrapped, + }} asJson, err = json.Marshal(msg) case msgType == msgRecv: - msg := RecvPacketMsg{RecvPacket: content} + msg := RecvPacketMsg{RecvPacket: PacketMsg{ + Packet: unwrapped, + }} asJson, err = json.Marshal(msg) default: return []byte{}, types.ErrBadMessage @@ -125,43 +151,3 @@ func BuildWasmExecMsg(msgType, sourceChannel, denom string, channelValue sdk.Int return asJson, nil } - -func GetFundsFromPacket(packet exported.PacketI) (string, string, error) { - var packetData transfertypes.FungibleTokenPacketData - err := json.Unmarshal(packet.GetData(), &packetData) - if err != nil { - return "", "", err - } - return packetData.Amount, GetLocalDenom(packetData.Denom), nil -} - -func GetLocalDenom(denom string) string { - // Expected denoms in the following cases: - // - // send non-native: transfer/channel-0/denom -> ibc/xxx - // send native: denom -> denom - // recv (B)non-native: denom - // recv (B)native: transfer/channel-0/denom - // - if strings.HasPrefix(denom, "transfer/") { - denomTrace := transfertypes.ParseDenomTrace(denom) - return denomTrace.IBCDenom() - } else { - return denom - } -} - -func CalculateChannelValue(ctx sdk.Context, denom string, port, channel string, bankKeeper bankkeeper.Keeper) sdk.Int { - if strings.HasPrefix(denom, "ibc/") { - return bankKeeper.GetSupplyWithOffset(ctx, denom).Amount - } - - if channel == "any" { - // ToDo: Get all channels and sum the escrow addr value over all the channels - escrowAddress := transfertypes.GetEscrowAddress(port, channel) - return bankKeeper.GetBalance(ctx, escrowAddress, denom).Amount - } else { - escrowAddress := transfertypes.GetEscrowAddress(port, channel) - return bankKeeper.GetBalance(ctx, escrowAddress, denom).Amount - } -} diff --git a/x/ibc-rate-limit/testdata/rate_limiter.wasm b/x/ibc-rate-limit/testdata/rate_limiter.wasm deleted file mode 100644 index e19651209c4..00000000000 Binary files a/x/ibc-rate-limit/testdata/rate_limiter.wasm and /dev/null differ diff --git a/x/ibc-rate-limit/testutil/chain.go b/x/ibc-rate-limit/testutil/chain.go index 3ab9c26f0e2..578a474d61f 100644 --- a/x/ibc-rate-limit/testutil/chain.go +++ b/x/ibc-rate-limit/testutil/chain.go @@ -1,6 +1,7 @@ package osmosisibctesting import ( + "encoding/json" "time" "github.com/cosmos/cosmos-sdk/baseapp" @@ -9,7 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" "github.com/cosmos/ibc-go/v3/testing/simapp/helpers" - "github.com/osmosis-labs/osmosis/v12/app" + "github.com/osmosis-labs/osmosis/v13/app" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -18,6 +19,11 @@ type TestChain struct { *ibctesting.TestChain } +func SetupTestingApp() (ibctesting.TestingApp, map[string]json.RawMessage) { + osmosisApp := app.Setup(false) + return osmosisApp, app.NewDefaultGenesisState() +} + // SendMsgsNoCheck overrides ibctesting.TestChain.SendMsgs so that it doesn't check for errors. That should be handled by the caller func (chain *TestChain) SendMsgsNoCheck(msgs ...sdk.Msg) (*sdk.Result, error) { // ensure the chain has the latest time diff --git a/x/ibc-rate-limit/testutil/wasm.go b/x/ibc-rate-limit/testutil/wasm.go index 2beabb9c02a..b764bfa4544 100644 --- a/x/ibc-rate-limit/testutil/wasm.go +++ b/x/ibc-rate-limit/testutil/wasm.go @@ -11,15 +11,15 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" "github.com/stretchr/testify/suite" ) -func (chain *TestChain) StoreContractCode(suite *suite.Suite) { +func (chain *TestChain) StoreContractCode(suite *suite.Suite, path string) { osmosisApp := chain.GetOsmosisApp() govKeeper := osmosisApp.GovKeeper - wasmCode, err := ioutil.ReadFile("./testdata/rate_limiter.wasm") + wasmCode, err := ioutil.ReadFile(path) suite.Require().NoError(err) addr := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) @@ -38,7 +38,7 @@ func (chain *TestChain) StoreContractCode(suite *suite.Suite) { suite.Require().NoError(err) } -func (chain *TestChain) InstantiateContract(suite *suite.Suite, quotas string) sdk.AccAddress { +func (chain *TestChain) InstantiateRLContract(suite *suite.Suite, quotas string) sdk.AccAddress { osmosisApp := chain.GetOsmosisApp() transferModule := osmosisApp.AccountKeeper.GetModuleAddress(transfertypes.ModuleName) govModule := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) @@ -58,6 +58,23 @@ func (chain *TestChain) InstantiateContract(suite *suite.Suite, quotas string) s return addr } +func (chain *TestChain) InstantiateContract(suite *suite.Suite, msg string) sdk.AccAddress { + osmosisApp := chain.GetOsmosisApp() + contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(osmosisApp.WasmKeeper) + codeID := uint64(1) + creator := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) + addr, _, err := contractKeeper.Instantiate(chain.GetContext(), codeID, creator, creator, []byte(msg), "contract", nil) + suite.Require().NoError(err) + return addr +} + +func (chain *TestChain) QueryContract(suite *suite.Suite, contract sdk.AccAddress, key []byte) string { + osmosisApp := chain.GetOsmosisApp() + state, err := osmosisApp.WasmKeeper.QuerySmart(chain.GetContext(), contract, key) + suite.Require().NoError(err) + return string(state) +} + func (chain *TestChain) RegisterRateLimitingContract(addr []byte) { addrStr, err := sdk.Bech32ifyAddressBytes("osmo", addr) require.NoError(chain.T, err) diff --git a/x/ibc-rate-limit/types/params.go b/x/ibc-rate-limit/types/params.go index ba78deadf2d..30d5c6126b4 100644 --- a/x/ibc-rate-limit/types/params.go +++ b/x/ibc-rate-limit/types/params.go @@ -53,6 +53,12 @@ func validateContractAddress(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + // Empty strings are valid for unsetting the param + if v == "" { + return nil + } + + // Checks that the contract address is valid bech32, err := sdk.AccAddressFromBech32(v) if err != nil { return err diff --git a/x/ibc-rate-limit/types/params.pb.go b/x/ibc-rate-limit/types/params.pb.go index 6ab4058029a..c4496c048ca 100644 --- a/x/ibc-rate-limit/types/params.pb.go +++ b/x/ibc-rate-limit/types/params.pb.go @@ -23,7 +23,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Params defines the parameters for the ibc-rate-limiting module. +// Params defines the parameters for the ibc-rate-limit module. type Params struct { ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"` } @@ -89,9 +89,9 @@ var fileDescriptor_ca004105b8c54072 = []byte{ 0x84, 0xae, 0x42, 0x29, 0x88, 0x1f, 0x26, 0xe4, 0x08, 0x11, 0x71, 0x0a, 0x39, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xab, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, - 0xfc, 0x5c, 0x7d, 0xa8, 0x53, 0x75, 0x73, 0x12, 0x93, 0x8a, 0x61, 0x1c, 0xfd, 0x32, 0x43, 0x03, + 0xfc, 0x5c, 0x7d, 0xa8, 0x53, 0x75, 0x73, 0x12, 0x93, 0x8a, 0x61, 0x1c, 0xfd, 0x32, 0x43, 0x63, 0xfd, 0x0a, 0x74, 0xaf, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x9d, 0x6b, 0x0c, 0x08, - 0x00, 0x00, 0xff, 0xff, 0x79, 0xe3, 0x68, 0xf2, 0x11, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xc6, 0xeb, 0x77, 0x3b, 0x11, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/ibc-rate-limit/types/query.pb.go b/x/ibc-rate-limit/types/query.pb.go new file mode 100644 index 00000000000..bdc3c53e93e --- /dev/null +++ b/x/ibc-rate-limit/types/query.pb.go @@ -0,0 +1,542 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/ibc-rate-limit/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9376d12c6390a846, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9376d12c6390a846, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.ibcratelimit.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.ibcratelimit.v1beta1.QueryParamsResponse") +} + +func init() { + proto.RegisterFile("osmosis/ibc-rate-limit/v1beta1/query.proto", fileDescriptor_9376d12c6390a846) +} + +var fileDescriptor_9376d12c6390a846 = []byte{ + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0xb1, 0x4a, 0x03, 0x31, + 0x18, 0xc7, 0x2f, 0xa2, 0x1d, 0xce, 0xed, 0xec, 0x20, 0xa5, 0x44, 0x29, 0x22, 0xa5, 0xd2, 0xc4, + 0x6b, 0x37, 0xc7, 0x3e, 0x81, 0x16, 0x17, 0xdd, 0x92, 0x23, 0xc4, 0x40, 0xef, 0xbe, 0xf4, 0x92, + 0x16, 0xbb, 0xfa, 0x04, 0x82, 0xb3, 0xb3, 0xaf, 0xd2, 0xb1, 0xe0, 0xe2, 0x24, 0xd2, 0xfa, 0x20, + 0x72, 0x49, 0x2c, 0xa8, 0x50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0d, 0x2e, 0xe7, 0x4b, + 0x8c, 0x16, 0x4b, 0x8c, 0xde, 0x96, 0x18, 0xdd, 0xaf, 0x70, 0xb4, 0x58, 0xe1, 0xe8, 0x65, 0x85, + 0xa3, 0xeb, 0x33, 0xa9, 0xec, 0xcd, 0x84, 0x93, 0x0c, 0xf2, 0x4f, 0x57, 0x77, 0xc4, 0xb8, 0x59, + 0x8b, 0xa7, 0x69, 0x9f, 0xde, 0x7e, 0xd7, 0xdb, 0x99, 0x16, 0x86, 0xd7, 0xdc, 0xdd, 0xfb, 0x1f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x86, 0x64, 0x1f, 0xc7, 0x50, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params defines a gRPC query method that returns the ibc-rate-limit module's + // parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/osmosis.ibcratelimit.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params defines a gRPC query method that returns the ibc-rate-limit module's + // parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.ibcratelimit.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.ibcratelimit.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/ibc-rate-limit/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc-rate-limit/types/query.pb.gw.go b/x/ibc-rate-limit/types/query.pb.gw.go new file mode 100644 index 00000000000..9e938b097e5 --- /dev/null +++ b/x/ibc-rate-limit/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/ibc-rate-limit/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "ibc-rate-limit", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/incentives/client/cli/cli_test.go b/x/incentives/client/cli/cli_test.go index 56285eccee2..a2d7e75e844 100644 --- a/x/incentives/client/cli/cli_test.go +++ b/x/incentives/client/cli/cli_test.go @@ -9,15 +9,15 @@ import ( tmcli "github.com/tendermint/tendermint/libs/cli" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app" - gammtestutil "github.com/osmosis-labs/osmosis/v12/x/gamm/client/testutil" - "github.com/osmosis-labs/osmosis/v12/x/incentives/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptestutil "github.com/osmosis-labs/osmosis/v12/x/lockup/client/testutil" + "github.com/osmosis-labs/osmosis/v13/app" + gammtestutil "github.com/osmosis-labs/osmosis/v13/x/gamm/client/testutil" + "github.com/osmosis-labs/osmosis/v13/x/incentives/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptestutil "github.com/osmosis-labs/osmosis/v13/x/lockup/client/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" diff --git a/x/incentives/client/cli/query.go b/x/incentives/client/cli/query.go index 2fbef68a6be..2086c80e2f0 100644 --- a/x/incentives/client/cli/query.go +++ b/x/incentives/client/cli/query.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/incentives/client/cli/query_test.go b/x/incentives/client/cli/query_test.go index a8806954497..facf430c94a 100644 --- a/x/incentives/client/cli/query_test.go +++ b/x/incentives/client/cli/query_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/client/cli/tx.go b/x/incentives/client/cli/tx.go index db2157ea8e8..21e969aa08f 100644 --- a/x/incentives/client/cli/tx.go +++ b/x/incentives/client/cli/tx.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/incentives/keeper/bench_test.go b/x/incentives/keeper/bench_test.go index 2f39e5fd169..9c54c616ad4 100644 --- a/x/incentives/keeper/bench_test.go +++ b/x/incentives/keeper/bench_test.go @@ -9,9 +9,9 @@ import ( "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index e3a4d06cf01..a6c6c336626 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -6,8 +6,8 @@ import ( db "github.com/tendermint/tm-db" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/distribute_test.go b/x/incentives/keeper/distribute_test.go index c96e862ce50..8b0a5cf654f 100644 --- a/x/incentives/keeper/distribute_test.go +++ b/x/incentives/keeper/distribute_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/export_test.go b/x/incentives/keeper/export_test.go index f7d329393f2..f492dce6e9c 100644 --- a/x/incentives/keeper/export_test.go +++ b/x/incentives/keeper/export_test.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" ) // AddGaugeRefByKey appends the provided gauge ID into an array associated with the provided key. diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index a376885be13..5bc2ba6158a 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -11,9 +11,9 @@ import ( "github.com/gogo/protobuf/proto" db "github.com/tendermint/tm-db" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/gauge_test.go b/x/incentives/keeper/gauge_test.go index 657cd17b7fe..e44706efd70 100644 --- a/x/incentives/keeper/gauge_test.go +++ b/x/incentives/keeper/gauge_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/genesis.go b/x/incentives/keeper/genesis.go index 5b1bb82835b..0eecdfed697 100644 --- a/x/incentives/keeper/genesis.go +++ b/x/incentives/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" ) // InitGenesis initializes the incentives module's state from a provided genesis state. @@ -17,6 +17,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { panic(err) } } + k.SetLastGaugeID(ctx, genState.LastGaugeId) } // ExportGenesis returns the x/incentives module's exported genesis. diff --git a/x/incentives/keeper/genesis_test.go b/x/incentives/keeper/genesis_test.go index 856f08f9556..e06bf59911d 100644 --- a/x/incentives/keeper/genesis_test.go +++ b/x/incentives/keeper/genesis_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - osmoapp "github.com/osmosis-labs/osmosis/v12/app" + osmoapp "github.com/osmosis-labs/osmosis/v13/app" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // TestIncentivesExportGenesis tests export genesis command for the incentives module. diff --git a/x/incentives/keeper/grpc_query.go b/x/incentives/keeper/grpc_query.go index c13894ebe46..7d7c933967b 100644 --- a/x/incentives/keeper/grpc_query.go +++ b/x/incentives/keeper/grpc_query.go @@ -12,8 +12,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) var _ types.QueryServer = Querier{} diff --git a/x/incentives/keeper/grpc_query_test.go b/x/incentives/keeper/grpc_query_test.go index ba0cc5d87f9..69533d1a900 100644 --- a/x/incentives/keeper/grpc_query_test.go +++ b/x/incentives/keeper/grpc_query_test.go @@ -8,9 +8,9 @@ import ( query "github.com/cosmos/cosmos-sdk/types/query" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - pooltypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + pooltypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) var _ = suite.TestingSuite(nil) diff --git a/x/incentives/keeper/hooks.go b/x/incentives/keeper/hooks.go index cc93459ed88..0b116adce58 100644 --- a/x/incentives/keeper/hooks.go +++ b/x/incentives/keeper/hooks.go @@ -1,9 +1,9 @@ package keeper import ( - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/iterator.go b/x/incentives/keeper/iterator.go index 63e8ffadb20..3e0526216d4 100644 --- a/x/incentives/keeper/iterator.go +++ b/x/incentives/keeper/iterator.go @@ -3,8 +3,8 @@ package keeper import ( "time" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/incentives/keeper/keeper.go b/x/incentives/keeper/keeper.go index a446be25abe..2469032930f 100644 --- a/x/incentives/keeper/keeper.go +++ b/x/incentives/keeper/keeper.go @@ -6,8 +6,8 @@ import ( "github.com/tendermint/tendermint/libs/log" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" diff --git a/x/incentives/keeper/keeper_test.go b/x/incentives/keeper/keeper_test.go index 887fb6f797c..fd5774c2420 100644 --- a/x/incentives/keeper/keeper_test.go +++ b/x/incentives/keeper/keeper_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/incentives/keeper" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/incentives/keeper" ) type KeeperTestSuite struct { diff --git a/x/incentives/keeper/msg_server.go b/x/incentives/keeper/msg_server.go index c06e6492751..7845993a337 100644 --- a/x/incentives/keeper/msg_server.go +++ b/x/incentives/keeper/msg_server.go @@ -3,8 +3,8 @@ package keeper import ( "context" - "github.com/osmosis-labs/osmosis/v12/x/gamm/utils" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/utils" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/incentives/keeper/msg_server_test.go b/x/incentives/keeper/msg_server_test.go index d3793767d7f..0bb87d01cc0 100644 --- a/x/incentives/keeper/msg_server_test.go +++ b/x/incentives/keeper/msg_server_test.go @@ -8,9 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/osmosis-labs/osmosis/v12/x/incentives/keeper" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/keeper" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/params.go b/x/incentives/keeper/params.go index 5b17e60d4ef..f5a41871044 100644 --- a/x/incentives/keeper/params.go +++ b/x/incentives/keeper/params.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/store.go b/x/incentives/keeper/store.go index 6f223804fcf..47476d6bce8 100644 --- a/x/incentives/keeper/store.go +++ b/x/incentives/keeper/store.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/suite_test.go b/x/incentives/keeper/suite_test.go index 4dcddf1afdb..9a583961cdf 100644 --- a/x/incentives/keeper/suite_test.go +++ b/x/incentives/keeper/suite_test.go @@ -5,8 +5,8 @@ import ( "math/rand" "time" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/utils.go b/x/incentives/keeper/utils.go index 94fd9c44d4d..4cabb2053bb 100644 --- a/x/incentives/keeper/utils.go +++ b/x/incentives/keeper/utils.go @@ -3,7 +3,7 @@ package keeper import ( "time" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/keeper/utils_test.go b/x/incentives/keeper/utils_test.go index f44dc0e6ed4..421e4709339 100644 --- a/x/incentives/keeper/utils_test.go +++ b/x/incentives/keeper/utils_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/module.go b/x/incentives/module.go index 2cdb56ce3f5..f014f6035cd 100644 --- a/x/incentives/module.go +++ b/x/incentives/module.go @@ -27,11 +27,11 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/x/incentives/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/incentives/keeper" - "github.com/osmosis-labs/osmosis/v12/x/incentives/simulation" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - "github.com/osmosis-labs/osmosis/v12/x/mint/client/rest" + "github.com/osmosis-labs/osmosis/v13/x/incentives/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/incentives/keeper" + "github.com/osmosis-labs/osmosis/v13/x/incentives/simulation" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/client/rest" ) var ( diff --git a/x/incentives/simulation/genesis.go b/x/incentives/simulation/genesis.go index 1c420fa8305..f32ead648fb 100644 --- a/x/incentives/simulation/genesis.go +++ b/x/incentives/simulation/genesis.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" ) // Simulation parameter constants. diff --git a/x/incentives/simulation/operations.go b/x/incentives/simulation/operations.go index 40fb3b75fc8..0186a075990 100644 --- a/x/incentives/simulation/operations.go +++ b/x/incentives/simulation/operations.go @@ -4,13 +4,13 @@ import ( "math/rand" "time" - osmosimtypes "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + osmosimtypes "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/osmosis-labs/osmosis/v12/x/incentives/keeper" - "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/incentives/keeper" + "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/codec" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go index ca1a7d06d21..a60bc72678c 100644 --- a/x/incentives/types/expected_keepers.go +++ b/x/incentives/types/expected_keepers.go @@ -3,8 +3,8 @@ package types import ( time "time" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/types/gauge.go b/x/incentives/types/gauge.go index 058615ab710..3d10f522528 100644 --- a/x/incentives/types/gauge.go +++ b/x/incentives/types/gauge.go @@ -3,7 +3,7 @@ package types import ( time "time" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/types/gauge.pb.go b/x/incentives/types/gauge.pb.go index f5dfd37ee5b..1a75c6d5974 100644 --- a/x/incentives/types/gauge.pb.go +++ b/x/incentives/types/gauge.pb.go @@ -11,7 +11,7 @@ import ( proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - types "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + types "github.com/osmosis-labs/osmosis/v13/x/lockup/types" io "io" math "math" math_bits "math/bits" @@ -202,42 +202,42 @@ func init() { func init() { proto.RegisterFile("osmosis/incentives/gauge.proto", fileDescriptor_c0304e2bb0159901) } var fileDescriptor_c0304e2bb0159901 = []byte{ - // 547 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x4f, 0x6f, 0xd3, 0x3e, - 0x18, 0xc7, 0x9b, 0xad, 0xdd, 0x6f, 0x3f, 0xb7, 0x43, 0xd4, 0x1a, 0x52, 0x5a, 0x89, 0xb4, 0x14, - 0x21, 0xf5, 0x32, 0x9b, 0x16, 0x89, 0x03, 0xc7, 0x0e, 0x84, 0x26, 0x21, 0x51, 0xaa, 0x1d, 0x10, - 0x97, 0xc8, 0x49, 0xdc, 0xcc, 0x6a, 0x92, 0x27, 0x8a, 0x9d, 0x6a, 0x7d, 0x07, 0x1c, 0x27, 0x4e, - 0xbc, 0x06, 0x5e, 0xc9, 0x8e, 0x3b, 0x72, 0xda, 0x50, 0xfb, 0x0e, 0x78, 0x05, 0x28, 0x76, 0xa2, - 0x56, 0xe5, 0xca, 0xc9, 0xf1, 0xf3, 0x7d, 0xfe, 0x7d, 0x3f, 0x72, 0x90, 0x03, 0x32, 0x06, 0x29, - 0x24, 0x15, 0x89, 0xcf, 0x13, 0x25, 0x96, 0x5c, 0xd2, 0x90, 0xe5, 0x21, 0x27, 0x69, 0x06, 0x0a, - 0x30, 0x2e, 0x75, 0xb2, 0xd5, 0xbb, 0xa7, 0x21, 0x84, 0xa0, 0x65, 0x5a, 0x7c, 0x99, 0xcc, 0xae, - 0x13, 0x02, 0x84, 0x11, 0xa7, 0xfa, 0xe6, 0xe5, 0x73, 0x1a, 0xe4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a, 0x3f, 0x37, 0x4e, 0xed, 0xcb, 0xeb, 0x1d, 0x83, 0xe5, - 0x7b, 0x3b, 0x8b, 0x98, 0x27, 0xab, 0x0b, 0x5d, 0x8e, 0xc6, 0xf4, 0x7a, 0xf7, 0xef, 0xd4, 0xa6, - 0xbd, 0x23, 0xbd, 0xde, 0xab, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x45, 0xcb, 0x05, 0xbe, 0xc0, - 0x03, 0x00, 0x00, + // 545 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcf, 0x6e, 0xd3, 0x30, + 0x1c, 0xc7, 0x9b, 0xad, 0x1d, 0xc3, 0xed, 0x10, 0xb5, 0x86, 0x94, 0x56, 0x22, 0x2d, 0x45, 0x48, + 0xbd, 0xcc, 0xa6, 0x9b, 0xc4, 0x81, 0x63, 0x07, 0x42, 0x93, 0x90, 0x28, 0xd5, 0x0e, 0x88, 0x4b, + 0xe4, 0x24, 0x6e, 0x66, 0x35, 0xc9, 0x2f, 0x8a, 0x9d, 0x6a, 0x7d, 0x03, 0x8e, 0x13, 0x27, 0x9e, + 0x81, 0x27, 0xd9, 0x71, 0x47, 0x4e, 0x1b, 0x6a, 0xdf, 0x80, 0x27, 0x40, 0xb1, 0x13, 0xb5, 0x2a, + 0x57, 0x4e, 0x8e, 0x7f, 0xdf, 0xdf, 0xbf, 0xef, 0x47, 0x0e, 0x72, 0x40, 0xc6, 0x20, 0x85, 0xa4, + 0x22, 0xf1, 0x79, 0xa2, 0xc4, 0x82, 0x4b, 0x1a, 0xb2, 0x3c, 0xe4, 0x24, 0xcd, 0x40, 0x01, 0xc6, + 0xa5, 0x4e, 0x36, 0x7a, 0xf7, 0x38, 0x84, 0x10, 0xb4, 0x4c, 0x8b, 0x2f, 0x93, 0xd9, 0x75, 0x42, + 0x80, 0x30, 0xe2, 0x54, 0xdf, 0xbc, 0x7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4, 0xee, 0xd6, 0x4e, 0xed, 0xd7, 0xda, 0xa9, 0x7d, 0x7d, 0xb3, 0x65, 0xb0, 0x7c, 0x6f, + 0x27, 0x11, 0xf3, 0x64, 0x75, 0xa1, 0x8b, 0xd1, 0x19, 0xbd, 0xde, 0xfe, 0x3b, 0xb5, 0x69, 0xef, + 0x40, 0xaf, 0x77, 0xf6, 0x37, 0x00, 0x00, 0xff, 0xff, 0x58, 0x36, 0xb0, 0xbf, 0xc0, 0x03, 0x00, + 0x00, } func (m *Gauge) Marshal() (dAtA []byte, err error) { diff --git a/x/incentives/types/genesis.pb.go b/x/incentives/types/genesis.pb.go index 622039da835..0583172f7d0 100644 --- a/x/incentives/types/genesis.pb.go +++ b/x/incentives/types/genesis.pb.go @@ -110,29 +110,29 @@ func init() { func init() { proto.RegisterFile("osmosis/incentives/genesis.proto", fileDescriptor_a288ccc95d977d2d) } var fileDescriptor_a288ccc95d977d2d = []byte{ - // 340 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0x86, 0x93, 0xb6, 0xea, 0x90, 0xc2, 0x80, 0xc5, 0x90, 0x76, 0x70, 0xa2, 0x48, 0x48, 0x5d, - 0xb0, 0x45, 0x91, 0x00, 0x31, 0x56, 0x48, 0x15, 0x5b, 0x55, 0x36, 0x96, 0xca, 0x69, 0x8d, 0xb1, - 0x48, 0xe2, 0xaa, 0xe7, 0x54, 0xf4, 0x2d, 0x98, 0x10, 0x8f, 0xd4, 0xb1, 0x23, 0x53, 0x41, 0xed, - 0x1b, 0xf0, 0x04, 0x28, 0x4e, 0x2c, 0x90, 0xda, 0xcd, 0xe7, 0xff, 0xbb, 0xff, 0xfe, 0x3b, 0x2f, - 0x54, 0x90, 0x2a, 0x90, 0x40, 0x65, 0x36, 0xe1, 0x99, 0x96, 0x0b, 0x0e, 0x54, 0xf0,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0xee, 0x7a, 0x8b, 0xdd, 0xef, 0x2d, 0x76, 0xdf, 0x76, 0xd8, 0x59, - 0xef, 0xb0, 0xf3, 0xb9, 0xc3, 0xce, 0xe3, 0x95, 0x90, 0xfa, 0x39, 0x8f, 0xc9, 0x44, 0xa5, 0xb4, - 0xda, 0xf0, 0x3c, 0x61, 0x31, 0xd8, 0x82, 0x2e, 0x2e, 0x7a, 0xf4, 0xf5, 0xff, 0xc1, 0xf5, 0x72, - 0xc6, 0x21, 0x6e, 0x9a, 0x15, 0x2e, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x4e, 0xbb, 0x49, - 0x20, 0x02, 0x00, 0x00, + // 341 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0x6e, 0xfa, 0x30, + 0x10, 0xc6, 0x13, 0x40, 0x0c, 0xe1, 0xff, 0x1f, 0x6a, 0x75, 0x08, 0x0c, 0x4e, 0x14, 0xa9, 0x12, + 0x4b, 0x6d, 0x15, 0xa4, 0xb6, 0xea, 0x88, 0x2a, 0xa1, 0x6e, 0x88, 0x6e, 0x5d, 0x90, 0x03, 0xae, + 0x6b, 0x35, 0x89, 0x11, 0xe7, 0xa0, 0xf2, 0x16, 0x9d, 0xaa, 0x3e, 0x12, 0x23, 0x63, 0x27, 0x5a, + 0xc1, 0x1b, 0xf4, 0x09, 0xaa, 0x38, 0xb1, 0x5a, 0x09, 0x36, 0x9f, 0xbf, 0xdf, 0x7d, 0xf7, 0xdd, + 0x79, 0xa1, 0x82, 0x54, 0x81, 0x04, 0x2a, 0xb3, 0x29, 0xcf, 0xb4, 0x5c, 0x72, 0xa0, 0x82, 0x67, + 0x1c, 0x24, 0x90, 0xf9, 0x42, 0x69, 0x85, 0x50, 0x45, 0x90, 0x5f, 0xa2, 0x73, 0x2a, 0x94, 0x50, + 0x46, 0xa6, 0xc5, 0xab, 0x24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x52, 0x3f, 0xe5, 0x31, 0x99, 0xaa, + 0x94, 0x56, 0x1b, 0x9e, 0x27, 0x2c, 0x06, 0x5b, 0xd0, 0xe5, 0x45, 0x9f, 0xbe, 0xfc, 0x3d, 0xb8, + 0x5e, 0xcd, 0x39, 0xc4, 0x4d, 0xb3, 0x42, 0xff, 0x27, 0x00, 0x00, 0xff, 0xff, 0x77, 0xb3, 0x0e, + 0x48, 0x20, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/incentives/types/msgs.go b/x/incentives/types/msgs.go index e646af1b6fa..e05cf7c567d 100644 --- a/x/incentives/types/msgs.go +++ b/x/incentives/types/msgs.go @@ -4,7 +4,7 @@ import ( "errors" "time" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentives/types/msgs_test.go b/x/incentives/types/msgs_test.go index 3459af4d51d..8d806b95d2d 100644 --- a/x/incentives/types/msgs_test.go +++ b/x/incentives/types/msgs_test.go @@ -9,12 +9,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" - appParams "github.com/osmosis-labs/osmosis/v12/app/params" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // TestMsgCreatePool tests if valid/invalid create pool messages are properly validated/invalidated diff --git a/x/incentives/types/params.go b/x/incentives/types/params.go index 9b9bd09e4fc..ae3a978d8df 100644 --- a/x/incentives/types/params.go +++ b/x/incentives/types/params.go @@ -1,7 +1,7 @@ package types import ( - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) diff --git a/x/incentives/types/params.pb.go b/x/incentives/types/params.pb.go index dd90ce81529..9bf398df45a 100644 --- a/x/incentives/types/params.pb.go +++ b/x/incentives/types/params.pb.go @@ -89,8 +89,8 @@ var fileDescriptor_1cc8b460d089f845 = []byte{ 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x2c, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, 0x62, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x18, 0x47, 0xbf, - 0xcc, 0xd0, 0x48, 0xbf, 0x02, 0xd9, 0x97, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xb7, - 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x57, 0xe5, 0x1b, 0x08, 0x01, 0x00, 0x00, + 0xcc, 0xd0, 0x58, 0xbf, 0x02, 0xd9, 0x97, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xb7, + 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xff, 0xaa, 0x50, 0x1a, 0x08, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/incentives/types/query.pb.go b/x/incentives/types/query.pb.go index e0c650d20f1..662ff4a3910 100644 --- a/x/incentives/types/query.pb.go +++ b/x/incentives/types/query.pb.go @@ -14,7 +14,7 @@ import ( proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + _ "github.com/osmosis-labs/osmosis/v13/x/lockup/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -938,71 +938,71 @@ func init() { proto.RegisterFile("osmosis/incentives/query.proto", fileDescripto var fileDescriptor_8124258a89427f98 = []byte{ // 1057 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x33, 0x4e, 0x5c, 0x9a, 0xd7, 0x12, 0x9a, 0x21, 0x40, 0xe2, 0xb6, 0x6b, 0xb3, 0x6a, - 0x53, 0x37, 0x25, 0x3b, 0xb1, 0x4d, 0x53, 0x04, 0x02, 0x09, 0xe3, 0x52, 0x2a, 0x81, 0x14, 0x56, - 0x20, 0x24, 0x24, 0xb4, 0x5a, 0x7b, 0x87, 0xed, 0x2a, 0xf6, 0x8e, 0xeb, 0xd9, 0x4d, 0xb0, 0xa2, - 0x5c, 0x10, 0xe7, 0x0a, 0x44, 0x84, 0x38, 0xf4, 0x2f, 0xe0, 0x08, 0x12, 0x47, 0x0e, 0x9c, 0x7a, - 0xac, 0x84, 0x84, 0x38, 0xa5, 0x28, 0xe1, 0x2f, 0xe8, 0x5f, 0x80, 0x76, 0x76, 0xd6, 0x5e, 0xdb, - 0xeb, 0x75, 0x82, 0x68, 0x94, 0x93, 0x33, 0x79, 0xbf, 0x3e, 0xef, 0xeb, 0xf1, 0x7b, 0x03, 0x0a, - 0xe3, 0x2d, 0xc6, 0x1d, 0x4e, 0x1c, 0xb7, 0x41, 0x5d, 0xcf, 0xd9, 0xa2, 0x9c, 0xdc, 0xf7, 0x69, - 0xa7, 0xab, 0xb5, 0x3b, 0xcc, 0x63, 0x18, 0x4b, 0xbb, 0xd6, 0xb7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0x95, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xab, 0x12, 0x45, 0x20, 0x23, 0x0f, 0x00, + 0x14, 0xc7, 0x33, 0x4e, 0x5c, 0xda, 0xd7, 0x12, 0x9a, 0x21, 0x40, 0xe2, 0xb6, 0x6b, 0xb3, 0x6a, + 0x53, 0x37, 0x25, 0x3b, 0x71, 0x4c, 0x53, 0x04, 0x02, 0x09, 0xe3, 0x52, 0x2a, 0x81, 0x14, 0x56, + 0x20, 0x24, 0x24, 0xb4, 0x5a, 0x7b, 0x87, 0xed, 0x2a, 0xf6, 0x8e, 0xbb, 0xb3, 0x9b, 0x60, 0x45, + 0xb9, 0x20, 0xce, 0x15, 0x88, 0x08, 0x71, 0xe8, 0x5f, 0xc0, 0x11, 0x24, 0x8e, 0x1c, 0x38, 0xf5, + 0x58, 0x09, 0x09, 0x71, 0x4a, 0x51, 0xc2, 0x5f, 0xd0, 0xbf, 0x00, 0xed, 0xec, 0xac, 0xbd, 0xb6, + 0xd7, 0xeb, 0x04, 0xd1, 0x2a, 0x27, 0x67, 0xf2, 0x7e, 0x7d, 0xde, 0xd7, 0xe3, 0xf7, 0x06, 0x14, + 0xc6, 0xdb, 0x8c, 0x3b, 0x9c, 0x38, 0x6e, 0x93, 0xba, 0xbe, 0xb3, 0x45, 0x39, 0xb9, 0x17, 0x50, + 0xaf, 0xab, 0x75, 0x3c, 0xe6, 0x33, 0x8c, 0xa5, 0x5d, 0xeb, 0xdb, 0x0b, 0xf3, 0x36, 0xb3, 0x99, + 0x30, 0x93, 0xf0, 0xaf, 0xc8, 0xb3, 0x70, 0xd1, 0x66, 0xcc, 0x6e, 0x51, 0x62, 0x76, 0x1c, 0x62, + 0xba, 0x2e, 0xf3, 0x4d, 0xdf, 0x61, 0x2e, 0x97, 0x56, 0x45, 0x5a, 0xc5, 0xa9, 0x11, 0x7c, 0x49, + 0xac, 0xc0, 0x13, 0x0e, 0xb1, 0xbd, 0x29, 0x0a, 0x91, 0x86, 0x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x61, 0x6d, 0xd7, 0x8e, 0x13, 0x22, 0xb1, 0xdf, 0x16, 0xd8, 0x37, 0xf1, 0x8d, 0x63, + 0x60, 0x27, 0xf4, 0xdd, 0x43, 0x00, 0xfd, 0xd9, 0x8d, 0x53, 0x7f, 0x98, 0x23, 0x0b, 0xa5, 0xb0, + 0x34, 0xc9, 0x4d, 0xc2, 0xdd, 0x14, 0x70, 0x15, 0x4c, 0xb2, 0xe0, 0xbc, 0x28, 0xce, 0xa0, 0xdc, + 0x27, 0x3b, 0x62, 0x11, 0xed, 0xe2, 0x9f, 0x11, 0xcc, 0x8d, 0x8c, 0xec, 0x74, 0x49, 0x33, 0x17, + 0x40, 0xba, 0xa4, 0xd9, 0x1b, 0x41, 0x5d, 0x17, 0xd4, 0xab, 0x58, 0xcb, 0xa2, 0x1e, 0x1d, 0xf8, + 0xb5, 0x8d, 0x87, 0x07, 0x0a, 0x7a, 0x74, 0xa0, 0xa0, 0xbf, 0x0f, 0x14, 0xf4, 0xed, 0xa1, 0x32, + 0xf5, 0xe8, 0x50, 0x99, 0xfa, 0xeb, 0x50, 0x99, 0xfa, 0x7c, 0x3d, 0xb1, 0xd8, 0x64, 0xce, 0x95, + 0x96, 0xd9, 0xe0, 0xbd, 0x02, 0x5b, 0x95, 0x2a, 0xf9, 0x2a, 0x59, 0x46, 0x2c, 0xbb, 0xc6, 0x29, + 0xb1, 0x77, 0xaa, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xb6, 0xef, 0xf0, 0x21, 0x23, 0x0f, 0x00, 0x00, } diff --git a/x/incentives/types/tx.pb.go b/x/incentives/types/tx.pb.go index 7f0227a82ab..7f87eafc918 100644 --- a/x/incentives/types/tx.pb.go +++ b/x/incentives/types/tx.pb.go @@ -13,7 +13,7 @@ import ( proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - types "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + types "github.com/osmosis-labs/osmosis/v13/x/lockup/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -278,45 +278,45 @@ func init() { func init() { proto.RegisterFile("osmosis/incentives/tx.proto", fileDescriptor_8ea120e22291556e) } var fileDescriptor_8ea120e22291556e = []byte{ - // 596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0xcd, 0x7c, 0x49, 0xff, 0x26, 0xed, 0xa7, 0x62, 0x15, 0x70, 0x03, 0xb2, 0x53, 0x2f, 0x90, - 0x41, 0xea, 0x0c, 0x0d, 0x12, 0x0b, 0x76, 0xa4, 0x42, 0xa8, 0x8b, 0x88, 0x60, 0x45, 0x42, 0xaa, - 0x84, 0xac, 0xb1, 0x3d, 0xb8, 0xa3, 0xc6, 0x1e, 0xcb, 0x33, 0x4e, 0x9b, 0xb7, 0xa8, 0xc4, 0x5b, - 0xf0, 0x06, 0xec, 0x58, 0x76, 0xd9, 0x25, 0xab, 0x14, 0x25, 0x6f, 0xd0, 0x27, 0x40, 0x1e, 0xdb, - 0x4d, 0x22, 0x7e, 0xba, 0x61, 0x35, 0x99, 0x39, 0xe7, 0x9e, 0xb9, 0x73, 0xce, 0x8d, 0xe1, 0x23, - 0x2e, 0x22, 0x2e, 0x98, 0xc0, 0x2c, 0xf6, 0x69, 0x2c, 0xd9, 0x88, 0x0a, 0x2c, 0xcf, 0x51, 0x92, - 0x72, 0xc9, 0x35, 0xad, 0x04, 0xd1, 0x1c, 0x6c, 0xed, 0x84, 0x3c, 0xe4, 0x0a, 0xc6, 0xf9, 0xaf, - 0x82, 0xd9, 0x32, 0x43, 0xce, 0xc3, 0x21, 0xc5, 0x6a, 0xe7, 0x65, 0x9f, 0xb0, 0x64, 0x11, 0x15, - 0x92, 0x44, 0x49, 0x49, 0x30, 0x7c, 0xa5, 0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 0x6b, 0xb4, 0x63, 0x08, 0x17, 0x7c, 0xdb, 0xfb, 0x43, 0xe5, 0x9c, 0xd2, - 0x7a, 0x7a, 0x27, 0xa5, 0xd2, 0xee, 0xf6, 0x2f, 0xa7, 0x06, 0xb8, 0x9a, 0x1a, 0xe0, 0xc7, 0xd4, - 0x00, 0x17, 0x33, 0xa3, 0x76, 0x35, 0x33, 0x6a, 0xdf, 0x67, 0x46, 0xed, 0xf8, 0xe5, 0x82, 0x51, - 0xa5, 0xdc, 0xfe, 0x90, 0x78, 0xa2, 0xda, 0xe0, 0xd1, 0x41, 0x07, 0x9f, 0x2f, 0x7d, 0x42, 0x72, - 0xf3, 0xbc, 0x55, 0x35, 0x71, 0x2f, 0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0x41, 0xff, 0xee, 0x97, - 0x65, 0x04, 0x00, 0x00, + // 595 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6e, 0xd3, 0x30, + 0x1c, 0xae, 0x69, 0xf7, 0xcf, 0xdd, 0xd0, 0x88, 0x06, 0x64, 0x05, 0x25, 0x5d, 0x0e, 0x28, 0x20, + 0xcd, 0x66, 0x9b, 0xc4, 0x81, 0x1b, 0x9d, 0x10, 0xda, 0xa1, 0xa2, 0x44, 0x95, 0x90, 0x26, 0xa1, + 0xc8, 0x49, 0x4c, 0x66, 0xad, 0x89, 0xa3, 0xd8, 0xe9, 0xd6, 0xb7, 0x98, 0xc4, 0x5b, 0xf0, 0x06, + 0xdc, 0x38, 0xee, 0xb8, 0x23, 0xa7, 0x0e, 0xb5, 0x6f, 0xb0, 0x27, 0x40, 0x71, 0x92, 0xb5, 0x15, + 0x7f, 0x76, 0xe1, 0xe4, 0xda, 0xdf, 0xf7, 0xfb, 0xfc, 0xf3, 0xf7, 0xfd, 0x1a, 0xf8, 0x84, 0x8b, + 0x88, 0x0b, 0x26, 0x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 0xf6, 0x47, 0x81, 0x46, 0xe1, 0x4a, 0x4a, 0xcf, 0x48, 0x1a, 0x08, 0xbd, 0xfe, 0xff, 0xdd, + 0xad, 0xb4, 0xad, 0xc7, 0xf0, 0xe1, 0x42, 0xeb, 0xd5, 0xa3, 0xf6, 0xbf, 0x03, 0x58, 0xef, 0x8a, + 0x50, 0xfb, 0x04, 0x9b, 0xf3, 0x83, 0x68, 0xa1, 0xdf, 0xff, 0x42, 0x68, 0xd1, 0x97, 0xd6, 0x8b, + 0xbb, 0x39, 0xd5, 0x35, 0xda, 0x31, 0x84, 0x73, 0xbe, 0xed, 0xfc, 0xa5, 0x72, 0x46, 0x69, 0x3d, + 0xbf, 0x93, 0x52, 0x69, 0x77, 0x7a, 0x97, 0x13, 0x03, 0x5c, 0x4d, 0x0c, 0xf0, 0x73, 0x62, 0x80, + 0x8b, 0xa9, 0x51, 0xbb, 0x9a, 0x1a, 0xb5, 0x1f, 0x53, 0xa3, 0x76, 0xfc, 0x6a, 0xce, 0xa8, 0x52, + 0x6e, 0x77, 0x40, 0x3c, 0x51, 0x6d, 0xf0, 0x70, 0xef, 0x00, 0x9f, 0x2f, 0x7c, 0x42, 0x72, 0xf3, + 0xbc, 0x65, 0x35, 0x71, 0x07, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x02, 0x5b, 0x96, 0x65, + 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/lockup/abci.go b/x/lockup/abci.go index 637a9d2c992..55aef5197e9 100644 --- a/x/lockup/abci.go +++ b/x/lockup/abci.go @@ -3,7 +3,7 @@ package lockup import ( abci "github.com/tendermint/tendermint/abci/types" - "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" + "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/client/cli/cli_test.go b/x/lockup/client/cli/cli_test.go index 2108a98a3d1..62fad3fec0b 100644 --- a/x/lockup/client/cli/cli_test.go +++ b/x/lockup/client/cli/cli_test.go @@ -9,11 +9,11 @@ import ( "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/lockup/client/cli" - lockuptestutil "github.com/osmosis-labs/osmosis/v12/x/lockup/client/testutil" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/lockup/client/cli" + lockuptestutil "github.com/osmosis-labs/osmosis/v13/x/lockup/client/testutil" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" diff --git a/x/lockup/client/cli/query.go b/x/lockup/client/cli/query.go index 634e41a6826..be8f3fb0fda 100644 --- a/x/lockup/client/cli/query.go +++ b/x/lockup/client/cli/query.go @@ -16,7 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // GetQueryCmd returns the cli query commands for this module. diff --git a/x/lockup/client/cli/query_test.go b/x/lockup/client/cli/query_test.go index 9532c5137d3..d04f510ea87 100644 --- a/x/lockup/client/cli/query_test.go +++ b/x/lockup/client/cli/query_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/client/cli/tx.go b/x/lockup/client/cli/tx.go index 997a28f49b4..34b370dbcb7 100644 --- a/x/lockup/client/cli/tx.go +++ b/x/lockup/client/cli/tx.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -29,6 +29,7 @@ func GetTxCmd() *cobra.Command { NewLockTokensCmd(), NewBeginUnlockingCmd(), NewBeginUnlockByIDCmd(), + NewForceUnlockByIdCmd(), ) return cmd @@ -154,3 +155,52 @@ func NewBeginUnlockByIDCmd() *cobra.Command { flags.AddTxFlagsToCmd(cmd) return cmd } + +// NewForceUnlockByIdCmd force unlocks individual period lock by ID if proper permissions exist. +func NewForceUnlockByIdCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "force-unlock-by-id [id]", + Short: "force unlocks individual period lock by ID", + Long: "force unlocks individual period lock by ID. if no amount provided, entire lock is unlocked", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + id, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + coins := sdk.Coins(nil) + amountStr, err := cmd.Flags().GetString(FlagAmount) + if err != nil { + return err + } + + if amountStr != "" { + coins, err = sdk.ParseCoinsNormalized(amountStr) + if err != nil { + return err + } + } + + msg := types.NewMsgForceUnlock( + clientCtx.GetFromAddress(), + uint64(id), + coins, + ) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + cmd.Flags().AddFlagSet(FlagSetUnlockTokens()) + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/lockup/client/rest/query.go b/x/lockup/client/rest/query.go index c15fb04fffb..40f9dacd3bb 100644 --- a/x/lockup/client/rest/query.go +++ b/x/lockup/client/rest/query.go @@ -8,7 +8,7 @@ import ( "github.com/gorilla/mux" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/lockup/client/rest/tx.go b/x/lockup/client/rest/tx.go index bd019ad2de6..4db840a66a3 100644 --- a/x/lockup/client/rest/tx.go +++ b/x/lockup/client/rest/tx.go @@ -6,7 +6,7 @@ import ( "github.com/gorilla/mux" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" diff --git a/x/lockup/client/testutil/test_helpers.go b/x/lockup/client/testutil/test_helpers.go index 4278efb56e2..2f9d59ef89f 100644 --- a/x/lockup/client/testutil/test_helpers.go +++ b/x/lockup/client/testutil/test_helpers.go @@ -3,7 +3,7 @@ package testutil import ( "fmt" - lockupcli "github.com/osmosis-labs/osmosis/v12/x/lockup/client/cli" + lockupcli "github.com/osmosis-labs/osmosis/v13/x/lockup/client/cli" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/lockup/keeper/admin_keeper.go b/x/lockup/keeper/admin_keeper.go index e56be70887b..db262d7c771 100644 --- a/x/lockup/keeper/admin_keeper.go +++ b/x/lockup/keeper/admin_keeper.go @@ -2,7 +2,7 @@ package keeper import ( "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/admin_keeper_test.go b/x/lockup/keeper/admin_keeper_test.go index 56aa8fae426..338f81d03bc 100644 --- a/x/lockup/keeper/admin_keeper_test.go +++ b/x/lockup/keeper/admin_keeper_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "time" - "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" + "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/bench_test.go b/x/lockup/keeper/bench_test.go index 9c8f63cc093..f291175b93d 100644 --- a/x/lockup/keeper/bench_test.go +++ b/x/lockup/keeper/bench_test.go @@ -9,8 +9,8 @@ import ( "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/app" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/app" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/lockup/keeper/export_test.go b/x/lockup/keeper/export_test.go index 9f96ffd7783..d55c92ff0f9 100644 --- a/x/lockup/keeper/export_test.go +++ b/x/lockup/keeper/export_test.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/genesis.go b/x/lockup/keeper/genesis.go index da14e318c48..a802de7d862 100644 --- a/x/lockup/keeper/genesis.go +++ b/x/lockup/keeper/genesis.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/genesis_test.go b/x/lockup/keeper/genesis_test.go index 8feac5836c4..09f70fbdb8b 100644 --- a/x/lockup/keeper/genesis_test.go +++ b/x/lockup/keeper/genesis_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - osmoapp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/lockup" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + osmoapp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/lockup" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/lockup/keeper/grpc_query.go b/x/lockup/keeper/grpc_query.go index af1ce919517..cb1c7dbe0ac 100644 --- a/x/lockup/keeper/grpc_query.go +++ b/x/lockup/keeper/grpc_query.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) var _ types.QueryServer = Querier{} diff --git a/x/lockup/keeper/grpc_query_test.go b/x/lockup/keeper/grpc_query_test.go index 91556ee29b9..74d45094d11 100644 --- a/x/lockup/keeper/grpc_query_test.go +++ b/x/lockup/keeper/grpc_query_test.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) func (suite *KeeperTestSuite) LockTokens(addr sdk.AccAddress, coins sdk.Coins, duration time.Duration) { diff --git a/x/lockup/keeper/invariants.go b/x/lockup/keeper/invariants.go index 9ae9c0fadfb..2014500b347 100644 --- a/x/lockup/keeper/invariants.go +++ b/x/lockup/keeper/invariants.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // RegisterInvariants registers all governance invariants. diff --git a/x/lockup/keeper/iterator.go b/x/lockup/keeper/iterator.go index 0f8b48c0d98..5ff252e81a2 100644 --- a/x/lockup/keeper/iterator.go +++ b/x/lockup/keeper/iterator.go @@ -5,7 +5,7 @@ import ( db "github.com/tendermint/tm-db" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/lockup/keeper/keeper.go b/x/lockup/keeper/keeper.go index ea937cd0eb7..8621eac166c 100644 --- a/x/lockup/keeper/keeper.go +++ b/x/lockup/keeper/keeper.go @@ -5,7 +5,7 @@ import ( "github.com/tendermint/tendermint/libs/log" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" diff --git a/x/lockup/keeper/keeper_test.go b/x/lockup/keeper/keeper_test.go index 1c07fc7e39b..0a560947d5d 100644 --- a/x/lockup/keeper/keeper_test.go +++ b/x/lockup/keeper/keeper_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" ) type KeeperTestSuite struct { diff --git a/x/lockup/keeper/lock.go b/x/lockup/keeper/lock.go index c313592a7ce..a4b59a19b18 100644 --- a/x/lockup/keeper/lock.go +++ b/x/lockup/keeper/lock.go @@ -10,8 +10,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/store" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils/sumtree" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // WithdrawAllMaturedLocks withdraws every lock thats in the process of unlocking, and has finished unlocking by @@ -613,8 +613,8 @@ func (k Keeper) SlashTokensFromLockByID(ctx sdk.Context, lockID uint64, coins sd return lock, nil } -func (k Keeper) accumulationStore(ctx sdk.Context, denom string) store.Tree { - return store.NewTree(prefix.NewStore(ctx.KVStore(k.storeKey), accumulationStorePrefix(denom)), 10) +func (k Keeper) accumulationStore(ctx sdk.Context, denom string) sumtree.Tree { + return sumtree.NewTree(prefix.NewStore(ctx.KVStore(k.storeKey), accumulationStorePrefix(denom)), 10) } // removeTokensFromLock is called by lockup slash function. diff --git a/x/lockup/keeper/lock_refs.go b/x/lockup/keeper/lock_refs.go index bda8ffae615..968e3130219 100644 --- a/x/lockup/keeper/lock_refs.go +++ b/x/lockup/keeper/lock_refs.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/lock_test.go b/x/lockup/keeper/lock_test.go index a2e76d68cce..6405538947a 100644 --- a/x/lockup/keeper/lock_test.go +++ b/x/lockup/keeper/lock_test.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/migration.go b/x/lockup/keeper/migration.go index 079b054b07a..e843f0cbbea 100644 --- a/x/lockup/keeper/migration.go +++ b/x/lockup/keeper/migration.go @@ -4,7 +4,7 @@ import ( "strconv" "time" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/migration_test.go b/x/lockup/keeper/migration_test.go index 2c92fdfbe6c..84f1696eee7 100644 --- a/x/lockup/keeper/migration_test.go +++ b/x/lockup/keeper/migration_test.go @@ -5,7 +5,7 @@ import ( "math/rand" "time" - "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" + "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/msg_server.go b/x/lockup/keeper/msg_server.go index 4e086caef20..b3f8845e9a7 100644 --- a/x/lockup/keeper/msg_server.go +++ b/x/lockup/keeper/msg_server.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/osmosis-labs/osmosis/v12/x/gamm/utils" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/utils" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -182,21 +182,28 @@ func (server msgServer) ExtendLockup(goCtx context.Context, msg *types.MsgExtend func (server msgServer) ForceUnlock(goCtx context.Context, msg *types.MsgForceUnlock) (*types.MsgForceUnlockResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + lock, err := server.keeper.GetLockByID(ctx, msg.ID) + if err != nil { + return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + + // check if message sender matches lock owner + if lock.Owner != msg.Owner { + return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "Sender (%s) does not match lock owner (%s)", msg.Owner, lock.Owner) + } + // check for chain parameter that the address is allowed to force unlock forceUnlockAllowedAddresses := server.keeper.GetParams(ctx).ForceUnlockAllowedAddresses found := false - for _, address := range forceUnlockAllowedAddresses { - if address == msg.Owner { + for _, addr := range forceUnlockAllowedAddresses { + // defense in depth, double checking the message owner and lock owner are both the same and is one of the allowed force unlock addresses + if addr == lock.Owner && addr == msg.Owner { found = true + break } } if !found { - return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "Sender (%s) not allowed to force unlock", msg.Owner) - } - - lock, err := server.keeper.GetLockByID(ctx, msg.ID) - if err != nil { - return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "Sender (%s) not allowed to force unlock", lock.Owner) } // check that given lock is not superfluid staked diff --git a/x/lockup/keeper/msg_server_test.go b/x/lockup/keeper/msg_server_test.go index d5d9d0aa525..8da6967b586 100644 --- a/x/lockup/keeper/msg_server_test.go +++ b/x/lockup/keeper/msg_server_test.go @@ -3,9 +3,9 @@ package keeper_test import ( "time" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/lockup/keeper/store.go b/x/lockup/keeper/store.go index 79f2c315fa1..31139a39aff 100644 --- a/x/lockup/keeper/store.go +++ b/x/lockup/keeper/store.go @@ -6,7 +6,7 @@ import ( "time" "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/lockup/keeper/synthetic_lock.go b/x/lockup/keeper/synthetic_lock.go index 1a993582d65..e353aef94a8 100644 --- a/x/lockup/keeper/synthetic_lock.go +++ b/x/lockup/keeper/synthetic_lock.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // A synthetic lock object is a lock obejct used for the superfluid module. diff --git a/x/lockup/keeper/synthetic_lock_test.go b/x/lockup/keeper/synthetic_lock_test.go index fa8a8768f1a..f011169b9f8 100644 --- a/x/lockup/keeper/synthetic_lock_test.go +++ b/x/lockup/keeper/synthetic_lock_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "time" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/utils.go b/x/lockup/keeper/utils.go index 7754555d564..071671a2510 100644 --- a/x/lockup/keeper/utils.go +++ b/x/lockup/keeper/utils.go @@ -4,7 +4,7 @@ import ( "bytes" "time" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/keeper/utils_test.go b/x/lockup/keeper/utils_test.go index d8cabf333c3..267eb3965ea 100644 --- a/x/lockup/keeper/utils_test.go +++ b/x/lockup/keeper/utils_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/lockup/module.go b/x/lockup/module.go index a8702257c13..c8bc6c7a5ce 100644 --- a/x/lockup/module.go +++ b/x/lockup/module.go @@ -28,13 +28,13 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - "github.com/osmosis-labs/osmosis/v12/x/lockup/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/lockup/client/rest" - "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/lockup/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/lockup/client/rest" + "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" - simulation "github.com/osmosis-labs/osmosis/v12/x/lockup/simulation" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + simulation "github.com/osmosis-labs/osmosis/v13/x/lockup/simulation" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) var ( diff --git a/x/lockup/simulation/operations.go b/x/lockup/simulation/operations.go index af6966fb170..d4909e5fea2 100644 --- a/x/lockup/simulation/operations.go +++ b/x/lockup/simulation/operations.go @@ -6,10 +6,10 @@ import ( legacysimulationtype "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/lockup/types/genesis.pb.go b/x/lockup/types/genesis.pb.go index 5d2a926350b..baef05db832 100644 --- a/x/lockup/types/genesis.pb.go +++ b/x/lockup/types/genesis.pb.go @@ -106,9 +106,9 @@ var fileDescriptor_648db7c6ebb608b0 = []byte{ 0x62, 0x64, 0xc1, 0x62, 0x27, 0x9f, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x1a, 0xac, 0x9b, - 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, 0x97, 0x19, 0x1a, 0xe9, 0x57, 0xc0, 0xc2, 0xa2, 0xa4, 0xb2, - 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x1a, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x0d, - 0x10, 0x26, 0x6e, 0x01, 0x00, 0x00, + 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, 0x97, 0x19, 0x1a, 0xeb, 0x57, 0xc0, 0xc2, 0xa2, 0xa4, 0xb2, + 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x1a, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x68, + 0x35, 0xa7, 0x6e, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/lockup/types/lock.pb.go b/x/lockup/types/lock.pb.go index 5ae7a54bad3..2df577f7666 100644 --- a/x/lockup/types/lock.pb.go +++ b/x/lockup/types/lock.pb.go @@ -317,45 +317,45 @@ func init() { func init() { proto.RegisterFile("osmosis/lockup/lock.proto", fileDescriptor_7e9d7527a237b489) } var fileDescriptor_7e9d7527a237b489 = []byte{ - // 596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x3f, 0x6f, 0xd3, 0x4e, - 0x18, 0xb6, 0x9d, 0xa4, 0xbf, 0xf6, 0xfa, 0x4b, 0x1a, 0x9d, 0x3a, 0xa4, 0x01, 0xec, 0xc8, 0x03, - 0x8a, 0x50, 0x6b, 0x93, 0xb0, 0x31, 0xba, 0x61, 0x88, 0xd4, 0x01, 0x4c, 0xc5, 0xc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, - 0xce, 0x04, 0x00, 0x00, + // 595 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xb6, 0xdd, 0xa4, 0xb4, 0x57, 0x92, 0x46, 0xa7, 0x0e, 0x69, 0x00, 0x3b, 0xf2, 0x80, 0x22, + 0xd4, 0xda, 0x24, 0xdd, 0x18, 0xdd, 0x30, 0x44, 0xea, 0x00, 0xa6, 0x62, 0x60, 0x89, 0xfc, 0xe3, + 0x70, 0x4e, 0xb1, 0x7d, 0xc6, 0x3f, 0x0a, 0xfe, 0x0f, 0x18, 0x3b, 0x82, 0xc4, 0xc6, 0xc6, 0x5f, + 0xd2, 0xb1, 0x23, 0x53, 0x8a, 0x12, 0xb1, 0x30, 0xf6, 0x2f, 0x40, 0x77, 0xe7, 0x4b, 0xd2, 0x22, + 0xa4, 0x0e, 0x30, 0x9d, 0xdf, 0x7d, 0xef, 0x7d, 0xef, 0xdd, 0xf7, 0x3e, 0x19, 0xec, 0x93, 0x2c, + 0x22, 0x19, 0xce, 0xcc, 0x90, 0x78, 0xd3, 0x22, 0x61, 0x87, 0x91, 0xa4, 0x24, 0x27, 0xb0, 0x59, + 0x41, 0x06, 0x87, 0x3a, 0x7b, 0x01, 0x09, 0x08, 0x83, 0x4c, 0xfa, 0xc5, 0xb3, 0x3a, 0x6a, 0x40, + 0x48, 0x10, 0x22, 0x93, 0x45, 0x6e, 0xf1, 0xd6, 0xf4, 0x8b, 0xd4, 0xc9, 0x31, 0x89, 0x2b, 0x5c, + 0xbb, 0x8d, 0xe7, 0x38, 0x42, 0x59, 0xee, 0x44, 0x89, 0x20, 0xf0, 0x58, 0x1f, 0xd3, 0x75, 0x32, + 0x64, 0x9e, 0xf5, 0x5d, 0x94, 0x3b, 0x7d, 0xd3, 0x23, 0xb8, 0x22, 0xd0, 0x7f, 0x2a, 0x00, 0xb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0x55, 0xfe, 0x31, 0x57, 0xe5, + 0xf3, 0x85, 0x2a, 0x5d, 0x2e, 0x54, 0xe9, 0xfb, 0x42, 0x95, 0xde, 0x0c, 0xd6, 0x8c, 0x5b, 0xb9, + 0xec, 0x30, 0x74, 0xdc, 0x4c, 0x04, 0xe6, 0x59, 0xff, 0xc8, 0xfc, 0x20, 0xfe, 0x57, 0xcc, 0xc8, + 0xee, 0x26, 0x7b, 0xd0, 0xd1, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x7f, 0xcc, 0xd3, 0xce, + 0x04, 0x00, 0x00, } func (m *PeriodLock) Marshal() (dAtA []byte, err error) { diff --git a/x/lockup/types/msgs_test.go b/x/lockup/types/msgs_test.go index 6d0ab74ed07..3357b50d935 100644 --- a/x/lockup/types/msgs_test.go +++ b/x/lockup/types/msgs_test.go @@ -8,12 +8,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/lockup/types" "github.com/tendermint/tendermint/crypto/ed25519" - appParams "github.com/osmosis-labs/osmosis/v12/app/params" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" ) func TestMsgLockTokens(t *testing.T) { diff --git a/x/lockup/types/params.pb.go b/x/lockup/types/params.pb.go index e07ef264fb0..ae640c83b90 100644 --- a/x/lockup/types/params.pb.go +++ b/x/lockup/types/params.pb.go @@ -86,9 +86,9 @@ var fileDescriptor_4595e58f5e17053c = []byte{ 0x49, 0x47, 0x98, 0x59, 0x4e, 0x3e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x94, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xf5, 0x82, 0x6e, - 0x4e, 0x62, 0x52, 0x31, 0x8c, 0xa3, 0x5f, 0x66, 0x68, 0xa4, 0x5f, 0x01, 0xf3, 0x72, 0x49, 0x65, - 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x33, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0xec, - 0x2b, 0x68, 0x11, 0x01, 0x00, 0x00, + 0x4e, 0x62, 0x52, 0x31, 0x8c, 0xa3, 0x5f, 0x66, 0x68, 0xac, 0x5f, 0x01, 0xf3, 0x72, 0x49, 0x65, + 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x33, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x89, + 0x0e, 0xe9, 0x11, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/lockup/types/query.pb.go b/x/lockup/types/query.pb.go index 1aca6de8f7a..4b6e4b9c749 100644 --- a/x/lockup/types/query.pb.go +++ b/x/lockup/types/query.pb.go @@ -1651,97 +1651,97 @@ var fileDescriptor_e906fda01cffd91a = []byte{ // 1492 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcd, 0x8f, 0x14, 0x45, 0x14, 0xdf, 0x02, 0x76, 0x95, 0x87, 0x7c, 0xa4, 0x58, 0x70, 0xb7, 0x17, 0x66, 0x96, 0x02, 0xd6, - 0x51, 0x77, 0xbb, 0xd9, 0x81, 0x00, 0x92, 0xe5, 0x6b, 0x58, 0x31, 0xab, 0xa3, 0xc2, 0x80, 0x12, - 0xbf, 0x32, 0xe9, 0x99, 0x69, 0x86, 0x0e, 0x33, 0x5d, 0xc3, 0x74, 0x0f, 0x3a, 0x12, 0x24, 0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0x99, 0x9a, 0x5a, 0x32, 0xdd, 0x80, 0xd7, 0x66, 0xe7, 0x95, 0x0f, 0x9c, 0xb0, 0xec, 0x33, + 0x55, 0x69, 0x84, 0x69, 0xbc, 0xf9, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x12, 0x71, 0xac, 0x36, 0x3f, 0x1c, 0x00, 0x00, } diff --git a/x/lockup/types/tx.pb.go b/x/lockup/types/tx.pb.go index d6fd29d617c..a49287c59b1 100644 --- a/x/lockup/types/tx.pb.go +++ b/x/lockup/types/tx.pb.go @@ -562,47 +562,47 @@ func init() { func init() { proto.RegisterFile("osmosis/lockup/tx.proto", fileDescriptor_bcdad5af0d24735f) } var fileDescriptor_bcdad5af0d24735f = []byte{ - // 630 bytes of a gzipped FileDescriptorProto + // 631 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0x8e, 0x13, 0x4a, 0xcb, 0xb4, 0xa4, 0xd4, 0x2a, 0x34, 0xb5, 0xc0, 0x0e, 0x16, 0xb4, 0x41, - 0x6a, 0xbd, 0x24, 0x85, 0x0b, 0x07, 0x24, 0x42, 0x40, 0xaa, 0xd4, 0x48, 0xc8, 0x6a, 0x25, 0xc4, + 0x10, 0x8e, 0x13, 0x4a, 0xcb, 0xb4, 0xa4, 0xd4, 0x2a, 0x34, 0xb5, 0xc0, 0x2e, 0x16, 0xb4, 0x41, + 0x6a, 0xbd, 0x24, 0x81, 0x0b, 0x07, 0x24, 0x42, 0x40, 0xaa, 0xd4, 0x48, 0xc8, 0x6a, 0x25, 0xc4, 0x01, 0xc9, 0x76, 0x96, 0xad, 0x15, 0xc7, 0x6b, 0x65, 0xed, 0x92, 0xdc, 0x79, 0x00, 0x8e, 0x3c, 0x03, 0x48, 0x5c, 0x78, 0x89, 0x1e, 0x2b, 0x71, 0xe1, 0x94, 0xa2, 0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xef, 0x23, 0x7b, 0x29, 0xdd, 0xbf, 0x14, 0x4e, 0xaa, 0x12, 0x58, 0x9b, 0xdc, 0xd1, + 0x7b, 0x53, 0x72, 0x27, 0xa2, 0xa4, 0xdd, 0x79, 0xa2, 0x92, 0x42, 0x6f, 0x21, 0x3f, 0xb6, 0x75, + 0x77, 0x67, 0xe6, 0x4b, 0x0f, 0x66, 0x86, 0x24, 0xfc, 0xaf, 0x61, 0x65, 0x64, 0xda, 0x95, 0x29, + 0xa9, 0xe9, 0x00, 0x69, 0x67, 0x46, 0x40, 0xc2, 0x7c, 0x04, 0xcb, 0xe9, 0xe1, 0x92, 0xa7, 0xe4, + 0xa5, 0x70, 0x69, 0xfb, 0x72, 0x3c, 0xa6, 0xad, 0x1e, 0x9c, 0xf6, 0x65, 0xe1, 0xac, 0x2f, 0x0b, + 0x3f, 0xfb, 0xb2, 0xf0, 0x71, 0x20, 0x67, 0xce, 0x06, 0x72, 0xe6, 0xc7, 0x40, 0xce, 0xbc, 0x29, + 0xa7, 0x86, 0x6a, 0xc8, 0xb5, 0xe7, 0x18, 0x26, 0x8b, 0x0f, 0xe8, 0xa4, 0x54, 0x41, 0x9d, 0xe4, + 0x13, 0x19, 0x0e, 0x99, 0x79, 0x95, 0xaf, 0x62, 0xe5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf5, + 0x2c, 0xd8, 0xaf, 0x41, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/mint/client/cli/cli_test.go b/x/mint/client/cli/cli_test.go index 7109014ed49..4c760c25afc 100644 --- a/x/mint/client/cli/cli_test.go +++ b/x/mint/client/cli/cli_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/mint/client/cli" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/mint/client/cli" "github.com/cosmos/cosmos-sdk/client/flags" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go index c5de1695c5c..7b917ee7177 100644 --- a/x/mint/client/cli/query.go +++ b/x/mint/client/cli/query.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/mint/client/cli/query_test.go b/x/mint/client/cli/query_test.go index 84ba9dc6605..67292edd54b 100644 --- a/x/mint/client/cli/query_test.go +++ b/x/mint/client/cli/query_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) type QueryTestSuite struct { diff --git a/x/mint/client/rest/query.go b/x/mint/client/rest/query.go index 934e674992e..24031247ce5 100644 --- a/x/mint/client/rest/query.go +++ b/x/mint/client/rest/query.go @@ -6,7 +6,7 @@ import ( "github.com/gorilla/mux" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/rest" diff --git a/x/mint/keeper/export_test.go b/x/mint/keeper/export_test.go index 8af33b19e01..b46bbfdfcce 100644 --- a/x/mint/keeper/export_test.go +++ b/x/mint/keeper/export_test.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) type ( diff --git a/x/mint/keeper/genesis.go b/x/mint/keeper/genesis.go index 711d438aa69..5739316f156 100644 --- a/x/mint/keeper/genesis.go +++ b/x/mint/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) const developerVestingAmount = 225_000_000_000_000 diff --git a/x/mint/keeper/genesis_test.go b/x/mint/keeper/genesis_test.go index bc51de7109b..2bdeb09d160 100644 --- a/x/mint/keeper/genesis_test.go +++ b/x/mint/keeper/genesis_test.go @@ -4,9 +4,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/mint/keeper" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/x/mint/keeper" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) var customGenesis = types.NewGenesisState( diff --git a/x/mint/keeper/grpc_query.go b/x/mint/keeper/grpc_query.go index 64a9830b4ca..6eac9825bea 100644 --- a/x/mint/keeper/grpc_query.go +++ b/x/mint/keeper/grpc_query.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) var _ types.QueryServer = Querier{} diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index 1fa54ac14af..feaebb562e1 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "context" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) func (suite *KeeperTestSuite) TestGRPCParams() { diff --git a/x/mint/keeper/hooks.go b/x/mint/keeper/hooks.go index 940a51850c9..68d98574501 100644 --- a/x/mint/keeper/hooks.go +++ b/x/mint/keeper/hooks.go @@ -3,8 +3,8 @@ package keeper import ( "fmt" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/mint/keeper/hooks_test.go b/x/mint/keeper/hooks_test.go index af8d62e72d5..0357831b24b 100644 --- a/x/mint/keeper/hooks_test.go +++ b/x/mint/keeper/hooks_test.go @@ -6,10 +6,10 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - osmoapp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/mint/keeper" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + osmoapp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/x/mint/keeper" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 20c70792128..721c731dd8d 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -5,9 +5,9 @@ import ( "github.com/tendermint/tendermint/libs/log" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" - poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index f076d439538..c1d5b124016 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -13,11 +13,11 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/mint/keeper" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" - poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/x/mint/keeper" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) type KeeperTestSuite struct { diff --git a/x/mint/module.go b/x/mint/module.go index 89535b19177..0c7cf8c7f6c 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -27,11 +27,11 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/osmosis-labs/osmosis/v12/x/mint/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/mint/client/rest" - "github.com/osmosis-labs/osmosis/v12/x/mint/keeper" - "github.com/osmosis-labs/osmosis/v12/x/mint/simulation" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/mint/client/rest" + "github.com/osmosis-labs/osmosis/v13/x/mint/keeper" + "github.com/osmosis-labs/osmosis/v13/x/mint/simulation" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) var ( diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go index 7b9c677daa5..a499ab91dbc 100644 --- a/x/mint/simulation/decoder.go +++ b/x/mint/simulation/decoder.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index 88322ca9861..a77d0ad08e2 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/require" - simapp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/mint/simulation" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + simapp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/mint/simulation" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go index aa15fd05812..96692f6731e 100644 --- a/x/mint/simulation/genesis.go +++ b/x/mint/simulation/genesis.go @@ -5,7 +5,7 @@ package simulation import ( "math/rand" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index f5e598a4b66..7b11586053b 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/x/mint/simulation" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/simulation" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go index 6bb42b3ca04..e1257f9b07f 100644 --- a/x/mint/types/expected_keepers.go +++ b/x/mint/types/expected_keepers.go @@ -1,7 +1,7 @@ package types // noalias import ( - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/mint/types/genesis.pb.go b/x/mint/types/genesis.pb.go index 715a38ff660..8f54c75e982 100644 --- a/x/mint/types/genesis.pb.go +++ b/x/mint/types/genesis.pb.go @@ -113,9 +113,9 @@ var fileDescriptor_12e6a5511ad3feeb = []byte{ 0xa2, 0x70, 0x99, 0x60, 0x88, 0x84, 0x2b, 0x48, 0xdc, 0xc9, 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, - 0xf5, 0xa1, 0x6e, 0xd5, 0xcd, 0x49, 0x4c, 0x2a, 0x86, 0x71, 0xf4, 0xcb, 0x0c, 0x8d, 0xf4, 0x2b, + 0xf5, 0xa1, 0x6e, 0xd5, 0xcd, 0x49, 0x4c, 0x2a, 0x86, 0x71, 0xf4, 0xcb, 0x0c, 0x8d, 0xf5, 0x2b, 0x20, 0xa1, 0x57, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x37, 0x63, 0x40, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xcc, 0x2a, 0x33, 0xf7, 0xaa, 0x01, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x0c, 0x4e, 0x1b, 0xe0, 0xaa, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index 5f01ff7d388..6feeafdaa00 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -323,8 +323,8 @@ var fileDescriptor_ccb38f8335e0f45b = []byte{ 0xfa, 0x83, 0xe4, 0xa9, 0xc6, 0x38, 0x5b, 0xb9, 0xfb, 0xcd, 0x2d, 0xb5, 0x2e, 0xee, 0x1f, 0xeb, 0xd6, 0xc3, 0x63, 0xdd, 0xfa, 0xfb, 0xb1, 0x6e, 0xfd, 0xfa, 0x54, 0x2f, 0x3d, 0x3c, 0xd5, 0x4b, 0x7f, 0x3e, 0xd5, 0x4b, 0x57, 0x9f, 0x3f, 0xeb, 0x0a, 0x53, 0xac, 0xa3, 0x7e, 0xd8, 0xe3, 0xf9, - 0xc1, 0x1f, 0x1e, 0x9f, 0xf8, 0x3f, 0xe9, 0x2f, 0xaa, 0xea, 0x91, 0x5e, 0x45, 0x7d, 0xc3, 0x4e, - 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x55, 0x53, 0x8c, 0x6e, 0x07, 0x00, 0x00, + 0xc1, 0x1f, 0x1e, 0x9f, 0xfa, 0x3f, 0xe9, 0x2f, 0xaa, 0xea, 0x91, 0x5e, 0x45, 0x7d, 0xc3, 0x4e, + 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xee, 0x31, 0x7b, 0x9b, 0x6e, 0x07, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index c1f7d18a499..b0ef3a8c5d1 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -4,7 +4,7 @@ import ( "math/rand" "testing" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" diff --git a/x/mint/types/params.go b/x/mint/types/params.go index c3245ce1bc1..b9a47ea129c 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -7,7 +7,7 @@ import ( yaml "gopkg.in/yaml.v2" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" diff --git a/x/mint/types/params_test.go b/x/mint/types/params_test.go index 32dd7173205..0df76eb9a65 100644 --- a/x/mint/types/params_test.go +++ b/x/mint/types/params_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) // TestGetInflationProportion sanity checks that inflation diff --git a/x/mint/types/query.pb.go b/x/mint/types/query.pb.go index 83fa3d14a98..828cfe0b693 100644 --- a/x/mint/types/query.pb.go +++ b/x/mint/types/query.pb.go @@ -202,31 +202,31 @@ func init() { proto.RegisterFile("osmosis/mint/v1beta1/query.proto", fileDescrip var fileDescriptor_cd2f42111e753fbb = []byte{ // 394 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xb1, 0x4e, 0xeb, 0x30, - 0x14, 0x86, 0x93, 0xea, 0xde, 0x0e, 0xbe, 0x57, 0xea, 0x95, 0x6f, 0x07, 0x14, 0x42, 0x5a, 0x45, - 0xa8, 0x2a, 0x43, 0x6d, 0x12, 0x36, 0xc6, 0x0a, 0x16, 0xa6, 0xb6, 0x1b, 0x2c, 0x28, 0x09, 0x56, - 0x1a, 0xd1, 0xc4, 0x69, 0xec, 0x56, 0x74, 0x85, 0x17, 0x40, 0xe2, 0x25, 0x78, 0x04, 0x1e, 0xa1, - 0x63, 0x25, 0x16, 0xc4, 0x50, 0xa1, 0x96, 0x07, 0x41, 0x71, 0x4c, 0x45, 0x8b, 0x85, 0x60, 0x4a, - 0xe4, 0xf3, 0x9f, 0xff, 0xff, 0x7c, 0x8e, 0x41, 0x9d, 0xb2, 0x98, 0xb2, 0x88, 0xe1, 0x38, 0x4a, - 0x38, 0x1e, 0x3b, 0x3e, 0xe1, 0x9e, 0x83, 0x87, 0x23, 0x92, 0x4d, 0x50, 0x9a, 0x51, 0x4e, 0x61, - 0x55, 0x2a, 0x50, 0xae, 0x40, 0x52, 0x61, 0x54, 0x43, 0x1a, 0x52, 0x21, 0xc0, 0xf9, 0x5f, 0xa1, - 0x35, 0xcc, 0x90, 0xd2, 0x70, 0x40, 0xb0, 0x97, 0x46, 0xd8, 0x4b, 0x12, 0xca, 0x3d, 0x1e, 0xd1, - 0x84, 0xc9, 0x6a, 0x4d, 0x99, 0x25, 0x6c, 0x85, 0xc0, 0xae, 0x02, 0xd8, 0xcd, 0x93, 0x3b, 0x5e, - 0xe6, 0xc5, 0xac, 0x47, 0x86, 0x23, 0xc2, 0xb8, 0xdd, 0x05, 0xff, 0xd7, 0x4e, 0x59, 0x4a, 0x13, - 0x46, 0xe0, 0x21, 0x28, 0xa7, 0xe2, 0x64, 0x4b, 0xaf, 0xeb, 0xcd, 0x3f, 0xae, 0x89, 0x54, 0xa0, - 0xa8, 0xe8, 0x6a, 0xff, 0x9a, 0xce, 0x6b, 0x5a, 0x4f, 0x76, 0xd8, 0x3b, 0x60, 0x5b, 0x58, 0x1e, - 0xa7, 0x34, 0xe8, 0x77, 0x32, 0x3a, 0x8e, 0x58, 0xce, 0xf9, 0x9e, 0x38, 0x01, 0xa6, 0xba, 0x2c, - 0xa3, 0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, 0x40, + 0x14, 0x86, 0x5b, 0x72, 0x2f, 0x8b, 0xb9, 0x37, 0xc1, 0x8c, 0x2c, 0x4c, 0xad, 0x85, 0x34, 0x86, + 0xe0, 0x82, 0x19, 0x0b, 0x3b, 0x97, 0x44, 0x37, 0xae, 0x80, 0x9d, 0x6e, 0x4c, 0x5b, 0x27, 0xa5, + 0x91, 0x76, 0x4a, 0x67, 0x20, 0xb2, 0xd5, 0x17, 0x30, 0xf1, 0x25, 0x7c, 0x04, 0x1f, 0x81, 0x25, + 0x89, 0x1b, 0xe3, 0x82, 0x18, 0xf0, 0x41, 0x4c, 0xa7, 0x23, 0x11, 0x9c, 0x18, 0x5d, 0xb5, 0x99, + 0xf3, 0x9f, 0xff, 0xff, 0xe6, 0x9c, 0x01, 0x55, 0xca, 0x22, 0xca, 0x42, 0x86, 0xa3, 0x30, 0xe6, + 0x78, 0xec, 0x78, 0x84, 0xbb, 0x0e, 0x1e, 0x8e, 0x48, 0x3a, 0x41, 0x49, 0x4a, 0x39, 0x85, 0x65, + 0xa9, 0x40, 0x99, 0x02, 0x49, 0x85, 0x51, 0x0e, 0x68, 0x40, 0x85, 0x00, 0x67, 0x7f, 0xb9, 0xd6, + 0x30, 0x03, 0x4a, 0x83, 0x01, 0xc1, 0x6e, 0x12, 0x62, 0x37, 0x8e, 0x29, 0x77, 0x79, 0x48, 0x63, + 0x26, 0xab, 0x15, 0x65, 0x96, 0xb0, 0x15, 0x02, 0xbb, 0x0c, 0x60, 0x37, 0x4b, 0xee, 0xb8, 0xa9, + 0x1b, 0xb1, 0x1e, 0x19, 0x8e, 0x08, 0xe3, 0x76, 0x17, 0x6c, 0xaf, 0x9d, 0xb2, 0x84, 0xc6, 0x8c, + 0xc0, 0x23, 0x50, 0x4c, 0xc4, 0xc9, 0x8e, 0x5e, 0xd5, 0xeb, 0xff, 0x9a, 0x26, 0x52, 0x81, 0xa2, + 0xbc, 0xab, 0xfd, 0x67, 0x3a, 0xaf, 0x68, 0x3d, 0x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00, + 0xff, 0xff, 0xc0, 0x59, 0x07, 0xeb, 0x1f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/pool-incentives/client/cli/cli_test.go b/x/pool-incentives/client/cli/cli_test.go index f853245248a..8695b7b91bf 100644 --- a/x/pool-incentives/client/cli/cli_test.go +++ b/x/pool-incentives/client/cli/cli_test.go @@ -4,9 +4,9 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" diff --git a/x/pool-incentives/client/cli/query.go b/x/pool-incentives/client/cli/query.go index b4dda50b225..6d19c6f9078 100644 --- a/x/pool-incentives/client/cli/query.go +++ b/x/pool-incentives/client/cli/query.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/pool-incentives/client/cli/query_test.go b/x/pool-incentives/client/cli/query_test.go index 565e3a7d31d..10d18a8d0a3 100644 --- a/x/pool-incentives/client/cli/query_test.go +++ b/x/pool-incentives/client/cli/query_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) type QueryTestSuite struct { diff --git a/x/pool-incentives/client/cli/tx.go b/x/pool-incentives/client/cli/tx.go index d1052829362..306085a7f63 100644 --- a/x/pool-incentives/client/cli/tx.go +++ b/x/pool-incentives/client/cli/tx.go @@ -12,8 +12,8 @@ import ( govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) func NewCmdSubmitUpdatePoolIncentivesProposal() *cobra.Command { diff --git a/x/pool-incentives/client/proposal_handler.go b/x/pool-incentives/client/proposal_handler.go index 676239dfbc7..c07dd32bb2f 100644 --- a/x/pool-incentives/client/proposal_handler.go +++ b/x/pool-incentives/client/proposal_handler.go @@ -1,8 +1,8 @@ package client import ( - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/client/rest" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/client/rest" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" ) diff --git a/x/pool-incentives/client/rest/tx.go b/x/pool-incentives/client/rest/tx.go index 5130ddbd4bc..8d8ba3ef296 100644 --- a/x/pool-incentives/client/rest/tx.go +++ b/x/pool-incentives/client/rest/tx.go @@ -10,7 +10,7 @@ import ( govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) type UpdatePoolIncentivesRequest struct { diff --git a/x/pool-incentives/handler.go b/x/pool-incentives/handler.go index 36a25549f2c..573f8551d1e 100644 --- a/x/pool-incentives/handler.go +++ b/x/pool-incentives/handler.go @@ -5,8 +5,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/keeper" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/keeper" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) // NewPoolIncentivesProposalHandler is a handler for governance proposals on new pool incentives. diff --git a/x/pool-incentives/keeper/distr.go b/x/pool-incentives/keeper/distr.go index 58e6cc01d6c..b346330c03e 100644 --- a/x/pool-incentives/keeper/distr.go +++ b/x/pool-incentives/keeper/distr.go @@ -4,8 +4,8 @@ import ( "fmt" "sort" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/pool-incentives/keeper/distr_test.go b/x/pool-incentives/keeper/distr_test.go index dff6cf49634..078aa18b6f0 100644 --- a/x/pool-incentives/keeper/distr_test.go +++ b/x/pool-incentives/keeper/distr_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/pool-incentives/keeper/genesis.go b/x/pool-incentives/keeper/genesis.go index 28a060f1657..27c723267d5 100644 --- a/x/pool-incentives/keeper/genesis.go +++ b/x/pool-incentives/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { diff --git a/x/pool-incentives/keeper/genesis_test.go b/x/pool-incentives/keeper/genesis_test.go index 37ba26504a5..1f9f628118d 100644 --- a/x/pool-incentives/keeper/genesis_test.go +++ b/x/pool-incentives/keeper/genesis_test.go @@ -9,11 +9,11 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - pool_incentives "github.com/osmosis-labs/osmosis/v12/x/pool-incentives" + pool_incentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives" - simapp "github.com/osmosis-labs/osmosis/v12/app" + simapp "github.com/osmosis-labs/osmosis/v13/app" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) var ( diff --git a/x/pool-incentives/keeper/gov.go b/x/pool-incentives/keeper/gov.go index 44b2a819341..29ca2121fbc 100644 --- a/x/pool-incentives/keeper/gov.go +++ b/x/pool-incentives/keeper/gov.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) func (k Keeper) HandleReplacePoolIncentivesProposal(ctx sdk.Context, p *types.ReplacePoolIncentivesProposal) error { diff --git a/x/pool-incentives/keeper/grpc_query.go b/x/pool-incentives/keeper/grpc_query.go index 7d92adafaaf..43da90861a6 100644 --- a/x/pool-incentives/keeper/grpc_query.go +++ b/x/pool-incentives/keeper/grpc_query.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - incentivetypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + incentivetypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) var _ types.QueryServer = Querier{} diff --git a/x/pool-incentives/keeper/grpc_query_test.go b/x/pool-incentives/keeper/grpc_query_test.go index d66a5702c72..15b8e23b509 100644 --- a/x/pool-incentives/keeper/grpc_query_test.go +++ b/x/pool-incentives/keeper/grpc_query_test.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) var ( diff --git a/x/pool-incentives/keeper/hooks.go b/x/pool-incentives/keeper/hooks.go index dda6354dd81..e2e0e4d695d 100644 --- a/x/pool-incentives/keeper/hooks.go +++ b/x/pool-incentives/keeper/hooks.go @@ -3,8 +3,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" ) type Hooks struct { diff --git a/x/pool-incentives/keeper/keeper.go b/x/pool-incentives/keeper/keeper.go index 8bd52174aff..b6f148b35bd 100644 --- a/x/pool-incentives/keeper/keeper.go +++ b/x/pool-incentives/keeper/keeper.go @@ -6,11 +6,11 @@ import ( "github.com/tendermint/tendermint/libs/log" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -136,3 +136,25 @@ func (k Keeper) GetAllGauges(ctx sdk.Context) []incentivestypes.Gauge { gauges := k.incentivesKeeper.GetGauges(ctx) return gauges } + +func (k Keeper) IsPoolIncentivized(ctx sdk.Context, poolId uint64) bool { + lockableDurations := k.GetLockableDurations(ctx) + distrInfo := k.GetDistrInfo(ctx) + + candidateGaugeIds := []uint64{} + for _, lockableDuration := range lockableDurations { + gaugeId, err := k.GetPoolGaugeId(ctx, poolId, lockableDuration) + if err == nil { + candidateGaugeIds = append(candidateGaugeIds, gaugeId) + } + } + + for _, record := range distrInfo.Records { + for _, gaugeId := range candidateGaugeIds { + if record.GaugeId == gaugeId { + return true + } + } + } + return false +} diff --git a/x/pool-incentives/keeper/keeper_test.go b/x/pool-incentives/keeper/keeper_test.go index d64ef2d8623..f33eeee2959 100644 --- a/x/pool-incentives/keeper/keeper_test.go +++ b/x/pool-incentives/keeper/keeper_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) type KeeperTestSuite struct { diff --git a/x/pool-incentives/keeper/params.go b/x/pool-incentives/keeper/params.go index 2a1b9e4bceb..7ad1c16e674 100644 --- a/x/pool-incentives/keeper/params.go +++ b/x/pool-incentives/keeper/params.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { diff --git a/x/pool-incentives/module.go b/x/pool-incentives/module.go index 8c5b4e3015c..645b9bdc441 100644 --- a/x/pool-incentives/module.go +++ b/x/pool-incentives/module.go @@ -29,9 +29,9 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gov/simulation" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/keeper" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/keeper" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) var ( diff --git a/x/pool-incentives/types/expected_keepers.go b/x/pool-incentives/types/expected_keepers.go index 569bced73af..9300467d1eb 100644 --- a/x/pool-incentives/types/expected_keepers.go +++ b/x/pool-incentives/types/expected_keepers.go @@ -7,8 +7,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // AccountKeeper interface contains functions for getting accounts and the module address diff --git a/x/pool-incentives/types/genesis.pb.go b/x/pool-incentives/types/genesis.pb.go index 45ff5dfaa00..f98e7240ec6 100644 --- a/x/pool-incentives/types/genesis.pb.go +++ b/x/pool-incentives/types/genesis.pb.go @@ -108,30 +108,30 @@ func init() { var fileDescriptor_cc1f078212600632 = []byte{ // 392 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcd, 0xaa, 0xd3, 0x40, - 0x14, 0xc7, 0x13, 0x7b, 0xb9, 0x60, 0xee, 0x45, 0xb8, 0x41, 0x21, 0x2d, 0x38, 0x29, 0x01, 0xa5, - 0x82, 0x9d, 0xb1, 0x75, 0xa7, 0xbb, 0x50, 0x28, 0xee, 0x24, 0xea, 0xc6, 0x4d, 0x98, 0xa4, 0xd3, - 0x71, 0x30, 0xc9, 0x89, 0x99, 0x49, 0xb1, 0x6f, 0xe1, 0xd2, 0x8d, 0xef, 0xd3, 0x65, 0x97, 0xae, - 0xa2, 0xb4, 0x6f, 0xd0, 0x27, 0x90, 0x4c, 0x12, 0x5a, 0x29, 0xdc, 0xee, 0x32, 0x9c, 0xdf, 0xff, - 0xe3, 0x1c, 0x62, 0x8d, 0x41, 0xa6, 0x20, 0x85, 0x24, 0x39, 0x40, 0x32, 0x16, 0x59, 0xcc, 0x32, - 0x25, 0x56, 0x4c, 0x92, 0xd5, 0x24, 0x62, 0x8a, 0x4e, 0x08, 0x67, 0x19, 0x93, 0x42, 0xe2, 0xbc, - 0x00, 0x05, 0x36, 0x6a, 0x71, 0x5c, 0xe3, 0x47, 0x1a, 0xb7, 0xf4, 0xe0, 0x31, 0x07, 0x0e, 0x1a, - 0x25, 0xf5, 0x57, 0xa3, 0x1a, 0x20, 0x0e, 0xc0, 0x13, 0x46, 0xf4, 0x2b, 0x2a, 0x97, 0x64, 0x51, - 0x16, 0x54, 0x09, 0xc8, 0xda, 0xf9, 0xab, 0x4b, 0x25, 0x4e, 0x92, 0xb4, 0xc2, 0xfb, 0xd5, 0xb3, - 0x6e, 0xe7, 0x4d, 0xb3, 0x0f, 0x8a, 0x2a, 0x66, 0xcf, 0xac, 0xeb, 0x9c, 0x16, 0x34, 0x95, 0x8e, - 0x39, 0x34, 0x47, 0x37, 0xd3, 0xe7, 0xf8, 0xfe, 0xa6, 0xf8, 0xbd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, - 0x7f, 0x82, 0x5a, 0xe7, 0x4c, 0x46, 0xd7, 0xfa, 0xf6, 0xaf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, - 0x76, 0x99, 0xc9, 0xcb, 0xb6, 0x02, 0x00, 0x00, + 0x14, 0xc7, 0x13, 0x7b, 0xb9, 0x60, 0xee, 0x45, 0xb8, 0x41, 0x21, 0xbd, 0xe0, 0xa4, 0x04, 0x94, + 0x0a, 0x76, 0xc6, 0xb6, 0x3b, 0xdd, 0x85, 0x42, 0x71, 0x27, 0x51, 0x37, 0x6e, 0xc2, 0x24, 0x9d, + 0x8e, 0x83, 0x49, 0x4e, 0xcc, 0x4c, 0x8a, 0x7d, 0x0b, 0x97, 0x6e, 0x7c, 0x9f, 0x2e, 0xbb, 0x74, + 0x15, 0xa5, 0x7d, 0x83, 0x3e, 0x81, 0x64, 0x92, 0xd0, 0x4a, 0xc1, 0xee, 0x32, 0x9c, 0xdf, 0xff, + 0xe3, 0x1c, 0x62, 0x8d, 0x40, 0xa6, 0x20, 0x85, 0x24, 0x39, 0x40, 0x32, 0x12, 0x59, 0xcc, 0x32, + 0x25, 0x56, 0x4c, 0x92, 0xd5, 0x38, 0x62, 0x8a, 0x8e, 0x09, 0x67, 0x19, 0x93, 0x42, 0xe2, 0xbc, + 0x00, 0x05, 0x36, 0x6a, 0x71, 0x5c, 0xe3, 0x47, 0x1a, 0xb7, 0xf4, 0xfd, 0x63, 0x0e, 0x1c, 0x34, + 0x4a, 0xea, 0xaf, 0x46, 0x75, 0x8f, 0x38, 0x00, 0x4f, 0x18, 0xd1, 0xaf, 0xa8, 0x5c, 0x92, 0x45, + 0x59, 0x50, 0x25, 0x20, 0x6b, 0xe7, 0xaf, 0x2e, 0x95, 0x38, 0x49, 0xd2, 0x0a, 0xef, 0x67, 0xcf, + 0xba, 0x9d, 0x37, 0xcd, 0xde, 0x2b, 0xaa, 0x98, 0x3d, 0xb3, 0xae, 0x73, 0x5a, 0xd0, 0x54, 0x3a, +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, 0x47, 0x09, 0x8d, 0x64, 0xf7, 0x20, 0xab, 0xf1, 0x94, 0x7c, 0x3b, + 0xfb, 0x13, 0xd4, 0x3a, 0x67, 0x32, 0xba, 0xd6, 0xb7, 0x9f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, + 0x85, 0x09, 0x3b, 0xfd, 0xb6, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/pool-incentives/types/genesis_test.go b/x/pool-incentives/types/genesis_test.go index 7aeeda3a14f..3dcf3983457 100644 --- a/x/pool-incentives/types/genesis_test.go +++ b/x/pool-incentives/types/genesis_test.go @@ -5,7 +5,7 @@ import ( "time" proto "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/pool-incentives/types/gov.pb.go b/x/pool-incentives/types/gov.pb.go index 6e30a7336a6..c41b759af33 100644 --- a/x/pool-incentives/types/gov.pb.go +++ b/x/pool-incentives/types/gov.pb.go @@ -141,8 +141,8 @@ var fileDescriptor_96caede426ba9516 = []byte{ 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x9d, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xb5, 0x4d, 0x37, 0x27, 0x31, 0xa9, 0x18, 0xc6, 0xd1, 0x2f, - 0x33, 0x34, 0xd2, 0xaf, 0xc0, 0x88, 0xd2, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x34, - 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x26, 0x53, 0x81, 0x5b, 0x02, 0x00, 0x00, + 0x33, 0x34, 0xd6, 0xaf, 0xc0, 0x88, 0xd2, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x34, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x79, 0xb6, 0xa1, 0xb7, 0x5b, 0x02, 0x00, 0x00, } func (this *ReplacePoolIncentivesProposal) Equal(that interface{}) bool { diff --git a/x/pool-incentives/types/gov_test.go b/x/pool-incentives/types/gov_test.go index f12ce21a672..c9296e4a666 100644 --- a/x/pool-incentives/types/gov_test.go +++ b/x/pool-incentives/types/gov_test.go @@ -4,7 +4,7 @@ import ( "testing" proto "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/pool-incentives/types/incentives.pb.go b/x/pool-incentives/types/incentives.pb.go index cae9214e3e9..0658880b6d7 100644 --- a/x/pool-incentives/types/incentives.pb.go +++ b/x/pool-incentives/types/incentives.pb.go @@ -330,7 +330,7 @@ var fileDescriptor_a8153bad03e553d1 = []byte{ // 565 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xbf, 0x6f, 0xd3, 0x40, 0x14, 0xc7, 0x73, 0x6d, 0x94, 0xb4, 0xe7, 0xf0, 0xcb, 0x05, 0x91, 0x16, 0xc9, 0x8e, 0x4e, 0x02, - 0x55, 0x8a, 0x62, 0x93, 0xb2, 0x85, 0x2d, 0x0a, 0xa0, 0x00, 0x43, 0x65, 0x51, 0x21, 0xb1, 0x44, + 0x55, 0x8a, 0x62, 0x13, 0xba, 0x85, 0x2d, 0x0a, 0xa0, 0x00, 0x43, 0x65, 0x51, 0x21, 0xb1, 0x44, 0x76, 0x7c, 0x75, 0xac, 0xda, 0x7e, 0x91, 0xef, 0x12, 0xe8, 0x7f, 0x80, 0xc4, 0xc2, 0xd8, 0xb1, 0xff, 0x07, 0x1b, 0x53, 0xc7, 0x8e, 0x88, 0xc1, 0xa0, 0x64, 0x61, 0xce, 0x5f, 0x80, 0x7c, 0x3e, 0x93, 0x13, 0x95, 0x2a, 0x98, 0x72, 0xcf, 0xef, 0xbe, 0xef, 0x7d, 0xbe, 0xef, 0x9d, 0x82, 0x1f, @@ -343,27 +343,27 @@ var fileDescriptor_a8153bad03e553d1 = []byte{ 0x9c, 0xba, 0x71, 0xd4, 0x23, 0x6a, 0x96, 0x38, 0x5a, 0x11, 0x0e, 0xf2, 0xa8, 0x57, 0x3d, 0x3b, 0x37, 0x2b, 0xe4, 0x23, 0xc2, 0xf7, 0x5e, 0xc3, 0xf8, 0xc4, 0xf5, 0x22, 0x3a, 0x90, 0x6d, 0xd8, 0x30, 0x39, 0x06, 0x1d, 0xb0, 0x1e, 0xc9, 0xc4, 0xa8, 0x04, 0x60, 0x4d, 0xd4, 0xda, 0xdc, 0xd7, - 0x0e, 0x76, 0xad, 0x02, 0xd1, 0x2a, 0x11, 0xad, 0x52, 0xdb, 0x7f, 0x78, 0x91, 0x99, 0x95, 0x55, - 0x66, 0xee, 0x16, 0x00, 0x57, 0x4b, 0x90, 0xb3, 0x1f, 0x26, 0x72, 0xee, 0x44, 0x7f, 0x37, 0x25, - 0x5f, 0x11, 0xde, 0x1e, 0x84, 0x8c, 0xa7, 0xa2, 0xfd, 0x04, 0x37, 0x38, 0x70, 0x37, 0x1a, 0xbd, - 0xa7, 0x61, 0x30, 0xe1, 0xd2, 0xda, 0xb3, 0xbc, 0xfa, 0xf7, 0xcc, 0x7c, 0x14, 0x84, 0x7c, 0x32, - 0xf3, 0xac, 0x31, 0xc4, 0xf6, 0x58, 0x0c, 0x59, 0xfe, 0x74, 0x98, 0x7f, 0x62, 0xf3, 0xd3, 0x29, - 0x65, 0xd6,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0xdb, 0xf0, 0x6a, 0xc2, 0xf7, 0xc1, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x38, 0xb1, + 0x8d, 0x36, 0x04, 0x00, 0x00, } func (this *DistrRecord) Equal(that interface{}) bool { diff --git a/x/pool-incentives/types/incentives_test.go b/x/pool-incentives/types/incentives_test.go index 2882cea707f..68b2f07a063 100644 --- a/x/pool-incentives/types/incentives_test.go +++ b/x/pool-incentives/types/incentives_test.go @@ -5,7 +5,7 @@ import ( "time" proto "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/pool-incentives/types/query.pb.go b/x/pool-incentives/types/query.pb.go index 0f4dd969b70..24013d4fed5 100644 --- a/x/pool-incentives/types/query.pb.go +++ b/x/pool-incentives/types/query.pb.go @@ -11,7 +11,7 @@ import ( proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - types1 "github.com/osmosis-labs/osmosis/v12/x/incentives/types" + types1 "github.com/osmosis-labs/osmosis/v13/x/incentives/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -724,9 +724,9 @@ var fileDescriptor_302873ecccbc7636 = []byte{ 0x81, 0x80, 0xc6, 0xba, 0xd2, 0xb8, 0x47, 0xee, 0x15, 0x6a, 0x64, 0x80, 0x34, 0xf4, 0x8f, 0x8b, 0x7a, 0xf2, 0xb2, 0xfe, 0xc9, 0xb3, 0x33, 0x13, 0x3d, 0x3f, 0x33, 0xd1, 0xdf, 0x67, 0x26, 0xfa, 0xf6, 0xdc, 0x9c, 0x7b, 0x7e, 0x6e, 0xce, 0xfd, 0x71, 0x6e, 0xce, 0x7d, 0x76, 0xdf, 0xe7, 0xd1, - 0x71, 0xaf, 0x69, 0xb5, 0x44, 0x5b, 0xe3, 0xef, 0x04, 0x6e, 0x53, 0xa6, 0xcd, 0x4e, 0x76, 0xab, + 0x71, 0xaf, 0x69, 0xb5, 0x44, 0x5b, 0xe3, 0xef, 0x04, 0x6e, 0x53, 0xa6, 0xcd, 0x4e, 0x76, 0x6b, 0xf6, 0xa3, 0x5c, 0xcb, 0xe8, 0xb4, 0xc3, 0x64, 0x73, 0x51, 0xfd, 0x4a, 0xd5, 0xfe, 0x0b, 0x00, - 0x00, 0xff, 0xff, 0x36, 0xb5, 0xdb, 0x7d, 0xb4, 0x0b, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xc5, 0x25, 0x29, 0x4b, 0xb4, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/pool-incentives/types/query_test.go b/x/pool-incentives/types/query_test.go index 6bafa087ff8..73dfe7bdb3d 100644 --- a/x/pool-incentives/types/query_test.go +++ b/x/pool-incentives/types/query_test.go @@ -5,7 +5,7 @@ import ( "time" proto "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" "github.com/stretchr/testify/require" ) diff --git a/x/pool-incentives/types/record_test.go b/x/pool-incentives/types/record_test.go index 6ff5d3c4dd5..4ddbbf72a94 100644 --- a/x/pool-incentives/types/record_test.go +++ b/x/pool-incentives/types/record_test.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" ) // TestDistrRecord is a test on the weights of distribution gauges. diff --git a/x/superfluid/abci.go b/x/superfluid/abci.go index c166df6c9c9..90ac94ac012 100644 --- a/x/superfluid/abci.go +++ b/x/superfluid/abci.go @@ -1,8 +1,8 @@ package superfluid import ( - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/client/cli/flags.go b/x/superfluid/client/cli/flags.go index 92d4d3c631c..04a8448ec86 100644 --- a/x/superfluid/client/cli/flags.go +++ b/x/superfluid/client/cli/flags.go @@ -3,4 +3,6 @@ package cli // Proposal flags. const ( FlagSuperfluidAssets = "superfluid-assets" + FlagPoolIds = "pool-ids" + FlagOverwrite = "is-overwrite" ) diff --git a/x/superfluid/client/cli/query.go b/x/superfluid/client/cli/query.go index 2ce05285b59..e4a0b69e338 100644 --- a/x/superfluid/client/cli/query.go +++ b/x/superfluid/client/cli/query.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -36,6 +36,7 @@ func GetQueryCmd() *cobra.Command { GetCmdSuperfluidUndelegationsByDelegator(), GetCmdTotalSuperfluidDelegations(), GetCmdTotalDelegationByDelegator(), + GetCmdUnpoolWhitelist(), ) return cmd @@ -378,3 +379,28 @@ func GetCmdTotalDelegationByDelegator() *cobra.Command { return cmd } + +func GetCmdUnpoolWhitelist() *cobra.Command { + cmd := &cobra.Command{ + Use: "unpool-whitelist", + Short: "Query whitelisted pool ids to unpool.", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.UnpoolWhitelist(cmd.Context(), &types.QueryUnpoolWhitelistRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/superfluid/client/cli/query_test.go b/x/superfluid/client/cli/query_test.go index a6f760cc521..98cc9cc82c7 100644 --- a/x/superfluid/client/cli/query_test.go +++ b/x/superfluid/client/cli/query_test.go @@ -11,8 +11,8 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) type QueryTestSuite struct { diff --git a/x/superfluid/client/cli/tx.go b/x/superfluid/client/cli/tx.go index f275df11425..991d66857e4 100644 --- a/x/superfluid/client/cli/tx.go +++ b/x/superfluid/client/cli/tx.go @@ -5,8 +5,11 @@ import ( "strconv" "strings" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" "github.com/spf13/cobra" + flag "github.com/spf13/pflag" + + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -402,3 +405,92 @@ func NewCmdUnPoolWhitelistedPool() *cobra.Command { flags.AddTxFlagsToCmd(cmd) return cmd } + +// NewCmdUpdateUnpoolWhitelistProposal defines the command to create a new update unpool whitelist proposal command. +func NewCmdUpdateUnpoolWhitelistProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-unpool-whitelist [flags]", + Args: cobra.ExactArgs(0), + Short: "Update unpool whitelist proposal", + Long: "This proposal will update the unpool whitelist if passed. " + + "Every pool id must be valid. If the pool id is invalid, the proposal will not be submitted. " + + "If the flag to overwrite is set, the whitelist is completely overridden. Otherwise, it is appended to the existing whitelist, having all duplicates removed.", + Example: "osmosisd tx gov submit-proposal update-unpool-whitelist --pool-ids \"1, 2, 3\" --title \"Title\" --description \"Description\"", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + content, err := parseUpdateUnpoolWhitelistArgsToContent(cmd.Flags()) + if err != nil { + return err + } + + from := clientCtx.GetFromAddress() + + depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit) + if err != nil { + return err + } + + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") + cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") + cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal") + cmd.Flags().String(FlagPoolIds, "", "The new pool id whitelist to set") + cmd.Flags().Bool(FlagOverwrite, false, "The flag indicating whether to overwrite the whitelist or append to it") + + return cmd +} + +func parseUpdateUnpoolWhitelistArgsToContent(flags *flag.FlagSet) (govtypes.Content, error) { + title, err := flags.GetString(govcli.FlagTitle) + if err != nil { + return nil, err + } + + description, err := flags.GetString(govcli.FlagDescription) + if err != nil { + return nil, err + } + + poolIdsStr, err := flags.GetString(FlagPoolIds) + if err != nil { + return nil, err + } + + poolIds, err := osmoutils.ParseUint64SliceFromString(poolIdsStr, ",") + if err != nil { + return nil, err + } + + isOverwrite, err := flags.GetBool(FlagOverwrite) + if err != nil { + return nil, err + } + + content := &types.UpdateUnpoolWhiteListProposal{ + Title: title, + Description: description, + Ids: poolIds, + IsOverwrite: isOverwrite, + } + return content, nil +} diff --git a/x/superfluid/client/proposal_handler.go b/x/superfluid/client/proposal_handler.go index ba7a5537525..9877463d730 100644 --- a/x/superfluid/client/proposal_handler.go +++ b/x/superfluid/client/proposal_handler.go @@ -1,8 +1,8 @@ package client import ( - "github.com/osmosis-labs/osmosis/v12/x/superfluid/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/client/rest" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/client/rest" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" ) @@ -10,4 +10,5 @@ import ( var ( SetSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitSetSuperfluidAssetsProposal, rest.ProposalSetSuperfluidAssetsRESTHandler) RemoveSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitRemoveSuperfluidAssetsProposal, rest.ProposalRemoveSuperfluidAssetsRESTHandler) + UpdateUnpoolWhitelistProposalHandler = govclient.NewProposalHandler(cli.NewCmdUpdateUnpoolWhitelistProposal, rest.ProposalUpdateUnpoolWhitelistProposal) ) diff --git a/x/superfluid/client/rest/tx.go b/x/superfluid/client/rest/tx.go index 24c67bb3775..bd0cc39a8bf 100644 --- a/x/superfluid/client/rest/tx.go +++ b/x/superfluid/client/rest/tx.go @@ -10,23 +10,25 @@ import ( func ProposalSetSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { return govrest.ProposalRESTHandler{ SubRoute: "set-superfluid-assets", - Handler: newSetSuperfluidAssetsHandler(clientCtx), + Handler: emptyHandler(clientCtx), } } -func newSetSuperfluidAssetsHandler(clientCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { +func ProposalRemoveSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { + return govrest.ProposalRESTHandler{ + SubRoute: "remove-superfluid-assets", + Handler: emptyHandler(clientCtx), } } -func ProposalRemoveSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { +func ProposalUpdateUnpoolWhitelistProposal(clientCtx client.Context) govrest.ProposalRESTHandler { return govrest.ProposalRESTHandler{ - SubRoute: "remove-superfluid-assets", - Handler: newRemoveSuperfluidAssetsHandler(clientCtx), + SubRoute: "update-unpool-whitelist", + Handler: emptyHandler(clientCtx), } } -func newRemoveSuperfluidAssetsHandler(clientCtx client.Context) http.HandlerFunc { +func emptyHandler(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { } } diff --git a/x/superfluid/keeper/distribution_test.go b/x/superfluid/keeper/distribution_test.go index 0c379f882e4..847e36a1da0 100644 --- a/x/superfluid/keeper/distribution_test.go +++ b/x/superfluid/keeper/distribution_test.go @@ -1,8 +1,8 @@ package keeper_test import ( - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/superfluid/keeper/edge_case_test.go b/x/superfluid/keeper/edge_case_test.go index 198a62ea732..2f91a4d6eef 100644 --- a/x/superfluid/keeper/edge_case_test.go +++ b/x/superfluid/keeper/edge_case_test.go @@ -7,7 +7,7 @@ import ( evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) func (suite *KeeperTestSuite) TestSuperfluidDelegatedValidatorJailed() { diff --git a/x/superfluid/keeper/epoch.go b/x/superfluid/keeper/epoch.go index 591317bee89..10102249ddd 100644 --- a/x/superfluid/keeper/epoch.go +++ b/x/superfluid/keeper/epoch.go @@ -7,11 +7,11 @@ import ( distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ int64) error { diff --git a/x/superfluid/keeper/genesis.go b/x/superfluid/keeper/genesis.go index 30120961a31..8758e2bd994 100644 --- a/x/superfluid/keeper/genesis.go +++ b/x/superfluid/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/superfluid/keeper/genesis_test.go b/x/superfluid/keeper/genesis_test.go index 5f0328f80b1..1f114c8e9d6 100644 --- a/x/superfluid/keeper/genesis_test.go +++ b/x/superfluid/keeper/genesis_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - simapp "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/x/superfluid" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + simapp "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/x/superfluid" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/gov/gov.go b/x/superfluid/keeper/gov/gov.go index 8804a4405b5..c98c0c56842 100644 --- a/x/superfluid/keeper/gov/gov.go +++ b/x/superfluid/keeper/gov/gov.go @@ -1,11 +1,13 @@ package gov import ( + "errors" "fmt" + "sort" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper/internal/events" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper/internal/events" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -32,3 +34,45 @@ func HandleRemoveSuperfluidAssetsProposal(ctx sdk.Context, k keeper.Keeper, p *t } return nil } + +// HandleUnpoolWhiteListChange handles the unpool whitelist change proposal. It validates that every new pool id exists. Fails if not. +// If IsOverwrite flag is set, the whitelist is completely overridden. Otherwise, it is merged with pre-existing whitelisted pool ids. +// Any duplicates are removed and the pool ids are sorted prior to being written to state. +// Returns nil on success, error on failure. +func HandleUnpoolWhiteListChange(ctx sdk.Context, k keeper.Keeper, gammKeeper types.GammKeeper, p *types.UpdateUnpoolWhiteListProposal) error { + allPoolIds := make([]uint64, 0, len(p.Ids)) + + // if overwrite flag is not set, we merge the old white list with the + // newly added pool ids. + if !p.IsOverwrite { + allPoolIds = append(allPoolIds, k.GetUnpoolAllowedPools(ctx)...) + } + + for _, newId := range p.Ids { + if newId == 0 { + return errors.New("pool id 0 is not allowed. Pool ids start from 0") + } + + if _, err := gammKeeper.GetPoolAndPoke(ctx, newId); err != nil { + return fmt.Errorf("failed to get pool with id (%d), likely does not exist: %w", newId, err) + } + allPoolIds = append(allPoolIds, newId) + } + + // Sort + sort.Slice(allPoolIds, func(i, j int) bool { + return allPoolIds[i] < allPoolIds[j] + }) + + // Remove duplicates, if any + duplicatesRemovedIds := make([]uint64, 0, len(allPoolIds)) + for i, curId := range allPoolIds { + if i < len(allPoolIds)-1 && curId == allPoolIds[i+1] { + continue + } + duplicatesRemovedIds = append(duplicatesRemovedIds, curId) + } + + k.SetUnpoolAllowedPools(ctx, duplicatesRemovedIds) + return nil +} diff --git a/x/superfluid/keeper/gov/gov_test.go b/x/superfluid/keeper/gov/gov_test.go index 049298319dd..0b3a88e311e 100644 --- a/x/superfluid/keeper/gov/gov_test.go +++ b/x/superfluid/keeper/gov/gov_test.go @@ -3,18 +3,17 @@ package gov_test import ( "fmt" - "github.com/tendermint/tendermint/crypto/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper/gov" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper/gov" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func (suite *KeeperTestSuite) createGammPool(denoms []string) uint64 { - coins := suite.app.GAMMKeeper.GetParams(suite.ctx).PoolCreationFee + coins := suite.App.GAMMKeeper.GetParams(suite.Ctx).PoolCreationFee poolAssets := []balancer.PoolAsset{} for _, denom := range denoms { coins = coins.Add(sdk.NewInt64Coin(denom, 1000000000000000000)) @@ -25,16 +24,16 @@ func (suite *KeeperTestSuite) createGammPool(denoms []string) uint64 { } acc1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) - err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + err := suite.App.BankKeeper.MintCoins(suite.Ctx, minttypes.ModuleName, coins) suite.Require().NoError(err) - err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, acc1, coins) + err = suite.App.BankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, minttypes.ModuleName, acc1, coins) suite.Require().NoError(err) msg := balancer.NewMsgCreateBalancerPool(acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.ZeroDec(), }, poolAssets, "") - poolId, err := suite.app.GAMMKeeper.CreatePool(suite.ctx, msg) + poolId, err := suite.App.GAMMKeeper.CreatePool(suite.Ctx, msg) suite.Require().NoError(err) return poolId @@ -98,7 +97,7 @@ func (suite *KeeperTestSuite) TestHandleSetSuperfluidAssetsProposal() { suite.SetupTest() // initial check - resp, err := suite.querier.AllAssets(sdk.WrapSDKContext(suite.ctx), &types.AllAssetsRequest{}) + resp, err := suite.querier.AllAssets(sdk.WrapSDKContext(suite.Ctx), &types.AllAssetsRequest{}) suite.Require().NoError(err) suite.Require().Len(resp.Assets, 0) @@ -118,14 +117,14 @@ func (suite *KeeperTestSuite) TestHandleSetSuperfluidAssetsProposal() { if action.isAdd { suite.createGammPool(poolDenoms) // set superfluid assets via proposal - err = gov.HandleSetSuperfluidAssetsProposal(suite.ctx, *suite.app.SuperfluidKeeper, *suite.app.EpochsKeeper, &types.SetSuperfluidAssetsProposal{ + err = gov.HandleSetSuperfluidAssetsProposal(suite.Ctx, *suite.App.SuperfluidKeeper, *suite.App.EpochsKeeper, &types.SetSuperfluidAssetsProposal{ Title: "title", Description: "description", Assets: action.assets, }) } else { // remove existing superfluid asset via proposal - err = gov.HandleRemoveSuperfluidAssetsProposal(suite.ctx, *suite.app.SuperfluidKeeper, &types.RemoveSuperfluidAssetsProposal{ + err = gov.HandleRemoveSuperfluidAssetsProposal(suite.Ctx, *suite.App.SuperfluidKeeper, &types.RemoveSuperfluidAssetsProposal{ Title: "title", Description: "description", SuperfluidAssetDenoms: govDenoms, @@ -135,18 +134,18 @@ func (suite *KeeperTestSuite) TestHandleSetSuperfluidAssetsProposal() { suite.Require().Error(err) } else { suite.Require().NoError(err) - suite.AssertEventEmitted(suite.ctx, tc.expectedEvent[i], 1) + suite.AssertEventEmitted(suite.Ctx, tc.expectedEvent[i], 1) } // check assets individually for _, asset := range action.expectedAssets { - res, err := suite.querier.AssetType(sdk.WrapSDKContext(suite.ctx), &types.AssetTypeRequest{Denom: asset.Denom}) + res, err := suite.querier.AssetType(sdk.WrapSDKContext(suite.Ctx), &types.AssetTypeRequest{Denom: asset.Denom}) suite.Require().NoError(err) suite.Require().Equal(res.AssetType, asset.AssetType, "tcname %s, action num %d", tc.name, i) } // check assets - resp, err = suite.querier.AllAssets(sdk.WrapSDKContext(suite.ctx), &types.AllAssetsRequest{}) + resp, err = suite.querier.AllAssets(sdk.WrapSDKContext(suite.Ctx), &types.AllAssetsRequest{}) fmt.Println(resp) suite.Require().NoError(err) suite.Require().Equal(resp.Assets, action.expectedAssets) @@ -154,3 +153,181 @@ func (suite *KeeperTestSuite) TestHandleSetSuperfluidAssetsProposal() { }) } } + +func (suite *KeeperTestSuite) TestHandleUnpoolWhiteListChange() { + const ( + testTitle = "test title" + testDescription = "test description" + ) + + var ( + basePoolIds = []uint64{1, 2, 3} + ) + + tests := map[string]struct { + preCreatedPoolCount int + preSetWhiteList []uint64 + + p types.UpdateUnpoolWhiteListProposal + expectError bool + expectedPoolIds []uint64 + }{ + "success; 3 pre-created poold ids and no pre-set whitelist, no overwrite": { + preCreatedPoolCount: 3, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: basePoolIds, + }, + + expectedPoolIds: basePoolIds, + }, + "success; 3 pre-created poold ids and no pre-set whitelist, overwrite": { + preCreatedPoolCount: 3, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: basePoolIds, + IsOverwrite: true, + }, + + expectedPoolIds: []uint64{1, 2, 3}, + }, + "success; 3 pre-created poold ids and pre-set whitelist, no overwrite": { + preCreatedPoolCount: 3, + + preSetWhiteList: []uint64{1}, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{2, 3}, + }, + + expectedPoolIds: basePoolIds, + }, + "success; 3 pre-created poold ids and pre-set whitelist, overwrite": { + preCreatedPoolCount: 3, + + preSetWhiteList: []uint64{1}, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{2, 3}, + IsOverwrite: true, + }, + + expectedPoolIds: []uint64{2, 3}, + }, + "success; duplicate id set, no overwrite": { + preCreatedPoolCount: 1, + + preSetWhiteList: []uint64{1}, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{1}, + }, + + expectedPoolIds: []uint64{1}, + }, + "success; duplicate id set, overwrite": { + preCreatedPoolCount: 1, + + preSetWhiteList: []uint64{1}, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{1}, + IsOverwrite: true, + }, + + expectedPoolIds: []uint64{1}, + }, + "success; many duplicates with old values but not all, no overwrite": { + preCreatedPoolCount: 10, + + preSetWhiteList: []uint64{1, 2, 3, 6, 9, 10}, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{3, 5, 6, 7, 10}, + }, + + expectedPoolIds: []uint64{1, 2, 3, 5, 6, 7, 9, 10}, + }, + "success; many duplicates with old values but not all, overwrite": { + preCreatedPoolCount: 10, + + preSetWhiteList: []uint64{1, 2, 3, 6, 9, 10}, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{3, 5, 6, 7, 10}, + IsOverwrite: true, + }, + + expectedPoolIds: []uint64{3, 5, 6, 7, 10}, + }, + "error; non-existent poold id provided": { + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{1}, + }, + + expectError: true, + }, + "error; pool ids of 0": { + preCreatedPoolCount: 1, + + p: types.UpdateUnpoolWhiteListProposal{ + Title: testTitle, + Description: testDescription, + Ids: []uint64{0}, + IsOverwrite: true, + }, + + expectError: true, + }, + } + + for name, tc := range tests { + tc := tc + suite.Run(name, func() { + suite.SetupTest() + + ctx := suite.Ctx + superfluidKeeper := suite.App.SuperfluidKeeper + gammKeeper := suite.App.GAMMKeeper + + // Setup. + for i := 0; i < tc.preCreatedPoolCount; i++ { + suite.PrepareBalancerPool() + } + + superfluidKeeper.SetUnpoolAllowedPools(ctx, tc.preSetWhiteList) + + // System under test. + err := gov.HandleUnpoolWhiteListChange(ctx, *superfluidKeeper, gammKeeper, &tc.p) + + if tc.expectError { + suite.Require().Error(err) + return + } + + suite.Require().NoError(err) + + // Validate that whitelist is set correctly. + actualAllowedPools := superfluidKeeper.GetUnpoolAllowedPools(ctx) + suite.Require().Equal(tc.expectedPoolIds, actualAllowedPools) + }) + } +} diff --git a/x/superfluid/keeper/gov/suite_test.go b/x/superfluid/keeper/gov/suite_test.go index 6583700f231..307f1971e63 100644 --- a/x/superfluid/keeper/gov/suite_test.go +++ b/x/superfluid/keeper/gov/suite_test.go @@ -2,30 +2,23 @@ package gov_test import ( "testing" - "time" "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/osmosis-labs/osmosis/v12/app" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) type KeeperTestSuite struct { apptesting.KeeperTestHelper - ctx sdk.Context - querier keeper.Querier - app *app.OsmosisApp + querier types.QueryServer } func (suite *KeeperTestSuite) SetupTest() { - suite.app = app.Setup(false) - suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "osmosis-1", Time: time.Now().UTC()}) - suite.querier = keeper.NewQuerier(*suite.app.SuperfluidKeeper) + suite.Setup() + suite.querier = keeper.NewQuerier(*suite.App.SuperfluidKeeper) } func TestKeeperTestSuite(t *testing.T) { diff --git a/x/superfluid/keeper/grpc_query.go b/x/superfluid/keeper/grpc_query.go index 409c60a6122..9745aaa6689 100644 --- a/x/superfluid/keeper/grpc_query.go +++ b/x/superfluid/keeper/grpc_query.go @@ -11,10 +11,10 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) var _ types.QueryServer = Querier{} @@ -392,6 +392,46 @@ func (q Querier) EstimateSuperfluidDelegatedAmountByValidatorDenom(goCtx context }, nil } +func (q Querier) TotalDelegationByValidatorForDenom(goCtx context.Context, req *types.QueryTotalDelegationByValidatorForDenomRequest) (*types.QueryTotalDelegationByValidatorForDenomResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + var intermediaryAccount types.SuperfluidIntermediaryAccount + + delegationsByValidator := []types.Delegations{} + intermediaryAccounts := q.Keeper.GetAllIntermediaryAccounts(ctx) + for _, intermediaryAccount = range intermediaryAccounts { + if intermediaryAccount.Denom != req.Denom { + continue + } + + valAddr, err := sdk.ValAddressFromBech32(intermediaryAccount.ValAddr) + if err != nil { + return nil, err + } + + delegation, _ := q.SuperfluidDelegationsByValidatorDenom(goCtx, &types.SuperfluidDelegationsByValidatorDenomRequest{ValidatorAddress: valAddr.String(), Denom: req.Denom}) + + amount := sdk.ZeroInt() + for _, record := range delegation.SuperfluidDelegationRecords { + amount = amount.Add(record.DelegationAmount.Amount) + } + + equivalentAmountOSMO := q.Keeper.GetSuperfluidOSMOTokens(ctx, req.Denom, amount) + + result := types.Delegations{ + ValAddr: valAddr.String(), + AmountSfsd: amount, + OsmoEquivalent: equivalentAmountOSMO, + } + + delegationsByValidator = append(delegationsByValidator, result) + } + + return &types.QueryTotalDelegationByValidatorForDenomResponse{ + Assets: delegationsByValidator, + }, nil +} + // TotalSuperfluidDelegations returns total amount of osmo delegated via superfluid staking. func (q Querier) TotalSuperfluidDelegations(goCtx context.Context, _ *types.TotalSuperfluidDelegationsRequest) (*types.TotalSuperfluidDelegationsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -481,3 +521,15 @@ func (q Querier) TotalDelegationByDelegator(goCtx context.Context, req *types.Qu return &res, nil } + +func (q Querier) UnpoolWhitelist(goCtx context.Context, req *types.QueryUnpoolWhitelistRequest) (*types.QueryUnpoolWhitelistResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + allowedPools := q.GetUnpoolAllowedPools(sdk.UnwrapSDKContext(goCtx)) + + return &types.QueryUnpoolWhitelistResponse{ + PoolIds: allowedPools, + }, nil +} diff --git a/x/superfluid/keeper/grpc_query_test.go b/x/superfluid/keeper/grpc_query_test.go index d8de2ddae1d..9278dc0ba9e 100644 --- a/x/superfluid/keeper/grpc_query_test.go +++ b/x/superfluid/keeper/grpc_query_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func (suite *KeeperTestSuite) TestGRPCParams() { @@ -16,6 +16,55 @@ func (suite *KeeperTestSuite) TestGRPCParams() { suite.Require().True(res.Params.MinimumRiskFactor.Equal(types.DefaultParams().MinimumRiskFactor)) } +func (suite *KeeperTestSuite) TestTotalDelegationByValidatorForAsset() { + suite.SetupTest() + ctx := suite.Ctx + querier := suite.querier + delegation_amount := int64(1000000) + + valAddrs := suite.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}) + denoms, _ := suite.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + + superfluidDelegations := []superfluidDelegation{ + {0, 0, 0, delegation_amount}, + {0, 1, 1, delegation_amount}, + {1, 0, 1, delegation_amount}, + {1, 1, 0, delegation_amount}, + } + + suite.setupSuperfluidDelegations(valAddrs, superfluidDelegations, denoms) + + for _, denom := range denoms { + res, err := querier.TotalDelegationByValidatorForDenom(sdk.WrapSDKContext(ctx), &types.QueryTotalDelegationByValidatorForDenomRequest{Denom: denom}) + + suite.Require().NoError(err) + suite.Require().Equal(len(valAddrs), len(res.Assets)) + + for _, result := range res.Assets { + // check osmo equivalent is correct + actual_response_osmo := result.OsmoEquivalent + needed_response_osmo := suite.App.SuperfluidKeeper.GetSuperfluidOSMOTokens(ctx, denom, sdk.NewInt(delegation_amount)) + + suite.Require().Equal(actual_response_osmo, needed_response_osmo) + + // check sfs'd asset amount correct + actual_response_asset := result.AmountSfsd + needed_response_asset := sdk.NewInt(delegation_amount) + suite.Require().Equal(actual_response_asset, needed_response_asset) + + // check validator addresses correct + actual_val := result.ValAddr + checks := 0 + for _, val := range valAddrs { + if val.String() == actual_val { + checks++ + break + } + } + suite.Require().True(checks == 1) + } + } +} func (suite *KeeperTestSuite) TestGRPCSuperfluidAsset() { suite.SetupTest() diff --git a/x/superfluid/keeper/hooks.go b/x/superfluid/keeper/hooks.go index 87ec0399e24..35049f3b555 100644 --- a/x/superfluid/keeper/hooks.go +++ b/x/superfluid/keeper/hooks.go @@ -3,8 +3,8 @@ package keeper import ( "time" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper/internal/events" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper/internal/events" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/hooks_test.go b/x/superfluid/keeper/hooks_test.go index f163052a3ed..9ea9397c73b 100644 --- a/x/superfluid/keeper/hooks_test.go +++ b/x/superfluid/keeper/hooks_test.go @@ -6,9 +6,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - lockupkeeper "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + lockupkeeper "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func (suite *KeeperTestSuite) TestSuperfluidAfterEpochEnd() { diff --git a/x/superfluid/keeper/intermediary_account.go b/x/superfluid/keeper/intermediary_account.go index 7f05e1ee251..c8a4a16d6d9 100644 --- a/x/superfluid/keeper/intermediary_account.go +++ b/x/superfluid/keeper/intermediary_account.go @@ -3,8 +3,8 @@ package keeper import ( "github.com/gogo/protobuf/proto" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/superfluid/keeper/intermediary_account_test.go b/x/superfluid/keeper/intermediary_account_test.go index 218a692b2ab..10d58875c09 100644 --- a/x/superfluid/keeper/intermediary_account_test.go +++ b/x/superfluid/keeper/intermediary_account_test.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func (suite *KeeperTestSuite) TestIntermediaryAccountCreation() { diff --git a/x/superfluid/keeper/internal/events/emit.go b/x/superfluid/keeper/internal/events/emit.go index 9ee484d6456..33d1ccc97d5 100644 --- a/x/superfluid/keeper/internal/events/emit.go +++ b/x/superfluid/keeper/internal/events/emit.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/utils" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/utils" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func EmitSetSuperfluidAssetEvent(ctx sdk.Context, denom string, assetType types.SuperfluidAssetType) { diff --git a/x/superfluid/keeper/internal/events/emit_test.go b/x/superfluid/keeper/internal/events/emit_test.go index 381468be5d1..53b215581d7 100644 --- a/x/superfluid/keeper/internal/events/emit_test.go +++ b/x/superfluid/keeper/internal/events/emit_test.go @@ -8,9 +8,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper/internal/events" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper/internal/events" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) type SuperfluidEventsTestSuite struct { diff --git a/x/superfluid/keeper/invariants.go b/x/superfluid/keeper/invariants.go index d121f785034..550d311cd9a 100644 --- a/x/superfluid/keeper/invariants.go +++ b/x/superfluid/keeper/invariants.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) const totalSuperfluidDelegationInvariantName = "total-superfluid-delegation-invariant-name" diff --git a/x/superfluid/keeper/keeper.go b/x/superfluid/keeper/keeper.go index 194577ea50f..18034463219 100644 --- a/x/superfluid/keeper/keeper.go +++ b/x/superfluid/keeper/keeper.go @@ -5,7 +5,7 @@ import ( "github.com/tendermint/tendermint/libs/log" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" diff --git a/x/superfluid/keeper/keeper_test.go b/x/superfluid/keeper/keeper_test.go index d7cb6a16a73..eab9fa01d8b 100644 --- a/x/superfluid/keeper/keeper_test.go +++ b/x/superfluid/keeper/keeper_test.go @@ -10,14 +10,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) type KeeperTestSuite struct { diff --git a/x/superfluid/keeper/msg_server.go b/x/superfluid/keeper/msg_server.go index bd9d91810ec..466b97480c1 100644 --- a/x/superfluid/keeper/msg_server.go +++ b/x/superfluid/keeper/msg_server.go @@ -3,17 +3,15 @@ package keeper import ( "context" "encoding/json" - "errors" "time" sdk "github.com/cosmos/cosmos-sdk/types" - v8constants "github.com/osmosis-labs/osmosis/v12/app/upgrades/v8/constants" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper/internal/events" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper/internal/events" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) type msgServer struct { @@ -123,11 +121,12 @@ func (server msgServer) LockAndSuperfluidDelegate(goCtx context.Context, msg *ty func (server msgServer) UnPoolWhitelistedPool(goCtx context.Context, msg *types.MsgUnPoolWhitelistedPool) (*types.MsgUnPoolWhitelistedPoolResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if ctx.BlockHeight() < v8constants.UpgradeHeight { - return nil, errors.New("message not activated") + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err } - sender, err := sdk.AccAddressFromBech32(msg.Sender) + err = server.keeper.checkUnpoolWhitelisted(ctx, msg.PoolId) if err != nil { return nil, err } diff --git a/x/superfluid/keeper/msg_server_test.go b/x/superfluid/keeper/msg_server_test.go index d00531e8bc2..d20072ba57e 100644 --- a/x/superfluid/keeper/msg_server_test.go +++ b/x/superfluid/keeper/msg_server_test.go @@ -7,11 +7,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - v8constants "github.com/osmosis-labs/osmosis/v12/app/upgrades/v8/constants" - lockupkeeper "github.com/osmosis-labs/osmosis/v12/x/lockup/keeper" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + v8constants "github.com/osmosis-labs/osmosis/v13/app/upgrades/v8/constants" + lockupkeeper "github.com/osmosis-labs/osmosis/v13/x/lockup/keeper" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) func (suite *KeeperTestSuite) TestMsgSuperfluidDelegate() { diff --git a/x/superfluid/keeper/params.go b/x/superfluid/keeper/params.go index 68db56fa29a..210afb39b16 100644 --- a/x/superfluid/keeper/params.go +++ b/x/superfluid/keeper/params.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/slash.go b/x/superfluid/keeper/slash.go index eaa9cffd8e3..6984aee8495 100644 --- a/x/superfluid/keeper/slash.go +++ b/x/superfluid/keeper/slash.go @@ -3,8 +3,8 @@ package keeper import ( "time" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/slash_test.go b/x/superfluid/keeper/slash_test.go index 296a0b13675..db00e8e087d 100644 --- a/x/superfluid/keeper/slash_test.go +++ b/x/superfluid/keeper/slash_test.go @@ -1,8 +1,8 @@ package keeper_test import ( - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/superfluid/keeper/stake.go b/x/superfluid/keeper/stake.go index 0a74e093699..5d2131e25a7 100644 --- a/x/superfluid/keeper/stake.go +++ b/x/superfluid/keeper/stake.go @@ -5,9 +5,9 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/superfluid/keeper/stake_test.go b/x/superfluid/keeper/stake_test.go index 3cee0f0ad93..7e2faca1856 100644 --- a/x/superfluid/keeper/stake_test.go +++ b/x/superfluid/keeper/stake_test.go @@ -5,9 +5,9 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/superfluid/keeper/superfluid_asset.go b/x/superfluid/keeper/superfluid_asset.go index a85e9e8ca49..fb716cb0647 100644 --- a/x/superfluid/keeper/superfluid_asset.go +++ b/x/superfluid/keeper/superfluid_asset.go @@ -1,8 +1,8 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/superfluid_asset_store.go b/x/superfluid/keeper/superfluid_asset_store.go index 139cb01278e..7415031da11 100644 --- a/x/superfluid/keeper/superfluid_asset_store.go +++ b/x/superfluid/keeper/superfluid_asset_store.go @@ -4,7 +4,7 @@ package keeper import ( "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/superfluid/keeper/superfluid_asset_test.go b/x/superfluid/keeper/superfluid_asset_test.go index be72e9fb78f..08a452a89ae 100644 --- a/x/superfluid/keeper/superfluid_asset_test.go +++ b/x/superfluid/keeper/superfluid_asset_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/synthetic_lock_wrapper.go b/x/superfluid/keeper/synthetic_lock_wrapper.go index dfff4522de6..57312c5796e 100644 --- a/x/superfluid/keeper/synthetic_lock_wrapper.go +++ b/x/superfluid/keeper/synthetic_lock_wrapper.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/twap_price.go b/x/superfluid/keeper/twap_price.go index 35eaa951712..c66c0f9426d 100644 --- a/x/superfluid/keeper/twap_price.go +++ b/x/superfluid/keeper/twap_price.go @@ -3,8 +3,8 @@ package keeper import ( "github.com/gogo/protobuf/proto" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/superfluid/keeper/twap_price_test.go b/x/superfluid/keeper/twap_price_test.go index 11619e0ae8b..25e017f058d 100644 --- a/x/superfluid/keeper/twap_price_test.go +++ b/x/superfluid/keeper/twap_price_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/superfluid/keeper/unpool.go b/x/superfluid/keeper/unpool.go index 0ccc55b1978..a2aa5fa9797 100644 --- a/x/superfluid/keeper/unpool.go +++ b/x/superfluid/keeper/unpool.go @@ -5,11 +5,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) // Returns a list of newly created lockIDs, or an error. @@ -156,7 +156,13 @@ func (k Keeper) unbondSuperfluidIfExists(ctx sdk.Context, sender sdk.AccAddress, func (k Keeper) GetUnpoolAllowedPools(ctx sdk.Context) []uint64 { store := ctx.KVStore(k.storeKey) allowedPools := types.UnpoolWhitelistedPools{} - osmoutils.MustGet(store, types.KeyUnpoolAllowedPools, &allowedPools) + found, err := osmoutils.Get(store, types.KeyUnpoolAllowedPools, &allowedPools) + if err != nil { + panic(err) + } + if !found { + return []uint64{} + } return allowedPools.Ids } diff --git a/x/superfluid/keeper/unpool_test.go b/x/superfluid/keeper/unpool_test.go index a48bd2989b3..80563cde841 100644 --- a/x/superfluid/keeper/unpool_test.go +++ b/x/superfluid/keeper/unpool_test.go @@ -4,14 +4,13 @@ import ( "time" "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/pool-models/balancer" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) var ( @@ -252,3 +251,37 @@ func (suite *KeeperTestSuite) TestUnpool() { }) } } + +// TestUnpoolAllowedPools_WhiteList tests that unpooling does not work for pools not in a whitelist. +// Should fail immediately if pool is not in whitelist. +func (suite *KeeperTestSuite) TestUnpoolAllowedPools_WhiteList() { + // lock id does not matter in the context of this test. + const ( + testLockId = 1 + whiteListedPoolId = 1 + ) + suite.SetupTest() + ctx := suite.Ctx + superfluidKeeper := suite.App.SuperfluidKeeper + + // id 1 + suite.PrepareBalancerPool() + // id 2 + suite.PrepareBalancerPool() + + // set id 1 to whitelist + superfluidKeeper.SetUnpoolAllowedPools(ctx, []uint64{whiteListedPoolId}) + + _, err := superfluidKeeper.UnpoolAllowedPools(ctx, suite.TestAccs[0], whiteListedPoolId, testLockId) + + // An error should still occur due to incorrect setup. However, it should be unrelated + // to whitelist. + suite.Error(err) + suite.Require().NotErrorIs(err, types.ErrPoolNotWhitelisted) + + _, err = superfluidKeeper.UnpoolAllowedPools(ctx, suite.TestAccs[0], whiteListedPoolId+1, testLockId) + + // Here, we used a non-whitelisted pool id so it should fail with the whitelist error. + suite.Error(err) + suite.Require().ErrorIs(err, types.ErrPoolNotWhitelisted) +} diff --git a/x/superfluid/module.go b/x/superfluid/module.go index a4d6703e5e8..37def417881 100644 --- a/x/superfluid/module.go +++ b/x/superfluid/module.go @@ -26,11 +26,11 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/osmosis-labs/osmosis/v12/x/mint/client/rest" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/simulation" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/mint/client/rest" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/simulation" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) var ( diff --git a/x/superfluid/proposal_handler.go b/x/superfluid/proposal_handler.go index 277a4f653b1..953c9e1fce5 100644 --- a/x/superfluid/proposal_handler.go +++ b/x/superfluid/proposal_handler.go @@ -5,18 +5,20 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper/gov" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper/gov" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) -func NewSuperfluidProposalHandler(k keeper.Keeper, ek types.EpochKeeper) govtypes.Handler { +func NewSuperfluidProposalHandler(k keeper.Keeper, ek types.EpochKeeper, gk types.GammKeeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { case *types.SetSuperfluidAssetsProposal: return handleSetSuperfluidAssetsProposal(ctx, k, ek, c) case *types.RemoveSuperfluidAssetsProposal: return handleRemoveSuperfluidAssetsProposal(ctx, k, c) + case *types.UpdateUnpoolWhiteListProposal: + return handleUnpoolWhitelistChange(ctx, k, gk, c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized pool incentives proposal content type: %T", c) @@ -31,3 +33,7 @@ func handleSetSuperfluidAssetsProposal(ctx sdk.Context, k keeper.Keeper, ek type func handleRemoveSuperfluidAssetsProposal(ctx sdk.Context, k keeper.Keeper, p *types.RemoveSuperfluidAssetsProposal) error { return gov.HandleRemoveSuperfluidAssetsProposal(ctx, k, p) } + +func handleUnpoolWhitelistChange(ctx sdk.Context, k keeper.Keeper, gammKeeper types.GammKeeper, p *types.UpdateUnpoolWhiteListProposal) error { + return gov.HandleUnpoolWhiteListChange(ctx, k, gammKeeper, p) +} diff --git a/x/superfluid/simulation/genesis.go b/x/superfluid/simulation/genesis.go index 3ab0800c4e6..640be6638eb 100644 --- a/x/superfluid/simulation/genesis.go +++ b/x/superfluid/simulation/genesis.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/x/superfluid/simulation/operations.go b/x/superfluid/simulation/operations.go index ca448b07578..e1d284b6943 100644 --- a/x/superfluid/simulation/operations.go +++ b/x/superfluid/simulation/operations.go @@ -3,13 +3,13 @@ package simulation import ( "math/rand" - osmosimtypes "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" + osmosimtypes "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" "github.com/cosmos/cosmos-sdk/baseapp" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/cosmos/cosmos-sdk/codec" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" diff --git a/x/superfluid/simulation/proposals.go b/x/superfluid/simulation/proposals.go index 723ba58f87e..25b2d9019e0 100644 --- a/x/superfluid/simulation/proposals.go +++ b/x/superfluid/simulation/proposals.go @@ -7,9 +7,9 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" ) const ( diff --git a/x/superfluid/types/codec.go b/x/superfluid/types/codec.go index 2387c279b80..eaf85e0101c 100644 --- a/x/superfluid/types/codec.go +++ b/x/superfluid/types/codec.go @@ -15,6 +15,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgLockAndSuperfluidDelegate{}, "osmosis/lock-and-superfluid-delegate", nil) cdc.RegisterConcrete(&MsgSuperfluidUnbondLock{}, "osmosis/superfluid-unbond-lock", nil) cdc.RegisterConcrete(&SetSuperfluidAssetsProposal{}, "osmosis/set-superfluid-assets-proposal", nil) + cdc.RegisterConcrete(&UpdateUnpoolWhiteListProposal{}, "osmosis/update-unpool-whitelist", nil) cdc.RegisterConcrete(&RemoveSuperfluidAssetsProposal{}, "osmosis/del-superfluid-assets-proposal", nil) cdc.RegisterConcrete(&MsgUnPoolWhitelistedPool{}, "osmosis/unpool-whitelisted-pool", nil) } @@ -33,6 +34,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { (*govtypes.Content)(nil), &SetSuperfluidAssetsProposal{}, &RemoveSuperfluidAssetsProposal{}, + &UpdateUnpoolWhiteListProposal{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/superfluid/types/expected_keepers.go b/x/superfluid/types/expected_keepers.go index e7473328617..f4625c4074a 100644 --- a/x/superfluid/types/expected_keepers.go +++ b/x/superfluid/types/expected_keepers.go @@ -7,10 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types" - lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + incentivestypes "github.com/osmosis-labs/osmosis/v13/x/incentives/types" + lockuptypes "github.com/osmosis-labs/osmosis/v13/x/lockup/types" ) // LockupKeeper defines the expected interface needed to retrieve locks. diff --git a/x/superfluid/types/genesis.pb.go b/x/superfluid/types/genesis.pb.go index 8715620a670..f9d1e62b2f1 100644 --- a/x/superfluid/types/genesis.pb.go +++ b/x/superfluid/types/genesis.pb.go @@ -113,31 +113,31 @@ func init() { func init() { proto.RegisterFile("osmosis/superfluid/genesis.proto", fileDescriptor_d5256ebb7c83fff3) } var fileDescriptor_d5256ebb7c83fff3 = []byte{ - // 383 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x4e, 0xf2, 0x40, - 0x10, 0xc7, 0xdb, 0x0f, 0x3e, 0x0e, 0xc5, 0x83, 0x36, 0x98, 0x54, 0x8c, 0x85, 0xc8, 0x85, 0x8b, - 0x6d, 0xa8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x04, 0x33, 0xd0, 0x0a, 0x89, 0xc1, 0xca, 0x33, 0xdc, - 0x81, 0x4f, 0xaf, 0xb2, 0xd4, 0x6d, 0x16, 0xea, 0x63, 0x87, 0xb2, 0x91, 0x10, 0x1e, 0xd0, 0x5f, - 0x28, 0x50, 0x3d, 0x65, 0x9f, 0x04, 0x1c, 0x33, 0x1f, 0x8f, 0x08, 0x62, 0x53, 0x1b, 0x39, 0x0e, - 0x8d, 0x02, 0x0e, 0x5a, 0x31, 0x71, 0xb6, 0xfe, 0x7e, 0x55, 0x77, 0x23, 0xda, 0x4e, 0x93, 0x42, - 0x59, 0x21, 0xdb, 0x2d, 0x50, 0x5f, 0x65, 0xa5, 0x16, 0x37, 0x7e, 0xd8, 0x6c, 0x87, 0x06, 0x01, - 0x76, 0x38, 0xa1, 0x01, 0x68, 0xff, 0x13, 0xf1, 0x79, 0x9e, 0xf8, 0x86, 0x3a, 0xcf, 0xdd, 0x3c, - 0xe9, 0x65, 0x96, 0x17, 0xfa, 0xa3, 0x0d, 0xcb, 0x16, 0x03, 0x9d, 0xde, 0x7c, 0xa9, 0xcb, 0x8b, - 0xa5, 0x2e, 0x7f, 0x2c, 0x75, 0x79, 0xb6, 0xd2, 0xa5, 0xc5, 0x4a, 0x97, 0xde, 0x56, 0xba, 0xf4, - 0x70, 0xe6, 0x12, 0xfe, 0x14, 0x0d, 0x0d, 0x87, 0xfa, 0xa6, 0xd8, 0xe0, 0xc4, 0x43, 0x43, 0xf8, - 0xfa, 0x30, 0xc7, 0x2d, 0xcb, 0x9c, 0x6c, 0xde, 0x1a, 0x9f, 0x86, 0x18, 0x86, 0xa5, 0xe4, 0xd6, - 0x4e, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x81, 0x5c, 0x80, 0xff, 0x02, 0x00, 0x00, + // 382 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0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, 0x7c, 0xe9, 0x81, 0xff, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/superfluid/types/gov.go b/x/superfluid/types/gov.go index 49eb1f727fe..b2d8908a4a5 100644 --- a/x/superfluid/types/gov.go +++ b/x/superfluid/types/gov.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -12,6 +12,7 @@ import ( const ( ProposalTypeSetSuperfluidAssets = "SetSuperfluidAssets" ProposalTypeRemoveSuperfluidAssets = "RemoveSuperfluidAssets" + ProposalTypeUpdateUnpoolWhitelist = "UpdateUnpoolWhitelist" ) func init() { @@ -19,11 +20,14 @@ func init() { govtypes.RegisterProposalTypeCodec(&SetSuperfluidAssetsProposal{}, "osmosis/SetSuperfluidAssetsProposal") govtypes.RegisterProposalType(ProposalTypeRemoveSuperfluidAssets) govtypes.RegisterProposalTypeCodec(&RemoveSuperfluidAssetsProposal{}, "osmosis/RemoveSuperfluidAssetsProposal") + govtypes.RegisterProposalType(ProposalTypeUpdateUnpoolWhitelist) + govtypes.RegisterProposalTypeCodec(&UpdateUnpoolWhiteListProposal{}, "osmosis/UpdateUnpoolWhiteListProposal") } var ( _ govtypes.Content = &SetSuperfluidAssetsProposal{} _ govtypes.Content = &RemoveSuperfluidAssetsProposal{} + _ govtypes.Content = &UpdateUnpoolWhiteListProposal{} ) func NewSetSuperfluidAssetsProposal(title, description string, assets []SuperfluidAsset) govtypes.Content { @@ -108,3 +112,46 @@ func (p RemoveSuperfluidAssetsProposal) String() string { `, p.Title, p.Description, p.SuperfluidAssetDenoms)) return b.String() } + +func NewUpdateUnpoolWhitelistProposal(title, description string, poolIds []uint64, isOverwrite bool) govtypes.Content { + return &UpdateUnpoolWhiteListProposal{ + Title: title, + Description: description, + Ids: poolIds, + IsOverwrite: isOverwrite, + } +} + +func (p *UpdateUnpoolWhiteListProposal) GetTitle() string { return p.Title } + +func (p *UpdateUnpoolWhiteListProposal) GetDescription() string { return p.Description } + +func (p *UpdateUnpoolWhiteListProposal) ProposalRoute() string { return RouterKey } + +func (p *UpdateUnpoolWhiteListProposal) ProposalType() string { + return ProposalTypeUpdateUnpoolWhitelist +} + +func (p *UpdateUnpoolWhiteListProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(p) + if err != nil { + return err + } + + for _, id := range p.Ids { + if id == 0 { + return fmt.Errorf("pool id cannot be 0") + } + } + + return nil +} + +func (p UpdateUnpoolWhiteListProposal) String() string { + return fmt.Sprintf(`Update Unpool Whitelist Assets Proposal: + Title: %s + Description: %s + Pool Ids: %+v + IsOverwrite: %t + `, p.Title, p.Description, p.Ids, p.IsOverwrite) +} diff --git a/x/superfluid/types/gov.pb.go b/x/superfluid/types/gov.pb.go index 838b7efabda..321caa67679 100644 --- a/x/superfluid/types/gov.pb.go +++ b/x/superfluid/types/gov.pb.go @@ -103,9 +103,51 @@ func (m *RemoveSuperfluidAssetsProposal) XXX_DiscardUnknown() { var xxx_messageInfo_RemoveSuperfluidAssetsProposal proto.InternalMessageInfo +// UpdateUnpoolWhiteListProposal is a gov Content type to update the +// allowed list of pool ids. +type UpdateUnpoolWhiteListProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Ids []uint64 `protobuf:"varint,3,rep,packed,name=ids,proto3" json:"ids,omitempty"` + IsOverwrite bool `protobuf:"varint,4,opt,name=is_overwrite,json=isOverwrite,proto3" json:"is_overwrite,omitempty"` +} + +func (m *UpdateUnpoolWhiteListProposal) Reset() { *m = UpdateUnpoolWhiteListProposal{} } +func (*UpdateUnpoolWhiteListProposal) ProtoMessage() {} +func (*UpdateUnpoolWhiteListProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_2e37d6a8d0e42294, []int{2} +} +func (m *UpdateUnpoolWhiteListProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateUnpoolWhiteListProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateUnpoolWhiteListProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UpdateUnpoolWhiteListProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateUnpoolWhiteListProposal.Merge(m, src) +} +func (m *UpdateUnpoolWhiteListProposal) XXX_Size() int { + return m.Size() +} +func (m *UpdateUnpoolWhiteListProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateUnpoolWhiteListProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateUnpoolWhiteListProposal proto.InternalMessageInfo + func init() { proto.RegisterType((*SetSuperfluidAssetsProposal)(nil), "osmosis.superfluid.v1beta1.SetSuperfluidAssetsProposal") proto.RegisterType((*RemoveSuperfluidAssetsProposal)(nil), "osmosis.superfluid.v1beta1.RemoveSuperfluidAssetsProposal") + proto.RegisterType((*UpdateUnpoolWhiteListProposal)(nil), "osmosis.superfluid.v1beta1.UpdateUnpoolWhiteListProposal") } func init() { @@ -113,27 +155,31 @@ func init() { } var fileDescriptor_2e37d6a8d0e42294 = []byte{ - // 312 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0x2f, 0xce, 0xcd, - 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x2e, 0x2d, 0x48, 0x2d, 0x4a, 0xcb, 0x29, 0xcd, 0x4c, 0xd1, 0x2f, - 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0xcf, 0x2f, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x92, 0x82, 0xaa, 0xd2, 0x43, 0xa8, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x2b, 0xd3, 0x07, 0xb1, 0x20, 0x3a, 0xa4, 0x94, 0xb1, 0x98, 0x8b, 0xa4, 0x19, 0xac, 0x48, - 0x69, 0x19, 0x23, 0x97, 0x74, 0x70, 0x6a, 0x49, 0x30, 0x5c, 0xdc, 0xb1, 0xb8, 0x38, 0xb5, 0xa4, - 0x38, 0xa0, 0x28, 0xbf, 0x20, 0xbf, 0x38, 0x31, 0x47, 0x48, 0x84, 0x8b, 0xb5, 0x24, 0xb3, 0x24, - 0x27, 0x55, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc2, 0x11, 0x52, 0xe0, 0xe2, 0x4e, 0x49, - 0x2d, 0x4e, 0x2e, 0xca, 0x2c, 0x28, 0xc9, 0xcc, 0xcf, 0x93, 0x60, 0x02, 0xcb, 0x21, 0x0b, 0x09, - 0x39, 0x72, 0xb1, 0x25, 0x82, 0x4d, 0x92, 0x60, 0x56, 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd6, 0xc3, - 0xe2, 0x7e, 0x34, 0x5b, 0x9d, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0x6a, 0xb4, 0xe2, 0xe9, - 0x58, 0x20, 0xcf, 0x30, 0x63, 0x81, 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x8c, 0x4a, 0xf3, 0x18, 0xb9, - 0xe4, 0x82, 0x52, 0x73, 0xf3, 0xcb, 0x52, 0xa9, 0xee, 0x56, 0x33, 0x2e, 0x71, 0x84, 0xa3, 0xe2, - 0xc1, 0xb6, 0xc7, 0xa7, 0xa4, 0xe6, 0xe5, 0xe7, 0x42, 0x1c, 0xcf, 0x19, 0x24, 0x5a, 0x8c, 0x6a, - 0xa5, 0x0b, 0x58, 0x12, 0xd5, 0x81, 0x4e, 0x01, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, - 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, - 0xc7, 0x10, 0x65, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x0d, - 0x05, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x18, 0x47, 0xbf, 0xcc, 0xd0, 0x48, 0xbf, 0x02, 0x39, 0x9a, - 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x51, 0x64, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0x91, 0xf8, 0x30, 0xb1, 0x21, 0x02, 0x00, 0x00, + // 377 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xbf, 0x4e, 0xc2, 0x50, + 0x14, 0xc6, 0x7b, 0x05, 0x89, 0x5c, 0x18, 0x4c, 0x83, 0xb1, 0xc1, 0xd8, 0x56, 0x70, 0x60, 0xb1, + 0x0d, 0x92, 0x30, 0xb8, 0x41, 0x1c, 0x4d, 0x24, 0x25, 0xc4, 0xc4, 0x85, 0xb4, 0xf4, 0x5a, 0x6e, + 0xd2, 0x72, 0x9a, 0xde, 0x4b, 0xd5, 0x37, 0x70, 0x74, 0x34, 0x0e, 0x86, 0xc9, 0x67, 0x61, 0x64, + 0x74, 0x32, 0x06, 0x16, 0x1f, 0xc3, 0xd0, 0x16, 0xf9, 0x13, 0x36, 0xdd, 0xee, 0x39, 0xe7, 0xfb, + 0xce, 0xf7, 0x4b, 0xee, 0xc1, 0xa7, 0xc0, 0x3c, 0x60, 0x94, 0xe9, 0x6c, 0xe8, 0x93, 0xe0, 0xce, + 0x1d, 0x52, 0x5b, 0x0f,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, 0xf9, 0x53, 0x3c, 0xc1, 0x79, + 0xca, 0xba, 0x10, 0x92, 0xe0, 0x3e, 0xa0, 0x9c, 0x48, 0x69, 0x15, 0x55, 0xf6, 0x8c, 0x1c, 0x65, + 0xd7, 0x8b, 0xd6, 0x3a, 0x5c, 0xb3, 0x35, 0x9e, 0xca, 0x68, 0x32, 0x95, 0xd1, 0xd7, 0x54, 0x46, + 0xcf, 0x33, 0x59, 0x98, 0xcc, 0x64, 0xe1, 0x63, 0x26, 0x0b, 0xb7, 0x75, 0x87, 0xf2, 0xfe, 0xd0, + 0xd2, 0x7a, 0xe0, 0xe9, 0xc9, 0x17, 0x9d, 0xb9, 0xa6, 0xc5, 0x16, 0x85, 0x1e, 0x56, 0x6b, 0xfa, + 0xc3, 0xea, 0x0d, 0xf1, 0x47, 0x9f, 0x30, 0x2b, 0x13, 0xdd, 0x4f, 0xed, 0x27, 0x00, 0x00, 0xff, + 0xff, 0xbf, 0xed, 0xd6, 0xf0, 0xbe, 0x02, 0x00, 0x00, } func (this *SetSuperfluidAssetsProposal) Equal(that interface{}) bool { @@ -206,6 +252,44 @@ func (this *RemoveSuperfluidAssetsProposal) Equal(that interface{}) bool { } return true } +func (this *UpdateUnpoolWhiteListProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UpdateUnpoolWhiteListProposal) + if !ok { + that2, ok := that.(UpdateUnpoolWhiteListProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if len(this.Ids) != len(that1.Ids) { + return false + } + for i := range this.Ids { + if this.Ids[i] != that1.Ids[i] { + return false + } + } + if this.IsOverwrite != that1.IsOverwrite { + return false + } + return true +} func (m *SetSuperfluidAssetsProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -303,6 +387,71 @@ func (m *RemoveSuperfluidAssetsProposal) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *UpdateUnpoolWhiteListProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UpdateUnpoolWhiteListProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateUnpoolWhiteListProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsOverwrite { + i-- + if m.IsOverwrite { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.Ids) > 0 { + dAtA2 := make([]byte, len(m.Ids)*10) + var j1 int + for _, num := range m.Ids { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintGov(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintGov(dAtA []byte, offset int, v uint64) int { offset -= sovGov(v) base := offset @@ -360,6 +509,33 @@ func (m *RemoveSuperfluidAssetsProposal) Size() (n int) { return n } +func (m *UpdateUnpoolWhiteListProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if len(m.Ids) > 0 { + l = 0 + for _, e := range m.Ids { + l += sovGov(uint64(e)) + } + n += 1 + sovGov(uint64(l)) + l + } + if m.IsOverwrite { + n += 2 + } + return n +} + func sovGov(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -660,6 +836,216 @@ func (m *RemoveSuperfluidAssetsProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *UpdateUnpoolWhiteListProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UpdateUnpoolWhiteListProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateUnpoolWhiteListProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Ids) == 0 { + m.Ids = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsOverwrite", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsOverwrite = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGov(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/superfluid/types/msg_test.go b/x/superfluid/types/msg_test.go index 0273647399f..44657c0b93b 100644 --- a/x/superfluid/types/msg_test.go +++ b/x/superfluid/types/msg_test.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/superfluid/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/tendermint/tendermint/crypto/ed25519" ) diff --git a/x/superfluid/types/params.pb.go b/x/superfluid/types/params.pb.go index 6c5355acb94..f8f07a57388 100644 --- a/x/superfluid/types/params.pb.go +++ b/x/superfluid/types/params.pb.go @@ -89,8 +89,8 @@ var fileDescriptor_0985261dfaf2a82e = []byte{ 0x62, 0xa4, 0x52, 0x90, 0x20, 0x54, 0x34, 0x28, 0xb3, 0x38, 0xdb, 0x0d, 0x2c, 0xe6, 0x14, 0x70, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x66, 0x48, 0x56, 0x42, 0xfd, 0xad, - 0x9b, 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, 0x97, 0x19, 0x1a, 0xe9, 0x57, 0x20, 0x87, 0x15, 0xd8, - 0x19, 0x49, 0x6c, 0x60, 0x1f, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xdf, 0xda, 0x5d, 0xb3, + 0x9b, 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, 0x97, 0x19, 0x1a, 0xeb, 0x57, 0x20, 0x87, 0x15, 0xd8, + 0x19, 0x49, 0x6c, 0x60, 0x1f, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x27, 0xe8, 0xb2, 0x4e, 0x01, 0x00, 0x00, } diff --git a/x/superfluid/types/query.pb.go b/x/superfluid/types/query.pb.go index c35537233e8..6dc9bc2099c 100644 --- a/x/superfluid/types/query.pb.go +++ b/x/superfluid/types/query.pb.go @@ -14,7 +14,7 @@ import ( grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" - types1 "github.com/osmosis-labs/osmosis/v12/x/lockup/types" + types1 "github.com/osmosis-labs/osmosis/v13/x/lockup/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -624,6 +624,148 @@ func (m *ConnectedIntermediaryAccountResponse) GetAccount() *SuperfluidIntermedi return nil } +type QueryTotalDelegationByValidatorForDenomRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryTotalDelegationByValidatorForDenomRequest) Reset() { + *m = QueryTotalDelegationByValidatorForDenomRequest{} +} +func (m *QueryTotalDelegationByValidatorForDenomRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryTotalDelegationByValidatorForDenomRequest) ProtoMessage() {} +func (*QueryTotalDelegationByValidatorForDenomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e3d9448e4ed3943f, []int{13} +} +func (m *QueryTotalDelegationByValidatorForDenomRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalDelegationByValidatorForDenomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalDelegationByValidatorForDenomRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalDelegationByValidatorForDenomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalDelegationByValidatorForDenomRequest.Merge(m, src) +} +func (m *QueryTotalDelegationByValidatorForDenomRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalDelegationByValidatorForDenomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalDelegationByValidatorForDenomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalDelegationByValidatorForDenomRequest proto.InternalMessageInfo + +func (m *QueryTotalDelegationByValidatorForDenomRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type QueryTotalDelegationByValidatorForDenomResponse struct { + Assets []Delegations `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets"` +} + +func (m *QueryTotalDelegationByValidatorForDenomResponse) Reset() { + *m = QueryTotalDelegationByValidatorForDenomResponse{} +} +func (m *QueryTotalDelegationByValidatorForDenomResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryTotalDelegationByValidatorForDenomResponse) ProtoMessage() {} +func (*QueryTotalDelegationByValidatorForDenomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e3d9448e4ed3943f, []int{14} +} +func (m *QueryTotalDelegationByValidatorForDenomResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalDelegationByValidatorForDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalDelegationByValidatorForDenomResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalDelegationByValidatorForDenomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalDelegationByValidatorForDenomResponse.Merge(m, src) +} +func (m *QueryTotalDelegationByValidatorForDenomResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalDelegationByValidatorForDenomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalDelegationByValidatorForDenomResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalDelegationByValidatorForDenomResponse proto.InternalMessageInfo + +func (m *QueryTotalDelegationByValidatorForDenomResponse) GetAssets() []Delegations { + if m != nil { + return m.Assets + } + return nil +} + +type Delegations struct { + ValAddr string `protobuf:"bytes,1,opt,name=val_addr,json=valAddr,proto3" json:"val_addr,omitempty"` + AmountSfsd github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount_sfsd,json=amountSfsd,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount_sfsd" yaml:"amount_sfsd"` + OsmoEquivalent github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=osmo_equivalent,json=osmoEquivalent,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"osmo_equivalent" yaml:"osmo_equivalent"` +} + +func (m *Delegations) Reset() { *m = Delegations{} } +func (m *Delegations) String() string { return proto.CompactTextString(m) } +func (*Delegations) ProtoMessage() {} +func (*Delegations) Descriptor() ([]byte, []int) { + return fileDescriptor_e3d9448e4ed3943f, []int{15} +} +func (m *Delegations) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Delegations) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Delegations.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Delegations) XXX_Merge(src proto.Message) { + xxx_messageInfo_Delegations.Merge(m, src) +} +func (m *Delegations) XXX_Size() int { + return m.Size() +} +func (m *Delegations) XXX_DiscardUnknown() { + xxx_messageInfo_Delegations.DiscardUnknown(m) +} + +var xxx_messageInfo_Delegations proto.InternalMessageInfo + +func (m *Delegations) GetValAddr() string { + if m != nil { + return m.ValAddr + } + return "" +} + type TotalSuperfluidDelegationsRequest struct { } @@ -631,7 +773,7 @@ func (m *TotalSuperfluidDelegationsRequest) Reset() { *m = TotalSuperflu func (m *TotalSuperfluidDelegationsRequest) String() string { return proto.CompactTextString(m) } func (*TotalSuperfluidDelegationsRequest) ProtoMessage() {} func (*TotalSuperfluidDelegationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{13} + return fileDescriptor_e3d9448e4ed3943f, []int{16} } func (m *TotalSuperfluidDelegationsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -668,7 +810,7 @@ func (m *TotalSuperfluidDelegationsResponse) Reset() { *m = TotalSuperfl func (m *TotalSuperfluidDelegationsResponse) String() string { return proto.CompactTextString(m) } func (*TotalSuperfluidDelegationsResponse) ProtoMessage() {} func (*TotalSuperfluidDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{14} + return fileDescriptor_e3d9448e4ed3943f, []int{17} } func (m *TotalSuperfluidDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -707,7 +849,7 @@ func (m *SuperfluidDelegationAmountRequest) Reset() { *m = SuperfluidDel func (m *SuperfluidDelegationAmountRequest) String() string { return proto.CompactTextString(m) } func (*SuperfluidDelegationAmountRequest) ProtoMessage() {} func (*SuperfluidDelegationAmountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{15} + return fileDescriptor_e3d9448e4ed3943f, []int{18} } func (m *SuperfluidDelegationAmountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -765,7 +907,7 @@ func (m *SuperfluidDelegationAmountResponse) Reset() { *m = SuperfluidDe func (m *SuperfluidDelegationAmountResponse) String() string { return proto.CompactTextString(m) } func (*SuperfluidDelegationAmountResponse) ProtoMessage() {} func (*SuperfluidDelegationAmountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{16} + return fileDescriptor_e3d9448e4ed3943f, []int{19} } func (m *SuperfluidDelegationAmountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -811,7 +953,7 @@ func (m *SuperfluidDelegationsByDelegatorRequest) Reset() { func (m *SuperfluidDelegationsByDelegatorRequest) String() string { return proto.CompactTextString(m) } func (*SuperfluidDelegationsByDelegatorRequest) ProtoMessage() {} func (*SuperfluidDelegationsByDelegatorRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{17} + return fileDescriptor_e3d9448e4ed3943f, []int{20} } func (m *SuperfluidDelegationsByDelegatorRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -859,7 +1001,7 @@ func (m *SuperfluidDelegationsByDelegatorResponse) Reset() { func (m *SuperfluidDelegationsByDelegatorResponse) String() string { return proto.CompactTextString(m) } func (*SuperfluidDelegationsByDelegatorResponse) ProtoMessage() {} func (*SuperfluidDelegationsByDelegatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{18} + return fileDescriptor_e3d9448e4ed3943f, []int{21} } func (m *SuperfluidDelegationsByDelegatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -922,7 +1064,7 @@ func (m *SuperfluidUndelegationsByDelegatorRequest) String() string { } func (*SuperfluidUndelegationsByDelegatorRequest) ProtoMessage() {} func (*SuperfluidUndelegationsByDelegatorRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{19} + return fileDescriptor_e3d9448e4ed3943f, []int{22} } func (m *SuperfluidUndelegationsByDelegatorRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -979,7 +1121,7 @@ func (m *SuperfluidUndelegationsByDelegatorResponse) String() string { } func (*SuperfluidUndelegationsByDelegatorResponse) ProtoMessage() {} func (*SuperfluidUndelegationsByDelegatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{20} + return fileDescriptor_e3d9448e4ed3943f, []int{23} } func (m *SuperfluidUndelegationsByDelegatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1042,7 +1184,7 @@ func (m *SuperfluidDelegationsByValidatorDenomRequest) String() string { } func (*SuperfluidDelegationsByValidatorDenomRequest) ProtoMessage() {} func (*SuperfluidDelegationsByValidatorDenomRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{21} + return fileDescriptor_e3d9448e4ed3943f, []int{24} } func (m *SuperfluidDelegationsByValidatorDenomRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1097,7 +1239,7 @@ func (m *SuperfluidDelegationsByValidatorDenomResponse) String() string { } func (*SuperfluidDelegationsByValidatorDenomResponse) ProtoMessage() {} func (*SuperfluidDelegationsByValidatorDenomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{22} + return fileDescriptor_e3d9448e4ed3943f, []int{25} } func (m *SuperfluidDelegationsByValidatorDenomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1146,7 +1288,7 @@ func (m *EstimateSuperfluidDelegatedAmountByValidatorDenomRequest) String() stri } func (*EstimateSuperfluidDelegatedAmountByValidatorDenomRequest) ProtoMessage() {} func (*EstimateSuperfluidDelegatedAmountByValidatorDenomRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{23} + return fileDescriptor_e3d9448e4ed3943f, []int{26} } func (m *EstimateSuperfluidDelegatedAmountByValidatorDenomRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1201,7 +1343,7 @@ func (m *EstimateSuperfluidDelegatedAmountByValidatorDenomResponse) String() str } func (*EstimateSuperfluidDelegatedAmountByValidatorDenomResponse) ProtoMessage() {} func (*EstimateSuperfluidDelegatedAmountByValidatorDenomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{24} + return fileDescriptor_e3d9448e4ed3943f, []int{27} } func (m *EstimateSuperfluidDelegatedAmountByValidatorDenomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1247,7 +1389,7 @@ func (m *QueryTotalDelegationByDelegatorRequest) Reset() { func (m *QueryTotalDelegationByDelegatorRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalDelegationByDelegatorRequest) ProtoMessage() {} func (*QueryTotalDelegationByDelegatorRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{25} + return fileDescriptor_e3d9448e4ed3943f, []int{28} } func (m *QueryTotalDelegationByDelegatorRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1296,7 +1438,7 @@ func (m *QueryTotalDelegationByDelegatorResponse) Reset() { func (m *QueryTotalDelegationByDelegatorResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalDelegationByDelegatorResponse) ProtoMessage() {} func (*QueryTotalDelegationByDelegatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3d9448e4ed3943f, []int{26} + return fileDescriptor_e3d9448e4ed3943f, []int{29} } func (m *QueryTotalDelegationByDelegatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1353,6 +1495,86 @@ func (m *QueryTotalDelegationByDelegatorResponse) GetTotalEquivalentStakedAmount return types.Coin{} } +type QueryUnpoolWhitelistRequest struct { +} + +func (m *QueryUnpoolWhitelistRequest) Reset() { *m = QueryUnpoolWhitelistRequest{} } +func (m *QueryUnpoolWhitelistRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUnpoolWhitelistRequest) ProtoMessage() {} +func (*QueryUnpoolWhitelistRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e3d9448e4ed3943f, []int{30} +} +func (m *QueryUnpoolWhitelistRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnpoolWhitelistRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnpoolWhitelistRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryUnpoolWhitelistRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnpoolWhitelistRequest.Merge(m, src) +} +func (m *QueryUnpoolWhitelistRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUnpoolWhitelistRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnpoolWhitelistRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnpoolWhitelistRequest proto.InternalMessageInfo + +type QueryUnpoolWhitelistResponse struct { + PoolIds []uint64 `protobuf:"varint,1,rep,packed,name=pool_ids,json=poolIds,proto3" json:"pool_ids,omitempty"` +} + +func (m *QueryUnpoolWhitelistResponse) Reset() { *m = QueryUnpoolWhitelistResponse{} } +func (m *QueryUnpoolWhitelistResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUnpoolWhitelistResponse) ProtoMessage() {} +func (*QueryUnpoolWhitelistResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e3d9448e4ed3943f, []int{31} +} +func (m *QueryUnpoolWhitelistResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnpoolWhitelistResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnpoolWhitelistResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryUnpoolWhitelistResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnpoolWhitelistResponse.Merge(m, src) +} +func (m *QueryUnpoolWhitelistResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUnpoolWhitelistResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnpoolWhitelistResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnpoolWhitelistResponse proto.InternalMessageInfo + +func (m *QueryUnpoolWhitelistResponse) GetPoolIds() []uint64 { + if m != nil { + return m.PoolIds + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.superfluid.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.superfluid.QueryParamsResponse") @@ -1367,6 +1589,9 @@ func init() { proto.RegisterType((*AllIntermediaryAccountsResponse)(nil), "osmosis.superfluid.AllIntermediaryAccountsResponse") proto.RegisterType((*ConnectedIntermediaryAccountRequest)(nil), "osmosis.superfluid.ConnectedIntermediaryAccountRequest") proto.RegisterType((*ConnectedIntermediaryAccountResponse)(nil), "osmosis.superfluid.ConnectedIntermediaryAccountResponse") + proto.RegisterType((*QueryTotalDelegationByValidatorForDenomRequest)(nil), "osmosis.superfluid.QueryTotalDelegationByValidatorForDenomRequest") + proto.RegisterType((*QueryTotalDelegationByValidatorForDenomResponse)(nil), "osmosis.superfluid.QueryTotalDelegationByValidatorForDenomResponse") + proto.RegisterType((*Delegations)(nil), "osmosis.superfluid.Delegations") proto.RegisterType((*TotalSuperfluidDelegationsRequest)(nil), "osmosis.superfluid.TotalSuperfluidDelegationsRequest") proto.RegisterType((*TotalSuperfluidDelegationsResponse)(nil), "osmosis.superfluid.TotalSuperfluidDelegationsResponse") proto.RegisterType((*SuperfluidDelegationAmountRequest)(nil), "osmosis.superfluid.SuperfluidDelegationAmountRequest") @@ -1381,116 +1606,131 @@ func init() { proto.RegisterType((*EstimateSuperfluidDelegatedAmountByValidatorDenomResponse)(nil), "osmosis.superfluid.EstimateSuperfluidDelegatedAmountByValidatorDenomResponse") proto.RegisterType((*QueryTotalDelegationByDelegatorRequest)(nil), "osmosis.superfluid.QueryTotalDelegationByDelegatorRequest") proto.RegisterType((*QueryTotalDelegationByDelegatorResponse)(nil), "osmosis.superfluid.QueryTotalDelegationByDelegatorResponse") + proto.RegisterType((*QueryUnpoolWhitelistRequest)(nil), "osmosis.superfluid.QueryUnpoolWhitelistRequest") + proto.RegisterType((*QueryUnpoolWhitelistResponse)(nil), "osmosis.superfluid.QueryUnpoolWhitelistResponse") } func init() { proto.RegisterFile("osmosis/superfluid/query.proto", fileDescriptor_e3d9448e4ed3943f) } var fileDescriptor_e3d9448e4ed3943f = []byte{ - // 1662 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x59, 0x4b, 0x6c, 0xd4, 0xc6, - 0x1b, 0xcf, 0x24, 0x21, 0x81, 0x0f, 0x09, 0x92, 0x01, 0xfe, 0x09, 0x06, 0x36, 0xe0, 0x84, 0x24, - 0xff, 0x00, 0x76, 0x13, 0x0a, 0xa4, 0x50, 0x10, 0x1b, 0x02, 0x34, 0x52, 0xd2, 0xd0, 0x25, 0x09, - 0x52, 0x1f, 0xb2, 0x9c, 0xf5, 0xb0, 0x58, 0xf1, 0xda, 0x9b, 0x1d, 0x6f, 0xca, 0x0a, 0xa1, 0x4a, - 0x54, 0x95, 0x8a, 0x7a, 0x68, 0x25, 0x4e, 0x3d, 0xb5, 0x57, 0x7a, 0xe8, 0xb5, 0x97, 0x5e, 0xaa, - 0x5e, 0x90, 0xaa, 0x4a, 0x48, 0xbd, 0x54, 0x3d, 0x40, 0x05, 0x3d, 0xb6, 0x97, 0x1e, 0xdb, 0x4b, - 0xe5, 0x99, 0xf1, 0x63, 0xb3,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0xec, 0x77, 0x7f, 0x82, 0xc7, 0xde, 0xe4, 0xf1, 0xe9, - 0xc4, 0x4b, 0x59, 0xe6, 0x5a, 0x21, 0x9d, 0xd9, 0x94, 0xac, 0x40, 0xbd, 0xc8, 0x50, 0xcf, 0xe3, - 0xb9, 0x34, 0xd4, 0xeb, 0xbf, 0x70, 0x66, 0x76, 0xc7, 0xd4, 0x95, 0x07, 0x4f, 0x72, 0xe8, 0xe1, - 0x93, 0x1c, 0xfa, 0xf5, 0x49, 0x0e, 0x7d, 0xf6, 0x34, 0xd7, 0xf6, 0xf0, 0x69, 0xae, 0xed, 0xe7, - 0xa7, 0xb9, 0xb6, 0xb7, 0x4f, 0x46, 0x6e, 0xc0, 0xc2, 0xe4, 0x31, 0x4b, 0x5f, 0xa6, 0x81, 0xfd, - 0xb5, 0xf1, 0x09, 0xf5, 0x66, 0xd4, 0x0b, 0x76, 0x2b, 0x5e, 0xee, 0x62, 0xff, 0x49, 0x3a, 0xfe, - 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x57, 0xa3, 0x99, 0xea, 0xc7, 0x1b, 0x00, 0x00, + // 1858 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x59, 0x4b, 0x6c, 0xd4, 0xdc, + 0x15, 0x8e, 0x27, 0xf9, 0x13, 0x72, 0x22, 0x91, 0xe4, 0x42, 0xff, 0x24, 0x06, 0x26, 0xfc, 0x4e, + 0x48, 0xd2, 0x00, 0x36, 0x09, 0x05, 0x02, 0x14, 0xc4, 0x0c, 0x21, 0x10, 0x29, 0x69, 0xe8, 0x84, + 0x04, 0xa9, 0x0f, 0x59, 0xce, 0xf8, 0x66, 0x62, 0xc5, 0x63, 0x4f, 0xe6, 0x7a, 0x02, 0x23, 0x84, + 0x2a, 0xa5, 0xaa, 0x54, 0xd4, 0x45, 0x2b, 0xb1, 0xea, 0xae, 0x5b, 0x58, 0xb4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 0x9a, 0x57, 0x36, 0xe2, 0x99, + 0x36, 0x54, 0xdc, 0x0c, 0x99, 0x9a, 0x31, 0x83, 0xa6, 0x92, 0xcc, 0x08, 0x16, 0x3a, 0xcc, 0x14, + 0x6f, 0x07, 0x13, 0x63, 0x4a, 0xd3, 0xda, 0x26, 0xc6, 0x94, 0xe6, 0x45, 0x4e, 0x4a, 0x53, 0x4c, + 0x53, 0x65, 0x83, 0x1c, 0xfa, 0x95, 0x00, 0x83, 0x4d, 0x5b, 0x18, 0x34, 0x1b, 0x8b, 0xba, 0x65, + 0xb7, 0x23, 0x9e, 0x4d, 0x45, 0xcb, 0x8d, 0xfb, 0x16, 0x35, 0x4e, 0x46, 0xe7, 0xda, 0xfb, 0x29, + 0x58, 0xf7, 0xa0, 0xdf, 0x0b, 0x30, 0x12, 0xb3, 0xa4, 0x40, 0xf3, 0x31, 0x5e, 0x49, 0x58, 0x9e, + 0x88, 0x17, 0x3b, 0xe2, 0xe1, 0xa6, 0xdf, 0xa0, 0xa6, 0x5f, 0x41, 0x97, 0xda, 0xf9, 0xd5, 0x08, + 0x49, 0x51, 0xfd, 0x5d, 0xc7, 0x5b, 0x01, 0x4e, 0x26, 0xed, 0x18, 0xd0, 0x95, 0x28, 0xa3, 0x52, + 0x6c, 0x35, 0xc4, 0x85, 0xce, 0x19, 0x39, 0xa4, 0x15, 0x0a, 0x69, 0x09, 0x2d, 0x26, 0x41, 0x2a, + 0x7a, 0x92, 0x22, 0x81, 0x29, 0x4f, 0xf8, 0x46, 0xe5, 0x29, 0xfa, 0x8d, 0x37, 0xe7, 0x26, 0xee, + 0x1f, 0x50, 0x3e, 0xb6, 0xb4, 0x53, 0x2f, 0x41, 0xc4, 0xdb, 0x1f, 0x24, 0x83, 0xa3, 0xef, 0x42, + 0x7f, 0x14, 0x40, 0x8c, 0x9f, 0xcc, 0x51, 0xe4, 0x72, 0xa7, 0xed, 0xbc, 0x2f, 0x5e, 0xee, 0x94, + 0x8d, 0xdb, 0x73, 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xc2, 0x5c, 0xbc, 0x9a, 0xd4, 0x10, + 0xa2, 0x1c, 0xf6, 0x0f, 0xaf, 0x83, 0x47, 0x4e, 0x35, 0xe8, 0x5a, 0xfa, 0x7b, 0xa2, 0xa5, 0x50, + 0xae, 0x1f, 0x8a, 0x97, 0xa3, 0xde, 0xa0, 0xa8, 0xd7, 0xd0, 0x6a, 0x12, 0xea, 0xe6, 0x6d, 0x6f, + 0xfb, 0xea, 0x78, 0x29, 0xc0, 0x60, 0xd3, 0xa7, 0x38, 0x52, 0x62, 0xed, 0x8c, 0xfe, 0xa6, 0x17, + 0x2f, 0xa4, 0x67, 0xe8, 0xe4, 0xab, 0xad, 0x46, 0x99, 0xd5, 0x47, 0x1e, 0x77, 0xfe, 0xfe, 0xab, + 0x77, 0x59, 0xe1, 0xf5, 0xbb, 0xac, 0xf0, 0xb7, 0x77, 0x59, 0xe1, 0x17, 0xef, 0xb3, 0x5d, 0xaf, + 0xdf, 0x67, 0xbb, 0xfe, 0xf2, 0x3e, 0xdb, 0xf5, 0xbd, 0xcb, 0xa1, 0xd1, 0x85, 0x4b, 0x3c, 0x6f, + 0x6a, 0x5b, 0xc4, 0x17, 0xbf, 0x3f, 0x77, 0x51, 0x79, 0x1c, 0x56, 0x42, 0xc7, 0x99, 0xad, 0x5e, + 0xfa, 0x1f, 0xdc, 0x8b, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xb9, 0x77, 0x9e, 0x3f, 0x1f, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1518,6 +1758,8 @@ type QueryClient interface { AllIntermediaryAccounts(ctx context.Context, in *AllIntermediaryAccountsRequest, opts ...grpc.CallOption) (*AllIntermediaryAccountsResponse, error) // Returns intermediary account connected to a superfluid staked lock by id ConnectedIntermediaryAccount(ctx context.Context, in *ConnectedIntermediaryAccountRequest, opts ...grpc.CallOption) (*ConnectedIntermediaryAccountResponse, error) + // Returns the amount of delegations of specific denom for all validators + TotalDelegationByValidatorForDenom(ctx context.Context, in *QueryTotalDelegationByValidatorForDenomRequest, opts ...grpc.CallOption) (*QueryTotalDelegationByValidatorForDenomResponse, error) // Returns the total amount of osmo superfluidly staked. // Response is denominated in uosmo. TotalSuperfluidDelegations(ctx context.Context, in *TotalSuperfluidDelegationsRequest, opts ...grpc.CallOption) (*TotalSuperfluidDelegationsResponse, error) @@ -1537,6 +1779,8 @@ type QueryClient interface { EstimateSuperfluidDelegatedAmountByValidatorDenom(ctx context.Context, in *EstimateSuperfluidDelegatedAmountByValidatorDenomRequest, opts ...grpc.CallOption) (*EstimateSuperfluidDelegatedAmountByValidatorDenomResponse, error) // Returns the specified delegations for a specific delegator TotalDelegationByDelegator(ctx context.Context, in *QueryTotalDelegationByDelegatorRequest, opts ...grpc.CallOption) (*QueryTotalDelegationByDelegatorResponse, error) + // Returns a list of whitelisted pool ids to unpool. + UnpoolWhitelist(ctx context.Context, in *QueryUnpoolWhitelistRequest, opts ...grpc.CallOption) (*QueryUnpoolWhitelistResponse, error) } type queryClient struct { @@ -1601,6 +1845,15 @@ func (c *queryClient) ConnectedIntermediaryAccount(ctx context.Context, in *Conn return out, nil } +func (c *queryClient) TotalDelegationByValidatorForDenom(ctx context.Context, in *QueryTotalDelegationByValidatorForDenomRequest, opts ...grpc.CallOption) (*QueryTotalDelegationByValidatorForDenomResponse, error) { + out := new(QueryTotalDelegationByValidatorForDenomResponse) + err := c.cc.Invoke(ctx, "/osmosis.superfluid.Query/TotalDelegationByValidatorForDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) TotalSuperfluidDelegations(ctx context.Context, in *TotalSuperfluidDelegationsRequest, opts ...grpc.CallOption) (*TotalSuperfluidDelegationsResponse, error) { out := new(TotalSuperfluidDelegationsResponse) err := c.cc.Invoke(ctx, "/osmosis.superfluid.Query/TotalSuperfluidDelegations", in, out, opts...) @@ -1664,6 +1917,15 @@ func (c *queryClient) TotalDelegationByDelegator(ctx context.Context, in *QueryT return out, nil } +func (c *queryClient) UnpoolWhitelist(ctx context.Context, in *QueryUnpoolWhitelistRequest, opts ...grpc.CallOption) (*QueryUnpoolWhitelistResponse, error) { + out := new(QueryUnpoolWhitelistResponse) + err := c.cc.Invoke(ctx, "/osmosis.superfluid.Query/UnpoolWhitelist", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params returns the total set of superfluid parameters. @@ -1679,6 +1941,8 @@ type QueryServer interface { AllIntermediaryAccounts(context.Context, *AllIntermediaryAccountsRequest) (*AllIntermediaryAccountsResponse, error) // Returns intermediary account connected to a superfluid staked lock by id ConnectedIntermediaryAccount(context.Context, *ConnectedIntermediaryAccountRequest) (*ConnectedIntermediaryAccountResponse, error) + // Returns the amount of delegations of specific denom for all validators + TotalDelegationByValidatorForDenom(context.Context, *QueryTotalDelegationByValidatorForDenomRequest) (*QueryTotalDelegationByValidatorForDenomResponse, error) // Returns the total amount of osmo superfluidly staked. // Response is denominated in uosmo. TotalSuperfluidDelegations(context.Context, *TotalSuperfluidDelegationsRequest) (*TotalSuperfluidDelegationsResponse, error) @@ -1698,6 +1962,8 @@ type QueryServer interface { EstimateSuperfluidDelegatedAmountByValidatorDenom(context.Context, *EstimateSuperfluidDelegatedAmountByValidatorDenomRequest) (*EstimateSuperfluidDelegatedAmountByValidatorDenomResponse, error) // Returns the specified delegations for a specific delegator TotalDelegationByDelegator(context.Context, *QueryTotalDelegationByDelegatorRequest) (*QueryTotalDelegationByDelegatorResponse, error) + // Returns a list of whitelisted pool ids to unpool. + UnpoolWhitelist(context.Context, *QueryUnpoolWhitelistRequest) (*QueryUnpoolWhitelistResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1722,6 +1988,9 @@ func (*UnimplementedQueryServer) AllIntermediaryAccounts(ctx context.Context, re func (*UnimplementedQueryServer) ConnectedIntermediaryAccount(ctx context.Context, req *ConnectedIntermediaryAccountRequest) (*ConnectedIntermediaryAccountResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ConnectedIntermediaryAccount not implemented") } +func (*UnimplementedQueryServer) TotalDelegationByValidatorForDenom(ctx context.Context, req *QueryTotalDelegationByValidatorForDenomRequest) (*QueryTotalDelegationByValidatorForDenomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalDelegationByValidatorForDenom not implemented") +} func (*UnimplementedQueryServer) TotalSuperfluidDelegations(ctx context.Context, req *TotalSuperfluidDelegationsRequest) (*TotalSuperfluidDelegationsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalSuperfluidDelegations not implemented") } @@ -1743,6 +2012,9 @@ func (*UnimplementedQueryServer) EstimateSuperfluidDelegatedAmountByValidatorDen func (*UnimplementedQueryServer) TotalDelegationByDelegator(ctx context.Context, req *QueryTotalDelegationByDelegatorRequest) (*QueryTotalDelegationByDelegatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalDelegationByDelegator not implemented") } +func (*UnimplementedQueryServer) UnpoolWhitelist(ctx context.Context, req *QueryUnpoolWhitelistRequest) (*QueryUnpoolWhitelistResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnpoolWhitelist not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1856,6 +2128,24 @@ func _Query_ConnectedIntermediaryAccount_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _Query_TotalDelegationByValidatorForDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalDelegationByValidatorForDenomRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalDelegationByValidatorForDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.superfluid.Query/TotalDelegationByValidatorForDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalDelegationByValidatorForDenom(ctx, req.(*QueryTotalDelegationByValidatorForDenomRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_TotalSuperfluidDelegations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(TotalSuperfluidDelegationsRequest) if err := dec(in); err != nil { @@ -1982,6 +2272,24 @@ func _Query_TotalDelegationByDelegator_Handler(srv interface{}, ctx context.Cont return interceptor(ctx, in, info, handler) } +func _Query_UnpoolWhitelist_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUnpoolWhitelistRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).UnpoolWhitelist(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.superfluid.Query/UnpoolWhitelist", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).UnpoolWhitelist(ctx, req.(*QueryUnpoolWhitelistRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.superfluid.Query", HandlerType: (*QueryServer)(nil), @@ -2010,6 +2318,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ConnectedIntermediaryAccount", Handler: _Query_ConnectedIntermediaryAccount_Handler, }, + { + MethodName: "TotalDelegationByValidatorForDenom", + Handler: _Query_TotalDelegationByValidatorForDenom_Handler, + }, { MethodName: "TotalSuperfluidDelegations", Handler: _Query_TotalSuperfluidDelegations_Handler, @@ -2038,6 +2350,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TotalDelegationByDelegator", Handler: _Query_TotalDelegationByDelegator_Handler, }, + { + MethodName: "UnpoolWhitelist", + Handler: _Query_UnpoolWhitelist_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "osmosis/superfluid/query.proto", @@ -2478,7 +2794,7 @@ func (m *ConnectedIntermediaryAccountResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *TotalSuperfluidDelegationsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalDelegationByValidatorForDenomRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2488,20 +2804,27 @@ func (m *TotalSuperfluidDelegationsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *TotalSuperfluidDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalDelegationByValidatorForDenomRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *TotalSuperfluidDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalDelegationByValidatorForDenomRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } -func (m *TotalSuperfluidDelegationsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalDelegationByValidatorForDenomResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2511,30 +2834,34 @@ func (m *TotalSuperfluidDelegationsResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *TotalSuperfluidDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalDelegationByValidatorForDenomResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *TotalSuperfluidDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalDelegationByValidatorForDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size := m.TotalDelegations.Size() - i -= size - if _, err := m.TotalDelegations.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.Assets) > 0 { + for iNdEx := len(m.Assets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Assets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - i = encodeVarintQuery(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *SuperfluidDelegationAmountRequest) Marshal() (dAtA []byte, err error) { +func (m *Delegations) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2544,25 +2871,131 @@ func (m *SuperfluidDelegationAmountRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SuperfluidDelegationAmountRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *Delegations) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SuperfluidDelegationAmountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Delegations) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x1a + { + size := m.OsmoEquivalent.Size() + i -= size + if _, err := m.OsmoEquivalent.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) + i-- + dAtA[i] = 0x1a + { + size := m.AmountSfsd.Size() + i -= size + if _, err := m.AmountSfsd.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ValAddr) > 0 { + i -= len(m.ValAddr) + copy(dAtA[i:], m.ValAddr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TotalSuperfluidDelegationsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TotalSuperfluidDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TotalSuperfluidDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *TotalSuperfluidDelegationsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TotalSuperfluidDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TotalSuperfluidDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TotalDelegations.Size() + i -= size + if _, err := m.TotalDelegations.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *SuperfluidDelegationAmountRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SuperfluidDelegationAmountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SuperfluidDelegationAmountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x1a + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) copy(dAtA[i:], m.ValidatorAddress) i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) i-- @@ -3061,6 +3494,70 @@ func (m *QueryTotalDelegationByDelegatorResponse) MarshalToSizedBuffer(dAtA []by return len(dAtA) - i, nil } +func (m *QueryUnpoolWhitelistRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryUnpoolWhitelistRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnpoolWhitelistRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryUnpoolWhitelistResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryUnpoolWhitelistResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnpoolWhitelistResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PoolIds) > 0 { + dAtA9 := make([]byte, len(m.PoolIds)*10) + var j8 int + for _, num := range m.PoolIds { + for num >= 1<<7 { + dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j8++ + } + dAtA9[j8] = uint8(num) + j8++ + } + i -= j8 + copy(dAtA[i:], dAtA9[:j8]) + i = encodeVarintQuery(dAtA, i, uint64(j8)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -3248,6 +3745,51 @@ func (m *ConnectedIntermediaryAccountResponse) Size() (n int) { return n } +func (m *QueryTotalDelegationByValidatorForDenomRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTotalDelegationByValidatorForDenomResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Assets) > 0 { + for _, e := range m.Assets { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *Delegations) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValAddr) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.AmountSfsd.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.OsmoEquivalent.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *TotalSuperfluidDelegationsRequest) Size() (n int) { if m == nil { return 0 @@ -3490,6 +4032,31 @@ func (m *QueryTotalDelegationByDelegatorResponse) Size() (n int) { return n } +func (m *QueryUnpoolWhitelistRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryUnpoolWhitelistResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PoolIds) > 0 { + l = 0 + for _, e := range m.PoolIds { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4608,7 +5175,7 @@ func (m *ConnectedIntermediaryAccountResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *TotalSuperfluidDelegationsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryTotalDelegationByValidatorForDenomRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4631,12 +5198,44 @@ func (m *TotalSuperfluidDelegationsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TotalSuperfluidDelegationsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalDelegationByValidatorForDenomRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TotalSuperfluidDelegationsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalDelegationByValidatorForDenomRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4658,7 +5257,7 @@ func (m *TotalSuperfluidDelegationsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *TotalSuperfluidDelegationsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryTotalDelegationByValidatorForDenomResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4681,17 +5280,17 @@ func (m *TotalSuperfluidDelegationsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TotalSuperfluidDelegationsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalDelegationByValidatorForDenomResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TotalSuperfluidDelegationsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalDelegationByValidatorForDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalDelegations", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Assets", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4701,23 +5300,307 @@ func (m *TotalSuperfluidDelegationsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TotalDelegations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Assets = append(m.Assets, Delegations{}) + if err := m.Assets[len(m.Assets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Delegations) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Delegations: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Delegations: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountSfsd", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AmountSfsd.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmoEquivalent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OsmoEquivalent.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TotalSuperfluidDelegationsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TotalSuperfluidDelegationsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TotalSuperfluidDelegationsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TotalSuperfluidDelegationsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TotalSuperfluidDelegationsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TotalSuperfluidDelegationsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalDelegations", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalDelegations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -6134,6 +7017,182 @@ func (m *QueryTotalDelegationByDelegatorResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryUnpoolWhitelistRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUnpoolWhitelistRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnpoolWhitelistRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUnpoolWhitelistResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUnpoolWhitelistResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnpoolWhitelistResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolIds = append(m.PoolIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PoolIds) == 0 { + m.PoolIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolIds = append(m.PoolIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PoolIds", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/superfluid/types/query.pb.gw.go b/x/superfluid/types/query.pb.gw.go index 71178790d6a..8b4b78a59c9 100644 --- a/x/superfluid/types/query.pb.gw.go +++ b/x/superfluid/types/query.pb.gw.go @@ -537,6 +537,24 @@ func local_request_Query_TotalDelegationByDelegator_0(ctx context.Context, marsh } +func request_Query_UnpoolWhitelist_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUnpoolWhitelistRequest + var metadata runtime.ServerMetadata + + msg, err := client.UnpoolWhitelist(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_UnpoolWhitelist_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUnpoolWhitelistRequest + var metadata runtime.ServerMetadata + + msg, err := server.UnpoolWhitelist(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -842,6 +860,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_UnpoolWhitelist_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_UnpoolWhitelist_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_UnpoolWhitelist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1143,6 +1184,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_UnpoolWhitelist_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_UnpoolWhitelist_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_UnpoolWhitelist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1172,6 +1233,8 @@ var ( pattern_Query_EstimateSuperfluidDelegatedAmountByValidatorDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "superfluid", "v1beta1", "estimate_superfluid_delegation_amount_by_validator_denom"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_TotalDelegationByDelegator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"osmosis", "superfluid", "v1beta1", "total_delegation_by_delegator", "delegator_address"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_UnpoolWhitelist_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "superfluid", "v1beta1", "unpool_whitelist"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1200,4 +1263,6 @@ var ( forward_Query_EstimateSuperfluidDelegatedAmountByValidatorDenom_0 = runtime.ForwardResponseMessage forward_Query_TotalDelegationByDelegator_0 = runtime.ForwardResponseMessage + + forward_Query_UnpoolWhitelist_0 = runtime.ForwardResponseMessage ) diff --git a/x/superfluid/types/superfluid.pb.go b/x/superfluid/types/superfluid.pb.go index 6085e63d4ab..dbe405df4db 100644 --- a/x/superfluid/types/superfluid.pb.go +++ b/x/superfluid/types/superfluid.pb.go @@ -404,51 +404,51 @@ func init() { } var fileDescriptor_79d3c29d82dbb734 = []byte{ - // 694 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x4f, 0xd4, 0x40, - 0x14, 0xdf, 0xb2, 0x2b, 0xb0, 0x83, 0xd1, 0xa5, 0x10, 0x5c, 0x36, 0xa1, 0x8b, 0x25, 0x91, 0x0d, - 0x84, 0x36, 0x8b, 0x89, 0x07, 0x6e, 0x0b, 0x68, 0x42, 0x82, 0x48, 0x8a, 0xc6, 0x84, 0xcb, 0x66, - 0xda, 0x19, 0xba, 0x93, 0x9d, 0x76, 0x4a, 0x67, 0x5a, 0xdd, 0x9b, 0x47, 0x8e, 0x7e, 0x04, 0x12, - 0x6f, 0x7e, 0x08, 0xcf, 0x1c, 0x39, 0x1a, 0x0f, 0x68, 0xe0, 0xe2, 0x99, 0x4f, 0x60, 0x3a, 0xed, - 0x76, 0x2b, 0x60, 0xd4, 0x53, 0x67, 0xde, 0xef, 0xbd, 0xdf, 0xfb, 0xbd, 0x3f, 0x1d, 0xb0, 0xc4, - 0xb8, 0xc7, 0x38, 0xe1, 0x26, 0x8f, 0x02, 0x1c, 0x1e, 0xd1, 0x88, 0xa0, 0xc2, 0xd1, 0x08, 0x42, - 0x26, 0x98, 0xaa, 0x66, 0x4e, 0xc6, 0x08, 0x69, 0xcc, 0xba, 0xcc, 0x65, 0x12, 0x36, 0x93, 0x53, - 0xea, 0xd9, 0xd0, 0x5c, 0xc6, 0x5c, 0x8a, 0x4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00, 0x00, 0xff, 0xff, 0xe9, 0x5d, - 0xb4, 0xdb, 0x23, 0x05, 0x00, 0x00, + // 696 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x4f, 0xd4, 0x4e, + 0x18, 0xde, 0xb2, 0xfb, 0x03, 0x76, 0xf8, 0x45, 0x97, 0x42, 0x70, 0xd9, 0x84, 0x2e, 0x96, 0x44, + 0x36, 0x10, 0xda, 0x2c, 0x24, 0x1e, 0xb8, 0x2d, 0xa0, 0x09, 0x09, 0x22, 0x29, 0x1a, 0x13, 0x2e, + 0x9b, 0x69, 0x67, 0xe8, 0x4e, 0x76, 0xda, 0x29, 0x9d, 0x69, 0x75, 0x6f, 0x1e, 0x39, 0xfa, 0x11, + 0x48, 0xbc, 0xf9, 0x21, 0x3c, 0x73, 0xe4, 0x68, 0x3c, 0xa0, 0x81, 0x8b, 0x67, 0x3e, 0x81, 0xe9, + 0xb4, 0xdb, 0xad, 0x80, 0x51, 0x4f, 0x9d, 0x79, 0x9f, 0xf7, 0x7d, 0xde, 0xe7, 0xfd, 0xd3, 0x01, + 0x4b, 0x8c, 0x7b, 0x8c, 0x13, 0x6e, 0xf2, 0x28, 0xc0, 0xe1, 0x31, 0x8d, 0x08, 0x2a, 0x1c, 0x8d, + 0x20, 0x64, 0x82, 0xa9, 0x6a, 0xe6, 0x64, 0x8c, 0x90, 0xc6, 0xac, 0xcb, 0x5c, 0x26, 0x61, 0x33, + 0x39, 0xa5, 0x9e, 0x0d, 0xcd, 0x65, 0xcc, 0xa5, 0xd8, 0x94, 0x37, 0x3b, 0x3a, 0x36, 0x51, 0x14, + 0x42, 0x41, 0x98, 0x9f, 0xe1, 0xcd, 0xdb, 0xb8, 0x20, 0x1e, 0xe6, 0x02, 0x7a, 0xc1, 0x90, 0xc0, + 0x91, 0xb9, 0x4c, 0x1b, 0x72, 0x6c, 0xc6, 0x6d,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 0xe8, 0x55, 0x1f, 0x81, 0x09, 0xca, 0x9c, 0x7e, 0xb2, 0x76, 0x8a, + 0x5c, 0xbb, 0x71, 0x2a, 0xa3, 0xd4, 0x36, 0x98, 0x25, 0x85, 0xc8, 0x2e, 0x4c, 0x43, 0xb3, 0x5e, + 0xcf, 0x90, 0xbb, 0xac, 0xfa, 0x0a, 0x98, 0x7b, 0xed, 0x07, 0x8c, 0xd1, 0x37, 0x3d, 0x22, 0x30, + 0x25, 0x5c, 0x60, 0x74, 0xc0, 0x18, 0xe5, 0x6a, 0x0d, 0x94, 0x09, 0x4a, 0x86, 0x5a, 0x6e, 0x55, + 0xac, 0xe4, 0xb8, 0x72, 0x04, 0x66, 0xee, 0xf9, 0xdb, 0xd4, 0x05, 0x30, 0x7f, 0x8f, 0x79, 0x1f, + 0x0a, 0x12, 0xe3, 0x5a, 0x49, 0xd5, 0x8a, 0x8b, 0x94, 0xc3, 0x7b, 0x07, 0x87, 0x3d, 0x18, 0xe2, + 0x9a, 0xd2, 0xa8, 0x9c, 0x7e, 0xd4, 0x4a, 0x5b, 0x07, 0xe7, 0x57, 0x9a, 0x72, 0x71, 0xa5, 0x29, + 0xdf, 0xaf, 0x34, 0xe5, 0xc3, 0xb5, 0x56, 0xba, 0xb8, 0xd6, 0x4a, 0x5f, 0xae, 0xb5, 0xd2, 0xd1, + 0xd3, 0x42, 0x57, 0xb3, 0xff, 0x7f, 0x8d, 0x42, 0x9b, 0x0f, 0x2f, 0x66, 0xdc, 0xde, 0x30, 0xdf, + 0x15, 0x1f, 0x40, 0xd9, 0x69, 0x7b, 0x5c, 0xbe, 0x38, 0x1b, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, + 0xf4, 0xa0, 0x01, 0xda, 0x23, 0x05, 0x00, 0x00, } func (this *SuperfluidAsset) Equal(that interface{}) bool { diff --git a/x/superfluid/types/tx.pb.go b/x/superfluid/types/tx.pb.go index 06af894c9ef..23d44b72597 100644 --- a/x/superfluid/types/tx.pb.go +++ b/x/superfluid/types/tx.pb.go @@ -533,7 +533,7 @@ var fileDescriptor_55b645f187d22814 = []byte{ // 608 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xd3, 0x40, 0x10, 0x8e, 0x93, 0x90, 0xc0, 0xa2, 0x16, 0x61, 0xb5, 0xaa, 0x63, 0xc0, 0x0e, 0x06, 0xa1, 0xa0, - 0x52, 0x6f, 0x93, 0xa2, 0x0a, 0x71, 0x6b, 0xc8, 0x25, 0xa8, 0x91, 0x2a, 0xa3, 0x0a, 0x09, 0x09, + 0x52, 0x6f, 0xd3, 0xa0, 0x0a, 0x71, 0x6b, 0xc8, 0x25, 0xa8, 0x91, 0x2a, 0xa3, 0x0a, 0x09, 0x09, 0x45, 0x76, 0x76, 0xeb, 0x5a, 0xd9, 0x78, 0x23, 0xaf, 0x63, 0xa5, 0xe2, 0x01, 0xb8, 0xf2, 0x1c, 0xbc, 0x08, 0x3d, 0xf6, 0xc8, 0x29, 0xa0, 0xe4, 0x0d, 0x2a, 0x1e, 0x00, 0xf9, 0x37, 0x14, 0xec, 0x90, 0x08, 0x7a, 0xf2, 0xce, 0xcc, 0xb7, 0xdf, 0x7c, 0xa3, 0x99, 0xf1, 0x82, 0x7b, 0x94, 0x0d, @@ -550,25 +550,25 @@ var fileDescriptor_55b645f187d22814 = []byte{ 0x98, 0x0d, 0xa9, 0xcd, 0xb0, 0xf2, 0x1e, 0x6c, 0x5d, 0x01, 0x1c, 0xdb, 0xe8, 0x3f, 0x4a, 0x53, 0x1e, 0x02, 0x39, 0x83, 0x7e, 0x81, 0x02, 0x83, 0xda, 0xe8, 0x90, 0xf6, 0xfa, 0xd7, 0xa4, 0x20, 0xa6, 0x4f, 0x14, 0x7c, 0xe1, 0xc0, 0xfd, 0x0e, 0x33, 0x7d, 0xdf, 0x81, 0x8d, 0xfe, 0xad, 0x49, - 0x3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x74, 0x3e, 0x95, 0xb8, 0x8b, 0xa9, 0xc4, 0x7d, 0x9f, 0x4a, 0xdc, 0xa7, 0x99, 0x94, + 0xbb, 0x98, 0x49, 0xb9, 0xaf, 0x33, 0x29, 0xf7, 0x6e, 0xff, 0x97, 0xa5, 0x8e, 0x98, 0x77, 0x88, + 0x6e, 0xb0, 0xd8, 0x80, 0x5e, 0xbd, 0x01, 0xc7, 0x57, 0x5e, 0x2e, 0x7f, 0xd1, 0x8d, 0x52, 0xf0, + 0x5c, 0x34, 0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0x64, 0xb3, 0x1a, 0x05, 0xdc, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/swaprouter/client/cli/cli_test.go b/x/swaprouter/client/cli/cli_test.go new file mode 100644 index 00000000000..85044c911d0 --- /dev/null +++ b/x/swaprouter/client/cli/cli_test.go @@ -0,0 +1,598 @@ +package cli_test + +import ( + "fmt" + "testing" + + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/app" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/cli" + swaprouterqueryproto "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" + swaproutertestutil "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/testutil" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" + tmcli "github.com/tendermint/tendermint/libs/cli" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.cfg = app.DefaultConfig() + s.cfg.GenesisState = swaproutertestutil.UpdateTxFeeDenom(s.cfg.Codec, s.cfg.BondDenom) + + s.network = network.New(s.T(), s.cfg) + + _, err := s.network.WaitForHeight(1) + s.Require().NoError(err) + + val := s.network.Validators[0] + + // create a new pool + _, err = swaproutertestutil.MsgCreatePool(s.T(), val.ClientCtx, val.Address, "5stake,5node0token", "100stake,100node0token", "0.01", "0.01", "") + s.Require().NoError(err) + + s.T().Log("test") + + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func TestIntegrationTestSuite(t *testing.T) { + + // TODO: re-enable this once swaprouter is fully merged. + t.SkipNow() + + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s IntegrationTestSuite) TestNewSwapExactAmountOutCmd() { + val := s.network.Validators[0] + + info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewSwapExactAmountOut", + keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + s.Require().NoError(err) + + newAddr := sdk.AccAddress(info.GetPubKey().Address()) + + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + newAddr, + sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 20000), sdk.NewInt64Coin("node0token", 20000)), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + osmoutils.DefaultFeeString(s.cfg), + ) + s.Require().NoError(err) + + testCases := []struct { + name string + args []string + + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "swap exact amount out", // osmosisd tx swaprouter swap-exact-amount-out 10stake 20 --swap-route-pool-ids=1 --swap-route-denoms=node0token --from=validator --keyring-backend=test --chain-id=testing --yes + []string{ + "10stake", "20", + fmt.Sprintf("--%s=%d", cli.FlagSwapRoutePoolIds, 1), + fmt.Sprintf("--%s=%s", cli.FlagSwapRouteDenoms, "node0token"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), + // common args + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + }, + false, &sdk.TxResponse{}, 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewSwapExactAmountOutCmd() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +// func (s *IntegrationTestSuite) TestGetCmdEstimateSwapExactAmountIn() { +// val := s.network.Validators[0] + +// testCases := []struct { +// name string +// args []string +// expectErr bool +// }{ +// { +// "query pool estimate swap exact amount in", // osmosisd query gamm estimate-swap-exact-amount-in 1 cosmos1n8skk06h3kyh550ad9qketlfhc2l5dsdevd3hq 10.0stake --swap-route-pool-ids=1 --swap-route-denoms=node0token +// []string{ +// "1", +// "cosmos1n8skk06h3kyh550ad9qketlfhc2l5dsdevd3hq", +// "10.0stake", +// fmt.Sprintf("--%s=%d", cli.FlagSwapRoutePoolIds, 1), +// fmt.Sprintf("--%s=%s", cli.FlagSwapRouteDenoms, "node0token"), +// fmt.Sprintf("--%s=%s", tmcli.OutputFlag, "json"), +// }, +// false, +// }, +// } + +// for _, tc := range testCases { +// tc := tc + +// s.Run(tc.name, func() { +// cmd := cli.GetCmdEstimateSwapExactAmountIn() +// clientCtx := val.ClientCtx + +// out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) +// if tc.expectErr { +// s.Require().Error(err) +// } else { +// resp := types.QuerySwapExactAmountInResponse{} +// s.Require().NoError(err, out.String()) +// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) +// } +// }) +// } +// } + +// func (s *IntegrationTestSuite) TestGetCmdEstimateSwapExactAmountOut() { +// val := s.network.Validators[0] + +// testCases := []struct { +// name string +// args []string +// expectErr bool +// }{ +// { +// "query pool estimate swap exact amount in", // osmosisd query gamm estimate-swap-exact-amount-in 1 cosmos1n8skk06h3kyh550ad9qketlfhc2l5dsdevd3hq 10.0stake --swap-route-pool-ids=1 --swap-route-denoms=node0token +// []string{ +// "1", +// val.Address.String(), +// "10.0stake", +// fmt.Sprintf("--%s=%d", cli.FlagSwapRoutePoolIds, 1), +// fmt.Sprintf("--%s=%s", cli.FlagSwapRouteDenoms, "node0token"), +// fmt.Sprintf("--%s=%s", tmcli.OutputFlag, "json"), +// }, +// false, +// }, +// } + +// for _, tc := range testCases { +// tc := tc + +// s.Run(tc.name, func() { +// cmd := cli.GetCmdEstimateSwapExactAmountOut() +// clientCtx := val.ClientCtx + +// out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) +// if tc.expectErr { +// s.Require().Error(err) +// } else { +// resp := types.QuerySwapExactAmountOutResponse{} +// s.Require().NoError(err, out.String()) +// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) +// } +// }) +// } +// } + +func (s IntegrationTestSuite) TestNewSwapExactAmountInCmd() { + val := s.network.Validators[0] + + info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewSwapExactAmountIn", + keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + s.Require().NoError(err) + + newAddr := sdk.AccAddress(info.GetPubKey().Address()) + + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + newAddr, + sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 20000), sdk.NewInt64Coin("node0token", 20000)), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + osmoutils.DefaultFeeString(s.cfg), + ) + s.Require().NoError(err) + + testCases := []struct { + name string + args []string + + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "swap exact amount in", // osmosisd tx swaprouter swap-exact-amount-in 10stake 3 --swap-route-pool-ids=1 --swap-route-denoms=node0token --from=validator --keyring-backend=test --chain-id=testing --yes + []string{ + "10stake", "3", + fmt.Sprintf("--%s=%d", cli.FlagSwapRoutePoolIds, 1), + fmt.Sprintf("--%s=%s", cli.FlagSwapRouteDenoms, "node0token"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), + // common args + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + }, + false, &sdk.TxResponse{}, 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewSwapExactAmountInCmd() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestGetCmdNumPools() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + }{ + { + "query num-pools", + []string{ + fmt.Sprintf("--%s=%s", tmcli.OutputFlag, "json"), + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdNumPools() // osmosisd query swaprouter num-pools + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + resp := swaprouterqueryproto.NumPoolsResponse{} + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + + s.Require().Greater(resp.NumPools, uint64(0), out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewCreatePoolCmd() { + val := s.network.Validators[0] + + info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewCreatePoolAddr", + keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + s.Require().NoError(err) + + newAddr := sdk.AccAddress(info.GetPubKey().Address()) + + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + newAddr, + sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 200000000), sdk.NewInt64Coin("node0token", 20000)), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + osmoutils.DefaultFeeString(s.cfg), + ) + s.Require().NoError(err) + + testCases := []struct { + name string + json string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "one token pair pool", + fmt.Sprintf(` + { + "%s": "1node0token", + "%s": "100node0token", + "%s": "0.001", + "%s": "0.001" + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee), + true, &sdk.TxResponse{}, 4, + }, + { + "two tokens pair pool", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "0.001" + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee), + false, &sdk.TxResponse{}, 0, + }, + { + "change order of json fields", + fmt.Sprintf(` + { + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "1node0token,3stake", + "%s": "0.001" + } + `, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileWeights, cli.PoolFileExitFee), + false, &sdk.TxResponse{}, 0, + }, + { // --record-tokens=100.0stake2 --record-tokens=100.0stake --record-tokens-weight=5 --record-tokens-weight=5 --swap-fee=0.01 --exit-fee=0.01 --from=validator --keyring-backend=test --chain-id=testing --yes + "three tokens pair pool - insufficient balance check", + fmt.Sprintf(` + { + "%s": "1node0token,1stake,2btc", + "%s": "100node0token,100stake,100btc", + "%s": "0.001", + "%s": "0.001" + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee), + false, &sdk.TxResponse{}, 5, + }, + { + "future governor address", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "0.001", + "%s": "osmo1fqlr98d45v5ysqgp6h56kpujcj4cvsjnjq9nck" + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, cli.PoolFileFutureGovernor), + false, &sdk.TxResponse{}, 0, + }, + // Due to CI time concerns, we leave these CLI tests commented out, and instead guaranteed via + // the logic tests. + // { + // "future governor time", + // fmt.Sprintf(` + // { + // "%s": "1node0token,3stake", + // "%s": "100node0token,100stake", + // "%s": "0.001", + // "%s": "0.001", + // "%s": "2h" + // } + // `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, cli.PoolFileFutureGovernor), + // false, &sdk.TxResponse{}, 0, + // }, + // { + // "future governor token + time", + // fmt.Sprintf(` + // { + // "%s": "1node0token,3stake", + // "%s": "100node0token,100stake", + // "%s": "0.001", + // "%s": "0.001", + // "%s": "token,1000h" + // } + // `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, cli.PoolFileFutureGovernor), + // false, &sdk.TxResponse{}, 0, + // }, + // { + // "invalid future governor", + // fmt.Sprintf(` + // { + // "%s": "1node0token,3stake", + // "%s": "100node0token,100stake", + // "%s": "0.001", + // "%s": "0.001", + // "%s": "validdenom,invalidtime" + // } + // `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, cli.PoolFileFutureGovernor), + // true, &sdk.TxResponse{}, 7, + // }, + { + "not valid json", + "bad json", + true, &sdk.TxResponse{}, 0, + }, + { + "bad pool json - missing quotes around exit fee", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": 0.001 + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee), + true, &sdk.TxResponse{}, 0, + }, + { + "empty pool json", + "", true, &sdk.TxResponse{}, 0, + }, + { + "smooth change params", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "0.001", + "%s": { + "%s": "864h", + "%s": "2node0token,1stake", + "%s": "2006-01-02T15:04:05Z" + } + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, + cli.PoolFileSmoothWeightChangeParams, cli.PoolFileDuration, cli.PoolFileTargetPoolWeights, cli.PoolFileStartTime, + ), + false, &sdk.TxResponse{}, 0, + }, + { + "smooth change params - no start time", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "0.001", + "%s": { + "%s": "864h", + "%s": "2node0token,1stake" + } + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, + cli.PoolFileSmoothWeightChangeParams, cli.PoolFileDuration, cli.PoolFileTargetPoolWeights, + ), + false, &sdk.TxResponse{}, 0, + }, + { + "empty smooth change params", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "0.001", + "%s": {} + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, + cli.PoolFileSmoothWeightChangeParams, + ), + false, &sdk.TxResponse{}, 0, + }, + { + "smooth change params wrong type", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "0.001", + "%s": "invalid string" + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, + cli.PoolFileSmoothWeightChangeParams, + ), + true, &sdk.TxResponse{}, 0, + }, + { + "smooth change params missing duration", + fmt.Sprintf(` + { + "%s": "1node0token,3stake", + "%s": "100node0token,100stake", + "%s": "0.001", + "%s": "0.001", + "%s": { + "%s": "2node0token,1stake" + } + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee, + cli.PoolFileSmoothWeightChangeParams, cli.PoolFileTargetPoolWeights, + ), + true, &sdk.TxResponse{}, 0, + }, + { + "unknown fields in json", + fmt.Sprintf(` + { + "%s": "1node0token", + "%s": "100node0token", + "%s": "0.001", + "%s": "0.001" + "unknown": true, + } + `, cli.PoolFileWeights, cli.PoolFileInitialDeposit, cli.PoolFileSwapFee, cli.PoolFileExitFee), + true, &sdk.TxResponse{}, 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewCreatePoolCmd() + clientCtx := val.ClientCtx + + jsonFile := testutil.WriteToNewTempFile(s.T(), tc.json) + + args := []string{ + fmt.Sprintf("--%s=%s", cli.FlagPoolFile, jsonFile.Name()), + fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), + // common args + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + osmoutils.DefaultFeeString(s.cfg), + fmt.Sprintf("--%s=%s", flags.FlagGas, fmt.Sprint(400000)), + } + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err, out.String()) + err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType) + s.Require().NoError(err, out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} diff --git a/x/swaprouter/client/cli/common.go b/x/swaprouter/client/cli/common.go new file mode 100644 index 00000000000..9e3d1757d57 --- /dev/null +++ b/x/swaprouter/client/cli/common.go @@ -0,0 +1,68 @@ +package cli + +import ( + "errors" + "strconv" + + flag "github.com/spf13/pflag" + + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +func swapAmountInRoutes(fs *flag.FlagSet) ([]types.SwapAmountInRoute, error) { + swapRoutePoolIds, err := fs.GetStringArray(FlagSwapRoutePoolIds) + if err != nil { + return nil, err + } + + swapRouteDenoms, err := fs.GetStringArray(FlagSwapRouteDenoms) + if err != nil { + return nil, err + } + + if len(swapRoutePoolIds) != len(swapRouteDenoms) { + return nil, errors.New("swap route pool ids and denoms mismatch") + } + + routes := []types.SwapAmountInRoute{} + for index, poolIDStr := range swapRoutePoolIds { + pID, err := strconv.Atoi(poolIDStr) + if err != nil { + return nil, err + } + routes = append(routes, types.SwapAmountInRoute{ + PoolId: uint64(pID), + TokenOutDenom: swapRouteDenoms[index], + }) + } + return routes, nil +} + +func swapAmountOutRoutes(fs *flag.FlagSet) ([]types.SwapAmountOutRoute, error) { + swapRoutePoolIds, err := fs.GetStringArray(FlagSwapRoutePoolIds) + if err != nil { + return nil, err + } + + swapRouteDenoms, err := fs.GetStringArray(FlagSwapRouteDenoms) + if err != nil { + return nil, err + } + + if len(swapRoutePoolIds) != len(swapRouteDenoms) { + return nil, errors.New("swap route pool ids and denoms mismatch") + } + + routes := []types.SwapAmountOutRoute{} + for index, poolIDStr := range swapRoutePoolIds { + pID, err := strconv.Atoi(poolIDStr) + if err != nil { + return nil, err + } + routes = append(routes, types.SwapAmountOutRoute{ + PoolId: uint64(pID), + TokenInDenom: swapRouteDenoms[index], + }) + } + return routes, nil +} diff --git a/x/swaprouter/client/cli/flags.go b/x/swaprouter/client/cli/flags.go new file mode 100644 index 00000000000..1ecb5fab0f6 --- /dev/null +++ b/x/swaprouter/client/cli/flags.go @@ -0,0 +1,71 @@ +package cli + +import flag "github.com/spf13/pflag" + +const ( + // Names of fields in pool json file. + PoolFileWeights = "weights" + PoolFileInitialDeposit = "initial-deposit" + PoolFileSwapFee = "swap-fee" + PoolFileExitFee = "exit-fee" + PoolFileFutureGovernor = "future-governor" + + PoolFileSmoothWeightChangeParams = "lbp-params" + PoolFileStartTime = "start-time" + PoolFileDuration = "duration" + PoolFileTargetPoolWeights = "target-pool-weights" + + // Will be parsed to string. + FlagPoolFile = "pool-file" + // Will be parsed to uint64. + FlagSwapRoutePoolIds = "swap-route-pool-ids" + // Will be parsed to []string. + FlagSwapRouteDenoms = "swap-route-denoms" +) + +type createBalancerPoolInputs struct { + Weights string `json:"weights"` + InitialDeposit string `json:"initial-deposit"` + SwapFee string `json:"swap-fee"` + ExitFee string `json:"exit-fee"` + FutureGovernor string `json:"future-governor"` + SmoothWeightChangeParams smoothWeightChangeParamsInputs `json:"lbp-params"` +} + +type createStableswapPoolInputs struct { + InitialDeposit string `json:"initial-deposit"` + SwapFee string `json:"swap-fee"` + ExitFee string `json:"exit-fee"` + FutureGovernor string `json:"future-governor"` + ScalingFactorController string `json:"scaling-factor-controller"` + ScalingFactors string `json:"scaling-factors"` +} + +type smoothWeightChangeParamsInputs struct { + StartTime string `json:"start-time"` + Duration string `json:"duration"` + TargetPoolWeights string `json:"target-pool-weights"` +} + +func FlagSetQuerySwapRoutes() *flag.FlagSet { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + fs.StringArray(FlagSwapRoutePoolIds, []string{""}, "swap route pool id") + fs.StringArray(FlagSwapRouteDenoms, []string{""}, "swap route amount") + return fs +} + +func FlagSetSwapAmountOutRoutes() *flag.FlagSet { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + fs.StringArray(FlagSwapRoutePoolIds, []string{""}, "swap route pool ids") + fs.StringArray(FlagSwapRouteDenoms, []string{""}, "swap route denoms") + return fs +} + +func FlagSetCreatePool() *flag.FlagSet { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + fs.String(FlagPoolFile, "", "Pool json file path (if this path is given, other create pool flags should not be used)") + return fs +} diff --git a/x/swaprouter/client/cli/parse.go b/x/swaprouter/client/cli/parse.go new file mode 100644 index 00000000000..951db760378 --- /dev/null +++ b/x/swaprouter/client/cli/parse.go @@ -0,0 +1,97 @@ +package cli + +import ( + "bytes" + "encoding/json" + "fmt" + "os" + + "github.com/spf13/pflag" +) + +// TODO: move these to exported types within an internal package +type XCreatePoolInputs createBalancerPoolInputs + +type XCreatePoolInputsExceptions struct { + XCreatePoolInputs + Other *string // Other won't raise an error +} + +type XCreateStableswapPoolInputs createStableswapPoolInputs + +type XCreateStableswapPoolInputsExceptions struct { + XCreateStableswapPoolInputs + Other *string // Other won't raise an error +} + +// UnmarshalJSON should error if there are fields unexpected. +func (release *createBalancerPoolInputs) UnmarshalJSON(data []byte) error { + var createPoolE XCreatePoolInputsExceptions + dec := json.NewDecoder(bytes.NewReader(data)) + dec.DisallowUnknownFields() // Force + + if err := dec.Decode(&createPoolE); err != nil { + return err + } + + *release = createBalancerPoolInputs(createPoolE.XCreatePoolInputs) + return nil +} + +func parseCreateBalancerPoolFlags(fs *pflag.FlagSet) (*createBalancerPoolInputs, error) { + pool := &createBalancerPoolInputs{} + poolFile, _ := fs.GetString(FlagPoolFile) + + if poolFile == "" { + return nil, fmt.Errorf("must pass in a pool json using the --%s flag", FlagPoolFile) + } + + contents, err := os.ReadFile(poolFile) + if err != nil { + return nil, err + } + + // make exception if unknown field exists + err = pool.UnmarshalJSON(contents) + if err != nil { + return nil, err + } + + return pool, nil +} + +// UnmarshalJSON should error if there are fields unexpected. +func (release *createStableswapPoolInputs) UnmarshalJSON(data []byte) error { + var createPoolE XCreateStableswapPoolInputsExceptions + dec := json.NewDecoder(bytes.NewReader(data)) + dec.DisallowUnknownFields() // Force + + if err := dec.Decode(&createPoolE); err != nil { + return err + } + + *release = createStableswapPoolInputs(createPoolE.XCreateStableswapPoolInputs) + return nil +} + +func parseCreateStableswapPoolFlags(fs *pflag.FlagSet) (*createStableswapPoolInputs, error) { + pool := &createStableswapPoolInputs{} + poolFile, _ := fs.GetString(FlagPoolFile) + + if poolFile == "" { + return nil, fmt.Errorf("must pass in a pool json using the --%s flag", FlagPoolFile) + } + + contents, err := os.ReadFile(poolFile) + if err != nil { + return nil, err + } + + // make exception if unknown field exists + err = pool.UnmarshalJSON(contents) + if err != nil { + return nil, err + } + + return pool, nil +} diff --git a/x/swaprouter/client/cli/query.go b/x/swaprouter/client/cli/query.go new file mode 100644 index 00000000000..2c968c33666 --- /dev/null +++ b/x/swaprouter/client/cli/query.go @@ -0,0 +1,175 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetCmdEstimateSwapExactAmountIn(), + GetCmdEstimateSwapExactAmountOut(), + GetCmdNumPools(), + ) + + return cmd +} + +// GetCmdEstimateSwapExactAmountIn returns estimation of output coin when amount of x token input. +func GetCmdEstimateSwapExactAmountIn() *cobra.Command { + cmd := &cobra.Command{ + Use: "estimate-swap-exact-amount-in ", + Short: "Query estimate-swap-exact-amount-in", + Long: strings.TrimSpace( + fmt.Sprintf(`Query estimate-swap-exact-amount-in. +Example: +$ %s query swaprouter estimate-swap-exact-amount-in 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3 +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := queryproto.NewQueryClient(clientCtx) + + poolID, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + routes, err := swapAmountInRoutes(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.EstimateSwapExactAmountIn(cmd.Context(), &queryproto.EstimateSwapExactAmountInRequest{ + Sender: args[1], // TODO: where sender is used? + PoolId: uint64(poolID), // TODO: is this poolId used? + TokenIn: args[2], + Routes: routes, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + cmd.Flags().AddFlagSet(FlagSetQuerySwapRoutes()) + flags.AddQueryFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(FlagSwapRoutePoolIds) + _ = cmd.MarkFlagRequired(FlagSwapRouteDenoms) + + return cmd +} + +// GetCmdEstimateSwapExactAmountOut returns estimation of input coin to get exact amount of x token output. +func GetCmdEstimateSwapExactAmountOut() *cobra.Command { + cmd := &cobra.Command{ + Use: "estimate-swap-exact-amount-out ", + Short: "Query estimate-swap-exact-amount-out", + Long: strings.TrimSpace( + fmt.Sprintf(`Query estimate-swap-exact-amount-out. +Example: +$ %s query swaprouter estimate-swap-exact-amount-out 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3 +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := queryproto.NewQueryClient(clientCtx) + + poolID, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + routes, err := swapAmountOutRoutes(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.EstimateSwapExactAmountOut(cmd.Context(), &queryproto.EstimateSwapExactAmountOutRequest{ + Sender: args[1], // TODO: where sender is used? + PoolId: uint64(poolID), // TODO: is this poolId used? + Routes: routes, + TokenOut: args[2], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + cmd.Flags().AddFlagSet(FlagSetQuerySwapRoutes()) + flags.AddQueryFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(FlagSwapRoutePoolIds) + _ = cmd.MarkFlagRequired(FlagSwapRouteDenoms) + + return cmd +} + +// GetCmdNumPools return number of pools available. +func GetCmdNumPools() *cobra.Command { + cmd := &cobra.Command{ + Use: "num-pools", + Short: "Query number of pools", + Long: strings.TrimSpace( + fmt.Sprintf(`Query number of pools. +Example: +$ %s query swaprouter num-pools +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := queryproto.NewQueryClient(clientCtx) + + res, err := queryClient.NumPools(cmd.Context(), &queryproto.NumPoolsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/swaprouter/client/cli/query_test.go b/x/swaprouter/client/cli/query_test.go new file mode 100644 index 00000000000..5eef93ed296 --- /dev/null +++ b/x/swaprouter/client/cli/query_test.go @@ -0,0 +1,58 @@ +package cli_test + +import ( + gocontext "context" + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + swaprouterqueryproto "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" +) + +type QueryTestSuite struct { + apptesting.KeeperTestHelper + queryClient swaprouterqueryproto.QueryClient +} + +func (s *QueryTestSuite) SetupSuite() { + s.Setup() + s.queryClient = swaprouterqueryproto.NewQueryClient(s.QueryHelper) + // create a new pool + s.PrepareBalancerPool() + s.Commit() +} + +func (s *QueryTestSuite) TestQueriesNeverAlterState() { + testCases := []struct { + name string + query string + input interface{} + output interface{} + }{ + { + "Query num pools", + "/osmosis.swaprouter.v1beta1.Query/NumPools", + &swaprouterqueryproto.NumPoolsRequest{}, + &swaprouterqueryproto.NumPoolsResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + s.SetupSuite() + err := s.QueryHelper.Invoke(gocontext.Background(), tc.query, tc.input, tc.output) + s.Require().NoError(err) + s.StateNotAltered() + }) + } +} + +func TestQueryTestSuite(t *testing.T) { + + // TODO: re-enable this once swaprouter is fully merged. + t.SkipNow() + + suite.Run(t, new(QueryTestSuite)) +} diff --git a/x/swaprouter/client/cli/tx.go b/x/swaprouter/client/cli/tx.go new file mode 100644 index 00000000000..c3d3dbcab67 --- /dev/null +++ b/x/swaprouter/client/cli/tx.go @@ -0,0 +1,360 @@ +package cli + +import ( + "errors" + "fmt" + "strconv" + "strings" + "time" + + flag "github.com/spf13/pflag" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Swap transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + NewCreatePoolCmd(), + NewSwapExactAmountInCmd(), + NewSwapExactAmountOutCmd(), + ) + + return txCmd +} + +func NewSwapExactAmountInCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "swap-exact-amount-in [token-in] [token-out-min-amount]", + Short: "swap exact amount in", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + txf, msg, err := NewBuildSwapExactAmountInMsg(clientCtx, args[0], args[1], txf, cmd.Flags()) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + cmd.Flags().AddFlagSet(FlagSetQuerySwapRoutes()) + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(FlagSwapRoutePoolIds) + _ = cmd.MarkFlagRequired(FlagSwapRouteDenoms) + + return cmd +} + +func NewSwapExactAmountOutCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "swap-exact-amount-out [token-out] [token-in-max-amount]", + Short: "swap exact amount out", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + txf, msg, err := NewBuildSwapExactAmountOutMsg(clientCtx, args[0], args[1], txf, cmd.Flags()) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + cmd.Flags().AddFlagSet(FlagSetSwapAmountOutRoutes()) + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(FlagSwapRoutePoolIds) + _ = cmd.MarkFlagRequired(FlagSwapRouteDenoms) + + return cmd +} + +func NewBuildSwapExactAmountInMsg(clientCtx client.Context, tokenInStr, tokenOutMinAmtStr string, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + routes, err := swapAmountInRoutes(fs) + if err != nil { + return txf, nil, err + } + + tokenIn, err := sdk.ParseCoinNormalized(tokenInStr) + if err != nil { + return txf, nil, err + } + + tokenOutMinAmt, ok := sdk.NewIntFromString(tokenOutMinAmtStr) + if !ok { + return txf, nil, fmt.Errorf("invalid token out min amount, %s", tokenOutMinAmtStr) + } + msg := &types.MsgSwapExactAmountIn{ + Sender: clientCtx.GetFromAddress().String(), + Routes: routes, + TokenIn: tokenIn, + TokenOutMinAmount: tokenOutMinAmt, + } + + return txf, msg, nil +} + +func NewBuildSwapExactAmountOutMsg(clientCtx client.Context, tokenOutStr, tokenInMaxAmountStr string, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + routes, err := swapAmountOutRoutes(fs) + if err != nil { + return txf, nil, err + } + + tokenOut, err := sdk.ParseCoinNormalized(tokenOutStr) + if err != nil { + return txf, nil, err + } + + tokenInMaxAmount, ok := sdk.NewIntFromString(tokenInMaxAmountStr) + if !ok { + return txf, nil, errors.New("invalid token in max amount") + } + msg := &types.MsgSwapExactAmountOut{ + Sender: clientCtx.GetFromAddress().String(), + Routes: routes, + TokenInMaxAmount: tokenInMaxAmount, + TokenOut: tokenOut, + } + + return txf, msg, nil +} + +func NewCreatePoolCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-pool [flags]", + Short: "create a new pool and provide the liquidity to it", + Long: `Must provide path to a pool JSON file (--pool-file) describing the pool to be created`, + Example: `Sample pool JSON file contents: +{ + "weights": "4uatom,4osmo,2uakt", + "initial-deposit": "100uatom,5osmo,20uakt", + "swap-fee": "0.01", + "exit-fee": "0.01", + "future-governor": "168h" +} +`, + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + txf, msg, err := NewBuildCreateBalancerPoolMsg(clientCtx, txf, cmd.Flags()) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + cmd.Flags().AddFlagSet(FlagSetCreatePool()) + flags.AddTxFlagsToCmd(cmd) + + _ = cmd.MarkFlagRequired(FlagPoolFile) + + return cmd +} + +func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + pool, err := parseCreateBalancerPoolFlags(fs) + if err != nil { + return txf, nil, fmt.Errorf("failed to parse pool: %w", err) + } + + deposit, err := sdk.ParseCoinsNormalized(pool.InitialDeposit) + if err != nil { + return txf, nil, err + } + + poolAssetCoins, err := sdk.ParseDecCoins(pool.Weights) + if err != nil { + return txf, nil, err + } + + if len(deposit) != len(poolAssetCoins) { + return txf, nil, errors.New("deposit tokens and token weights should have same length") + } + + swapFee, err := sdk.NewDecFromStr(pool.SwapFee) + if err != nil { + return txf, nil, err + } + + exitFee, err := sdk.NewDecFromStr(pool.ExitFee) + if err != nil { + return txf, nil, err + } + + var poolAssets []balancer.PoolAsset + for i := 0; i < len(poolAssetCoins); i++ { + if poolAssetCoins[i].Denom != deposit[i].Denom { + return txf, nil, errors.New("deposit tokens and token weights should have same denom order") + } + + poolAssets = append(poolAssets, balancer.PoolAsset{ + Weight: poolAssetCoins[i].Amount.RoundInt(), + Token: deposit[i], + }) + } + + poolParams := &balancer.PoolParams{ + SwapFee: swapFee, + ExitFee: exitFee, + } + + msg := &balancer.MsgCreateBalancerPool{ + Sender: clientCtx.GetFromAddress().String(), + PoolParams: poolParams, + PoolAssets: poolAssets, + FuturePoolGovernor: pool.FutureGovernor, + } + + if (pool.SmoothWeightChangeParams != smoothWeightChangeParamsInputs{}) { + duration, err := time.ParseDuration(pool.SmoothWeightChangeParams.Duration) + if err != nil { + return txf, nil, fmt.Errorf("could not parse duration: %w", err) + } + + targetPoolAssetCoins, err := sdk.ParseDecCoins(pool.SmoothWeightChangeParams.TargetPoolWeights) + if err != nil { + return txf, nil, err + } + + var targetPoolAssets []balancer.PoolAsset + for i := 0; i < len(targetPoolAssetCoins); i++ { + if targetPoolAssetCoins[i].Denom != poolAssetCoins[i].Denom { + return txf, nil, errors.New("initial pool weights and target pool weights should have same denom order") + } + + targetPoolAssets = append(targetPoolAssets, balancer.PoolAsset{ + Weight: targetPoolAssetCoins[i].Amount.RoundInt(), + Token: deposit[i], + // TODO: This doesn't make sense. Should only use denom, not an sdk.Coin + }) + } + + smoothWeightParams := balancer.SmoothWeightChangeParams{ + Duration: duration, + InitialPoolWeights: poolAssets, + TargetPoolWeights: targetPoolAssets, + } + + if pool.SmoothWeightChangeParams.StartTime != "" { + startTime, err := time.Parse(time.RFC3339, pool.SmoothWeightChangeParams.StartTime) + if err != nil { + return txf, nil, fmt.Errorf("could not parse time: %w", err) + } + + smoothWeightParams.StartTime = startTime + } + + msg.PoolParams.SmoothWeightChangeParams = &smoothWeightParams + } + + return txf, msg, nil +} + +// Apologies to whoever has to touch this next, this code is horrendous +func NewBuildCreateStableswapPoolMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + flags, err := parseCreateStableswapPoolFlags(fs) + if err != nil { + return txf, nil, fmt.Errorf("failed to parse pool: %w", err) + } + + deposit, err := ParseCoinsNoSort(flags.InitialDeposit) + if err != nil { + return txf, nil, err + } + + swapFee, err := sdk.NewDecFromStr(flags.SwapFee) + if err != nil { + return txf, nil, err + } + + exitFee, err := sdk.NewDecFromStr(flags.ExitFee) + if err != nil { + return txf, nil, err + } + + poolParams := &stableswap.PoolParams{ + SwapFee: swapFee, + ExitFee: exitFee, + } + + scalingFactors := []uint64{} + trimmedSfString := strings.Trim(flags.ScalingFactors, "[] {}") + if len(trimmedSfString) > 0 { + ints := strings.Split(trimmedSfString, ",") + for _, i := range ints { + u, err := strconv.ParseUint(i, 10, 64) + if err != nil { + return txf, nil, err + } + scalingFactors = append(scalingFactors, u) + } + if len(scalingFactors) != len(deposit) { + return txf, nil, fmt.Errorf("number of scaling factors doesn't match number of assets") + } + } + + msg := &stableswap.MsgCreateStableswapPool{ + Sender: clientCtx.GetFromAddress().String(), + PoolParams: poolParams, + InitialPoolLiquidity: deposit, + ScalingFactors: scalingFactors, + ScalingFactorController: flags.ScalingFactorController, + FuturePoolGovernor: flags.FutureGovernor, + } + + return txf, msg, nil +} + +// ParseCoinsNoSort parses coins from coinsStr but does not sort them. +// Returns error if parsing fails. +func ParseCoinsNoSort(coinsStr string) (sdk.Coins, error) { + coinStrs := strings.Split(coinsStr, ",") + decCoins := make(sdk.DecCoins, len(coinStrs)) + for i, coinStr := range coinStrs { + coin, err := sdk.ParseDecCoin(coinStr) + if err != nil { + return sdk.Coins{}, err + } + + decCoins[i] = coin + } + return sdk.NormalizeCoins(decCoins), nil +} diff --git a/x/swaprouter/client/cli/tx_test.go b/x/swaprouter/client/cli/tx_test.go new file mode 100644 index 00000000000..2e1f85aa111 --- /dev/null +++ b/x/swaprouter/client/cli/tx_test.go @@ -0,0 +1,71 @@ +package cli_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/cli" +) + +func TestParseCoinsNoSort(t *testing.T) { + const ( + a = "aaa" + b = "bbb" + c = "ccc" + d = "ddd" + ) + + var ( + ten = sdk.NewInt(10) + + coinA = sdk.NewCoin(a, ten) + coinB = sdk.NewCoin(b, ten) + coinC = sdk.NewCoin(c, ten) + coinD = sdk.NewCoin(d, ten) + ) + + tests := map[string]struct { + coinsStr string + expectedCoins sdk.Coins + }{ + "ascending": { + coinsStr: "10aaa,10bbb,10ccc,10ddd", + expectedCoins: sdk.Coins{ + coinA, + coinB, + coinC, + coinD, + }, + }, + "descending": { + coinsStr: "10ddd,10ccc,10bbb,10aaa", + expectedCoins: sdk.Coins{ + coinD, + coinC, + coinB, + coinA, + }, + }, + "mixed with different values.": { + coinsStr: "100ddd,20bbb,300aaa,40ccc", + expectedCoins: sdk.Coins{ + sdk.NewCoin(d, sdk.NewInt(100)), + sdk.NewCoin(b, sdk.NewInt(20)), + sdk.NewCoin(a, sdk.NewInt(300)), + sdk.NewCoin(c, sdk.NewInt(40)), + }, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + + coins, err := cli.ParseCoinsNoSort(tc.coinsStr) + + require.NoError(t, err) + require.Equal(t, tc.expectedCoins, coins) + }) + } +} diff --git a/x/swaprouter/client/grpc/grpc_query.go b/x/swaprouter/client/grpc/grpc_query.go new file mode 100644 index 00000000000..3b6f67f0d71 --- /dev/null +++ b/x/swaprouter/client/grpc/grpc_query.go @@ -0,0 +1,62 @@ +package grpc + +// THIS FILE IS GENERATED CODE, DO NOT EDIT +// SOURCE AT `proto/osmosis/swaprouter/v1beta1/query.yml` + +import ( + context "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" +) + +type Querier struct { + Q client.Querier +} + +var _ queryproto.QueryServer = Querier{} + +func (q Querier) Params(grpcCtx context.Context, + req *queryproto.ParamsRequest, +) (*queryproto.ParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(grpcCtx) + return q.Q.Params(ctx, *req) +} + +func (q Querier) NumPools(grpcCtx context.Context, + req *queryproto.NumPoolsRequest, +) (*queryproto.NumPoolsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(grpcCtx) + return q.Q.NumPools(ctx, *req) +} + +func (q Querier) EstimateSwapExactAmountOut(grpcCtx context.Context, + req *queryproto.EstimateSwapExactAmountOutRequest, +) (*queryproto.EstimateSwapExactAmountOutResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(grpcCtx) + return q.Q.EstimateSwapExactAmountOut(ctx, *req) +} + +func (q Querier) EstimateSwapExactAmountIn(grpcCtx context.Context, + req *queryproto.EstimateSwapExactAmountInRequest, +) (*queryproto.EstimateSwapExactAmountInResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(grpcCtx) + return q.Q.EstimateSwapExactAmountIn(ctx, *req) +} + diff --git a/x/swaprouter/client/query_proto_wrap.go b/x/swaprouter/client/query_proto_wrap.go new file mode 100644 index 00000000000..2e3ef1d176d --- /dev/null +++ b/x/swaprouter/client/query_proto_wrap.go @@ -0,0 +1,81 @@ +package client + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/osmosis-labs/osmosis/v13/x/swaprouter" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +// This file should evolve to being code gen'd, off of `proto/swaprouter/v1beta/query.yml` + +type Querier struct { + K swaprouter.Keeper +} + +func (q Querier) Params(ctx sdk.Context, + req queryproto.ParamsRequest, +) (*queryproto.ParamsResponse, error) { + params := q.K.GetParams(ctx) + return &queryproto.ParamsResponse{Params: params}, nil +} + +// EstimateSwapExactAmountIn estimates input token amount for a swap. +func (q Querier) EstimateSwapExactAmountIn(ctx sdk.Context, req queryproto.EstimateSwapExactAmountInRequest) (*queryproto.EstimateSwapExactAmountInResponse, error) { + if req.TokenIn == "" { + return nil, status.Error(codes.InvalidArgument, "invalid token") + } + + tokenIn, err := sdk.ParseCoinNormalized(req.TokenIn) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid token: %s", err.Error()) + } + + tokenOutAmount, err := q.K.MultihopEstimateOutGivenExactAmountIn(ctx, req.Routes, tokenIn) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &queryproto.EstimateSwapExactAmountInResponse{ + TokenOutAmount: tokenOutAmount, + }, nil +} + +// EstimateSwapExactAmountOut estimates token output amount for a swap. +func (q Querier) EstimateSwapExactAmountOut(ctx sdk.Context, req queryproto.EstimateSwapExactAmountOutRequest) (*queryproto.EstimateSwapExactAmountOutResponse, error) { + if req.Sender == "" { + return nil, status.Error(codes.InvalidArgument, "address cannot be empty") + } + + if req.TokenOut == "" { + return nil, status.Error(codes.InvalidArgument, "invalid token") + } + + if err := types.SwapAmountOutRoutes(req.Routes).Validate(); err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + tokenOut, err := sdk.ParseCoinNormalized(req.TokenOut) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid token: %s", err.Error()) + } + + tokenInAmount, err := q.K.MultihopEstimateInGivenExactAmountOut(ctx, req.Routes, tokenOut) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &queryproto.EstimateSwapExactAmountOutResponse{ + TokenInAmount: tokenInAmount, + }, nil +} + +// NumPools returns total number of pools. +func (q Querier) NumPools(ctx sdk.Context, _ queryproto.NumPoolsRequest) (*queryproto.NumPoolsResponse, error) { + return &queryproto.NumPoolsResponse{ + NumPools: q.K.GetNextPoolId(ctx) - 1, + }, nil +} diff --git a/x/swaprouter/client/queryproto/query.pb.go b/x/swaprouter/client/queryproto/query.pb.go new file mode 100644 index 00000000000..3e7429d167f --- /dev/null +++ b/x/swaprouter/client/queryproto/query.pb.go @@ -0,0 +1,1932 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/swaprouter/v1beta1/query.proto + +package queryproto + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" + types "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// =============================== Params +type ParamsRequest struct { +} + +func (m *ParamsRequest) Reset() { *m = ParamsRequest{} } +func (m *ParamsRequest) String() string { return proto.CompactTextString(m) } +func (*ParamsRequest) ProtoMessage() {} +func (*ParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{0} +} +func (m *ParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsRequest.Merge(m, src) +} +func (m *ParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *ParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsRequest proto.InternalMessageInfo + +type ParamsResponse struct { + Params types.Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *ParamsResponse) Reset() { *m = ParamsResponse{} } +func (m *ParamsResponse) String() string { return proto.CompactTextString(m) } +func (*ParamsResponse) ProtoMessage() {} +func (*ParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{1} +} +func (m *ParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsResponse.Merge(m, src) +} +func (m *ParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *ParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsResponse proto.InternalMessageInfo + +func (m *ParamsResponse) GetParams() types.Params { + if m != nil { + return m.Params + } + return types.Params{} +} + +// =============================== EstimateSwapExactAmountIn +type EstimateSwapExactAmountInRequest struct { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenIn string `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty" yaml:"token_in"` + Routes []types.SwapAmountInRoute `protobuf:"bytes,4,rep,name=routes,proto3" json:"routes" yaml:"routes"` +} + +func (m *EstimateSwapExactAmountInRequest) Reset() { *m = EstimateSwapExactAmountInRequest{} } +func (m *EstimateSwapExactAmountInRequest) String() string { return proto.CompactTextString(m) } +func (*EstimateSwapExactAmountInRequest) ProtoMessage() {} +func (*EstimateSwapExactAmountInRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{2} +} +func (m *EstimateSwapExactAmountInRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EstimateSwapExactAmountInRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EstimateSwapExactAmountInRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EstimateSwapExactAmountInRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EstimateSwapExactAmountInRequest.Merge(m, src) +} +func (m *EstimateSwapExactAmountInRequest) XXX_Size() int { + return m.Size() +} +func (m *EstimateSwapExactAmountInRequest) XXX_DiscardUnknown() { + xxx_messageInfo_EstimateSwapExactAmountInRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_EstimateSwapExactAmountInRequest proto.InternalMessageInfo + +func (m *EstimateSwapExactAmountInRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *EstimateSwapExactAmountInRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *EstimateSwapExactAmountInRequest) GetTokenIn() string { + if m != nil { + return m.TokenIn + } + return "" +} + +func (m *EstimateSwapExactAmountInRequest) GetRoutes() []types.SwapAmountInRoute { + if m != nil { + return m.Routes + } + return nil +} + +type EstimateSwapExactAmountInResponse struct { + TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` +} + +func (m *EstimateSwapExactAmountInResponse) Reset() { *m = EstimateSwapExactAmountInResponse{} } +func (m *EstimateSwapExactAmountInResponse) String() string { return proto.CompactTextString(m) } +func (*EstimateSwapExactAmountInResponse) ProtoMessage() {} +func (*EstimateSwapExactAmountInResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{3} +} +func (m *EstimateSwapExactAmountInResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EstimateSwapExactAmountInResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EstimateSwapExactAmountInResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EstimateSwapExactAmountInResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EstimateSwapExactAmountInResponse.Merge(m, src) +} +func (m *EstimateSwapExactAmountInResponse) XXX_Size() int { + return m.Size() +} +func (m *EstimateSwapExactAmountInResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EstimateSwapExactAmountInResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_EstimateSwapExactAmountInResponse proto.InternalMessageInfo + +// =============================== EstimateSwapExactAmountOut +type EstimateSwapExactAmountOutRequest struct { + // TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + Routes []types.SwapAmountOutRoute `protobuf:"bytes,3,rep,name=routes,proto3" json:"routes" yaml:"routes"` + TokenOut string `protobuf:"bytes,4,opt,name=token_out,json=tokenOut,proto3" json:"token_out,omitempty" yaml:"token_out"` +} + +func (m *EstimateSwapExactAmountOutRequest) Reset() { *m = EstimateSwapExactAmountOutRequest{} } +func (m *EstimateSwapExactAmountOutRequest) String() string { return proto.CompactTextString(m) } +func (*EstimateSwapExactAmountOutRequest) ProtoMessage() {} +func (*EstimateSwapExactAmountOutRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{4} +} +func (m *EstimateSwapExactAmountOutRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EstimateSwapExactAmountOutRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EstimateSwapExactAmountOutRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EstimateSwapExactAmountOutRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EstimateSwapExactAmountOutRequest.Merge(m, src) +} +func (m *EstimateSwapExactAmountOutRequest) XXX_Size() int { + return m.Size() +} +func (m *EstimateSwapExactAmountOutRequest) XXX_DiscardUnknown() { + xxx_messageInfo_EstimateSwapExactAmountOutRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_EstimateSwapExactAmountOutRequest proto.InternalMessageInfo + +func (m *EstimateSwapExactAmountOutRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *EstimateSwapExactAmountOutRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *EstimateSwapExactAmountOutRequest) GetRoutes() []types.SwapAmountOutRoute { + if m != nil { + return m.Routes + } + return nil +} + +func (m *EstimateSwapExactAmountOutRequest) GetTokenOut() string { + if m != nil { + return m.TokenOut + } + return "" +} + +type EstimateSwapExactAmountOutResponse struct { + TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` +} + +func (m *EstimateSwapExactAmountOutResponse) Reset() { *m = EstimateSwapExactAmountOutResponse{} } +func (m *EstimateSwapExactAmountOutResponse) String() string { return proto.CompactTextString(m) } +func (*EstimateSwapExactAmountOutResponse) ProtoMessage() {} +func (*EstimateSwapExactAmountOutResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{5} +} +func (m *EstimateSwapExactAmountOutResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EstimateSwapExactAmountOutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EstimateSwapExactAmountOutResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EstimateSwapExactAmountOutResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EstimateSwapExactAmountOutResponse.Merge(m, src) +} +func (m *EstimateSwapExactAmountOutResponse) XXX_Size() int { + return m.Size() +} +func (m *EstimateSwapExactAmountOutResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EstimateSwapExactAmountOutResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_EstimateSwapExactAmountOutResponse proto.InternalMessageInfo + +// =============================== NumPools +type NumPoolsRequest struct { +} + +func (m *NumPoolsRequest) Reset() { *m = NumPoolsRequest{} } +func (m *NumPoolsRequest) String() string { return proto.CompactTextString(m) } +func (*NumPoolsRequest) ProtoMessage() {} +func (*NumPoolsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{6} +} +func (m *NumPoolsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NumPoolsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NumPoolsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NumPoolsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_NumPoolsRequest.Merge(m, src) +} +func (m *NumPoolsRequest) XXX_Size() int { + return m.Size() +} +func (m *NumPoolsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_NumPoolsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_NumPoolsRequest proto.InternalMessageInfo + +type NumPoolsResponse struct { + NumPools uint64 `protobuf:"varint,1,opt,name=num_pools,json=numPools,proto3" json:"num_pools,omitempty" yaml:"num_pools"` +} + +func (m *NumPoolsResponse) Reset() { *m = NumPoolsResponse{} } +func (m *NumPoolsResponse) String() string { return proto.CompactTextString(m) } +func (*NumPoolsResponse) ProtoMessage() {} +func (*NumPoolsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4d9de31afe32e1e0, []int{7} +} +func (m *NumPoolsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NumPoolsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NumPoolsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NumPoolsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_NumPoolsResponse.Merge(m, src) +} +func (m *NumPoolsResponse) XXX_Size() int { + return m.Size() +} +func (m *NumPoolsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_NumPoolsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_NumPoolsResponse proto.InternalMessageInfo + +func (m *NumPoolsResponse) GetNumPools() uint64 { + if m != nil { + return m.NumPools + } + return 0 +} + +func init() { + proto.RegisterType((*ParamsRequest)(nil), "osmosis.swaprouter.v1beta1.ParamsRequest") + proto.RegisterType((*ParamsResponse)(nil), "osmosis.swaprouter.v1beta1.ParamsResponse") + proto.RegisterType((*EstimateSwapExactAmountInRequest)(nil), "osmosis.swaprouter.v1beta1.EstimateSwapExactAmountInRequest") + proto.RegisterType((*EstimateSwapExactAmountInResponse)(nil), "osmosis.swaprouter.v1beta1.EstimateSwapExactAmountInResponse") + proto.RegisterType((*EstimateSwapExactAmountOutRequest)(nil), "osmosis.swaprouter.v1beta1.EstimateSwapExactAmountOutRequest") + proto.RegisterType((*EstimateSwapExactAmountOutResponse)(nil), "osmosis.swaprouter.v1beta1.EstimateSwapExactAmountOutResponse") + proto.RegisterType((*NumPoolsRequest)(nil), "osmosis.swaprouter.v1beta1.NumPoolsRequest") + proto.RegisterType((*NumPoolsResponse)(nil), "osmosis.swaprouter.v1beta1.NumPoolsResponse") +} + +func init() { + proto.RegisterFile("osmosis/swaprouter/v1beta1/query.proto", fileDescriptor_4d9de31afe32e1e0) +} + +var fileDescriptor_4d9de31afe32e1e0 = []byte{ + // 820 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0xd3, 0x6c, 0x36, 0x9d, 0x55, 0x9b, 0xee, 0xb0, 0x40, 0xd6, 0x42, 0x71, 0x18, 0x60, + 0xc9, 0xb6, 0xc4, 0x56, 0xba, 0x37, 0x44, 0x4b, 0x89, 0x14, 0x44, 0x2e, 0xb4, 0x98, 0x1b, 0x2a, + 0x8a, 0x26, 0xc9, 0x60, 0xac, 0xc6, 0x33, 0x6e, 0x66, 0xdc, 0x36, 0x42, 0x5c, 0x38, 0x21, 0x21, + 0x24, 0x24, 0x10, 0xe2, 0x23, 0xf5, 0x58, 0x89, 0x0b, 0xe2, 0x10, 0x50, 0xc3, 0x27, 0x88, 0xf8, + 0x00, 0xc8, 0x33, 0x63, 0x27, 0xad, 0x14, 0x37, 0x14, 0x71, 0xb2, 0xfd, 0xde, 0xef, 0xbd, 0xf9, + 0xfd, 0xde, 0x1f, 0x0f, 0x78, 0xc6, 0x78, 0xc0, 0xb8, 0xcf, 0x1d, 0x7e, 0x8e, 0xc3, 0x11, 0x8b, + 0x04, 0x19, 0x39, 0x67, 0xcd, 0x1e, 0x11, 0xb8, 0xe9, 0x9c, 0x46, 0x64, 0x34, 0xb6, 0xc3, 0x11, + 0x13, 0x0c, 0x9a, 0x1a, 0x67, 0xcf, 0x71, 0xb6, 0xc6, 0x99, 0x4f, 0x3c, 0xe6, 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 0xc4, 0xc9, + 0x74, 0x83, 0xbb, 0x3e, 0x85, 0x53, 0x03, 0x98, 0xcb, 0x87, 0x0d, 0xde, 0x87, 0xe4, 0x7c, 0x69, + 0xcd, 0xfd, 0xfb, 0x86, 0x6b, 0x91, 0x1f, 0x4a, 0x91, 0x07, 0x70, 0xff, 0x3f, 0x88, 0x64, 0x91, + 0x80, 0x3f, 0x19, 0xa0, 0x94, 0xcc, 0x29, 0xdc, 0xc9, 0x22, 0x75, 0x6b, 0xc0, 0xcd, 0x77, 0x56, + 0x03, 0x6b, 0xbe, 0x0d, 0xc9, 0xf7, 0x6d, 0xf8, 0x56, 0xd6, 0x6c, 0xa5, 0x1b, 0xd0, 0x3a, 0xbe, + 0xbc, 0xae, 0x1a, 0x57, 0xd7, 0x55, 0xe3, 0xcf, 0xeb, 0xaa, 0xf1, 0xc3, 0xb4, 0x9a, 0xbb, 0x9a, + 0x56, 0x73, 0xbf, 0x4d, 0xab, 0xb9, 0xcf, 0x5a, 0x0b, 0xbb, 0xab, 0x53, 0x35, 0x86, 0xb8, 0xc7, + 0xd3, 0xbc, 0x67, 0xcd, 0x17, 0xce, 0xc5, 0x62, 0xf6, 0xfe, 0xd0, 0x27, 0x54, 0xa8, 0xbb, 0x5e, + 0xdd, 0xba, 0x45, 0xf9, 0x78, 0xf1, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xcc, 0x3e, 0x24, + 0x02, 0x09, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error) + // Estimates swap amount out given in. + EstimateSwapExactAmountIn(ctx context.Context, in *EstimateSwapExactAmountInRequest, opts ...grpc.CallOption) (*EstimateSwapExactAmountInResponse, error) + // Estimates swap amount in given out. + EstimateSwapExactAmountOut(ctx context.Context, in *EstimateSwapExactAmountOutRequest, opts ...grpc.CallOption) (*EstimateSwapExactAmountOutResponse, error) + NumPools(ctx context.Context, in *NumPoolsRequest, opts ...grpc.CallOption) (*NumPoolsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error) { + out := new(ParamsResponse) + err := c.cc.Invoke(ctx, "/osmosis.swaprouter.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) EstimateSwapExactAmountIn(ctx context.Context, in *EstimateSwapExactAmountInRequest, opts ...grpc.CallOption) (*EstimateSwapExactAmountInResponse, error) { + out := new(EstimateSwapExactAmountInResponse) + err := c.cc.Invoke(ctx, "/osmosis.swaprouter.v1beta1.Query/EstimateSwapExactAmountIn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) EstimateSwapExactAmountOut(ctx context.Context, in *EstimateSwapExactAmountOutRequest, opts ...grpc.CallOption) (*EstimateSwapExactAmountOutResponse, error) { + out := new(EstimateSwapExactAmountOutResponse) + err := c.cc.Invoke(ctx, "/osmosis.swaprouter.v1beta1.Query/EstimateSwapExactAmountOut", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) NumPools(ctx context.Context, in *NumPoolsRequest, opts ...grpc.CallOption) (*NumPoolsResponse, error) { + out := new(NumPoolsResponse) + err := c.cc.Invoke(ctx, "/osmosis.swaprouter.v1beta1.Query/NumPools", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Params(context.Context, *ParamsRequest) (*ParamsResponse, error) + // Estimates swap amount out given in. + EstimateSwapExactAmountIn(context.Context, *EstimateSwapExactAmountInRequest) (*EstimateSwapExactAmountInResponse, error) + // Estimates swap amount in given out. + EstimateSwapExactAmountOut(context.Context, *EstimateSwapExactAmountOutRequest) (*EstimateSwapExactAmountOutResponse, error) + NumPools(context.Context, *NumPoolsRequest) (*NumPoolsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *ParamsRequest) (*ParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) EstimateSwapExactAmountIn(ctx context.Context, req *EstimateSwapExactAmountInRequest) (*EstimateSwapExactAmountInResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EstimateSwapExactAmountIn not implemented") +} +func (*UnimplementedQueryServer) EstimateSwapExactAmountOut(ctx context.Context, req *EstimateSwapExactAmountOutRequest) (*EstimateSwapExactAmountOutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EstimateSwapExactAmountOut not implemented") +} +func (*UnimplementedQueryServer) NumPools(ctx context.Context, req *NumPoolsRequest) (*NumPoolsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NumPools not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.swaprouter.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*ParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_EstimateSwapExactAmountIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EstimateSwapExactAmountInRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EstimateSwapExactAmountIn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.swaprouter.v1beta1.Query/EstimateSwapExactAmountIn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EstimateSwapExactAmountIn(ctx, req.(*EstimateSwapExactAmountInRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_EstimateSwapExactAmountOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EstimateSwapExactAmountOutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EstimateSwapExactAmountOut(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.swaprouter.v1beta1.Query/EstimateSwapExactAmountOut", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EstimateSwapExactAmountOut(ctx, req.(*EstimateSwapExactAmountOutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_NumPools_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NumPoolsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NumPools(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.swaprouter.v1beta1.Query/NumPools", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NumPools(ctx, req.(*NumPoolsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.swaprouter.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "EstimateSwapExactAmountIn", + Handler: _Query_EstimateSwapExactAmountIn_Handler, + }, + { + MethodName: "EstimateSwapExactAmountOut", + Handler: _Query_EstimateSwapExactAmountOut_Handler, + }, + { + MethodName: "NumPools", + Handler: _Query_NumPools_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/swaprouter/v1beta1/query.proto", +} + +func (m *ParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *EstimateSwapExactAmountInRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EstimateSwapExactAmountInRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EstimateSwapExactAmountInRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Routes) > 0 { + for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.TokenIn) > 0 { + i -= len(m.TokenIn) + copy(dAtA[i:], m.TokenIn) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenIn))) + i-- + dAtA[i] = 0x1a + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EstimateSwapExactAmountInResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EstimateSwapExactAmountInResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EstimateSwapExactAmountInResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TokenOutAmount.Size() + i -= size + if _, err := m.TokenOutAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *EstimateSwapExactAmountOutRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EstimateSwapExactAmountOutRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EstimateSwapExactAmountOutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenOut) > 0 { + i -= len(m.TokenOut) + copy(dAtA[i:], m.TokenOut) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenOut))) + i-- + dAtA[i] = 0x22 + } + if len(m.Routes) > 0 { + for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EstimateSwapExactAmountOutResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EstimateSwapExactAmountOutResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EstimateSwapExactAmountOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TokenInAmount.Size() + i -= size + if _, err := m.TokenInAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *NumPoolsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NumPoolsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NumPoolsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *NumPoolsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NumPoolsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NumPoolsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumPools != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.NumPools)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *EstimateSwapExactAmountInRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.TokenIn) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Routes) > 0 { + for _, e := range m.Routes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *EstimateSwapExactAmountInResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TokenOutAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *EstimateSwapExactAmountOutRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + if len(m.Routes) > 0 { + for _, e := range m.Routes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + l = len(m.TokenOut) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *EstimateSwapExactAmountOutResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TokenInAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *NumPoolsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *NumPoolsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NumPools != 0 { + n += 1 + sovQuery(uint64(m.NumPools)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EstimateSwapExactAmountInRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EstimateSwapExactAmountInRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EstimateSwapExactAmountInRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenIn", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenIn = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Routes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Routes = append(m.Routes, types.SwapAmountInRoute{}) + if err := m.Routes[len(m.Routes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EstimateSwapExactAmountInResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EstimateSwapExactAmountInResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EstimateSwapExactAmountInResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOutAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenOutAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EstimateSwapExactAmountOutRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EstimateSwapExactAmountOutRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EstimateSwapExactAmountOutRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Routes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Routes = append(m.Routes, types.SwapAmountOutRoute{}) + if err := m.Routes[len(m.Routes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOut", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenOut = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EstimateSwapExactAmountOutResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EstimateSwapExactAmountOutResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EstimateSwapExactAmountOutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenInAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenInAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NumPoolsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NumPoolsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NumPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NumPoolsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NumPoolsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NumPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumPools", wireType) + } + m.NumPools = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumPools |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/swaprouter/client/queryproto/query.pb.gw.go b/x/swaprouter/client/queryproto/query.pb.gw.go new file mode 100644 index 00000000000..5ddc6f256aa --- /dev/null +++ b/x/swaprouter/client/queryproto/query.pb.gw.go @@ -0,0 +1,456 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/swaprouter/v1beta1/query.proto + +/* +Package queryproto is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package queryproto + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_EstimateSwapExactAmountIn_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_EstimateSwapExactAmountIn_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EstimateSwapExactAmountInRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EstimateSwapExactAmountIn_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.EstimateSwapExactAmountIn(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EstimateSwapExactAmountIn_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EstimateSwapExactAmountInRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EstimateSwapExactAmountIn_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.EstimateSwapExactAmountIn(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_EstimateSwapExactAmountOut_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_EstimateSwapExactAmountOut_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EstimateSwapExactAmountOutRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EstimateSwapExactAmountOut_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.EstimateSwapExactAmountOut(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EstimateSwapExactAmountOut_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EstimateSwapExactAmountOutRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EstimateSwapExactAmountOut_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.EstimateSwapExactAmountOut(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_NumPools_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq NumPoolsRequest + var metadata runtime.ServerMetadata + + msg, err := client.NumPools(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_NumPools_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq NumPoolsRequest + var metadata runtime.ServerMetadata + + msg, err := server.NumPools(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EstimateSwapExactAmountIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_EstimateSwapExactAmountIn_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EstimateSwapExactAmountIn_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EstimateSwapExactAmountOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_EstimateSwapExactAmountOut_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EstimateSwapExactAmountOut_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NumPools_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_NumPools_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NumPools_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EstimateSwapExactAmountIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_EstimateSwapExactAmountIn_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EstimateSwapExactAmountIn_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EstimateSwapExactAmountOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_EstimateSwapExactAmountOut_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EstimateSwapExactAmountOut_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NumPools_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_NumPools_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NumPools_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "swaprouter", "v1beta1", "Params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_EstimateSwapExactAmountIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pool_id", "estimate", "swap_exact_amount_in"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_EstimateSwapExactAmountOut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pool_id", "estimate", "swap_exact_amount_out"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_NumPools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "swaprouter", "v1beta1", "num_pools"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_EstimateSwapExactAmountIn_0 = runtime.ForwardResponseMessage + + forward_Query_EstimateSwapExactAmountOut_0 = runtime.ForwardResponseMessage + + forward_Query_NumPools_0 = runtime.ForwardResponseMessage +) diff --git a/x/swaprouter/client/testutil/test_helpers.go b/x/swaprouter/client/testutil/test_helpers.go new file mode 100644 index 00000000000..59d14a5b047 --- /dev/null +++ b/x/swaprouter/client/testutil/test_helpers.go @@ -0,0 +1,82 @@ +package testutil + +import ( + "encoding/json" + "fmt" + "testing" + + "github.com/osmosis-labs/osmosis/v13/app" + swaproutercli "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/cli" + swaproutertypes "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// commonArgs is args for CLI test commands. +var commonArgs = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), +} + +// MsgCreatePool broadcast a pool creation message. +func MsgCreatePool( + t *testing.T, + clientCtx client.Context, + owner fmt.Stringer, + tokenWeights string, + initialDeposit string, + swapFee string, + exitFee string, + futureGovernor string, + extraArgs ...string, +) (testutil.BufferWriter, error) { + args := []string{} + + jsonFile := testutil.WriteToNewTempFile(t, + fmt.Sprintf(` + { + "%s": "%s", + "%s": "%s", + "%s": "%s", + "%s": "%s", + "%s": "%s" + } + `, swaproutercli.PoolFileWeights, + tokenWeights, + swaproutercli.PoolFileInitialDeposit, + initialDeposit, + swaproutercli.PoolFileSwapFee, + swapFee, + swaproutercli.PoolFileExitFee, + exitFee, + swaproutercli.PoolFileExitFee, + exitFee, + ), + ) + + args = append(args, + fmt.Sprintf("--%s=%s", swaproutercli.FlagPoolFile, jsonFile.Name()), + fmt.Sprintf("--%s=%s", flags.FlagFrom, owner.String()), + fmt.Sprintf("--%s=%d", flags.FlagGas, 400000), + ) + + args = append(args, commonArgs...) + return clitestutil.ExecTestCLICmd(clientCtx, swaproutercli.NewCreatePoolCmd(), args) +} + +// UpdateTxFeeDenom creates and modifies gamm genesis to pay fee with given denom. +func UpdateTxFeeDenom(cdc codec.Codec, denom string) map[string]json.RawMessage { + // modification to pay fee with test bond denom "stake" + genesisState := app.ModuleBasics.DefaultGenesis(cdc) + swaprouterGen := swaproutertypes.DefaultGenesis() + swaprouterGen.Params.PoolCreationFee = sdk.Coins{sdk.NewInt64Coin(denom, 1000000)} + swaprouterGenJson := cdc.MustMarshalJSON(swaprouterGen) + genesisState[swaproutertypes.ModuleName] = swaprouterGenJson + return genesisState +} diff --git a/x/swaprouter/creator.go b/x/swaprouter/creator.go new file mode 100644 index 00000000000..6b662bd5c97 --- /dev/null +++ b/x/swaprouter/creator.go @@ -0,0 +1,20 @@ +package swaprouter + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +// CreatePool attempts to create a pool returning the newly created pool ID or +// an error upon failure. The pool creation fee is used to fund the community +// pool. It will create a dedicated module account for the pool and sends the +// initial liquidity to the created module account. +// +// After the initial liquidity is sent to the pool's account, shares are minted +// and sent to the pool creator. The shares are created using a denomination in +// the form of /pool/{poolID}. In addition, the x/bank metadata is updated +// to reflect the newly created GAMM share denomination. +func (k Keeper) CreatePool(ctx sdk.Context, msg types.CreatePoolMsg) (uint64, error) { + panic("not implemented") +} diff --git a/x/swaprouter/events/emit.go b/x/swaprouter/events/emit.go new file mode 100644 index 00000000000..696bfde4176 --- /dev/null +++ b/x/swaprouter/events/emit.go @@ -0,0 +1,58 @@ +package events + +import ( + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" +) + +func EmitSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { + ctx.EventManager().EmitEvents(sdk.Events{ + newSwapEvent(sender, poolId, input, output), + }) +} + +func newSwapEvent(sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) sdk.Event { + return sdk.NewEvent( + types.TypeEvtTokenSwapped, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensIn, input.String()), + sdk.NewAttribute(types.AttributeKeyTokensOut, output.String()), + ) +} + +func EmitAddLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) { + ctx.EventManager().EmitEvents(sdk.Events{ + newAddLiquidityEvent(sender, poolId, liquidity), + }) +} + +func newAddLiquidityEvent(sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) sdk.Event { + return sdk.NewEvent( + types.TypeEvtPoolJoined, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensIn, liquidity.String()), + ) +} + +func EmitRemoveLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) { + ctx.EventManager().EmitEvents(sdk.Events{ + newRemoveLiquidityEvent(sender, poolId, liquidity), + }) +} + +func newRemoveLiquidityEvent(sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) sdk.Event { + return sdk.NewEvent( + types.TypeEvtPoolExited, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensOut, liquidity.String()), + ) +} diff --git a/x/swaprouter/events/emit_test.go b/x/swaprouter/events/emit_test.go new file mode 100644 index 00000000000..05a01f620a2 --- /dev/null +++ b/x/swaprouter/events/emit_test.go @@ -0,0 +1,186 @@ +package events_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/events" +) + +type SwapRouterEventsTestSuite struct { + apptesting.KeeperTestHelper +} + +const ( + addressString = "addr1---------------" + testDenomA = "denoma" + testDenomB = "denomb" + testDenomC = "denomc" + testDenomD = "denomd" +) + +func TestSwapRouterEventsTestSuite(t *testing.T) { + suite.Run(t, new(SwapRouterEventsTestSuite)) +} + +func (suite *SwapRouterEventsTestSuite) TestEmitSwapEvent() { + testcases := map[string]struct { + ctx sdk.Context + testAccountAddr sdk.AccAddress + poolId uint64 + tokensIn sdk.Coins + tokensOut sdk.Coins + }{ + "basic valid": { + ctx: suite.CreateTestContext(), + testAccountAddr: sdk.AccAddress([]byte(addressString)), + poolId: 1, + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(1234))), + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomB, sdk.NewInt(5678))), + }, + "valid with multiple tokens in and out": { + ctx: suite.CreateTestContext(), + testAccountAddr: sdk.AccAddress([]byte(addressString)), + poolId: 200, + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(12)), sdk.NewCoin(testDenomB, sdk.NewInt(99))), + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomC, sdk.NewInt(88)), sdk.NewCoin(testDenomD, sdk.NewInt(34))), + }, + } + + for name, tc := range testcases { + suite.Run(name, func() { + expectedEvents := sdk.Events{ + sdk.NewEvent( + types.TypeEvtTokenSwapped, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, tc.testAccountAddr.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(tc.poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensIn, tc.tokensIn.String()), + sdk.NewAttribute(types.AttributeKeyTokensOut, tc.tokensOut.String()), + ), + } + + hasNoEventManager := tc.ctx.EventManager() == nil + + // System under test. + events.EmitSwapEvent(tc.ctx, tc.testAccountAddr, tc.poolId, tc.tokensIn, tc.tokensOut) + + // Assertions + if hasNoEventManager { + // If there is no event manager on context, this is a no-op. + return + } + + eventManager := tc.ctx.EventManager() + actualEvents := eventManager.Events() + suite.Equal(expectedEvents, actualEvents) + }) + } +} + +func (suite *SwapRouterEventsTestSuite) TestEmitAddLiquidityEvent() { + testcases := map[string]struct { + ctx sdk.Context + testAccountAddr sdk.AccAddress + poolId uint64 + tokensIn sdk.Coins + }{ + "basic valid": { + ctx: suite.CreateTestContext(), + testAccountAddr: sdk.AccAddress([]byte(addressString)), + poolId: 1, + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(1234))), + }, + "valid with multiple tokens in": { + ctx: suite.CreateTestContext(), + testAccountAddr: sdk.AccAddress([]byte(addressString)), + poolId: 200, + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(12)), sdk.NewCoin(testDenomB, sdk.NewInt(99))), + }, + } + + for name, tc := range testcases { + suite.Run(name, func() { + expectedEvents := sdk.Events{ + sdk.NewEvent( + types.TypeEvtPoolJoined, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, tc.testAccountAddr.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(tc.poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensIn, tc.tokensIn.String()), + ), + } + + hasNoEventManager := tc.ctx.EventManager() == nil + + // System under test. + events.EmitAddLiquidityEvent(tc.ctx, tc.testAccountAddr, tc.poolId, tc.tokensIn) + + // Assertions + if hasNoEventManager { + // If there is no event manager on context, this is a no-op. + return + } + + eventManager := tc.ctx.EventManager() + actualEvents := eventManager.Events() + suite.Equal(expectedEvents, actualEvents) + }) + } +} + +func (suite *SwapRouterEventsTestSuite) TestEmitRemoveLiquidityEvent() { + testcases := map[string]struct { + ctx sdk.Context + testAccountAddr sdk.AccAddress + poolId uint64 + tokensOut sdk.Coins + }{ + "basic valid": { + ctx: suite.CreateTestContext(), + testAccountAddr: sdk.AccAddress([]byte(addressString)), + poolId: 1, + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(1234))), + }, + "valid with multiple tokens out": { + ctx: suite.CreateTestContext(), + testAccountAddr: sdk.AccAddress([]byte(addressString)), + poolId: 200, + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(12)), sdk.NewCoin(testDenomB, sdk.NewInt(99))), + }, + } + + for name, tc := range testcases { + suite.Run(name, func() { + expectedEvents := sdk.Events{ + sdk.NewEvent( + types.TypeEvtPoolExited, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, tc.testAccountAddr.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(tc.poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensOut, tc.tokensOut.String()), + ), + } + + hasNoEventManager := tc.ctx.EventManager() == nil + + // System under test. + events.EmitRemoveLiquidityEvent(tc.ctx, tc.testAccountAddr, tc.poolId, tc.tokensOut) + + // Assertions + if hasNoEventManager { + // If there is no event manager on context, this is a no-op. + return + } + + eventManager := tc.ctx.EventManager() + actualEvents := eventManager.Events() + suite.Equal(expectedEvents, actualEvents) + }) + } +} diff --git a/x/swaprouter/export_test.go b/x/swaprouter/export_test.go new file mode 100644 index 00000000000..9f8dc2357ee --- /dev/null +++ b/x/swaprouter/export_test.go @@ -0,0 +1,14 @@ +package swaprouter + +import ( + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +// SetPoolRoutesUnsafe sets the given routes to the swaprouter keeper +// to allow routing from a pool type to a certain swap module. +// For example, balancer -> gamm. +// This utility function is only exposed for testing and should not be moved +// outside of the _test.go files. +func (k *Keeper) SetPoolRoutesUnsafe(routes map[types.PoolType]types.SwapI) { + k.routes = routes +} diff --git a/x/swaprouter/keeper.go b/x/swaprouter/keeper.go new file mode 100644 index 00000000000..1f87618092f --- /dev/null +++ b/x/swaprouter/keeper.go @@ -0,0 +1,103 @@ +package swaprouter + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/gogo/protobuf/types" + + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +type Keeper struct { + storeKey sdk.StoreKey + + gammKeeper types.SwapI + concentratedKeeper types.SwapI + poolIncentivesKeeper types.PoolIncentivesKeeperI + bankKeeper types.BankI + accountKeeper types.AccountI + communityPoolKeeper types.CommunityPoolI + + poolCreationListeners types.PoolCreationListeners + + routes map[types.PoolType]types.SwapI + + paramSpace paramtypes.Subspace +} + +func NewKeeper(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, gammKeeper types.SwapI, concentratedKeeper types.SwapI, bankKeeper types.BankI, accountKeeper types.AccountI, communityPoolKeeper types.CommunityPoolI) *Keeper { + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + + routes := map[types.PoolType]types.SwapI{ + types.Balancer: gammKeeper, + types.StableSwap: gammKeeper, + types.Concentrated: concentratedKeeper, + } + + return &Keeper{storeKey: storeKey, paramSpace: paramSpace, gammKeeper: gammKeeper, concentratedKeeper: concentratedKeeper, bankKeeper: bankKeeper, accountKeeper: accountKeeper, communityPoolKeeper: communityPoolKeeper, routes: routes} +} + +// GetParams returns the total set of swaprouter parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramSpace.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams sets the total set of swaprouter parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} + +// InitGenesis initializes the swaprouter module's state from a provided genesis +// state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { + k.SetNextPoolId(ctx, genState.NextPoolId) + if err := genState.Validate(); err != nil { + panic(err) + } + + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the swaprouter module's exported genesis. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return &types.GenesisState{ + Params: k.GetParams(ctx), + NextPoolId: k.GetNextPoolId(ctx), + } +} + +// GetNextPoolId returns the next pool id. +func (k Keeper) GetNextPoolId(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + nextPoolId := gogotypes.UInt64Value{} + osmoutils.MustGet(store, types.KeyNextGlobalPoolId, &nextPoolId) + return nextPoolId.Value +} + +// SetPoolCreationListeners sets the pool creation listeners. +func (k *Keeper) SetPoolCreationListeners(listeners types.PoolCreationListeners) *Keeper { + if k.poolCreationListeners != nil { + panic("cannot set pool creation listeners twice") + } + + k.poolCreationListeners = listeners + + return k +} + +// SetNextPoolId sets next pool Id. +func (k Keeper) SetNextPoolId(ctx sdk.Context, poolId uint64) { + store := ctx.KVStore(k.storeKey) + osmoutils.MustSet(store, types.KeyNextGlobalPoolId, &gogotypes.UInt64Value{Value: poolId}) +} + +// SetPoolIncentivesKeeper sets pool incentives keeper +func (k *Keeper) SetPoolIncentivesKeeper(poolIncentivesKeeper types.PoolIncentivesKeeperI) { + k.poolIncentivesKeeper = poolIncentivesKeeper +} diff --git a/x/swaprouter/keeper_test.go b/x/swaprouter/keeper_test.go new file mode 100644 index 00000000000..98e05f6a7b1 --- /dev/null +++ b/x/swaprouter/keeper_test.go @@ -0,0 +1,56 @@ +package swaprouter_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +type KeeperTestSuite struct { + apptesting.KeeperTestHelper +} + +const testExpectedPoolId = 3 + +var testPoolCreationFee = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000_000_000)} + +func TestKeeperTestSuite(t *testing.T) { + + // TODO: re-enable this once swaprouter is fully merged. + t.SkipNow() + + suite.Run(t, new(KeeperTestSuite)) +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.Setup() +} + +// createPoolFromType creates a basic pool of the given type for testing. +func (suite *KeeperTestSuite) createPoolFromType(poolType types.PoolType) { + switch poolType { + case types.Balancer: + suite.PrepareBalancerPool() + return + case types.StableSwap: + // TODO + return + case types.Concentrated: + // TODO + return + } +} + +// createBalancerPoolsFromCoins creates balancer pools from given sets of coins. +// Where element 1 of the input corresponds to the first pool created, +// element 2 to the second pool created, up until the last element. +func (suite *KeeperTestSuite) createBalancerPoolsFromCoins(poolCoins []sdk.Coins) { + for _, curPoolCoins := range poolCoins { + suite.FundAcc(suite.TestAccs[0], curPoolCoins) + suite.PrepareBalancerPoolWithCoins(curPoolCoins...) + } +} diff --git a/x/swaprouter/module/module.go b/x/swaprouter/module/module.go new file mode 100644 index 00000000000..35e320af96f --- /dev/null +++ b/x/swaprouter/module/module.go @@ -0,0 +1,154 @@ +package module + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +type AppModuleBasic struct{} + +func (AppModuleBasic) Name() string { return types.ModuleName } + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the swaprouter module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// --------------------------------------- +// Interfaces. +func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) { +} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := queryproto.RegisterQueryHandlerClient(context.Background(), mux, queryproto.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// RegisterInterfaces registers interfaces and implementations of the gamm module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +} + +type AppModule struct { + AppModuleBasic + + k swaprouter.Keeper + gammKeeper types.GammKeeper +} + +func (am AppModule) RegisterServices(cfg module.Configurator) { +} + +func NewAppModule(swaprouterKeeper swaprouter.Keeper, gammKeeper types.GammKeeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + k: swaprouterKeeper, + gammKeeper: gammKeeper, + } +} + +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +} + +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// QuerierRoute returns the gamm module's querier route name. +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// LegacyQuerierHandler returns the x/gamm module's sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { + return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName) + } +} + +// InitGenesis performs genesis initialization for the swaprouter module. +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(gs, &genesisState) + + am.k.InitGenesis(ctx, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the swaprouter. +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.k.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// BeginBlock performs a no-op. +func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock performs a no-op. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// **** simulation implementation **** +// GenerateGenesisState creates a randomized GenState of the swaprouter module. +// **** simulation implementation **** +// GenerateGenesisState creates a randomized GenState of the gamm module. +func (am AppModule) SimulatorGenesisState(simState *module.SimulationState, s *simtypes.SimCtx) { + swaprouterGen := types.DefaultGenesis() + // change the pool creation fee denom from uosmo to stake + // TODO: uncomment this once simulation is enabled. + // swaprouterGen.Params.PoolCreationFee = sdk.NewCoins(swaproutersimulation.PoolCreationFee) + DefaultGenJson := simState.Cdc.MustMarshalJSON(swaprouterGen) + simState.GenState[types.ModuleName] = DefaultGenJson +} + +func (am AppModule) Actions() []simtypes.Action { + // TODO: uncomment this once simulation is enabled. + // return swaproutersimulation.DefaultActions(am.k, am.gammKeeper) + return nil +} diff --git a/x/swaprouter/msg_server.go b/x/swaprouter/msg_server.go new file mode 100644 index 00000000000..1838c824611 --- /dev/null +++ b/x/swaprouter/msg_server.go @@ -0,0 +1,99 @@ +package swaprouter + +import ( + "context" + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +type msgServer struct { + keeper *Keeper +} + +func NewMsgServerImpl(keeper *Keeper) types.MsgServer { + return &msgServer{ + keeper: keeper, + } +} + +// CreatePool attempts to create a pool returning the newly created pool ID or an error upon failure. +// The pool creation fee is used to fund the community pool. +// It will create a dedicated module account for the pool and sends the initial liquidity to the created module account. +func (server msgServer) CreatePool(goCtx context.Context, msg types.CreatePoolMsg) (poolId uint64, err error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + poolId, err = server.keeper.CreatePool(ctx, msg) + if err != nil { + return 0, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + gammtypes.TypeEvtPoolCreated, + sdk.NewAttribute(gammtypes.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.PoolCreator().String()), + ), + }) + + return poolId, nil +} + +// TODO: spec and tests, including events +func (server msgServer) SwapExactAmountIn(goCtx context.Context, msg *types.MsgSwapExactAmountIn) (*types.MsgSwapExactAmountInResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err + } + + tokenOutAmount, err := server.keeper.RouteExactAmountIn(ctx, sender, msg.Routes, msg.TokenIn, msg.TokenOutMinAmount) + if err != nil { + return nil, err + } + + // Swap event is handled elsewhere + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + }) + + return &types.MsgSwapExactAmountInResponse{TokenOutAmount: tokenOutAmount}, nil +} + +// TODO: spec and tests, including events +func (server msgServer) SwapExactAmountOut(goCtx context.Context, msg *types.MsgSwapExactAmountOut) (*types.MsgSwapExactAmountOutResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err + } + + tokenInAmount, err := server.keeper.RouteExactAmountOut(ctx, sender, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut) + if err != nil { + return nil, err + } + + // Swap event is handled elsewhere + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + }) + + return &types.MsgSwapExactAmountOutResponse{TokenInAmount: tokenInAmount}, nil +} diff --git a/x/swaprouter/router.go b/x/swaprouter/router.go new file mode 100644 index 00000000000..2ec9c2ed4c7 --- /dev/null +++ b/x/swaprouter/router.go @@ -0,0 +1,48 @@ +package swaprouter + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +// RouteExactAmountIn defines the input denom and input amount for the first pool, +// the output of the first pool is chained as the input for the next routed pool +// transaction succeeds when final amount out is greater than tokenOutMinAmount defined. +func (k Keeper) RouteExactAmountIn( + ctx sdk.Context, + sender sdk.AccAddress, + routes []types.SwapAmountInRoute, + tokenIn sdk.Coin, + tokenOutMinAmount sdk.Int) (tokenOutAmount sdk.Int, err error) { + panic("not implemented") +} + +func (k Keeper) MultihopEstimateOutGivenExactAmountIn( + ctx sdk.Context, + routes []types.SwapAmountInRoute, + tokenIn sdk.Coin, +) (tokenOutAmount sdk.Int, err error) { + panic("not implemented") +} + +// MultihopSwapExactAmountOut defines the output denom and output amount for the last pool. +// Calculation starts by providing the tokenOutAmount of the final pool to calculate the required tokenInAmount +// the calculated tokenInAmount is used as defined tokenOutAmount of the previous pool, calculating in reverse order of the swap +// Transaction succeeds if the calculated tokenInAmount of the first pool is less than the defined tokenInMaxAmount defined. +func (k Keeper) RouteExactAmountOut(ctx sdk.Context, + sender sdk.AccAddress, + routes []types.SwapAmountOutRoute, + tokenInMaxAmount sdk.Int, + tokenOut sdk.Coin, +) (tokenInAmount sdk.Int, err error) { + panic("not implemented") +} + +func (k Keeper) MultihopEstimateInGivenExactAmountOut( + ctx sdk.Context, + routes []types.SwapAmountOutRoute, + tokenOut sdk.Coin, +) (tokenInAmount sdk.Int, err error) { + panic("not implemented") +} diff --git a/x/swaprouter/router_test.go b/x/swaprouter/router_test.go new file mode 100644 index 00000000000..d91fa9d3ddd --- /dev/null +++ b/x/swaprouter/router_test.go @@ -0,0 +1,314 @@ +package swaprouter_test + +import ( + "reflect" + + sdk "github.com/cosmos/cosmos-sdk/types" + + gamm "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" +) + +const ( + foo = "foo" + bar = "bar" + baz = "baz" + uosmo = "uosmo" +) + +var ( + defaultInitPoolAmount = sdk.NewInt(1000000000000) + defaultPoolSwapFee = sdk.NewDecWithPrec(1, 2) // 1% pool swap fee default + defaultSwapAmount = sdk.NewInt(1000000) + gammKeeperType = reflect.TypeOf(&gamm.Keeper{}) +) + +// TestEstimateMultihopSwapExactAmountIn tests that the estimation done via `EstimateSwapExactAmountIn` +// results in the same amount of token out as the actual swap. +func (suite *KeeperTestSuite) TestEstimateMultihopSwapExactAmountIn() { + type param struct { + routes []types.SwapAmountInRoute + estimateRoutes []types.SwapAmountInRoute + tokenIn sdk.Coin + tokenOutMinAmount sdk.Int + } + + tests := []struct { + name string + param param + expectPass bool + reducedFeeApplied bool + }{ + { + name: "Proper swap - foo -> bar(pool 1) - bar(pool 2) -> baz", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: bar, + }, + { + PoolId: 2, + TokenOutDenom: baz, + }, + }, + estimateRoutes: []types.SwapAmountInRoute{ + { + PoolId: 3, + TokenOutDenom: bar, + }, + { + PoolId: 4, + TokenOutDenom: baz, + }, + }, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + expectPass: true, + }, + { + name: "Swap - foo -> uosmo(pool 1) - uosmo(pool 2) -> baz with a half fee applied", + param: param{ + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: baz, + }, + }, + estimateRoutes: []types.SwapAmountInRoute{ + { + PoolId: 3, + TokenOutDenom: uosmo, + }, + { + PoolId: 4, + TokenOutDenom: baz, + }, + }, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + }, + reducedFeeApplied: true, + expectPass: true, + }, + } + + for _, test := range tests { + // Init suite for each test. + suite.SetupTest() + + suite.Run(test.name, func() { + swaprouterKeeper := suite.App.SwapRouterKeeper + poolDefaultSwapFee := sdk.NewDecWithPrec(1, 2) // 1% + + // Prepare 4 pools, + // Two pools for calculating `MultihopSwapExactAmountIn` + // and two pools for calculating `EstimateMultihopSwapExactAmountIn` + suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + + firstEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + secondEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + + firstEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + // calculate token out amount using `MultihopSwapExactAmountIn` + multihopTokenOutAmount, err := swaprouterKeeper.RouteExactAmountIn( + suite.Ctx, + suite.TestAccs[0], + test.param.routes, + test.param.tokenIn, + test.param.tokenOutMinAmount) + suite.Require().NoError(err) + + // calculate token out amount using `EstimateMultihopSwapExactAmountIn` + estimateMultihopTokenOutAmount, err := swaprouterKeeper.MultihopEstimateOutGivenExactAmountIn( + suite.Ctx, + test.param.estimateRoutes, + test.param.tokenIn) + suite.Require().NoError(err) + + // ensure that the token out amount is same + suite.Require().Equal(multihopTokenOutAmount, estimateMultihopTokenOutAmount) + + // ensure that pool state has not been altered after estimation + firstEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + suite.Require().Equal(firstEstimatePool, firstEstimatePoolAfterSwap) + suite.Require().Equal(secondEstimatePool, secondEstimatePoolAfterSwap) + }) + } +} + +// TestEstimateMultihopSwapExactAmountOut tests that the estimation done via `EstimateSwapExactAmountOut` +// results in the same amount of token in as the actual swap. +func (suite *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { + type param struct { + routes []types.SwapAmountOutRoute + estimateRoutes []types.SwapAmountOutRoute + tokenInMaxAmount sdk.Int + tokenOut sdk.Coin + } + + tests := []struct { + name string + param param + expectPass bool + reducedFeeApplied bool + }{ + { + name: "Proper swap: foo -> bar (pool 1), bar -> baz (pool 2)", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: foo, + }, + { + PoolId: 2, + TokenInDenom: bar, + }, + }, + estimateRoutes: []types.SwapAmountOutRoute{ + { + PoolId: 3, + TokenInDenom: foo, + }, + { + PoolId: 4, + TokenInDenom: bar, + }, + }, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + }, + expectPass: true, + }, + { + name: "Swap - foo -> uosmo(pool 1) - uosmo(pool 2) -> baz with a half fee applied", + param: param{ + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: foo, + }, + { + PoolId: 2, + TokenInDenom: uosmo, + }, + }, + estimateRoutes: []types.SwapAmountOutRoute{ + { + PoolId: 3, + TokenInDenom: foo, + }, + { + PoolId: 4, + TokenInDenom: uosmo, + }, + }, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + }, + expectPass: true, + reducedFeeApplied: true, + }, + } + + for _, test := range tests { + // Init suite for each test. + suite.SetupTest() + + suite.Run(test.name, func() { + swaprouterKeeper := suite.App.SwapRouterKeeper + poolDefaultSwapFee := sdk.NewDecWithPrec(1, 2) // 1% + + // Prepare 4 pools, + // Two pools for calculating `MultihopSwapExactAmountOut` + // and two pools for calculating `EstimateMultihopSwapExactAmountOut` + suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, // 1% + ExitFee: sdk.NewDec(0), + }) + suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + firstEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, // 1% + ExitFee: sdk.NewDec(0), + }) + secondEstimatePoolId := suite.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ + SwapFee: poolDefaultSwapFee, + ExitFee: sdk.NewDec(0), + }) + firstEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + multihopTokenInAmount, err := swaprouterKeeper.RouteExactAmountOut( + suite.Ctx, + suite.TestAccs[0], + test.param.routes, + test.param.tokenInMaxAmount, + test.param.tokenOut) + suite.Require().NoError(err, "test: %v", test.name) + + estimateMultihopTokenInAmount, err := swaprouterKeeper.MultihopEstimateInGivenExactAmountOut( + suite.Ctx, + test.param.estimateRoutes, + test.param.tokenOut) + suite.Require().NoError(err, "test: %v", test.name) + + suite.Require().Equal(multihopTokenInAmount, estimateMultihopTokenInAmount) + + // ensure that pool state has not been altered after estimation + firstEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, firstEstimatePoolId) + suite.Require().NoError(err) + secondEstimatePoolAfterSwap, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, secondEstimatePoolId) + suite.Require().NoError(err) + + suite.Require().Equal(firstEstimatePool, firstEstimatePoolAfterSwap) + suite.Require().Equal(secondEstimatePool, secondEstimatePoolAfterSwap) + }) + } +} + +func (suite *KeeperTestSuite) makeGaugesIncentivized(incentivizedGauges []uint64) { + var records []poolincentivestypes.DistrRecord + totalWeight := sdk.NewInt(int64(len(incentivizedGauges))) + for _, gauge := range incentivizedGauges { + records = append(records, poolincentivestypes.DistrRecord{GaugeId: gauge, Weight: sdk.OneInt()}) + } + distInfo := poolincentivestypes.DistrInfo{ + TotalWeight: totalWeight, + Records: records, + } + suite.App.PoolIncentivesKeeper.SetDistrInfo(suite.Ctx, distInfo) +} diff --git a/x/swaprouter/types/constants.go b/x/swaprouter/types/constants.go new file mode 100644 index 00000000000..7a99299341b --- /dev/null +++ b/x/swaprouter/types/constants.go @@ -0,0 +1,6 @@ +package types + +const ( + MinPoolAssets = 2 + MaxPoolAssets = 8 +) diff --git a/x/swaprouter/types/errors.go b/x/swaprouter/types/errors.go new file mode 100644 index 00000000000..888b40334a6 --- /dev/null +++ b/x/swaprouter/types/errors.go @@ -0,0 +1,38 @@ +package types + +import ( + "errors" + "fmt" +) + +var ( + ErrEmptyRoutes = errors.New("provided empty routes") + ErrInvalidPool = errors.New("attempting to create an invalid pool") + ErrTooFewPoolAssets = errors.New("pool should have at least 2 assets, as they must be swapping between at least two assets") + ErrTooManyPoolAssets = errors.New("pool has too many assets (currently capped at 8 assets per pool)") +) + +type nonPositiveAmountError struct { + Amount string +} + +func (e nonPositiveAmountError) Error() string { + return fmt.Sprintf("min out amount or max in amount should be positive, was (%s)", e.Amount) +} + +type FailedToFindRouteError struct { + PoolId uint64 +} + +func (e FailedToFindRouteError) Error() string { + return fmt.Sprintf("failed to find route for pool id (%d)", e.PoolId) +} + +type UndefinedRouteError struct { + PoolType PoolType + PoolId uint64 +} + +func (e UndefinedRouteError) Error() string { + return fmt.Sprintf("route is not defined for the given pool type (%s) and pool id (%d)", e.PoolType, e.PoolId) +} diff --git a/x/swaprouter/types/events.go b/x/swaprouter/types/events.go new file mode 100644 index 00000000000..885a885a754 --- /dev/null +++ b/x/swaprouter/types/events.go @@ -0,0 +1,5 @@ +package types + +const ( + AttributeValueCategory = ModuleName +) diff --git a/x/swaprouter/types/expected_keepers.go b/x/swaprouter/types/expected_keepers.go new file mode 100644 index 00000000000..d5c52b4d794 --- /dev/null +++ b/x/swaprouter/types/expected_keepers.go @@ -0,0 +1,12 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GammKeeper defines the expected interface needed for swaprouter module +type GammKeeper interface { + GetPool(ctx sdk.Context, poolId uint64) (PoolI, error) + + GetNextPoolId(ctx sdk.Context) uint64 +} diff --git a/x/swaprouter/types/genesis.go b/x/swaprouter/types/genesis.go new file mode 100644 index 00000000000..cce472a4cdb --- /dev/null +++ b/x/swaprouter/types/genesis.go @@ -0,0 +1,18 @@ +package types + +// DefaultGenesis returns the default swaprouter genesis state. +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + NextPoolId: 1, + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + if err := gs.Params.Validate(); err != nil { + return err + } + return nil +} diff --git a/x/swaprouter/types/genesis.pb.go b/x/swaprouter/types/genesis.pb.go new file mode 100644 index 00000000000..5d397564251 --- /dev/null +++ b/x/swaprouter/types/genesis.pb.go @@ -0,0 +1,558 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/swaprouter/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params holds parameters for the swaprouter module +type Params struct { + PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_7ec914d8a231e19c, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetPoolCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.PoolCreationFee + } + return nil +} + +// GenesisState defines the swaprouter module's genesis state. +type GenesisState struct { + // the next_pool_id + NextPoolId uint64 `protobuf:"varint,1,opt,name=next_pool_id,json=nextPoolId,proto3" json:"next_pool_id,omitempty"` + // params is the container of swaprouter parameters. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_7ec914d8a231e19c, []int{1} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetNextPoolId() uint64 { + if m != nil { + return m.NextPoolId + } + return 0 +} + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*Params)(nil), "osmosis.swaprouter.v1beta1.Params") + proto.RegisterType((*GenesisState)(nil), "osmosis.swaprouter.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("osmosis/swaprouter/v1beta1/genesis.proto", fileDescriptor_7ec914d8a231e19c) +} + +var fileDescriptor_7ec914d8a231e19c = []byte{ + // 377 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x3d, 0x6e, 0xe2, 0x40, + 0x14, 0xf6, 0xec, 0x22, 0x0a, 0x83, 0xb4, 0x5a, 0x6b, 0x0b, 0x43, 0x61, 0x2c, 0x57, 0x6e, 0x98, + 0x11, 0x20, 0x6d, 0xb1, 0xd5, 0x0a, 0xa4, 0x5d, 0x45, 0x4a, 0x81, 0x48, 0x97, 0xc6, 0x1a, 0xdb, + 0x83, 0x63, 0xc5, 0xf6, 0xb3, 0x3c, 0x63, 0x02, 0xb7, 0x88, 0x94, 0x3e, 0x07, 0xc8, 0x49, 0x28, + 0x29, 0x53, 0x91, 0x08, 0x6e, 0x90, 0x13, 0x44, 0x1e, 0x8f, 0x13, 0x94, 0x28, 0x95, 0xfd, 0xe6, + 0xfb, 0x79, 0xef, 0x7b, 0x33, 0xba, 0x0b, 0x3c, 0x05, 0x1e, 0x73, 0xc2, 0x6f, 0x68, 0x5e, 0x40, + 0x29, 0x58, 0x41, 0x56, 0x23, 0x9f, 0x09, 0x3a, 0x22, 0x11, 0xcb, 0x18, 0x8f, 0x39, 0xce, 0x0b, + 0x10, 0x60, 0xf4, 0x15, 0x13, 0xbf, 0x33, 0xb1, 0x62, 0xf6, 0x7f, 0x45, 0x10, 0x81, 0xa4, 0x91, + 0xea, 0xaf, 0x56, 0xf4, 0x7b, 0x11, 0x40, 0x94, 0x30, 0x22, 0x2b, 0xbf, 0x5c, 0x12, 0x9a, 0x6d, + 0x1a, 0x28, 0x90, 0x6e, 0x5e, 0xad, 0xa9, 0x0b, 0x05, 0x59, 0x1f, 0x55, 0x61, 0x59, 0x50, 0x11, + 0x43, 0xd6, 0xe0, 0x35, 0x9b, 0xf8, 0x94, 0xb3, 0xb7, 0x51, 0x03, 0x88, 0x15, 0xee, 0xdc, 0x23, + 0xbd, 0x3d, 0xa7, 0x05, 0x4d, 0xb9, 0x71, 0x87, 0xf4, 0x9f, 0x39, 0x40, 0xe2, 0x05, 0x05, 0x93, + 0x16, 0xde, 0x92, 0x31, 0x13, 0xd9, 0xdf, 0xdd, 0xce, 0xb8, 0x87, 0x55, 0xd7, 0xca, 0xa7, 0x09, + 0x82, 0x67, 0x10, 0x67, 0xd3, 0xf3, 0xed, 0x7e, 0xa0, 0xbd, 0xec, 0x07, 0xe6, 0x86, 0xa6, 0xc9, + 0x1f, 0xe7, 0x93, 0x83, 0xf3, 0xf0, 0x34, 0x70, 0xa3, 0x58, 0x5c, 0x95, 0x3e, 0x0e, 0x20, 0x55, + 0xe3, 0xab, 0xcf, 0x90, 0x87, 0xd7, 0x44, 0x6c, 0x72, 0xc6, 0xa5, 0x19, 0x5f, 0xfc, 0xa8, 0xf4, + 0x33, 0x25, 0xff, 0xc7, 0x98, 0x53, 0xe8, 0xdd, 0xff, 0xf5, 0x66, 0x2f, 0x04, 0x15, 0xcc, 0xb0, + 0xf5, 0x6e, 0xc6, 0xd6, 0xc2, 0x93, 0x7d, 0xe2, 0xd0, 0x44, 0x36, 0x72, 0x5b, 0x0b, 0xbd, 0x3a, + 0x9b, 0x03, 0x24, 0x67, 0xa1, 0xf1, 0x57, 0x6f, 0xe7, 0x32, 0x91, 0xf9, 0xcd, 0x46, 0x6e, 0x67, + 0xec, 0xe0, 0xaf, 0xef, 0x02, 0xd7, 0xd9, 0xa7, 0xad, 0x2a, 0xc4, 0x42, 0xe9, 0xa6, 0xf3, 0xed, + 0xc1, 0x42, 0xbb, 0x83, 0x85, 0x9e, 0x0f, 0x16, 0xba, 0x3d, 0x5a, 0xda, 0xee, 0x68, 0x69, 0x8f, + 0x47, 0x4b, 0xbb, 0xfc, 0x7d, 0x12, 0x44, 0xb9, 0x0e, 0x13, 0xea, 0xf3, 0xa6, 0x20, 0xab, 0xd1, + 0x84, 0xac, 0x4f, 0x9f, 0x87, 0x0c, 0xe7, 0xb7, 0xe5, 0xb6, 0x27, 0xaf, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x7d, 0xee, 0x88, 0x63, 0x41, 0x02, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PoolCreationFee) > 0 { + for iNdEx := len(m.PoolCreationFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolCreationFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.NextPoolId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextPoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PoolCreationFee) > 0 { + for _, e := range m.PoolCreationFee { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NextPoolId != 0 { + n += 1 + sovGenesis(uint64(m.NextPoolId)) + } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolCreationFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PoolCreationFee = append(m.PoolCreationFee, types.Coin{}) + if err := m.PoolCreationFee[len(m.PoolCreationFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextPoolId", wireType) + } + m.NextPoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextPoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/swaprouter/types/keys.go b/x/swaprouter/types/keys.go new file mode 100644 index 00000000000..b7aea814801 --- /dev/null +++ b/x/swaprouter/types/keys.go @@ -0,0 +1,43 @@ +package types + +import ( + "errors" + "fmt" + + "github.com/gogo/protobuf/proto" +) + +const ( + ModuleName = "swaprouter" + + StoreKey = ModuleName + + RouterKey = ModuleName +) + +var ( + // KeyNextGlobalPoolId defines key to store the next Pool ID to be used. + KeyNextGlobalPoolId = []byte{0x01} + + // SwapModuleRouterPrefix defines prefix to store pool id to swap module mappings. + SwapModuleRouterPrefix = []byte{0x02} +) + +// ModuleRouteToBytes serializes moduleRoute to bytes. +func FormatModuleRouteKey(poolId uint64) []byte { + return []byte(fmt.Sprintf("%s%d", SwapModuleRouterPrefix, poolId)) +} + +// ParseModuleRouteFromBz parses the raw bytes into ModuleRoute. +// Returns error if fails to parse or if the bytes are empty. +func ParseModuleRouteFromBz(bz []byte) (ModuleRoute, error) { + if len(bz) == 0 { + return ModuleRoute{}, errors.New("module route not found") + } + moduleRoute := ModuleRoute{} + err := proto.Unmarshal(bz, &moduleRoute) + if err != nil { + return ModuleRoute{}, err + } + return moduleRoute, err +} diff --git a/x/swaprouter/types/listeners.go b/x/swaprouter/types/listeners.go new file mode 100644 index 00000000000..8e3df6e040b --- /dev/null +++ b/x/swaprouter/types/listeners.go @@ -0,0 +1,21 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type PoolCreationListener interface { + // AfterPoolCreated is called after CreatePool + AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) +} + +type PoolCreationListeners []PoolCreationListener + +func (l PoolCreationListeners) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) { + for i := range l { + l[i].AfterPoolCreated(ctx, sender, poolId) + } +} + +// Creates hooks for the Gamm Module. +func NewPoolCreationListeners(listeners ...PoolCreationListener) PoolCreationListeners { + return listeners +} diff --git a/x/swaprouter/types/module_route.pb.go b/x/swaprouter/types/module_route.pb.go new file mode 100644 index 00000000000..694c267d69d --- /dev/null +++ b/x/swaprouter/types/module_route.pb.go @@ -0,0 +1,348 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/swaprouter/v1beta1/module_route.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PoolType is an enumeration of all supported pool types. +type PoolType int32 + +const ( + // Balancer is the standard xy=k curve. Its pool model is defined in x/gamm. + Balancer PoolType = 0 + // Stableswap is the Solidly cfmm stable swap curve. Its pool model is defined + // in x/gamm. + StableSwap PoolType = 1 + // Concentrated is the pool model specific to concentrated liquidity. It is + // defined in x/concentrated-liquidity. + Concentrated PoolType = 2 +) + +var PoolType_name = map[int32]string{ + 0: "Balancer", + 1: "StableSwap", + 2: "Concentrated", +} + +var PoolType_value = map[string]int32{ + "Balancer": 0, + "StableSwap": 1, + "Concentrated": 2, +} + +func (x PoolType) String() string { + return proto.EnumName(PoolType_name, int32(x)) +} + +func (PoolType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c26575d86edff56b, []int{0} +} + +// ModuleRouter defines a route encapsulating pool type. +// It is used as the value of a mapping from pool id to the pool type, +// allowing the swap router to know which module to route swaps to given the +// pool id. +type ModuleRoute struct { + // pool_type specifies the type of the pool + PoolType PoolType `protobuf:"varint,1,opt,name=pool_type,json=poolType,proto3,enum=osmosis.swaprouter.v1beta1.PoolType" json:"pool_type,omitempty"` +} + +func (m *ModuleRoute) Reset() { *m = ModuleRoute{} } +func (m *ModuleRoute) String() string { return proto.CompactTextString(m) } +func (*ModuleRoute) ProtoMessage() {} +func (*ModuleRoute) Descriptor() ([]byte, []int) { + return fileDescriptor_c26575d86edff56b, []int{0} +} +func (m *ModuleRoute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleRoute.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModuleRoute) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleRoute.Merge(m, src) +} +func (m *ModuleRoute) XXX_Size() int { + return m.Size() +} +func (m *ModuleRoute) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleRoute.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleRoute proto.InternalMessageInfo + +func (m *ModuleRoute) GetPoolType() PoolType { + if m != nil { + return m.PoolType + } + return Balancer +} + +func init() { + proto.RegisterEnum("osmosis.swaprouter.v1beta1.PoolType", PoolType_name, PoolType_value) + proto.RegisterType((*ModuleRoute)(nil), "osmosis.swaprouter.v1beta1.ModuleRoute") +} + +func init() { + proto.RegisterFile("osmosis/swaprouter/v1beta1/module_route.proto", fileDescriptor_c26575d86edff56b) +} + +var fileDescriptor_c26575d86edff56b = []byte{ + // 265 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xcd, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x2e, 0x4f, 0x2c, 0x28, 0xca, 0x2f, 0x2d, 0x49, 0x2d, 0xd2, 0x2f, + 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x8d, 0x07, 0x8b, + 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x49, 0x41, 0x95, 0xeb, 0x21, 0x94, 0xeb, 0x41, 0x95, + 0x4b, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xe9, 0x83, 0x58, 0x10, 0x1d, 0x4a, 0x01, 0x5c, + 0xdc, 0xbe, 0x60, 0x73, 0x82, 0x40, 0xaa, 0x85, 0x1c, 0xb9, 0x38, 0x0b, 0xf2, 0xf3, 0x73, 0xe2, + 0x4b, 0x2a, 0x0b, 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0x54, 0xf4, 0x70, 0x1b, 0xaa, + 0x17, 0x90, 0x9f, 0x9f, 0x13, 0x52, 0x59, 0x90, 0x1a, 0xc4, 0x51, 0x00, 0x65, 0x69, 0x39, 0x70, + 0x71, 0xc0, 0x44, 0x85, 0x78, 0xb8, 0x38, 0x9c, 0x12, 0x73, 0x12, 0xf3, 0x92, 0x53, 0x8b, 0x04, + 0x18, 0x84, 0xf8, 0xb8, 0xb8, 0x82, 0x4b, 0x12, 0x93, 0x72, 0x52, 0x83, 0xcb, 0x13, 0x0b, 0x04, + 0x18, 0x85, 0x04, 0xb8, 0x78, 0x9c, 0xf3, 0xf3, 0x92, 0x53, 0xf3, 0x4a, 0x8a, 0x12, 0x4b, 0x52, + 0x53, 0x04, 0x98, 0xa4, 0x58, 0x3a, 0x16, 0xcb, 0x31, 0x38, 0x05, 0x9c, 0x78, 0x24, 0xc7, 0x78, + 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, + 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x59, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, + 0xae, 0x3e, 0xd4, 0x55, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x30, 0x8e, 0x7e, 0x99, 0xa1, 0xb1, 0x7e, + 0x05, 0x72, 0x60, 0x81, 0x3c, 0x52, 0x9c, 0xc4, 0x06, 0xf6, 0xac, 0x31, 0x20, 0x00, 0x00, 0xff, + 0xff, 0x6e, 0x93, 0xbb, 0x4a, 0x4f, 0x01, 0x00, 0x00, +} + +func (m *ModuleRoute) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleRoute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolType != 0 { + i = encodeVarintModuleRoute(dAtA, i, uint64(m.PoolType)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintModuleRoute(dAtA []byte, offset int, v uint64) int { + offset -= sovModuleRoute(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ModuleRoute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolType != 0 { + n += 1 + sovModuleRoute(uint64(m.PoolType)) + } + return n +} + +func sovModuleRoute(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModuleRoute(x uint64) (n int) { + return sovModuleRoute(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ModuleRoute) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModuleRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleRoute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolType", wireType) + } + m.PoolType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModuleRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolType |= PoolType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipModuleRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModuleRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModuleRoute(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModuleRoute + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModuleRoute + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModuleRoute + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthModuleRoute + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModuleRoute + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModuleRoute + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModuleRoute = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModuleRoute = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModuleRoute = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/swaprouter/types/msg_create_pool.go b/x/swaprouter/types/msg_create_pool.go new file mode 100644 index 00000000000..ae8cedd9ded --- /dev/null +++ b/x/swaprouter/types/msg_create_pool.go @@ -0,0 +1,21 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// CreatePoolMsg defines an interface that every CreatePool transaction should implement. +// The gamm logic will use this to create a pool. +type CreatePoolMsg interface { + // GetPoolType returns the type of the pool to create. + GetPoolType() PoolType + // The creator of the pool, who pays the PoolCreationFee, provides initial liquidity, + // and gets the initial LP shares. + PoolCreator() sdk.AccAddress + // A stateful validation function. + Validate(ctx sdk.Context) error + // Initial Liquidity for the pool that the sender is required to send to the pool account + InitialLiquidity() sdk.Coins + // CreatePool creates a pool implementing PoolI, using data from the message. + CreatePool(ctx sdk.Context, poolID uint64) (PoolI, error) +} diff --git a/x/swaprouter/types/msgs.go b/x/swaprouter/types/msgs.go new file mode 100644 index 00000000000..ed85dd3d35c --- /dev/null +++ b/x/swaprouter/types/msgs.go @@ -0,0 +1,93 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// constants. +const ( + TypeMsgSwapExactAmountIn = "swap_exact_amount_in" + TypeMsgSwapExactAmountOut = "swap_exact_amount_out" +) + +var _ sdk.Msg = &MsgSwapExactAmountIn{} + +func (msg MsgSwapExactAmountIn) Route() string { return RouterKey } +func (msg MsgSwapExactAmountIn) Type() string { return TypeMsgSwapExactAmountIn } +func (msg MsgSwapExactAmountIn) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + err = SwapAmountInRoutes(msg.Routes).Validate() + if err != nil { + return err + } + + if !msg.TokenIn.IsValid() || !msg.TokenIn.IsPositive() { + // TODO: remove sdk errors + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.TokenIn.String()) + } + + if !msg.TokenOutMinAmount.IsPositive() { + return nonPositiveAmountError{msg.TokenOutMinAmount.String()} + } + + return nil +} + +// TODO: uncomment when types are registered. +func (msg MsgSwapExactAmountIn) GetSignBytes() []byte { + // return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) + panic("not implemented") +} + +func (msg MsgSwapExactAmountIn) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +var _ sdk.Msg = &MsgSwapExactAmountOut{} + +func (msg MsgSwapExactAmountOut) Route() string { return RouterKey } +func (msg MsgSwapExactAmountOut) Type() string { return TypeMsgSwapExactAmountOut } +func (msg MsgSwapExactAmountOut) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + err = SwapAmountOutRoutes(msg.Routes).Validate() + if err != nil { + return err + } + + if !msg.TokenOut.IsValid() || !msg.TokenOut.IsPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.TokenOut.String()) + } + + if !msg.TokenInMaxAmount.IsPositive() { + return nonPositiveAmountError{msg.TokenInMaxAmount.String()} + } + + return nil +} + +// TODO: uncomment when types are registered. +func (msg MsgSwapExactAmountOut) GetSignBytes() []byte { + // return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) + panic("not implemented") +} + +func (msg MsgSwapExactAmountOut) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} diff --git a/x/swaprouter/types/msgs_test.go b/x/swaprouter/types/msgs_test.go new file mode 100644 index 00000000000..bafa98cd88f --- /dev/null +++ b/x/swaprouter/types/msgs_test.go @@ -0,0 +1,326 @@ +package types_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" +) + +func TestMsgSwapExactAmountIn(t *testing.T) { + appParams.SetAddressPrefixes() + pk1 := ed25519.GenPrivKey().PubKey() + addr1 := sdk.AccAddress(pk1.Address()).String() + invalidAddr := sdk.AccAddress("invalid") + + createMsg := func(after func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + properMsg := types.MsgSwapExactAmountIn{ + Sender: addr1, + Routes: []types.SwapAmountInRoute{{ + PoolId: 0, + TokenOutDenom: "test", + }, { + PoolId: 1, + TokenOutDenom: "test2", + }}, + TokenIn: sdk.NewCoin("test", sdk.NewInt(100)), + TokenOutMinAmount: sdk.NewInt(200), + } + + return after(properMsg) + } + + msg := createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + // Do nothing + return msg + }) + + require.Equal(t, msg.Route(), types.RouterKey) + require.Equal(t, msg.Type(), "swap_exact_amount_in") + signers := msg.GetSigners() + require.Equal(t, len(signers), 1) + require.Equal(t, signers[0].String(), addr1) + + tests := []struct { + name string + msg types.MsgSwapExactAmountIn + expectPass bool + }{ + { + name: "proper msg", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + // Do nothing + return msg + }), + expectPass: true, + }, + { + name: "invalid sender", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.Sender = invalidAddr.String() + return msg + }), + expectPass: false, + }, + { + name: "empty routes", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.Routes = nil + return msg + }), + expectPass: false, + }, + { + name: "empty routes2", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.Routes = []types.SwapAmountInRoute{} + return msg + }), + expectPass: false, + }, + { + name: "invalid denom", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.Routes[1].TokenOutDenom = "1" + return msg + }), + expectPass: false, + }, + { + name: "invalid denom2", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.TokenIn.Denom = "1" + return msg + }), + expectPass: false, + }, + { + name: "zero amount token", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.TokenIn.Amount = sdk.NewInt(0) + return msg + }), + expectPass: false, + }, + { + name: "negative amount token", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.TokenIn.Amount = sdk.NewInt(-10) + return msg + }), + expectPass: false, + }, + { + name: "zero amount criteria", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.TokenOutMinAmount = sdk.NewInt(0) + return msg + }), + expectPass: false, + }, + { + name: "negative amount criteria", + msg: createMsg(func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { + msg.TokenOutMinAmount = sdk.NewInt(-10) + return msg + }), + expectPass: false, + }, + } + + for _, test := range tests { + if test.expectPass { + require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) + } else { + require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) + } + } +} + +func TestMsgSwapExactAmountOut(t *testing.T) { + appParams.SetAddressPrefixes() + pk1 := ed25519.GenPrivKey().PubKey() + addr1 := sdk.AccAddress(pk1.Address()).String() + invalidAddr := sdk.AccAddress("invalid") + + createMsg := func(after func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + properMsg := types.MsgSwapExactAmountOut{ + Sender: addr1, + Routes: []types.SwapAmountOutRoute{{ + PoolId: 0, + TokenInDenom: "test", + }, { + PoolId: 1, + TokenInDenom: "test2", + }}, + TokenOut: sdk.NewCoin("test", sdk.NewInt(100)), + TokenInMaxAmount: sdk.NewInt(200), + } + + return after(properMsg) + } + + msg := createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + // Do nothing + return msg + }) + + require.Equal(t, msg.Route(), types.RouterKey) + require.Equal(t, msg.Type(), "swap_exact_amount_out") + signers := msg.GetSigners() + require.Equal(t, len(signers), 1) + require.Equal(t, signers[0].String(), addr1) + + tests := []struct { + name string + msg types.MsgSwapExactAmountOut + expectPass bool + }{ + { + name: "proper msg", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + // Do nothing + return msg + }), + expectPass: true, + }, + { + name: "invalid sender", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.Sender = invalidAddr.String() + return msg + }), + expectPass: false, + }, + { + name: "empty routes", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.Routes = nil + return msg + }), + expectPass: false, + }, + { + name: "empty routes2", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.Routes = []types.SwapAmountOutRoute{} + return msg + }), + expectPass: false, + }, + { + name: "invalid denom", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.Routes[1].TokenInDenom = "1" + return msg + }), + expectPass: false, + }, + { + name: "invalid denom", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.TokenOut.Denom = "1" + return msg + }), + expectPass: false, + }, + { + name: "zero amount token", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.TokenOut.Amount = sdk.NewInt(0) + return msg + }), + expectPass: false, + }, + { + name: "negative amount token", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.TokenOut.Amount = sdk.NewInt(-10) + return msg + }), + expectPass: false, + }, + { + name: "zero amount criteria", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.TokenInMaxAmount = sdk.NewInt(0) + return msg + }), + expectPass: false, + }, + { + name: "negative amount criteria", + msg: createMsg(func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { + msg.TokenInMaxAmount = sdk.NewInt(-10) + return msg + }), + expectPass: false, + }, + } + + for _, test := range tests { + if test.expectPass { + require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) + } else { + require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) + } + } +} + +// Test authz serialize and de-serializes for swaprouter msg. +func TestAuthzMsg(t *testing.T) { + + // TODO: remove when types are registered. + t.SkipNow() + + pk1 := ed25519.GenPrivKey().PubKey() + addr1 := sdk.AccAddress(pk1.Address()).String() + coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)) + + testCases := []struct { + name string + gammMsg sdk.Msg + }{ + { + name: "MsgJoinSwapShareAmountOut", + gammMsg: &types.MsgSwapExactAmountIn{ + Sender: addr1, + Routes: []types.SwapAmountInRoute{{ + PoolId: 0, + TokenOutDenom: "test", + }, { + PoolId: 1, + TokenOutDenom: "test2", + }}, + TokenIn: coin, + TokenOutMinAmount: sdk.NewInt(1), + }, + }, + { + name: "MsgSwapExactAmountOut", + gammMsg: &types.MsgSwapExactAmountOut{ + Sender: addr1, + Routes: []types.SwapAmountOutRoute{{ + PoolId: 0, + TokenInDenom: "test", + }, { + PoolId: 1, + TokenInDenom: "test2", + }}, + TokenOut: coin, + TokenInMaxAmount: sdk.NewInt(1), + }, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + apptesting.TestMessageAuthzSerialization(t, tc.gammMsg) + }) + } +} diff --git a/x/swaprouter/types/params.go b/x/swaprouter/types/params.go new file mode 100644 index 00000000000..f648ef0d738 --- /dev/null +++ b/x/swaprouter/types/params.go @@ -0,0 +1,62 @@ +package types + +import ( + "fmt" + + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Parameter store keys. +var ( + KeyPoolCreationFee = []byte("PoolCreationFee") +) + +// ParamTable for gamm module. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func NewParams(poolCreationFee sdk.Coins) Params { + return Params{ + PoolCreationFee: poolCreationFee, + } +} + +// DefaultParams are the default swaprouter module parameters. +func DefaultParams() Params { + return Params{ + PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO + } +} + +// validate params. +func (p Params) Validate() error { + if err := validatePoolCreationFee(p.PoolCreationFee); err != nil { + return err + } + + return nil +} + +// Implements params.ParamSet. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), + } +} + +func validatePoolCreationFee(i interface{}) error { + v, ok := i.(sdk.Coins) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.Validate() != nil { + return fmt.Errorf("invalid pool creation fee: %+v", i) + } + + return nil +} diff --git a/x/swaprouter/types/pool.go b/x/swaprouter/types/pool.go new file mode 100644 index 00000000000..13be3d40763 --- /dev/null +++ b/x/swaprouter/types/pool.go @@ -0,0 +1,35 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/proto" +) + +// PoolI defines an interface for pools that hold tokens. +type PoolI interface { + proto.Message + + GetAddress() sdk.AccAddress + String() string + GetId() uint64 + // GetSwapFee returns the pool's swap fee, based on the current state. + // Pools may choose to make their swap fees dependent upon state + // (prior TWAPs, network downtime, other pool states, etc.) + // hence Context is provided as an argument. + GetSwapFee(ctx sdk.Context) sdk.Dec + // GetExitFee returns the pool's exit fee, based on the current state. + // Pools may choose to make their exit fees dependent upon state. + GetExitFee(ctx sdk.Context) sdk.Dec + // Returns whether the pool has swaps enabled at the moment + IsActive(ctx sdk.Context) bool + // GetTotalShares returns the total number of LP shares in the pool + GetTotalShares() sdk.Int + // GetTotalPoolLiquidity returns the coins in the pool owned by all LPs + GetTotalPoolLiquidity(ctx sdk.Context) sdk.Coins + + // Returns the spot price of the 'base asset' in terms of the 'quote asset' in the pool, + // errors if either baseAssetDenom, or quoteAssetDenom does not exist. + // For example, if this was a UniV2 50-50 pool, with 2 ETH, and 8000 UST + // pool.SpotPrice(ctx, "eth", "ust") = 4000.00 + SpotPrice(ctx sdk.Context, baseAssetDenom string, quoteAssetDenom string) (sdk.Dec, error) +} diff --git a/x/swaprouter/types/routes.go b/x/swaprouter/types/routes.go new file mode 100644 index 00000000000..d9e8bbbc64a --- /dev/null +++ b/x/swaprouter/types/routes.go @@ -0,0 +1,163 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// AccountI defines the account contract that must be fulfilled when +// creating a x/gamm keeper. +type AccountI interface { + NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + SetAccount(ctx sdk.Context, acc authtypes.AccountI) +} + +// BankI defines the banking contract that must be fulfilled when +// creating a x/gamm keeper. +type BankI interface { + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata) +} + +// CommunityPoolI defines the contract needed to be fulfilled for distribution keeper. +type CommunityPoolI interface { + FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error +} + +// TODO: godoc +type SwapI interface { + InitializePool(ctx sdk.Context, pool PoolI, creatorAddress sdk.AccAddress) error + + GetPool(ctx sdk.Context, poolId uint64) (PoolI, error) + + SwapExactAmountIn( + ctx sdk.Context, + sender sdk.AccAddress, + pool PoolI, + tokenIn sdk.Coin, + tokenOutDenom string, + tokenOutMinAmount sdk.Int, + swapFee sdk.Dec, + ) (sdk.Int, error) + + CalcOutAmtGivenIn( + ctx sdk.Context, + poolI PoolI, + tokenIn sdk.Coin, + tokenOutDenom string, + swapFee sdk.Dec, + ) (tokenOut sdk.Coin, err error) + + SwapExactAmountOut( + ctx sdk.Context, + sender sdk.AccAddress, + pool PoolI, + tokenInDenom string, + tokenInMaxAmount sdk.Int, + tokenOut sdk.Coin, + swapFee sdk.Dec, + ) (tokenInAmount sdk.Int, err error) + + CalcInAmtGivenOut( + ctx sdk.Context, + poolI PoolI, + tokenOut sdk.Coin, + tokenInDenom string, + swapFee sdk.Dec, + ) (tokenIn sdk.Coin, err error) +} + +type PoolIncentivesKeeperI interface { + IsPoolIncentivized(ctx sdk.Context, poolId uint64) bool +} + +type MultihopRoute interface { + Length() int + PoolIds() []uint64 + IntermediateDenoms() []string +} + +type SwapAmountInRoutes []SwapAmountInRoute + +func (routes SwapAmountInRoutes) Validate() error { + if len(routes) == 0 { + return ErrEmptyRoutes + } + + for _, route := range routes { + err := sdk.ValidateDenom(route.TokenOutDenom) + if err != nil { + return err + } + } + + return nil +} + +func (routes SwapAmountInRoutes) IntermediateDenoms() []string { + if len(routes) < 2 { + return nil + } + intermediateDenoms := make([]string, 0, len(routes)-1) + for _, route := range routes[:len(routes)-1] { + intermediateDenoms = append(intermediateDenoms, route.TokenOutDenom) + } + + return intermediateDenoms +} + +func (routes SwapAmountInRoutes) PoolIds() []uint64 { + poolIds := make([]uint64, 0, len(routes)) + for _, route := range routes { + poolIds = append(poolIds, route.PoolId) + } + return poolIds +} + +func (routes SwapAmountInRoutes) Length() int { + return len(routes) +} + +type SwapAmountOutRoutes []SwapAmountOutRoute + +func (routes SwapAmountOutRoutes) Validate() error { + if len(routes) == 0 { + return ErrEmptyRoutes + } + + for _, route := range routes { + err := sdk.ValidateDenom(route.TokenInDenom) + if err != nil { + return err + } + } + + return nil +} + +func (routes SwapAmountOutRoutes) IntermediateDenoms() []string { + if len(routes) < 2 { + return nil + } + intermediateDenoms := make([]string, 0, len(routes)-1) + for _, route := range routes[1:] { + intermediateDenoms = append(intermediateDenoms, route.TokenInDenom) + } + + return intermediateDenoms +} + +func (routes SwapAmountOutRoutes) PoolIds() []uint64 { + poolIds := make([]uint64, 0, len(routes)) + for _, route := range routes { + poolIds = append(poolIds, route.PoolId) + } + return poolIds +} + +func (routes SwapAmountOutRoutes) Length() int { + return len(routes) +} diff --git a/x/swaprouter/types/swap_route.pb.go b/x/swaprouter/types/swap_route.pb.go new file mode 100644 index 00000000000..6999306502a --- /dev/null +++ b/x/swaprouter/types/swap_route.pb.go @@ -0,0 +1,565 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/swaprouter/v1beta1/swap_route.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type SwapAmountInRoute struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenOutDenom string `protobuf:"bytes,2,opt,name=token_out_denom,json=tokenOutDenom,proto3" json:"token_out_denom,omitempty" yaml:"token_out_denom"` +} + +func (m *SwapAmountInRoute) Reset() { *m = SwapAmountInRoute{} } +func (m *SwapAmountInRoute) String() string { return proto.CompactTextString(m) } +func (*SwapAmountInRoute) ProtoMessage() {} +func (*SwapAmountInRoute) Descriptor() ([]byte, []int) { + return fileDescriptor_9eda4cafb53adf83, []int{0} +} +func (m *SwapAmountInRoute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SwapAmountInRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SwapAmountInRoute.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SwapAmountInRoute) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapAmountInRoute.Merge(m, src) +} +func (m *SwapAmountInRoute) XXX_Size() int { + return m.Size() +} +func (m *SwapAmountInRoute) XXX_DiscardUnknown() { + xxx_messageInfo_SwapAmountInRoute.DiscardUnknown(m) +} + +var xxx_messageInfo_SwapAmountInRoute proto.InternalMessageInfo + +func (m *SwapAmountInRoute) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *SwapAmountInRoute) GetTokenOutDenom() string { + if m != nil { + return m.TokenOutDenom + } + return "" +} + +type SwapAmountOutRoute struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenInDenom string `protobuf:"bytes,2,opt,name=token_in_denom,json=tokenInDenom,proto3" json:"token_in_denom,omitempty" yaml:"token_out_denom"` +} + +func (m *SwapAmountOutRoute) Reset() { *m = SwapAmountOutRoute{} } +func (m *SwapAmountOutRoute) String() string { return proto.CompactTextString(m) } +func (*SwapAmountOutRoute) ProtoMessage() {} +func (*SwapAmountOutRoute) Descriptor() ([]byte, []int) { + return fileDescriptor_9eda4cafb53adf83, []int{1} +} +func (m *SwapAmountOutRoute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SwapAmountOutRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SwapAmountOutRoute.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SwapAmountOutRoute) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapAmountOutRoute.Merge(m, src) +} +func (m *SwapAmountOutRoute) XXX_Size() int { + return m.Size() +} +func (m *SwapAmountOutRoute) XXX_DiscardUnknown() { + xxx_messageInfo_SwapAmountOutRoute.DiscardUnknown(m) +} + +var xxx_messageInfo_SwapAmountOutRoute proto.InternalMessageInfo + +func (m *SwapAmountOutRoute) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *SwapAmountOutRoute) GetTokenInDenom() string { + if m != nil { + return m.TokenInDenom + } + return "" +} + +func init() { + proto.RegisterType((*SwapAmountInRoute)(nil), "osmosis.swaprouter.v1beta1.SwapAmountInRoute") + proto.RegisterType((*SwapAmountOutRoute)(nil), "osmosis.swaprouter.v1beta1.SwapAmountOutRoute") +} + +func init() { + proto.RegisterFile("osmosis/swaprouter/v1beta1/swap_route.proto", fileDescriptor_9eda4cafb53adf83) +} + +var fileDescriptor_9eda4cafb53adf83 = []byte{ + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xce, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x2e, 0x4f, 0x2c, 0x28, 0xca, 0x2f, 0x2d, 0x49, 0x2d, 0xd2, 0x2f, + 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0x04, 0x0b, 0xc5, 0x83, 0xc5, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, + 0xf2, 0x85, 0xa4, 0xa0, 0x8a, 0xf5, 0x10, 0x8a, 0xf5, 0xa0, 0x8a, 0xa5, 0x44, 0xd2, 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xfa, 0xd0, 0x30, 0xd6, 0xcd, 0x49, 0x4c, 0x2a, 0x86, 0x71, 0xf4, 0xcb, + 0x0c, 0x8d, 0xf5, 0x2b, 0x90, 0xe3, 0xa8, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0xca, + 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x4f, 0xbf, 0xa2, 0xc6, 0x01, 0x00, 0x00, +} + +func (m *SwapAmountInRoute) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SwapAmountInRoute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SwapAmountInRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenOutDenom) > 0 { + i -= len(m.TokenOutDenom) + copy(dAtA[i:], m.TokenOutDenom) + i = encodeVarintSwapRoute(dAtA, i, uint64(len(m.TokenOutDenom))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintSwapRoute(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SwapAmountOutRoute) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SwapAmountOutRoute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SwapAmountOutRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenInDenom) > 0 { + i -= len(m.TokenInDenom) + copy(dAtA[i:], m.TokenInDenom) + i = encodeVarintSwapRoute(dAtA, i, uint64(len(m.TokenInDenom))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintSwapRoute(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintSwapRoute(dAtA []byte, offset int, v uint64) int { + offset -= sovSwapRoute(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SwapAmountInRoute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovSwapRoute(uint64(m.PoolId)) + } + l = len(m.TokenOutDenom) + if l > 0 { + n += 1 + l + sovSwapRoute(uint64(l)) + } + return n +} + +func (m *SwapAmountOutRoute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovSwapRoute(uint64(m.PoolId)) + } + l = len(m.TokenInDenom) + if l > 0 { + n += 1 + l + sovSwapRoute(uint64(l)) + } + return n +} + +func sovSwapRoute(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSwapRoute(x uint64) (n int) { + return sovSwapRoute(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SwapAmountInRoute) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SwapAmountInRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SwapAmountInRoute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOutDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSwapRoute + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSwapRoute + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenOutDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSwapRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSwapRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SwapAmountOutRoute) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SwapAmountOutRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SwapAmountOutRoute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenInDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSwapRoute + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSwapRoute + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenInDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSwapRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSwapRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSwapRoute(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSwapRoute + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthSwapRoute + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSwapRoute + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSwapRoute + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSwapRoute = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSwapRoute = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSwapRoute = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/swaprouter/types/tx.pb.go b/x/swaprouter/types/tx.pb.go new file mode 100644 index 00000000000..3c6c671a3c8 --- /dev/null +++ b/x/swaprouter/types/tx.pb.go @@ -0,0 +1,1295 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/swaprouter/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ===================== MsgSwapExactAmountIn +type MsgSwapExactAmountIn struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []SwapAmountInRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` + TokenOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` +} + +func (m *MsgSwapExactAmountIn) Reset() { *m = MsgSwapExactAmountIn{} } +func (m *MsgSwapExactAmountIn) String() string { return proto.CompactTextString(m) } +func (*MsgSwapExactAmountIn) ProtoMessage() {} +func (*MsgSwapExactAmountIn) Descriptor() ([]byte, []int) { + return fileDescriptor_05a4da63b1afc25d, []int{0} +} +func (m *MsgSwapExactAmountIn) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapExactAmountIn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapExactAmountIn.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSwapExactAmountIn) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapExactAmountIn.Merge(m, src) +} +func (m *MsgSwapExactAmountIn) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapExactAmountIn) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapExactAmountIn.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapExactAmountIn proto.InternalMessageInfo + +func (m *MsgSwapExactAmountIn) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSwapExactAmountIn) GetRoutes() []SwapAmountInRoute { + if m != nil { + return m.Routes + } + return nil +} + +func (m *MsgSwapExactAmountIn) GetTokenIn() types.Coin { + if m != nil { + return m.TokenIn + } + return types.Coin{} +} + +type MsgSwapExactAmountInResponse struct { + TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` +} + +func (m *MsgSwapExactAmountInResponse) Reset() { *m = MsgSwapExactAmountInResponse{} } +func (m *MsgSwapExactAmountInResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSwapExactAmountInResponse) ProtoMessage() {} +func (*MsgSwapExactAmountInResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_05a4da63b1afc25d, []int{1} +} +func (m *MsgSwapExactAmountInResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapExactAmountInResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapExactAmountInResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSwapExactAmountInResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapExactAmountInResponse.Merge(m, src) +} +func (m *MsgSwapExactAmountInResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapExactAmountInResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapExactAmountInResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapExactAmountInResponse proto.InternalMessageInfo + +// ===================== MsgSwapExactAmountOut +type MsgSwapExactAmountOut struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []SwapAmountOutRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` + TokenOut types.Coin `protobuf:"bytes,4,opt,name=token_out,json=tokenOut,proto3" json:"token_out" yaml:"token_out"` +} + +func (m *MsgSwapExactAmountOut) Reset() { *m = MsgSwapExactAmountOut{} } +func (m *MsgSwapExactAmountOut) String() string { return proto.CompactTextString(m) } +func (*MsgSwapExactAmountOut) ProtoMessage() {} +func (*MsgSwapExactAmountOut) Descriptor() ([]byte, []int) { + return fileDescriptor_05a4da63b1afc25d, []int{2} +} +func (m *MsgSwapExactAmountOut) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapExactAmountOut) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapExactAmountOut.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSwapExactAmountOut) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapExactAmountOut.Merge(m, src) +} +func (m *MsgSwapExactAmountOut) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapExactAmountOut) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapExactAmountOut.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapExactAmountOut proto.InternalMessageInfo + +func (m *MsgSwapExactAmountOut) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSwapExactAmountOut) GetRoutes() []SwapAmountOutRoute { + if m != nil { + return m.Routes + } + return nil +} + +func (m *MsgSwapExactAmountOut) GetTokenOut() types.Coin { + if m != nil { + return m.TokenOut + } + return types.Coin{} +} + +type MsgSwapExactAmountOutResponse struct { + TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` +} + +func (m *MsgSwapExactAmountOutResponse) Reset() { *m = MsgSwapExactAmountOutResponse{} } +func (m *MsgSwapExactAmountOutResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSwapExactAmountOutResponse) ProtoMessage() {} +func (*MsgSwapExactAmountOutResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_05a4da63b1afc25d, []int{3} +} +func (m *MsgSwapExactAmountOutResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapExactAmountOutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapExactAmountOutResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSwapExactAmountOutResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapExactAmountOutResponse.Merge(m, src) +} +func (m *MsgSwapExactAmountOutResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapExactAmountOutResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapExactAmountOutResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapExactAmountOutResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSwapExactAmountIn)(nil), "osmosis.swaprouter.v1beta1.MsgSwapExactAmountIn") + proto.RegisterType((*MsgSwapExactAmountInResponse)(nil), "osmosis.swaprouter.v1beta1.MsgSwapExactAmountInResponse") + proto.RegisterType((*MsgSwapExactAmountOut)(nil), "osmosis.swaprouter.v1beta1.MsgSwapExactAmountOut") + proto.RegisterType((*MsgSwapExactAmountOutResponse)(nil), "osmosis.swaprouter.v1beta1.MsgSwapExactAmountOutResponse") +} + +func init() { + proto.RegisterFile("osmosis/swaprouter/v1beta1/tx.proto", fileDescriptor_05a4da63b1afc25d) +} + +var fileDescriptor_05a4da63b1afc25d = []byte{ + // 583 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x5f, 0x6b, 0xd3, 0x50, + 0x14, 0x6f, 0xda, 0x31, 0xb7, 0x3b, 0xe6, 0xda, 0x58, 0x5d, 0x8d, 0x9a, 0x96, 0x08, 0x52, 0x91, + 0xde, 0xd8, 0x0e, 0x44, 0x7d, 0xb3, 0x22, 0x58, 0x5c, 0xe8, 0x88, 0x6f, 0xbe, 0x94, 0xdb, 0x2e, + 0xd4, 0xb0, 0xe5, 0xde, 0xd0, 0x7b, 0xb3, 0x75, 0x08, 0x0a, 0xbe, 0xfa, 0xa2, 0xf8, 0xa5, 0xf6, + 0xb8, 0x47, 0x11, 0xac, 0xd2, 0x7e, 0x83, 0x7e, 0x02, 0xc9, 0xfd, 0x93, 0xb5, 0x5d, 0x2d, 0xe6, + 0x69, 0xd9, 0xc9, 0x39, 0xbf, 0xf3, 0xfb, 0x73, 0x1a, 0x70, 0x9f, 0xd0, 0x80, 0x50, 0x9f, 0xda, + 0xf4, 0x14, 0x85, 0x03, 0x12, 0x31, 0x6f, 0x60, 0x9f, 0xd4, 0xbb, 0x1e, 0x43, 0x75, 0x9b, 0x0d, + 0x61, 0x38, 0x20, 0x8c, 0xe8, 0x86, 0x6c, 0x82, 0x97, 0x4d, 0x50, 0x36, 0x19, 0xc5, 0x3e, 0xe9, + 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 0x57, 0xa5, 0xb7, 0xec, 0x82, + 0x8d, 0xa7, 0x69, 0x27, 0x12, 0xe9, 0x9f, 0x35, 0xa0, 0x2f, 0xb9, 0xbd, 0x7a, 0x3a, 0xc0, 0x76, + 0xc4, 0x8c, 0x67, 0xa9, 0x47, 0x14, 0x89, 0xe6, 0xc1, 0xf9, 0xd8, 0xd4, 0x2e, 0xc6, 0xa6, 0xf6, + 0x67, 0x6c, 0x6a, 0x5f, 0x27, 0x66, 0xe6, 0x62, 0x62, 0x66, 0x7e, 0x4c, 0xcc, 0xcc, 0xbb, 0x27, + 0x33, 0xc6, 0x4b, 0xf8, 0xda, 0x31, 0xea, 0x52, 0xf5, 0x8f, 0x7d, 0x52, 0xdf, 0xb3, 0x87, 0xb3, + 0x9f, 0x57, 0x1e, 0x46, 0x77, 0x9d, 0x7f, 0x52, 0xf7, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xbb, + 0x56, 0xac, 0xa7, 0xf8, 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + SwapExactAmountIn(ctx context.Context, in *MsgSwapExactAmountIn, opts ...grpc.CallOption) (*MsgSwapExactAmountInResponse, error) + SwapExactAmountOut(ctx context.Context, in *MsgSwapExactAmountOut, opts ...grpc.CallOption) (*MsgSwapExactAmountOutResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SwapExactAmountIn(ctx context.Context, in *MsgSwapExactAmountIn, opts ...grpc.CallOption) (*MsgSwapExactAmountInResponse, error) { + out := new(MsgSwapExactAmountInResponse) + err := c.cc.Invoke(ctx, "/osmosis.swaprouter.v1beta1.Msg/SwapExactAmountIn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SwapExactAmountOut(ctx context.Context, in *MsgSwapExactAmountOut, opts ...grpc.CallOption) (*MsgSwapExactAmountOutResponse, error) { + out := new(MsgSwapExactAmountOutResponse) + err := c.cc.Invoke(ctx, "/osmosis.swaprouter.v1beta1.Msg/SwapExactAmountOut", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + SwapExactAmountIn(context.Context, *MsgSwapExactAmountIn) (*MsgSwapExactAmountInResponse, error) + SwapExactAmountOut(context.Context, *MsgSwapExactAmountOut) (*MsgSwapExactAmountOutResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SwapExactAmountIn(ctx context.Context, req *MsgSwapExactAmountIn) (*MsgSwapExactAmountInResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SwapExactAmountIn not implemented") +} +func (*UnimplementedMsgServer) SwapExactAmountOut(ctx context.Context, req *MsgSwapExactAmountOut) (*MsgSwapExactAmountOutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SwapExactAmountOut not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SwapExactAmountIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSwapExactAmountIn) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SwapExactAmountIn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.swaprouter.v1beta1.Msg/SwapExactAmountIn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SwapExactAmountIn(ctx, req.(*MsgSwapExactAmountIn)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SwapExactAmountOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSwapExactAmountOut) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SwapExactAmountOut(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.swaprouter.v1beta1.Msg/SwapExactAmountOut", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SwapExactAmountOut(ctx, req.(*MsgSwapExactAmountOut)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.swaprouter.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SwapExactAmountIn", + Handler: _Msg_SwapExactAmountIn_Handler, + }, + { + MethodName: "SwapExactAmountOut", + Handler: _Msg_SwapExactAmountOut_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/swaprouter/v1beta1/tx.proto", +} + +func (m *MsgSwapExactAmountIn) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSwapExactAmountIn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapExactAmountIn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TokenOutMinAmount.Size() + i -= size + if _, err := m.TokenOutMinAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.TokenIn.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Routes) > 0 { + for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSwapExactAmountInResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSwapExactAmountInResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapExactAmountInResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TokenOutAmount.Size() + i -= size + if _, err := m.TokenOutAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgSwapExactAmountOut) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSwapExactAmountOut) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapExactAmountOut) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.TokenOut.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.TokenInMaxAmount.Size() + i -= size + if _, err := m.TokenInMaxAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Routes) > 0 { + for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSwapExactAmountOutResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSwapExactAmountOutResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapExactAmountOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TokenInAmount.Size() + i -= size + if _, err := m.TokenInAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSwapExactAmountIn) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Routes) > 0 { + for _, e := range m.Routes { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = m.TokenIn.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.TokenOutMinAmount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSwapExactAmountInResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TokenOutAmount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSwapExactAmountOut) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Routes) > 0 { + for _, e := range m.Routes { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = m.TokenInMaxAmount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.TokenOut.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSwapExactAmountOutResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TokenInAmount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSwapExactAmountIn) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSwapExactAmountIn: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapExactAmountIn: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Routes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Routes = append(m.Routes, SwapAmountInRoute{}) + if err := m.Routes[len(m.Routes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenIn", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenIn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOutMinAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenOutMinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSwapExactAmountInResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSwapExactAmountInResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapExactAmountInResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOutAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenOutAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSwapExactAmountOut) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSwapExactAmountOut: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapExactAmountOut: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Routes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Routes = append(m.Routes, SwapAmountOutRoute{}) + if err := m.Routes[len(m.Routes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenInMaxAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenInMaxAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOut", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSwapExactAmountOutResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSwapExactAmountOutResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapExactAmountOutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenInAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenInAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tokenfactory/client/cli/query.go b/x/tokenfactory/client/cli/query.go index bbbd1301ba4..cf9a1eefa8d 100644 --- a/x/tokenfactory/client/cli/query.go +++ b/x/tokenfactory/client/cli/query.go @@ -13,7 +13,7 @@ import ( // "github.com/cosmos/cosmos-sdk/client/flags" // sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/tokenfactory/client/cli/query_test.go b/x/tokenfactory/client/cli/query_test.go index ea756feb9e9..4a625270575 100644 --- a/x/tokenfactory/client/cli/query_test.go +++ b/x/tokenfactory/client/cli/query_test.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) type QueryTestSuite struct { diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go index 1483620b8fe..7c375ceabef 100644 --- a/x/tokenfactory/client/cli/tx.go +++ b/x/tokenfactory/client/cli/tx.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/tokenfactory/keeper/admins.go b/x/tokenfactory/keeper/admins.go index 03f33077245..1d4a68a3936 100644 --- a/x/tokenfactory/keeper/admins.go +++ b/x/tokenfactory/keeper/admins.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) // GetAuthorityMetadata returns the authority metadata for a specific denom diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go index dc0e92a580d..2209cf27d18 100644 --- a/x/tokenfactory/keeper/admins_test.go +++ b/x/tokenfactory/keeper/admins_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) func (suite *KeeperTestSuite) TestAdminMsgs() { diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index 5c35d4c2f27..6b5bd2cdc0d 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error { diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index 8abec1efd52..a4b2a5782fc 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) // ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index 3b8b376a7c1..f6ba2a02feb 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) func (suite *KeeperTestSuite) TestMsgCreateDenom() { diff --git a/x/tokenfactory/keeper/genesis.go b/x/tokenfactory/keeper/genesis.go index 3a0c9f76809..6b44a6a5075 100644 --- a/x/tokenfactory/keeper/genesis.go +++ b/x/tokenfactory/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) // InitGenesis initializes the tokenfactory module's state from a provided genesis diff --git a/x/tokenfactory/keeper/genesis_test.go b/x/tokenfactory/keeper/genesis_test.go index 928eba12292..36058ae7dfb 100644 --- a/x/tokenfactory/keeper/genesis_test.go +++ b/x/tokenfactory/keeper/genesis_test.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) func (suite *KeeperTestSuite) TestGenesis() { diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index deabce2d2fa..06520c175c8 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index c37b66bc301..563144c02a2 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go index 400bcaa0557..3062b6ca51d 100644 --- a/x/tokenfactory/keeper/keeper_test.go +++ b/x/tokenfactory/keeper/keeper_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) type KeeperTestSuite struct { diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 17160705d8b..fb816b2fbef 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) type msgServer struct { diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index 42fe3735828..6f12a71c74d 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "fmt" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/tokenfactory/keeper/params.go b/x/tokenfactory/keeper/params.go index 78b43345a14..332b93c06d5 100644 --- a/x/tokenfactory/keeper/params.go +++ b/x/tokenfactory/keeper/params.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index a892be013c3..10554f848d2 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -23,12 +23,12 @@ import ( "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - simulation "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/simulation" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + simulation "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/simulation" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) var ( diff --git a/x/tokenfactory/simulation/sim_msgs.go b/x/tokenfactory/simulation/sim_msgs.go index fbd251186d1..27c80a56a22 100644 --- a/x/tokenfactory/simulation/sim_msgs.go +++ b/x/tokenfactory/simulation/sim_msgs.go @@ -5,10 +5,10 @@ import ( legacysimulationtype "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/simulation/simtypes" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/simulation/simtypes" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/tokenfactory/types/authorityMetadata.pb.go b/x/tokenfactory/types/authorityMetadata.pb.go index 9241dde20b7..676878a881e 100644 --- a/x/tokenfactory/types/authorityMetadata.pb.go +++ b/x/tokenfactory/types/authorityMetadata.pb.go @@ -95,8 +95,8 @@ var fileDescriptor_99435de88ae175f7 = []byte{ 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3d, 0xa0, 0x9b, 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, 0x97, - 0x19, 0x1a, 0xe9, 0x57, 0xa0, 0x86, 0x44, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x89, - 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x05, 0xcf, 0xa3, 0x03, 0x2e, 0x01, 0x00, 0x00, + 0x19, 0x1a, 0xeb, 0x57, 0xa0, 0x86, 0x44, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x89, + 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0d, 0x2c, 0xc3, 0x3f, 0x2e, 0x01, 0x00, 0x00, } func (this *DenomAuthorityMetadata) Equal(that interface{}) bool { diff --git a/x/tokenfactory/types/denoms_test.go b/x/tokenfactory/types/denoms_test.go index 2aab290c1c3..f5c7ea6c590 100644 --- a/x/tokenfactory/types/denoms_test.go +++ b/x/tokenfactory/types/denoms_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) func TestDeconstructDenom(t *testing.T) { diff --git a/x/tokenfactory/types/genesis.pb.go b/x/tokenfactory/types/genesis.pb.go index c06731902f5..97c53d14a7d 100644 --- a/x/tokenfactory/types/genesis.pb.go +++ b/x/tokenfactory/types/genesis.pb.go @@ -164,8 +164,8 @@ var fileDescriptor_5749c3f71850298b = []byte{ 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x45, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x55, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x30, 0x8e, 0x7e, 0x99, 0xa1, - 0x91, 0x7e, 0x05, 0x6a, 0x8c, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x63, 0xda, 0x18, - 0x10, 0x00, 0x00, 0xff, 0xff, 0x16, 0xe9, 0x52, 0x6a, 0xac, 0x02, 0x00, 0x00, + 0xb1, 0x7e, 0x05, 0x6a, 0x8c, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x63, 0xda, 0x18, + 0x10, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x0a, 0x32, 0x56, 0xac, 0x02, 0x00, 0x00, } func (this *GenesisDenom) Equal(that interface{}) bool { diff --git a/x/tokenfactory/types/genesis_test.go b/x/tokenfactory/types/genesis_test.go index 91a11b8dc10..af4c2e4a985 100644 --- a/x/tokenfactory/types/genesis_test.go +++ b/x/tokenfactory/types/genesis_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/tokenfactory/types/msgs_test.go b/x/tokenfactory/types/msgs_test.go index 854658328c4..b2cd5f3ddb4 100644 --- a/x/tokenfactory/types/msgs_test.go +++ b/x/tokenfactory/types/msgs_test.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/tokenfactory/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/tendermint/tendermint/crypto/ed25519" diff --git a/x/tokenfactory/types/params.go b/x/tokenfactory/types/params.go index c7579b7986c..435d381a769 100644 --- a/x/tokenfactory/types/params.go +++ b/x/tokenfactory/types/params.go @@ -3,7 +3,7 @@ package types import ( "fmt" - appparams "github.com/osmosis-labs/osmosis/v12/app/params" + appparams "github.com/osmosis-labs/osmosis/v13/app/params" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" diff --git a/x/tokenfactory/types/params.pb.go b/x/tokenfactory/types/params.pb.go index 4ad1f92ffc2..705203b01d4 100644 --- a/x/tokenfactory/types/params.pb.go +++ b/x/tokenfactory/types/params.pb.go @@ -83,7 +83,7 @@ var fileDescriptor_cc8299d306f3ff47 = []byte{ // 309 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xbf, 0x4e, 0xf3, 0x30, 0x14, 0xc5, 0x63, 0x7d, 0x52, 0x87, 0x7e, 0x0b, 0xaa, 0x18, 0x68, 0x85, 0x1c, 0x94, 0xa9, 0x0c, - 0xb5, 0x95, 0xc2, 0x80, 0x18, 0x5b, 0x89, 0xad, 0x12, 0xea, 0xc8, 0x12, 0xdd, 0x24, 0x6e, 0x6a, + 0xb5, 0x15, 0xca, 0x80, 0x18, 0x5b, 0x89, 0xad, 0x12, 0xea, 0xc8, 0x12, 0xdd, 0x24, 0x6e, 0x6a, 0xb5, 0xc9, 0x8d, 0x62, 0xb7, 0x22, 0x6f, 0xc1, 0xc4, 0xce, 0xca, 0x93, 0x74, 0xec, 0xc8, 0x54, 0x50, 0xf2, 0x06, 0x3c, 0x01, 0xaa, 0xe3, 0xa2, 0x22, 0x24, 0x26, 0xfb, 0xe8, 0x9e, 0xf3, 0xbb, 0x7f, 0xda, 0x97, 0xa8, 0x52, 0x54, 0x52, 0x71, 0x8d, 0x0b, 0x91, 0xcd, 0x20, 0xd2, 0x58, 0x94, @@ -93,14 +93,14 @@ var fileDescriptor_cc8299d306f3ff47 = []byte{ 0x75, 0x23, 0x13, 0x0b, 0x1a, 0x5c, 0x23, 0x6c, 0x89, 0x36, 0x8a, 0x87, 0xa0, 0xc4, 0x37, 0x27, 0x42, 0x99,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0x15, 0xb2, 0x08, 0x53, 0x3b, 0xa0, 0x7d, 0x06, 0x2a, 0x5e, 0x70, 0x5d, 0xe6, + 0x42, 0x19, 0x9a, 0x9a, 0x9e, 0x18, 0xc0, 0xd8, 0xe6, 0xef, 0x84, 0x18, 0x4d, 0x37, 0x15, 0x25, + 0xdb, 0x8a, 0x92, 0x8f, 0x8a, 0x92, 0xa7, 0x9a, 0x3a, 0xdb, 0x9a, 0x3a, 0x6f, 0x35, 0x75, 0x1e, + 0x6e, 0x8e, 0xa8, 0xf6, 0x72, 0x83, 0x25, 0x84, 0xea, 0x20, 0xf8, 0xda, 0x1f, 0xf2, 0xc7, 0x9f, + 0xc7, 0x34, 0xbd, 0xc2, 0x96, 0x59, 0x7f, 0xf8, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x6a, 0xd8, + 0xe6, 0xd0, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go index aec8c192dee..97702cbef97 100644 --- a/x/tokenfactory/types/query.pb.go +++ b/x/tokenfactory/types/query.pb.go @@ -311,43 +311,43 @@ func init() { } var fileDescriptor_6f22013ad0f72e3f = []byte{ - // 574 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0xce, 0xfc, 0x7f, 0x1b, 0xd4, 0xe1, 0x22, 0x32, 0x54, 0x08, 0xa2, 0xe2, 0xc0, 0x50, 0x55, - 0x29, 0x2a, 0x1e, 0x12, 0xba, 0x40, 0x14, 0x04, 0x71, 0x11, 0x2c, 0xa0, 0x12, 0x78, 0x07, 0x9b, - 0x68, 0x92, 0x4e, 0x5d, 0x8b, 0xd8, 0xe3, 0x7a, 0x26, 0x15, 0x51, 0xd5, 0x0d, 0x0b, 0xd6, 0x48, - 0x2c, 0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xe8, 0x3b, - 0x80, 0x97, 0x27, 0x2f, 0x05, 0x3d, 0x9e, 0x42, 0x3b, 0xf7, 0xf2, 0xca, 0x8d, 0x7f, 0x60, 0x30, - 0x69, 0x9e, 0xa9, 0x34, 0x0d, 0xf4, 0x28, 0x3f, 0x8d, 0x9e, 0x3a, 0xd9, 0x53, 0xbf, 0xfb, 0x24, - 0x7b, 0x40, 0xe8, 0x08, 0xc0, 0x52, 0x66, 0xb3, 0x68, 0x6d, 0x5a, 0x87, 0x13, 0xce, 0xab, 0xfc, - 0xe0, 0xef, 0x9a, 0x4d, 0xb2, 0x75, 0x95, 0xec, 0x21, 0x5a, 0x9b, 0x26, 0x59, 0x73, 0x2b, 0xe6, - 0x41, 0xd3, 0x5c, 0x2a, 0xd9, 0x33, 0x1f, 0xfb, 0x8e, 0x7b, 0xd0, 0xb7, 0xc0, 0x61, 0xdf, 0x02, - 0xdf, 0xfa, 0x16, 0xf8, 0x38, 0xb0, 0x0a, 0x87, 0x03, 0xab, 0xf0, 0x75, 0x60, 0x15, 0xde, 0xdc, - 0xf3, 0x7c, 0xb9, 0xdd, 0x6d, 0xd9, 0x6d, 0x1e, 0x8c, 0x04, 0x6e, 0x77, 0x68, 0x4b, 0x8c, 0xd5, - 0x76, 0x6b, 0x75, 0xf2, 0xee, 0xb4, 0xa6, 0xec, 0x45, 0x4c, 0xb4, 0x8a, 0xea, 0xdf, 0xec, 0xee, - 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x3a, 0x54, 0xaf, 0xd8, 0x05, 0x00, 0x00, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x6b, 0x13, 0x41, + 0x14, 0xcf, 0x68, 0x1b, 0xe9, 0xf8, 0x07, 0x33, 0x16, 0xd1, 0x50, 0x37, 0x3a, 0x96, 0x92, 0x4a, + 0xdd, 0x31, 0x6d, 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x87, 0x09, 0x89, 0xdf, 0xc0, 0x2b, 0xa7, 0x5e, + 0x45, 0xc4, 0x43, 0xc1, 0x90, 0x03, 0x8b, 0xba, 0xf9, 0x1a, 0xb8, 0x09, 0xaa, 0xe7, 0x97, 0xe7, + 0xed, 0xbc, 0xe1, 0xd8, 0xba, 0xdb, 0x99, 0x3a, 0x48, 0x2a, 0x05, 0xd7, 0x74, 0xe2, 0x97, 0x10, + 0x2b, 0xea, 0xa7, 0x2c, 0xe4, 0x41, 0xfd, 0xf7, 0x00, 0xc6, 0x00, 0x5a, 0x80, 0xd3, 0x9b, 0x29, + 0x40, 0x09, 0xcd, 0x38, 0x97, 0x07, 0x49, 0xe5, 0x42, 0x97, 0x06, 0xed, 0x07, 0x58, 0x3d, 0x63, + 0x57, 0x97, 0xf1, 0x57, 0x00, 0x6f, 0xe7, 0xd2, 0x19, 0xe7, 0x1f, 0x01, 0x44, 0xa3, 0x69, 0x35, + 0x02, 0x53, 0x36, 0x31, 0x56, 0xf3, 0x63, 0x8c, 0xa7, 0x76, 0x6e, 0xa5, 0xb1, 0x06, 0x49, 0xe5, + 0xba, 0xf6, 0x95, 0x65, 0xc7, 0x6e, 0x29, 0xb3, 0x20, 0xbc, 0x01, 0x6f, 0xfc, 0xf2, 0x2b, 0x9e, + 0xc5, 0x3c, 0x58, 0x8f, 0x19, 0x95, 0x3c, 0x1e, 0x26, 0x5f, 0x82, 0xe7, 0x5a, 0xfa, 0xc5, 0x64, + 0x47, 0x83, 0xa4, 0x72, 0x49, 0x6b, 0x98, 0x02, 0x76, 0x87, 0x10, 0xfc, 0x02, 0x5a, 0x7f, 0xa2, + 0x33, 0xc9, 0x17, 0x61, 0x51, 0x8d, 0x2a, 0xdd, 0xd9, 0xd9, 0xea, 0x8c, 0x53, 0x1a, 0x24, 0x95, + 0x8b, 0x27, 0x46, 0x29, 0xb0, 0x6b, 0x00, 0xcb, 0xc7, 0x53, 0x70, 0x5a, 0xb1, 0xa1, 0x2f, 0x00, + 0x16, 0xf5, 0xf6, 0xd0, 0xbd, 0xfc, 0xe1, 0x64, 0x8f, 0xa7, 0x5c, 0xfb, 0x8b, 0x0e, 0x6d, 0x12, + 0x2f, 0x7d, 0x38, 0x3a, 0xfe, 0x7c, 0x66, 0x01, 0xcd, 0x93, 0x09, 0x2e, 0x17, 0xfd, 0x00, 0xf0, + 0xea, 0xf8, 0xa5, 0xa0, 0x27, 0x13, 0x68, 0xe7, 0x5e, 0x5e, 0xb9, 0xfe, 0x1f, 0x0c, 0x26, 0xcd, + 0x73, 0x95, 0xa6, 0x8e, 0x1e, 0xe7, 0xa7, 0xd1, 0x53, 0x27, 0x7b, 0xea, 0x77, 0x9f, 0x64, 0x0f, + 0x08, 0x1d, 0x01, 0x58, 0xca, 0x6c, 0x16, 0xad, 0x4d, 0xea, 0x70, 0xcc, 0x79, 0x95, 0x1f, 0xfe, + 0x5b, 0xb3, 0x49, 0xb6, 0xae, 0x92, 0x3d, 0x42, 0x6b, 0x93, 0x24, 0x6b, 0x6c, 0xc5, 0x3c, 0x68, + 0x98, 0x4b, 0x25, 0x7b, 0xe6, 0x63, 0xdf, 0x71, 0x0f, 0x7a, 0x16, 0x38, 0xec, 0x59, 0xe0, 0x7b, + 0xcf, 0x02, 0x9f, 0xfa, 0x56, 0xe1, 0xb0, 0x6f, 0x15, 0xbe, 0xf5, 0xad, 0xc2, 0xdb, 0xfb, 0x9e, + 0x2f, 0xb7, 0x3b, 0x4d, 0xbb, 0xc5, 0x83, 0xa1, 0xc0, 0xdd, 0x36, 0x6d, 0x8a, 0x91, 0xda, 0x6e, + 0x6d, 0x85, 0xbc, 0x3f, 0xad, 0x29, 0xbb, 0x11, 0x13, 0xcd, 0xa2, 0xfa, 0x37, 0x5b, 0xf9, 0x19, + 0x00, 0x00, 0xff, 0xff, 0x03, 0xd9, 0x34, 0x93, 0xd8, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index b61b87b67a2..f2d5e9b1dc1 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -528,45 +528,45 @@ func init() { } var fileDescriptor_283b6c9a90a846b4 = []byte{ - // 593 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x41, 0x6e, 0xd3, 0x40, - 0x14, 0x8d, 0x69, 0x29, 0xe9, 0x94, 0x92, 0xd4, 0x2d, 0x25, 0x18, 0x6a, 0xa3, 0x91, 0x8a, 0x40, - 0xa2, 0xb6, 0x12, 0x58, 0x00, 0x3b, 0x5c, 0x16, 0x6c, 0xbc, 0x31, 0xac, 0x50, 0xa5, 0x6a, 0x9c, - 0x0c, 0xae, 0x95, 0x78, 0x26, 0x64, 0x26, 0x4d, 0xb3, 0x41, 0x1c, 0x81, 0x05, 0xe2, 0x10, 0x9c, - 0xa4, 0xcb, 0x2e, 0x59, 0x59, 0x28, 0xb9, 0x41, 0x4e, 0x80, 0x3c, 0x33, 0x76, 0x9c, 0x06, 0x91, - 0x64, 0xc5, 0x2e, 0xf6, 0x7f, 0xef, 0xcd, 0x9b, 0xf7, 0xff, 0x8f, 0xc1, 0x21, 0x65, 0x31, 0x65, - 0x11, 0x73, 0x38, 0x6d, 0x63, 0xf2, 0x09, 0x35, 0x39, 0xed, 0x0d, 0x9d, 0xf3, 0x7a, 0x80, 0x39, - 0xaa, 0x3b, 0xfc, 0xc2, 0xee, 0xf6, 0x28, 0xa7, 0xfa, 0x43, 0x05, 0xb3, 0x8b, 0x30, 0x5b, 0xc1, - 0x8c, 0xbd, 0x90, 0x86, 0x54, 0x00, 0x9d, 0xf4, 0x97, 0xe4, 0x18, 0x66, 0x53, 0x90, 0x9c, 0x00, - 0x31, 0x9c, 0x2b, 0x36, 0x69, 0x44, 0xe6, 0xea, 0xa4, 0x9d, 0xd7, 0xd3, 0x07, 0x59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 0xbf, 0x1c, 0x99, 0xda, 0xd5, 0xc8, - 0xd4, 0x7e, 0x8f, 0x4c, 0xed, 0xdb, 0xd8, 0x2c, 0x5d, 0x8d, 0xcd, 0xd2, 0xaf, 0xb1, 0x59, 0xfa, - 0xf8, 0x32, 0x8c, 0xf8, 0x59, 0x3f, 0xb0, 0x9b, 0x34, 0x76, 0x94, 0xfc, 0x51, 0x07, 0x05, 0x2c, - 0x7b, 0x70, 0xce, 0xeb, 0x0d, 0xe7, 0x62, 0xf6, 0xd3, 0xc2, 0x87, 0x5d, 0xcc, 0x82, 0x0d, 0xf1, - 0x17, 0xff, 0xfc, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x60, 0x4c, 0x1d, 0x7f, 0x06, 0x00, - 0x00, + // 594 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xc1, 0x6e, 0xd3, 0x4a, + 0x14, 0x8d, 0x5f, 0xfb, 0x42, 0x3a, 0xa5, 0x24, 0x75, 0x4b, 0x09, 0x86, 0xda, 0x68, 0xa4, 0x22, + 0x90, 0xa8, 0xad, 0xb4, 0x2c, 0x80, 0x1d, 0x2e, 0x0b, 0x36, 0xde, 0x18, 0x56, 0xa8, 0x52, 0x35, + 0x4e, 0x06, 0xd7, 0x4a, 0x3c, 0x13, 0x32, 0x93, 0xa6, 0xd9, 0x20, 0x3e, 0x81, 0x05, 0xe2, 0x23, + 0xf8, 0x92, 0x2e, 0xbb, 0x64, 0x65, 0xa1, 0xe4, 0x0f, 0xf2, 0x05, 0xc8, 0x33, 0x63, 0xc7, 0x69, + 0x10, 0x49, 0x56, 0xec, 0x62, 0xdf, 0x73, 0xce, 0x9c, 0x39, 0xf7, 0xde, 0x18, 0x1c, 0x50, 0x16, + 0x53, 0x16, 0x31, 0x87, 0xd3, 0x36, 0x26, 0x1f, 0x51, 0x93, 0xd3, 0xde, 0xd0, 0xb9, 0x68, 0x04, + 0x98, 0xa3, 0x86, 0xc3, 0x2f, 0xed, 0x6e, 0x8f, 0x72, 0xaa, 0x3f, 0x54, 0x30, 0xbb, 0x08, 0xb3, + 0x15, 0xcc, 0xd8, 0x0d, 0x69, 0x48, 0x05, 0xd0, 0x49, 0x7f, 0x49, 0x8e, 0x61, 0x36, 0x05, 0xc9, + 0x09, 0x10, 0xc3, 0xb9, 0x62, 0x93, 0x46, 0x64, 0xae, 0x4e, 0xda, 0x79, 0x3d, 0x7d, 0x90, 0x75, + 0xd8, 0x01, 0x77, 0x3c, 0x16, 0x9e, 0xf4, 0x30, 0xe2, 0xf8, 0x0d, 0x26, 0x34, 0xd6, 0x9f, 0x82, + 0x32, 0xc3, 0xa4, 0x85, 0x7b, 0x75, 0xed, 0x91, 0xf6, 0x64, 0xc3, 0xdd, 0x9e, 0x24, 0xd6, 0xd6, + 0x10, 0xc5, 0x9d, 0x57, 0x50, 0xbe, 0x87, 0xbe, 0x02, 0xe8, 0x0e, 0xa8, 0xb0, 0x7e, 0xd0, 0x4a, + 0x69, 0xf5, 0xff, 0x04, 0x78, 0x67, 0x92, 0x58, 0x55, 0x05, 0x56, 0x15, 0xe8, 0xe7, 0x20, 0x78, + 0x0a, 0xf6, 0x66, 0x4f, 0xf3, 0x31, 0xeb, 0x52, 0xc2, 0xb0, 0xee, 0x82, 0x2a, 0xc1, 0x83, 0x33, + 0x71, 0xf3, 0x33, 0xa9, 0x28, 0x8f, 0x37, 0x26, 0x89, 0xb5, 0x27, 0x15, 0x6f, 0x00, 0xa0, 0xbf, + 0x45, 0xf0, 0xe0, 0x7d, 0xfa, 0x42, 0x68, 0xc1, 0xcf, 0xe0, 0x96, 0xc7, 0x42, 0x2f, 0x22, 0x7c, + 0x95, 0x4b, 0xbc, 0x05, 0x65, 0x14, 0xd3, 0x3e, 0xe1, 0xe2, 0x0a, 0x9b, 0x47, 0xf7, 0x6d, 0x19, + 0x99, 0x9d, 0x46, 0x9a, 0xa5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 0x0a, 0x33, 0x0e, 0x97, 0x82, 0x15, + 0xd5, 0xc5, 0x44, 0x2f, 0x56, 0x4f, 0x61, 0x4b, 0xa8, 0x17, 0xe7, 0x53, 0xc4, 0x55, 0x98, 0xcd, + 0x25, 0xe2, 0x9a, 0xa2, 0x97, 0x89, 0x6b, 0x7e, 0xbe, 0xf4, 0x2f, 0x1a, 0xa8, 0xcd, 0x0d, 0x57, + 0x63, 0xa1, 0xd4, 0x4d, 0x8a, 0xf1, 0x72, 0x65, 0x4a, 0x66, 0xc1, 0xf5, 0xaf, 0x46, 0xa6, 0x76, + 0x3d, 0x32, 0xb5, 0x5f, 0x23, 0x53, 0xfb, 0x3a, 0x36, 0x4b, 0xd7, 0x63, 0xb3, 0xf4, 0x73, 0x6c, + 0x96, 0x3e, 0xbc, 0x08, 0x23, 0x7e, 0xde, 0x0f, 0xec, 0x26, 0x8d, 0x1d, 0x25, 0x7f, 0xd8, 0x41, + 0x01, 0xcb, 0x1e, 0x9c, 0x8b, 0xc6, 0xb1, 0x73, 0x39, 0xfb, 0x69, 0xe1, 0xc3, 0x2e, 0x66, 0x41, + 0x59, 0xfc, 0xc5, 0x1f, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xff, 0x83, 0x2c, 0x21, 0x7f, 0x06, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/twap/README.md b/x/twap/README.md index 1596cbb22a1..ca5d48a1d9d 100644 --- a/x/twap/README.md +++ b/x/twap/README.md @@ -12,6 +12,29 @@ Notice that the latest price `p_n` isn't used, as it has lasted for a time inter To illustrate with an example, given the sequence: `(0s, $1), (4s, $6), (5s, $1)`, the arithmetic mean TWAP is: $$\frac{\$1 * (4s - 0s) + \$6 * (5s - 4s)}{5s - 0s} = \frac{\$10}{5} = \$2$$ +## Geometric mean TWAP + +While the arithmetic mean TWAPs are much more widely used, they should theoretically be less accurate in measuring a geometric Brownian motion process (which is how price movements are usually modeled) + +Arithmetic TWAP tends to overweight higher prices relative to lower ones. + +Therefore, we also support a geometric mean TWAP. + +The core functionality stays similar to the arithmetic mean TWAP. However, instead of computing the geometric mean TWAP naively as +a [weighted geometric mean](https://en.wikipedia.org//wiki/Weighted_geometric_mean), we use the following property: + + +$$GeometricMean(P) = 2^{ArithmeticMean(log_{2}{P})}$$ + +$$ {(\prod_{i=a}^{b} P_i)}^{\frac{1}\{b-a}} = exp(\sum_{i=a}^{b}{\frac{1}{b-a} ln{(P_i)}}) $$ + +Note that in the second expression we use a different logarithm and power bases of `e`. +This is for brevity, and the true value used in our implementation is currently `2`. + +Naive computation is expensive and easily overflows. As a result, we track logarithms of prices instead of prices themselves in the accumulators. +When geometric twap is requested, we first compute the arithmetic mean of the logarithms, and then exponentiate it with the same base as the logarithm +to get the final result. + ## Computation via accumulators method The prior example for how to compute the TWAP takes linear time in the number of time entries in a range, which is too inefficient. We require TWAP operations to have constant time complexity (in the number of records). @@ -34,7 +57,7 @@ The primary intended API is `GetArithmeticTwap`, which is documented below, and ```go // GetArithmeticTwap returns an arithmetic time weighted average price. -// The returned twap is the time weighted average price (TWAP), using the arithmetic mean, of: +// The returned twap is the time weighted average price (TWAP), using the arithmetic mean of: // * the base asset, in units of the quote asset (1 unit of base = x units of quote) // * from (startTime, endTime), // * as determined by prices from AMM pool `poolId`. @@ -46,12 +69,18 @@ The primary intended API is `GetArithmeticTwap`, which is documented below, and // startTime must be within 48 hours of ctx.BlockTime(), if you need older TWAPs, // you will have to maintain the accumulator yourself. // +// endTime will be set in the function ArithmeticTwap() to ctx.BlockTime() which calls GetArithmeticTwap function if: +// * it is not provided externally +// * it is set to current time +// // This function will error if: // * startTime > endTime // * endTime in the future // * startTime older than 48 hours OR pool creation // * pool with id poolId does not exist, or does not contain quoteAssetDenom, baseAssetDenom -// +// * there were some computational errors during computing arithmetic twap within the time range of +// startRecord, endRecord - including the exact record times, which indicates that the result returned could be faulty + // N.B. If there is a notable use case, the state machine could maintain more historical records, e.g. at one per hour. func (k Keeper) GetArithmeticTwap(ctx sdk.Context, poolId uint64, @@ -85,13 +114,32 @@ Because Osmosis supports multi-asset pools, a complicating factor is that we hav For every pool, at a given point in time, we make one twap record entry per unique pair of denoms in the pool. If a pool has `k` denoms, the number of unique pairs is `k * (k - 1) / 2`. All public API's for the module will sort the input denoms to the canonical representation, so the caller does not need to worry about this. (The canonical representation is the denoms in lexicographical order) -Each twap record stores [(source)](https://github.com/osmosis-labs/osmosis/tree/main/proto/osmosis/gamm/twap): +Example of historical TWAP time index records for a pool containing 3 assets. +* Number of records per time: `3 * (3 - 1) / 2 = 3` +* Records are in a format: + HistoricalTWAPTimeIndexPrefix | time | pool id | denom1 | denom2 + + For our pool with Id = 1 and 3 assets: denomA, denomB and denomC: + + historical_time_index|2009-11-10T23:00:00.000000000|1|denomA|denomB + historical_time_index|2009-11-10T23:00:00.000000000|1|denomA|denomC + historical_time_index|2009-11-10T23:00:00.000000000|1|denomB|denomC + + + + +Each twap record stores [(source)](../../proto/osmosis/twap/v1beta1/twap_record.proto): * last spot price of base asset A in terms of quote asset B * last spot price of base asset B in terms of quote asset A * Accumulation value of base asset A in terms of quote asset B * Accumulation value of base asset B in terms of quote asset A +important for calculation of arthmetic twap. + +Besides those values, TWAP records currently hold: poolId, Asset0Denom, Asset1Denom, Height (for debugging purposes), Time and +Last error time - time in which the last spot price error occured. This will allert the caller if they are getting a potentially erroneous TWAP. + All TWAP records are indexed in state by the time of write. A new TWAP record is created in two situations: @@ -108,6 +156,10 @@ During `EndBlock`, new records are created, with: In the event that a pool is created, and has a swap in the same block, the record entries are over written with the end block price. +Error handling during records creation/updating: +* If there are issues with creating a record after pool creation, the creation of a pool will be aborted. +* Whereas, if there is an issue with updating records for a pool with potentially price changing events, existing errors will be ignored and the records will not be updated. + ### Tracking spot-price changing events in a block The flow by which we currently track spot price changing events in a block is as follows: @@ -115,7 +167,7 @@ The flow by which we currently track spot price changing events in a block is as * AMM hook triggers for Swapping, LPing or Exiting a pool * TWAP listens for this hook, and adds this pool ID to a local tracker * In end block, TWAP iterates over every changed pool in that block, based on the local tracker, and updates their TWAP records -* In end block, TWAP clears the changed pool list, so it is blank by the next block. +* After execution in end block, when the block is committed, `Transient Store` that will hold the changed pool "list" within - will be cleared. This guarantees us that there are no changed pool IDs remaining by for processing in the next block. The mechanism by which we maintain this changed pool list, is the SDK `Transient Store`. The transient store is a KV store in the SDK, that stores entries in memory, for the duration of a block, @@ -124,8 +176,22 @@ and then clears on the block committing. This is done to save on gas (and I/O fo ## Pruning To avoid infinite growth of the state with the TWAP records, we attempt to delete some old records after every epoch. -Essentially, records younger than a configurable parameter are pruned away. Currently, this parameter is set to 48 hours. -Therefore, at the end of an epoch records younger than 48 hours before the current block time are pruned away. +Essentially, records older than a configurable parameter `RecordHistoryKeepPeriod` are pruned away. Currently, this parameter is set to 48 hours. +Therefore, at the end of an epoch, records older than 48 hours before the current block time are pruned away. +This could potentially leave the store with only one record - or no records at all within the "keep" period, so the pruning mechanism keeps the newest record that is older than the pruning time. This record is necessary to enable us interpolating from and getting TWAPs from the "keep" period. +Such record is preserved for each pool. + + +## TWAP - storing records and pruning process flow +
+ +

+ + + +

+ +
## Testing Methodology diff --git a/x/twap/TWAP module - process flow.png b/x/twap/TWAP module - process flow.png new file mode 100644 index 00000000000..f899b501255 Binary files /dev/null and b/x/twap/TWAP module - process flow.png differ diff --git a/x/twap/api.go b/x/twap/api.go index 20249756760..49fe42ddcea 100644 --- a/x/twap/api.go +++ b/x/twap/api.go @@ -5,7 +5,17 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" +) + +type twapType bool + +const ( + // arithmeticTwapType is the type of twap that is calculated by taking the arithmetic weighted average of the spot prices. + arithmeticTwapType twapType = true + // geometricTwapType is the type of twap that is calculated by taking the geometric weighted average of the spot prices. + // nolint: unused + geometricTwapType twapType = false ) // GetArithmeticTwap returns an arithmetic time weighted average price. @@ -21,12 +31,18 @@ import ( // startTime must be within 48 hours of ctx.BlockTime(), if you need older TWAPs, // you will have to maintain the accumulator yourself. // +// endTime will be set in the function ArithmeticTwap() to ctx.BlockTime() which calls GetArithmeticTwap function if: +// * it is not provided externally +// * it is set to current time +// // This function will error if: // * startTime > endTime // * endTime in the future // * startTime older than 48 hours OR pool creation // * pool with id poolId does not exist, or does not contain quoteAssetDenom, baseAssetDenom -// +// * there were some computational errors during computing arithmetic twap within the time range of +// startRecord, endRecord - including the exact record times, which indicates that the result returned could be faulty + // N.B. If there is a notable use case, the state machine could maintain more historical records, e.g. at one per hour. func (k Keeper) GetArithmeticTwap( ctx sdk.Context, @@ -52,7 +68,7 @@ func (k Keeper) GetArithmeticTwap( if err != nil { return sdk.Dec{}, err } - return computeArithmeticTwap(startRecord, endRecord, quoteAssetDenom) + return computeTwap(startRecord, endRecord, quoteAssetDenom, arithmeticTwapType) } // GetArithmeticTwapToNow returns GetArithmeticTwap on the input, with endTime being fixed to ctx.BlockTime() @@ -76,7 +92,7 @@ func (k Keeper) GetArithmeticTwapToNow( if err != nil { return sdk.Dec{}, err } - return computeArithmeticTwap(startRecord, endRecord, quoteAssetDenom) + return computeTwap(startRecord, endRecord, quoteAssetDenom, arithmeticTwapType) } // GetBeginBlockAccumulatorRecord returns a TwapRecord struct corresponding to the state of pool `poolId` diff --git a/x/twap/api_test.go b/x/twap/api_test.go index 33f307acd1b..58092f781b8 100644 --- a/x/twap/api_test.go +++ b/x/twap/api_test.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) var ( @@ -22,28 +22,38 @@ var ( ThreePlusOneThird sdk.Dec = sdk.MustNewDecFromStr("3.333333333333333333") // base record is a record with t=baseTime, sp0=10(sp1=0.1) accumulators set to 0 - baseRecord types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(baseTime, sdk.NewDec(10), sdk.ZeroDec(), sdk.ZeroDec()) + baseRecord types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(baseTime, sdk.NewDec(10), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) threeAssetRecordAB, threeAssetRecordAC, threeAssetRecordBC types.TwapRecord = newThreeAssetPoolTwapRecordWithDefaults( baseTime, sdk.NewDec(10), // spot price 0 sdk.ZeroDec(), // accum A sdk.ZeroDec(), // accum B - sdk.ZeroDec()) // accum C + sdk.ZeroDec(), // accum C + sdk.ZeroDec(), // geomAccum AB + sdk.ZeroDec(), // geomAccum AC + sdk.ZeroDec(), // geomAccum BC + ) // accumA = 10 seconds * (spot price = 10) = OneSec * 10 * 10 // accumB = 10 seconds * (spot price = 0.1) = OneSec // accumC = 10 seconds * (spot price = 20) = OneSec * 10 * 20 accumA, accumB, accumC sdk.Dec = OneSec.MulInt64(10 * 10), OneSec, OneSec.MulInt64(10 * 20) + // geomAccumAB = 10 seconds * (log_{1.0001}{spot price = 10}) + geomAccumAB = geometricTenSecAccum.MulInt64(10) + geomAccumAC = geomAccumAB + // geomAccumBC = 10 seconds * (log_{1.0001}{spot price = 0.1}) + geomAccumBC = OneSec.Mul(logOneOverTen).MulInt64(10) + // accumulators updated from baseRecord with // t = baseTime + 10 // spA = 5, spB = 0.2, spC = 10 tPlus10sp5Record = newTwoAssetPoolTwapRecordWithDefaults( - baseTime.Add(10*time.Second), sdk.NewDec(5), accumA, accumB) + baseTime.Add(10*time.Second), sdk.NewDec(5), accumA, accumB, geomAccumAB) tPlus10sp5ThreeAssetRecordAB, tPlus10sp5ThreeAssetRecordAC, tPlus10sp5ThreeAssetRecordBC = newThreeAssetPoolTwapRecordWithDefaults( - baseTime.Add(10*time.Second), sdk.NewDec(5), accumA, accumB, accumC) + baseTime.Add(10*time.Second), sdk.NewDec(5), accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC) // accumulators updated from tPlus10sp5Record with // t = baseTime + 20 @@ -52,21 +62,27 @@ var ( baseTime.Add(20*time.Second), sdk.NewDec(2), // spot price 0 OneSec.MulInt64(10*10+5*10), // accum A - OneSec.MulInt64(3)) // accum B + OneSec.MulInt64(3), // accum B + sdk.ZeroDec(), // TODO: choose correct + ) tPlus20sp2ThreeAssetRecordAB, tPlus20sp2ThreeAssetRecordAC, tPlus20sp2ThreeAssetRecordBC = newThreeAssetPoolTwapRecordWithDefaults( baseTime.Add(20*time.Second), sdk.NewDec(2), // spot price 0 OneSec.MulInt64(10*10+5*10), // accum A OneSec.MulInt64(3), // accum B - OneSec.MulInt64(20*10+10*10)) // accum C + OneSec.MulInt64(20*10+10*10), // accum C + sdk.ZeroDec(), // TODO: choose correct + sdk.ZeroDec(), // TODO: choose correct + sdk.ZeroDec(), // TODO: choose correct + ) spotPriceError = errors.New("twap: error in pool spot price occurred between start and end time, twap result may be faulty") ) func (s *TestSuite) TestGetBeginBlockAccumulatorRecord() { poolId, denomA, denomB := s.setupDefaultPool() - initStartRecord := newRecord(poolId, s.Ctx.BlockTime(), sdk.OneDec(), sdk.ZeroDec(), sdk.ZeroDec()) + initStartRecord := newRecord(poolId, s.Ctx.BlockTime(), sdk.OneDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) initStartRecord.PoolId, initStartRecord.Height = poolId, s.Ctx.BlockHeight() initStartRecord.Asset0Denom, initStartRecord.Asset1Denom = denomB, denomA @@ -87,12 +103,12 @@ func (s *TestSuite) TestGetBeginBlockAccumulatorRecord() { "default record": {initStartRecord, initStartRecord, baseTime, 1, denomA, denomB, nil}, "default record but same denom": {initStartRecord, initStartRecord, baseTime, 1, denomA, denomA, fmt.Errorf("both assets cannot be of the same denom: assetA: %s, assetB: %s", denomA, denomA)}, "default record wrong order (should get reordered)": {initStartRecord, initStartRecord, baseTime, 1, denomB, denomA, nil}, - "one second later record": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec), tPlusOne, 1, denomA, denomB, nil}, + "one second later record": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec, sdk.ZeroDec()), tPlusOne, 1, denomA, denomB, nil}, "idempotent overwrite": {initStartRecord, initStartRecord, baseTime, 1, denomA, denomB, nil}, - "idempotent overwrite2": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec), tPlusOne, 1, denomA, denomB, nil}, + "idempotent overwrite2": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec, sdk.ZeroDec()), tPlusOne, 1, denomA, denomB, nil}, "diff spot price": { zeroAccumTenPoint1Record, - recordWithUpdatedAccum(zeroAccumTenPoint1Record, OneSec.MulInt64(10), OneSec.QuoInt64(10)), + recordWithUpdatedAccum(zeroAccumTenPoint1Record, OneSec.MulInt64(10), OneSec.QuoInt64(10), geometricTenSecAccum), tPlusOne, 1, denomA, denomB, nil, }, } @@ -285,7 +301,23 @@ func (s *TestSuite) TestGetArithmeticTwap() { input: makeSimpleTwapInput(baseTime.Add(-time.Hour), baseTime, baseQuoteAB), expectError: twap.TimeTooOldError{Time: baseTime.Add(-time.Hour)}, }, - "spot price error in record": { + "spot price error in record at record time (start time = record time)": { + recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, baseTime)}, + ctxTime: tPlusOneMin, + input: makeSimpleTwapInput(baseTime, tPlusOneMin, baseQuoteAB), + expTwap: sdk.NewDec(10), + expectError: spotPriceError, + expectSpErr: baseTime, + }, + "spot price error in record at record time (start time > record time)": { + recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, baseTime)}, + ctxTime: tPlusOneMin, + input: makeSimpleTwapInput(tPlusOne, tPlusOneMin, baseQuoteAB), + expTwap: sdk.NewDec(10), + expectError: spotPriceError, + expectSpErr: baseTime, + }, + "spot price error in record after record time": { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, tPlusOne)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOneMin, baseQuoteAB), @@ -435,8 +467,9 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod() { periodBetweenBaseAndOneHourBeforeThreshold = (defaultRecordHistoryKeepPeriod.Milliseconds() - time.Hour.Milliseconds()) accumBeforeKeepThreshold0, accumBeforeKeepThreshold1 = sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10), sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10) + geomAccumBeforeKeepThreshold = sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold).Mul(logTen) // recordBeforeKeepThreshold is a record with t=baseTime+keepPeriod-1h, sp0=30(sp1=0.3) accumulators set relative to baseRecord - recordBeforeKeepThreshold types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(oneHourBeforeKeepThreshold, sdk.NewDec(30), accumBeforeKeepThreshold0, accumBeforeKeepThreshold1) + recordBeforeKeepThreshold types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(oneHourBeforeKeepThreshold, sdk.NewDec(30), accumBeforeKeepThreshold0, accumBeforeKeepThreshold1, geomAccumBeforeKeepThreshold) ) // N.B.: when ctxTime = end time, we trigger the "TWAP to now path". @@ -573,7 +606,16 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod_ThreeAsset() { periodBetweenBaseAndOneHourBeforeThreshold = (defaultRecordHistoryKeepPeriod.Milliseconds() - time.Hour.Milliseconds()) accumBeforeKeepThresholdA, accumBeforeKeepThresholdB, accumBeforeKeepThresholdC = sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10), sdk.NewDecWithPrec(1, 1).MulInt64(periodBetweenBaseAndOneHourBeforeThreshold), sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 20) // recordBeforeKeepThreshold is a record with t=baseTime+keepPeriod-1h, spA=30(spB=0.3)(spC=60) accumulators set relative to baseRecord - recordBeforeKeepThresholdAB, recordBeforeKeepThresholdAC, recordBeforeKeepThresholdBC = newThreeAssetPoolTwapRecordWithDefaults(oneHourBeforeKeepThreshold, sdk.NewDec(30), accumBeforeKeepThresholdA, accumBeforeKeepThresholdB, accumBeforeKeepThresholdC) + recordBeforeKeepThresholdAB, recordBeforeKeepThresholdAC, recordBeforeKeepThresholdBC = newThreeAssetPoolTwapRecordWithDefaults( + oneHourBeforeKeepThreshold, + sdk.NewDec(30), + accumBeforeKeepThresholdA, + accumBeforeKeepThresholdB, + accumBeforeKeepThresholdC, + sdk.ZeroDec(), // TODO: choose correct + sdk.ZeroDec(), // TODO: choose correct + sdk.ZeroDec(), // TODO: choose correct + ) ) tests := map[string]struct { @@ -702,6 +744,13 @@ func (s *TestSuite) TestGetArithmeticTwapToNow() { input: makeSimpleTwapToNowInput(baseTime.Add(time.Hour), baseQuoteAB), expectedError: types.StartTimeAfterEndTimeError{StartTime: baseTime.Add(time.Hour), EndTime: tPlusOne}, }, + "spot price error in record at record time (start time > record time)": { + recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, baseTime)}, + ctxTime: tPlusOneMin, + input: makeSimpleTwapInput(tPlusOne, tPlusOneMin, baseQuoteAB), + expTwap: sdk.NewDec(10), + expectedError: spotPriceError, + }, } for name, test := range tests { s.Run(name, func() { @@ -719,7 +768,7 @@ func (s *TestSuite) TestGetArithmeticTwapToNow() { if test.expectedError != nil { s.Require().Error(err) - s.Require().ErrorIs(err, test.expectedError) + s.Require().Equal(test.expectedError, err) return } s.Require().NoError(err) diff --git a/x/twap/client/cli/query.go b/x/twap/client/cli/query.go new file mode 100644 index 00000000000..213f82a9fa1 --- /dev/null +++ b/x/twap/client/cli/query.go @@ -0,0 +1,216 @@ +package twapcli + +import ( + "fmt" + "strconv" + "strings" + "time" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + // Group superfluid queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(GetQueryTwapCommand()) + cmd.AddCommand(GetQueryTwapLegacyCommand()) + + return cmd +} + +// GetQueryTwapCommand returns multiplier of an asset by denom. +func GetQueryTwapCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "twap [poolid] [base denom] [start time] [end time]", + Short: "Query twap", + Long: strings.TrimSpace( + fmt.Sprintf(`Query twap for pool. Start time must be unix time. End time can be unix time or duration. + +Example: +$ %s q twap 1 uosmo 1667088000 24h +$ %s q twap 1 uosmo 1667088000 1667174400 +`, + version.AppName, version.AppName, + ), + ), + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + // boilerplate parse fields + poolId, baseDenom, startTime, endTime, err := twapQueryParseArgs(args) + if err != nil { + return err + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := queryproto.NewQueryClient(clientCtx) + gammClient := gammtypes.NewQueryClient(clientCtx) + liquidity, err := gammClient.TotalPoolLiquidity(cmd.Context(), &gammtypes.QueryTotalPoolLiquidityRequest{PoolId: poolId}) + if err != nil { + return err + } + if len(liquidity.Liquidity) != 2 { + return fmt.Errorf("pool %d has %d assets of liquidity, CLI support only exists for 2 assets right now.", poolId, len(liquidity.Liquidity)) + } + quoteDenom := "" + if liquidity.Liquidity[0].Denom == baseDenom { + quoteDenom = liquidity.Liquidity[1].Denom + } else if liquidity.Liquidity[1].Denom == baseDenom { + quoteDenom = liquidity.Liquidity[0].Denom + } else { + return fmt.Errorf("pool %d doesn't have provided baseDenom %s, has %s and %s", + poolId, baseDenom, liquidity.Liquidity[0], liquidity.Liquidity[1]) + } + + res, err := queryClient.ArithmeticTwap(cmd.Context(), &queryproto.ArithmeticTwapRequest{ + PoolId: poolId, + BaseAsset: baseDenom, + QuoteAsset: quoteDenom, + StartTime: startTime, + EndTime: &endTime, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetQueryTwapCommand returns multiplier of an asset by denom. +func GetQueryTwapLegacyCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "twap-legacy [poolid] [base denom] [start time] [end time]", + Short: "Query twap", + Long: strings.TrimSpace( + fmt.Sprintf(`Query twap for pool. Start time must be unix time. End time can be unix time or duration. + +Example: +$ %s q twap 1 uosmo 1667088000 24h +$ %s q twap 1 uosmo 1667088000 1667174400 +`, + version.AppName, version.AppName, + ), + ), + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + poolId, baseDenom, startTime, endTime, err := twapQueryParseArgs(args) + if err != nil { + return err + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := queryproto.NewQueryClient(clientCtx) + gammClient := gammtypes.NewQueryClient(clientCtx) + liquidity, err := gammClient.TotalPoolLiquidity(cmd.Context(), &gammtypes.QueryTotalPoolLiquidityRequest{PoolId: poolId}) + if err != nil { + return err + } + if len(liquidity.Liquidity) != 2 { + return fmt.Errorf("pool %d has %d assets of liquidity, CLI support only exists for 2 assets right now.", poolId, len(liquidity.Liquidity)) + } + quoteDenom := "" + if liquidity.Liquidity[0].Denom == baseDenom { + quoteDenom = liquidity.Liquidity[1].Denom + } else if liquidity.Liquidity[1].Denom == baseDenom { + quoteDenom = liquidity.Liquidity[0].Denom + } else { + return fmt.Errorf("pool %d doesn't have provided baseDenom %s, has %s and %s", + poolId, baseDenom, liquidity.Liquidity[0], liquidity.Liquidity[1]) + } + + // nolint: staticcheck + res, err := queryClient.ArithmeticTwap(cmd.Context(), &queryproto.ArithmeticTwapRequest{ + PoolId: poolId, + BaseAsset: baseDenom, + QuoteAsset: quoteDenom, + StartTime: startTime, + EndTime: &endTime, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func twapQueryParseArgs(args []string) (poolId uint64, baseDenom string, startTime time.Time, endTime time.Time, err error) { + // boilerplate parse fields + // + poolId, err = parseUint(args[0], "poolId") + if err != nil { + return + } + + // + baseDenom = strings.TrimSpace(args[1]) + + // + startTime, err = parseUnixTime(args[2], "start time") + if err != nil { + return + } + + // END TIME PARSE: ONEOF {, } + // try parsing in unix time, if failed try parsing in duration + endTime, err = parseUnixTime(args[3], "end time") + if err != nil { + // TODO if we don't use protoreflect: + // make better error combiner, rather than just returning last error + duration, err2 := time.ParseDuration(args[3]) + if err2 != nil { + err = err2 + return + } + endTime = startTime.Add(duration) + } + return poolId, baseDenom, startTime, endTime, nil +} + +func parseUint(arg string, fieldName string) (uint64, error) { + v, err := strconv.ParseUint(arg, 10, 64) + if err != nil { + return 0, fmt.Errorf("could not parse %s as uint for field %s: %w", arg, fieldName, err) + } + return v, nil +} + +func parseUnixTime(arg string, fieldName string) (time.Time, error) { + timeUnix, err := strconv.ParseInt(arg, 10, 64) + if err != nil { + return time.Time{}, fmt.Errorf("could not parse %s as unix time for field %s: %w", arg, fieldName, err) + } + startTime := time.Unix(timeUnix, 0) + return startTime, nil +} diff --git a/x/twap/client/grpc/grpc_query.go b/x/twap/client/grpc/grpc_query.go index e8a3b02b655..a941908d503 100644 --- a/x/twap/client/grpc/grpc_query.go +++ b/x/twap/client/grpc/grpc_query.go @@ -10,8 +10,8 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/client" - "github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/twap/client" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" ) type Querier struct { diff --git a/x/twap/client/query_proto_wrap.go b/x/twap/client/query_proto_wrap.go index 5b3b822d48a..d57291f10f7 100644 --- a/x/twap/client/query_proto_wrap.go +++ b/x/twap/client/query_proto_wrap.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap" - "github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/twap" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" ) // This file should evolve to being code gen'd, off of `proto/twap/v1beta/query.yml` @@ -16,9 +16,12 @@ type Querier struct { } func (q Querier) ArithmeticTwap(ctx sdk.Context, - req queryproto.ArithmeticTwapRequest, + req queryproto.ArithmeticTwapRequest, // nolint: staticcheck ) (*queryproto.ArithmeticTwapResponse, error) { - if (req.EndTime == nil || *req.EndTime == time.Time{}) { + if req.EndTime == nil { + req.EndTime = &time.Time{} + } + if (*req.EndTime == time.Time{}) { *req.EndTime = ctx.BlockTime() } @@ -31,7 +34,7 @@ func (q Querier) ArithmeticTwap(ctx sdk.Context, } func (q Querier) ArithmeticTwapToNow(ctx sdk.Context, - req queryproto.ArithmeticTwapToNowRequest, + req queryproto.ArithmeticTwapToNowRequest, // nolint: staticcheck ) (*queryproto.ArithmeticTwapToNowResponse, error) { twap, err := q.K.GetArithmeticTwapToNow(ctx, req.PoolId, req.BaseAsset, req.QuoteAsset, req.StartTime) success := true diff --git a/x/twap/client/query_proto_wrap_test.go b/x/twap/client/query_proto_wrap_test.go new file mode 100644 index 00000000000..d66a01b28dd --- /dev/null +++ b/x/twap/client/query_proto_wrap_test.go @@ -0,0 +1,192 @@ +package client_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/client" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" +) + +type QueryTestSuite struct { + apptesting.KeeperTestHelper + + queryClient types.QueryClient +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(QueryTestSuite)) +} + +func (suite *QueryTestSuite) SetupTest() { + suite.Setup() +} + +func (suite *QueryTestSuite) TestQueryTwap() { + suite.SetupTest() + + var ( + coins = sdk.NewCoins( + sdk.NewInt64Coin("tokenA", 1000), + sdk.NewInt64Coin("tokenB", 2000), + sdk.NewInt64Coin("tokenC", 3000), + sdk.NewInt64Coin("tokenD", 4000), + sdk.NewInt64Coin("tokenE", 4000), // 4000 intentional + ) + poolID = suite.PrepareBalancerPoolWithCoins(coins...) + validStartTime = suite.Ctx.BlockTime() + newBlockTime = validStartTime.Add(time.Hour) + startTimeTooOld = validStartTime.Add(-time.Hour) + + // Set current block time one hour from initial. + ctx = suite.Ctx.WithBlockTime(newBlockTime) + ) + + testCases := []struct { + name string + poolId uint64 + baseAssetDenom string + quoteAssetDenom string + startTimeOverwrite *time.Time + endTime *time.Time + expectErr bool + result string + }{ + { + name: "non-existant pool", + poolId: 0, + baseAssetDenom: "tokenA", + quoteAssetDenom: "tokenB", + expectErr: true, + }, + { + name: "missing asset denoms", + poolId: poolID, + + expectErr: true, + }, + { + name: "missing pool ID and quote denom", + baseAssetDenom: "tokenA", + + expectErr: true, + }, + { + name: "missing pool ID and base denom", + quoteAssetDenom: "tokenB", + + expectErr: true, + }, + { + name: "tokenA in terms of tokenB", + poolId: poolID, + baseAssetDenom: "tokenA", + quoteAssetDenom: "tokenB", + endTime: &newBlockTime, + + result: sdk.NewDec(2).String(), + }, + { + name: "tokenB in terms of tokenA", + poolId: poolID, + baseAssetDenom: "tokenB", + quoteAssetDenom: "tokenA", + endTime: &newBlockTime, + + result: sdk.NewDecWithPrec(5, 1).String(), + }, + { + name: "tokenC in terms of tokenD (rounded decimal of 4/3)", + poolId: poolID, + baseAssetDenom: "tokenC", + quoteAssetDenom: "tokenD", + endTime: &newBlockTime, + + result: sdk.MustNewDecFromStr("1.333333330000000000").String(), + }, + { + name: "tokenD in terms of tokenE (1)", + poolId: poolID, + baseAssetDenom: "tokenD", + quoteAssetDenom: "tokenE", + endTime: &newBlockTime, + + result: sdk.OneDec().String(), + }, + { + name: "tokenA in terms of tokenB - no end time", + poolId: poolID, + baseAssetDenom: "tokenA", + quoteAssetDenom: "tokenB", + endTime: nil, + + result: sdk.NewDec(2).String(), + }, + { + name: "tokenA in terms of tokenB - end time is empty", + poolId: poolID, + baseAssetDenom: "tokenA", + quoteAssetDenom: "tokenB", + endTime: &time.Time{}, + + result: sdk.NewDec(2).String(), + }, + { + name: "tokenA in terms of tokenB - start time too old", + poolId: poolID, + baseAssetDenom: "tokenA", + quoteAssetDenom: "tokenB", + startTimeOverwrite: &startTimeTooOld, + + expectErr: true, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + client := client.Querier{K: *suite.App.TwapKeeper} + + startTime := validStartTime + if tc.startTimeOverwrite != nil { + startTime = *tc.startTimeOverwrite + } + + result, err := client.ArithmeticTwap(ctx, queryproto.ArithmeticTwapRequest{ + PoolId: tc.poolId, + BaseAsset: tc.baseAssetDenom, + QuoteAsset: tc.quoteAssetDenom, + StartTime: startTime, + EndTime: tc.endTime, + }) + + if tc.expectErr { + suite.Require().Error(err, "expected error - ArithmeticTwap") + } else { + suite.Require().NoError(err, "unexpected error - ArithmeticTwap") + suite.Require().Equal(tc.result, result.ArithmeticTwap.String()) + } + + resultToNow, err := client.ArithmeticTwapToNow(ctx, queryproto.ArithmeticTwapToNowRequest{ + PoolId: tc.poolId, + BaseAsset: tc.baseAssetDenom, + QuoteAsset: tc.quoteAssetDenom, + StartTime: startTime, + }) + + if tc.expectErr { + suite.Require().Error(err, "expected error - ArithmeticTwapToNow") + } else { + suite.Require().NoError(err, "unexpected error - ArithmeticTwapToNow") + suite.Require().Equal(tc.result, resultToNow.ArithmeticTwap.String()) + } + }) + } +} diff --git a/x/twap/client/queryproto/query.pb.go b/x/twap/client/queryproto/query.pb.go index 746776b25ee..e1cfd0697a4 100644 --- a/x/twap/client/queryproto/query.pb.go +++ b/x/twap/client/queryproto/query.pb.go @@ -16,7 +16,7 @@ import ( proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - types1 "github.com/osmosis-labs/osmosis/v12/x/twap/types" + types1 "github.com/osmosis-labs/osmosis/v13/x/twap/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -454,6 +454,7 @@ func (c *queryClient) ArithmeticTwap(ctx context.Context, in *ArithmeticTwapRequ return out, nil } +// Deprecated: Do not use. func (c *queryClient) ArithmeticTwapToNow(ctx context.Context, in *ArithmeticTwapToNowRequest, opts ...grpc.CallOption) (*ArithmeticTwapToNowResponse, error) { out := new(ArithmeticTwapToNowResponse) err := c.cc.Invoke(ctx, "/osmosis.twap.v1beta1.Query/ArithmeticTwapToNow", in, out, opts...) diff --git a/x/twap/export_test.go b/x/twap/export_test.go index 462808753ea..1f9654de0cc 100644 --- a/x/twap/export_test.go +++ b/x/twap/export_test.go @@ -5,11 +5,17 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) type ( TimeTooOldError = timeTooOldError + TwapType = twapType +) + +const ( + ArithmeticTwapType = arithmeticTwapType + GeometricTwapType = geometricTwapType ) func (k Keeper) StoreNewRecord(ctx sdk.Context, record types.TwapRecord) { @@ -64,10 +70,18 @@ func (k Keeper) GetInterpolatedRecord(ctx sdk.Context, poolId uint64, asset0Deno return k.getInterpolatedRecord(ctx, poolId, t, asset0Denom, asset1Denom) } -func ComputeArithmeticTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) (sdk.Dec, error) { +func ComputeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string, twapType twapType) (sdk.Dec, error) { + return computeTwap(startRecord, endRecord, quoteAsset, twapType) +} + +func ComputeArithmeticTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { return computeArithmeticTwap(startRecord, endRecord, quoteAsset) } +func ComputeGeometricTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { + return computeGeometricTwap(startRecord, endRecord, quoteAsset) +} + func RecordWithUpdatedAccumulators(record types.TwapRecord, t time.Time) types.TwapRecord { return recordWithUpdatedAccumulators(record, t) } @@ -76,6 +90,14 @@ func NewTwapRecord(k types.AmmInterface, ctx sdk.Context, poolId uint64, denom0, return newTwapRecord(k, ctx, poolId, denom0, denom1) } +func TwapLog(x sdk.Dec) sdk.Dec { + return twapLog(x) +} + +func TwapPow(x sdk.Dec) sdk.Dec { + return twapPow(x) +} + func GetSpotPrices( ctx sdk.Context, k types.AmmInterface, diff --git a/x/twap/grpc_query_test.go b/x/twap/grpc_query_test.go index 407dfe6e19e..4a37034a4b3 100644 --- a/x/twap/grpc_query_test.go +++ b/x/twap/grpc_query_test.go @@ -4,8 +4,8 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) func (s *TestSuite) TestGetArithmeticTwap_Query() { diff --git a/x/twap/keeper.go b/x/twap/keeper.go index 4bf89ce07b6..c7924f0d17e 100644 --- a/x/twap/keeper.go +++ b/x/twap/keeper.go @@ -8,7 +8,7 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) type Keeper struct { diff --git a/x/twap/keeper_test.go b/x/twap/keeper_test.go index 3305a041e5c..98ecf3c50d8 100644 --- a/x/twap/keeper_test.go +++ b/x/twap/keeper_test.go @@ -8,12 +8,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/twap" - "github.com/osmosis-labs/osmosis/v12/x/twap/client" - "github.com/osmosis-labs/osmosis/v12/x/twap/client/grpc" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/x/twap" + "github.com/osmosis-labs/osmosis/v13/x/twap/client" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/grpc" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) // TODO: Consider switching this everywhere @@ -60,6 +60,7 @@ var ( P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), } basicCustomGenesis = types.NewGenesisState( @@ -81,6 +82,7 @@ var ( P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), }, { PoolId: basePoolId, @@ -92,6 +94,7 @@ var ( P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), }, mostRecentRecordPoolOne, }) @@ -106,6 +109,7 @@ var ( P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), } decreasingOrderByTimeRecordsPoolTwo = types.NewGenesisState( @@ -122,6 +126,7 @@ var ( P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), }, { PoolId: basePoolId, @@ -133,6 +138,7 @@ var ( P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), }, }) @@ -218,6 +224,7 @@ func (suite *TestSuite) TestTwapInitGenesis() { P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), }, }), @@ -403,7 +410,7 @@ func (s *TestSuite) createTestRecordsFromTimeInPool(t time.Time, poolId uint64) // newTwoAssetPoolTwapRecordWithDefaults creates a single twap records, mimicking what one would expect from a two asset pool. // given a spot price 0 (sp0), this spot price is assigned to denomA and sp0 is then created and assigned to denomB by // calculating (1 / spA). -func newTwoAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accum0, accum1 sdk.Dec) types.TwapRecord { +func newTwoAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accum0, accum1, geomAccum sdk.Dec) types.TwapRecord { return types.TwapRecord{ PoolId: 1, Time: t, @@ -414,13 +421,14 @@ func newTwoAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accum0, accum1 sdk. P1LastSpotPrice: sdk.OneDec().Quo(sp0), P0ArithmeticTwapAccumulator: accum0, P1ArithmeticTwapAccumulator: accum1, + GeometricTwapAccumulator: geomAccum, } } // newThreeAssetPoolTwapRecordWithDefaults creates three twap records, mimicking what one would expect from a three asset pool. // given a spot price 0 (sp0), this spot price is assigned to denomA and referred to as spA. spB is then created and assigned by // calculating (1 / spA). Finally spC is created and assigned by calculating (2 * spA). -func newThreeAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accumA, accumB, accumC sdk.Dec) (types.TwapRecord, types.TwapRecord, types.TwapRecord) { +func newThreeAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC sdk.Dec) (types.TwapRecord, types.TwapRecord, types.TwapRecord) { spA := sp0 spB := sdk.OneDec().Quo(sp0) spC := sp0.Mul(sdk.NewDec(2)) @@ -434,15 +442,18 @@ func newThreeAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accumA, accumB, a P1LastSpotPrice: spB, P0ArithmeticTwapAccumulator: accumA, P1ArithmeticTwapAccumulator: accumB, + GeometricTwapAccumulator: geomAccumAB, } twapAC := twapAB twapAC.Asset1Denom = denom2 twapAC.P1LastSpotPrice = spC twapAC.P1ArithmeticTwapAccumulator = accumC + twapAC.GeometricTwapAccumulator = geomAccumAC twapBC := twapAC twapBC.Asset0Denom = denom1 twapBC.P0LastSpotPrice = spB twapBC.P0ArithmeticTwapAccumulator = accumB + twapBC.GeometricTwapAccumulator = geomAccumBC return twapAB, twapAC, twapBC } @@ -458,10 +469,21 @@ func newEmptyPriceRecord(poolId uint64, t time.Time, asset0 string, asset1 strin P1LastSpotPrice: sdk.ZeroDec(), P0ArithmeticTwapAccumulator: sdk.ZeroDec(), P1ArithmeticTwapAccumulator: sdk.ZeroDec(), + GeometricTwapAccumulator: sdk.ZeroDec(), } } -func newRecord(poolId uint64, t time.Time, sp0, accum0, accum1 sdk.Dec) types.TwapRecord { +func withPrice0Set(twapRecord types.TwapRecord, price0ToSet sdk.Dec) types.TwapRecord { + twapRecord.P0LastSpotPrice = price0ToSet + return twapRecord +} + +func withPrice1Set(twapRecord types.TwapRecord, price1ToSet sdk.Dec) types.TwapRecord { + twapRecord.P1LastSpotPrice = price1ToSet + return twapRecord +} + +func newRecord(poolId uint64, t time.Time, sp0, accum0, accum1, geomAccum sdk.Dec) types.TwapRecord { return types.TwapRecord{ PoolId: poolId, Asset0Denom: defaultTwoAssetCoins[0].Denom, @@ -472,21 +494,23 @@ func newRecord(poolId uint64, t time.Time, sp0, accum0, accum1 sdk.Dec) types.Tw // make new copies P0ArithmeticTwapAccumulator: accum0.Add(sdk.ZeroDec()), P1ArithmeticTwapAccumulator: accum1.Add(sdk.ZeroDec()), + GeometricTwapAccumulator: geomAccum.Add(sdk.ZeroDec()), } } // make an expected record for math tests, we adjust other values in the test runner. -func newExpRecord(accum0, accum1 sdk.Dec) types.TwapRecord { +func newExpRecord(accum0, accum1, geomAccum sdk.Dec) types.TwapRecord { return types.TwapRecord{ Asset0Denom: defaultTwoAssetCoins[0].Denom, Asset1Denom: defaultTwoAssetCoins[1].Denom, // make new copies P0ArithmeticTwapAccumulator: accum0.Add(sdk.ZeroDec()), P1ArithmeticTwapAccumulator: accum1.Add(sdk.ZeroDec()), + GeometricTwapAccumulator: geomAccum.Add(sdk.ZeroDec()), } } -func newThreeAssetRecord(poolId uint64, t time.Time, sp0, accumA, accumB, accumC sdk.Dec) []types.TwapRecord { +func newThreeAssetRecord(poolId uint64, t time.Time, sp0, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC sdk.Dec) []types.TwapRecord { spA := sp0 spB := sdk.OneDec().Quo(sp0) spC := sp0.Mul(sdk.NewDec(2)) @@ -500,20 +524,23 @@ func newThreeAssetRecord(poolId uint64, t time.Time, sp0, accumA, accumB, accumC // make new copies P0ArithmeticTwapAccumulator: accumA.Add(sdk.ZeroDec()), P1ArithmeticTwapAccumulator: accumB.Add(sdk.ZeroDec()), + GeometricTwapAccumulator: geomAccumAB.Add(sdk.ZeroDec()), } twapAC := twapAB twapAC.Asset1Denom = denom2 twapAC.P1LastSpotPrice = spC twapAC.P1ArithmeticTwapAccumulator = accumC + twapAC.GeometricTwapAccumulator = geomAccumAC.Add(sdk.ZeroDec()) twapBC := twapAC twapBC.Asset0Denom = denom1 twapBC.P0LastSpotPrice = spB twapBC.P0ArithmeticTwapAccumulator = accumB + twapBC.GeometricTwapAccumulator = geomAccumBC.Add(sdk.ZeroDec()) return []types.TwapRecord{twapAB, twapAC, twapBC} } // make an expected record for math tests, we adjust other values in the test runner. -func newThreeAssetExpRecord(poolId uint64, accumA, accumB, accumC sdk.Dec) []types.TwapRecord { +func newThreeAssetExpRecord(poolId uint64, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC sdk.Dec) []types.TwapRecord { twapAB := types.TwapRecord{ PoolId: poolId, Asset0Denom: defaultThreeAssetCoins[0].Denom, @@ -521,13 +548,16 @@ func newThreeAssetExpRecord(poolId uint64, accumA, accumB, accumC sdk.Dec) []typ // make new copies P0ArithmeticTwapAccumulator: accumA.Add(sdk.ZeroDec()), P1ArithmeticTwapAccumulator: accumB.Add(sdk.ZeroDec()), + GeometricTwapAccumulator: geomAccumAB.Add(sdk.ZeroDec()), } twapAC := twapAB twapAC.Asset1Denom = denom2 twapAC.P1ArithmeticTwapAccumulator = accumC + twapAC.GeometricTwapAccumulator = geomAccumAC.Add(sdk.ZeroDec()) twapBC := twapAC twapBC.Asset0Denom = denom1 twapBC.P0ArithmeticTwapAccumulator = accumB + twapBC.GeometricTwapAccumulator = geomAccumBC.Add(sdk.ZeroDec()) return []types.TwapRecord{twapAB, twapAC, twapBC} } @@ -543,6 +573,13 @@ func newOneSidedRecord(time time.Time, accum sdk.Dec, useP0 bool) types.TwapReco return record } +func newOneSidedGeometricRecord(time time.Time, accum sdk.Dec) types.TwapRecord { + record := types.TwapRecord{Time: time, Asset0Denom: denom0, Asset1Denom: denom1} + record.GeometricTwapAccumulator = accum + record.P0LastSpotPrice = sdk.NewDec(10) + return record +} + func newThreeAssetOneSidedRecord(time time.Time, accum sdk.Dec, useP0 bool) []types.TwapRecord { record := types.TwapRecord{Time: time, Asset0Denom: denom0, Asset1Denom: denom1} if useP0 { @@ -559,9 +596,10 @@ func newThreeAssetOneSidedRecord(time time.Time, accum sdk.Dec, useP0 bool) []ty return records } -func recordWithUpdatedAccum(record types.TwapRecord, accum0 sdk.Dec, accum1 sdk.Dec) types.TwapRecord { +func recordWithUpdatedAccum(record types.TwapRecord, accum0 sdk.Dec, accum1, geomAccum sdk.Dec) types.TwapRecord { record.P0ArithmeticTwapAccumulator = accum0 record.P1ArithmeticTwapAccumulator = accum1 + record.GeometricTwapAccumulator = geomAccum return record } diff --git a/x/twap/listeners.go b/x/twap/listeners.go index 0c8a057a749..9e4fc46eb32 100644 --- a/x/twap/listeners.go +++ b/x/twap/listeners.go @@ -3,8 +3,8 @@ package twap import ( sdk "github.com/cosmos/cosmos-sdk/types" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) var ( diff --git a/x/twap/listeners_test.go b/x/twap/listeners_test.go index f267d15b053..968f2032a02 100644 --- a/x/twap/listeners_test.go +++ b/x/twap/listeners_test.go @@ -5,9 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/twap" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/twap" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) // TestAfterPoolCreatedHook tests if internal tracking logic has been triggered correctly, @@ -47,10 +47,10 @@ func (s *TestSuite) TestAfterPoolCreatedHook() { } denoms := osmoutils.CoinsDenoms(tc.poolCoins) - denomPairs0, denomPairs1 := types.GetAllUniqueDenomPairs(denoms) + denomPairs := types.GetAllUniqueDenomPairs(denoms) expectedRecords := []types.TwapRecord{} - for i := 0; i < len(denomPairs0); i++ { - expectedRecord, err := twap.NewTwapRecord(s.App.GAMMKeeper, s.Ctx, poolId, denomPairs0[i], denomPairs1[i]) + for _, denomPair := range denomPairs { + expectedRecord, err := twap.NewTwapRecord(s.App.GAMMKeeper, s.Ctx, poolId, denomPair.Denom0, denomPair.Denom1) s.Require().NoError(err) expectedRecords = append(expectedRecords, expectedRecord) } @@ -61,11 +61,11 @@ func (s *TestSuite) TestAfterPoolCreatedHook() { s.Commit() // check on the correctness of all individual twap records - for i := 0; i < len(denomPairs0); i++ { - actualRecord, err := s.twapkeeper.GetMostRecentRecordStoreRepresentation(s.Ctx, poolId, denomPairs0[i], denomPairs1[i]) + for i, denomPair := range denomPairs { + actualRecord, err := s.twapkeeper.GetMostRecentRecordStoreRepresentation(s.Ctx, poolId, denomPair.Denom0, denomPair.Denom1) s.Require().NoError(err) s.Require().Equal(expectedRecords[i], actualRecord) - actualRecord, err = s.twapkeeper.GetRecordAtOrBeforeTime(s.Ctx, poolId, s.Ctx.BlockTime(), denomPairs0[i], denomPairs1[i]) + actualRecord, err = s.twapkeeper.GetRecordAtOrBeforeTime(s.Ctx, poolId, s.Ctx.BlockTime(), denomPair.Denom0, denomPair.Denom1) s.Require().NoError(err) s.Require().Equal(expectedRecords[i], actualRecord) } @@ -73,7 +73,7 @@ func (s *TestSuite) TestAfterPoolCreatedHook() { // consistency check that the number of records is exactly equal to the number of denompairs allRecords, err := s.twapkeeper.GetAllMostRecentRecordsForPool(s.Ctx, poolId) s.Require().NoError(err) - s.Require().Equal(len(denomPairs0), len(allRecords)) + s.Require().Equal(len(denomPairs), len(allRecords)) }) } } diff --git a/x/twap/logic.go b/x/twap/logic.go index f90328fe3d5..35a707936cb 100644 --- a/x/twap/logic.go +++ b/x/twap/logic.go @@ -7,7 +7,17 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" +) + +// geometricTwapMathBase is the base used for geometric twap calculation +// in logarithm and power math functions. +// See twapLog and computeGeometricTwap functions for more details. +var ( + geometricTwapMathBase = sdk.NewDec(2) + // TODO: analyze choice. + geometricTwapPowPrecision = sdk.MustNewDecFromStr("0.00000001") ) func newTwapRecord(k types.AmmInterface, ctx sdk.Context, poolId uint64, denom0, denom1 string) (types.TwapRecord, error) { @@ -27,6 +37,7 @@ func newTwapRecord(k types.AmmInterface, ctx sdk.Context, poolId uint64, denom0, P1LastSpotPrice: sp1, P0ArithmeticTwapAccumulator: sdk.ZeroDec(), P1ArithmeticTwapAccumulator: sdk.ZeroDec(), + GeometricTwapAccumulator: sdk.ZeroDec(), LastErrorTime: lastErrorTime, }, nil } @@ -70,9 +81,9 @@ func getSpotPrices( // afterCreatePool creates new twap records of all the unique pairs of denoms within a pool. func (k Keeper) afterCreatePool(ctx sdk.Context, poolId uint64) error { denoms, err := k.ammkeeper.GetPoolDenoms(ctx, poolId) - denomPairs0, denomPairs1 := types.GetAllUniqueDenomPairs(denoms) - for i := 0; i < len(denomPairs0); i++ { - record, err := newTwapRecord(k.ammkeeper, ctx, poolId, denomPairs0[i], denomPairs1[i]) + denomPairs := types.GetAllUniqueDenomPairs(denoms) + for _, denomPair := range denomPairs { + record, err := newTwapRecord(k.ammkeeper, ctx, poolId, denomPair.Denom0, denomPair.Denom1) // err should be impossible given GetAllUniqueDenomPairs guarantees if err != nil { return err @@ -190,30 +201,33 @@ func recordWithUpdatedAccumulators(record types.TwapRecord, newTime time.Time) t p1NewAccum := types.SpotPriceMulDuration(record.P1LastSpotPrice, timeDelta) newRecord.P1ArithmeticTwapAccumulator = newRecord.P1ArithmeticTwapAccumulator.Add(p1NewAccum) + // logP0SpotPrice = log_{2}{P_0} + logP0SpotPrice := twapLog(record.P0LastSpotPrice) + // p0NewGeomAccum = log_{2}{P_0} * timeDelta + p0NewGeomAccum := types.SpotPriceMulDuration(logP0SpotPrice, timeDelta) + newRecord.GeometricTwapAccumulator = newRecord.GeometricTwapAccumulator.Add(p0NewGeomAccum) + return newRecord } // getInterpolatedRecord returns a record for this pool, representing its accumulator state at time `t`. // This is achieved by getting the record `r` that is at, or immediately preceding in state time `t`. // To be clear: the record r s.t. `t - r.Time` is minimized AND `t >= r.Time` +// If for the record obtained, r.Time == r.LastErrorTime, this will also hold for the interpolated record. func (k Keeper) getInterpolatedRecord(ctx sdk.Context, poolId uint64, t time.Time, assetA, assetB string) (types.TwapRecord, error) { - assetA, assetB, err := types.LexicographicalOrderDenoms(assetA, assetB) - if err != nil { - return types.TwapRecord{}, err - } record, err := k.getRecordAtOrBeforeTime(ctx, poolId, t, assetA, assetB) if err != nil { return types.TwapRecord{}, err } + // if it had errored on the last record, make this record inherit the error + if record.Time.Equal(record.LastErrorTime) { + record.LastErrorTime = t + } record = recordWithUpdatedAccumulators(record, t) return record, nil } func (k Keeper) getMostRecentRecord(ctx sdk.Context, poolId uint64, assetA, assetB string) (types.TwapRecord, error) { - assetA, assetB, err := types.LexicographicalOrderDenoms(assetA, assetB) - if err != nil { - return types.TwapRecord{}, err - } record, err := k.getMostRecentRecordStoreRepresentation(ctx, poolId, assetA, assetB) if err != nil { return types.TwapRecord{}, err @@ -222,17 +236,21 @@ func (k Keeper) getMostRecentRecord(ctx sdk.Context, poolId uint64, assetA, asse return record, nil } -// computeArithmeticTwap computes and returns an arithmetic TWAP between -// two records given the quote asset. +// computeTwap computes and returns a TWAP of a given +// type - arithmetic or geometric. +// Between two records given the quote asset. // precondition: endRecord.Time >= startRecord.Time -// if endRecord.LastErrorTime is after startRecord.Time, return an error at end + result +// if (endRecord.LastErrorTime >= startRecord.Time) returns an error at end + result +// if (startRecord.LastErrorTime == startRecord.Time) returns an error at end + result // if (endRecord.Time == startRecord.Time) returns endRecord.LastSpotPrice // else returns // (endRecord.Accumulator - startRecord.Accumulator) / (endRecord.Time - startRecord.Time) -func computeArithmeticTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) (sdk.Dec, error) { +func computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string, isArithmeticTwap twapType) (sdk.Dec, error) { // see if we need to return an error, due to spot price issues var err error = nil - if endRecord.LastErrorTime.After(startRecord.Time) || endRecord.LastErrorTime.Equal(startRecord.Time) { + if endRecord.LastErrorTime.After(startRecord.Time) || + endRecord.LastErrorTime.Equal(startRecord.Time) || + startRecord.LastErrorTime.Equal(startRecord.Time) { err = errors.New("twap: error in pool spot price occurred between start and end time, twap result may be faulty") } timeDelta := endRecord.Time.Sub(startRecord.Time) @@ -243,11 +261,55 @@ func computeArithmeticTwap(startRecord types.TwapRecord, endRecord types.TwapRec } return endRecord.P1LastSpotPrice, err } + + if isArithmeticTwap { + return computeArithmeticTwap(startRecord, endRecord, quoteAsset), err + } + return computeGeometricTwap(startRecord, endRecord, quoteAsset), err +} + +// computeArithmeticTwap computes and returns an arithmetic TWAP between +// two records given the quote asset. +func computeArithmeticTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { var accumDiff sdk.Dec if quoteAsset == startRecord.Asset0Denom { accumDiff = endRecord.P0ArithmeticTwapAccumulator.Sub(startRecord.P0ArithmeticTwapAccumulator) } else { accumDiff = endRecord.P1ArithmeticTwapAccumulator.Sub(startRecord.P1ArithmeticTwapAccumulator) } - return types.AccumDiffDivDuration(accumDiff, timeDelta), err + timeDelta := endRecord.Time.Sub(startRecord.Time) + return types.AccumDiffDivDuration(accumDiff, timeDelta) +} + +// computeGeometricTwap computes and returns a geometric TWAP between +// two records given the quote asset. +// The computation works as follows: +// - compute arithmetic mean of logarithms of spot prices. +// - exponentiate the result to get the geometric mean. +// - if quoted asset is asset 1, take reciprocal of the exponentiated result. +func computeGeometricTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { + accumDiff := endRecord.GeometricTwapAccumulator.Sub(startRecord.GeometricTwapAccumulator) + + timeDelta := endRecord.Time.Sub(startRecord.Time) + arithmeticMeanOfLogPrices := types.AccumDiffDivDuration(accumDiff, timeDelta) + + geometricMeanDenom0 := twapPow(arithmeticMeanOfLogPrices) + // N.B.: Geometric mean of recprocals is reciprocal of geometric mean. + // https://proofwiki.org/wiki/Geometric_Mean_of_Reciprocals_is_Reciprocal_of_Geometric_Mean + if quoteAsset == startRecord.Asset1Denom { + return sdk.OneDec().Quo(geometricMeanDenom0) + } + return geometricMeanDenom0 +} + +// twapLog returns the logarithm of the given spot price, base 2. +// TODO: basic test +func twapLog(price sdk.Dec) sdk.Dec { + return osmomath.BigDecFromSDKDec(price).LogBase2().SDKDec() +} + +// twapPow exponentiates the geometricTwapMathBase to the given exponent. +// TODO: basic test and benchmark. +func twapPow(exponent sdk.Dec) sdk.Dec { + return osmomath.PowApprox(geometricTwapMathBase, exponent, geometricTwapPowPrecision) } diff --git a/x/twap/logic_test.go b/x/twap/logic_test.go index 8d629c99589..029ef12b7a2 100644 --- a/x/twap/logic_test.go +++ b/x/twap/logic_test.go @@ -9,19 +9,25 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/twap" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/types/twapmock" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/osmomath" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/twap" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/types/twapmock" ) var ( - zeroDec = sdk.ZeroDec() - oneDec = sdk.OneDec() - twoDec = oneDec.Add(oneDec) - OneSec = sdk.MustNewDecFromStr("1000.000000000000000000") + zeroDec = sdk.ZeroDec() + oneDec = sdk.OneDec() + twoDec = oneDec.Add(oneDec) + pointFiveDec = sdk.OneDec().Quo(twoDec) + OneSec = sdk.MustNewDecFromStr("1000.000000000000000000") + logTen = twap.TwapLog(sdk.NewDec(10)) + logOneOverTen = twap.TwapLog(sdk.OneDec().QuoInt64(10)) + tenSecAccum = OneSec.MulInt64(10) + geometricTenSecAccum = OneSec.Mul(logTen) ) func (s *TestSuite) TestGetSpotPrices() { @@ -143,6 +149,7 @@ func (s *TestSuite) TestNewTwapRecord() { s.Require().Equal(s.Ctx.BlockTime(), twapRecord.Time) s.Require().Equal(sdk.ZeroDec(), twapRecord.P0ArithmeticTwapAccumulator) s.Require().Equal(sdk.ZeroDec(), twapRecord.P1ArithmeticTwapAccumulator) + s.Require().Equal(sdk.ZeroDec(), twapRecord.GeometricTwapAccumulator) } }) } @@ -160,8 +167,8 @@ func (s *TestSuite) TestUpdateRecord() { updateTime := time.Unix(3, 0).UTC() baseTimeMinusOne := time.Unix(1, 0).UTC() - zeroAccumNoErrSp10Record := newRecord(poolId, baseTime, sdk.NewDec(10), zeroDec, zeroDec) - sp10OneTimeUnitAccumRecord := newExpRecord(OneSec.MulInt64(10), OneSec.QuoInt64(10)) + zeroAccumNoErrSp10Record := newRecord(poolId, baseTime, sdk.NewDec(10), zeroDec, zeroDec, zeroDec) + sp10OneTimeUnitAccumRecord := newExpRecord(OneSec.MulInt64(10), OneSec.QuoInt64(10), geometricTenSecAccum) // all tests occur with updateTime = base time + time.Unix(1, 0) tests := map[string]struct { record types.TwapRecord @@ -236,31 +243,42 @@ func (s *TestSuite) TestUpdateRecord() { func TestRecordWithUpdatedAccumulators(t *testing.T) { poolId := uint64(1) - defaultRecord := newRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), oneDec, twoDec) + defaultRecord := newRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), oneDec, twoDec, pointFiveDec) tests := map[string]struct { - record types.TwapRecord - newTime time.Time - expRecord types.TwapRecord + record types.TwapRecord + newTime time.Time + expRecord types.TwapRecord + expectPanic bool }{ "accum with zero value": { - record: newRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), zeroDec, zeroDec), + record: newRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), zeroDec, zeroDec, zeroDec), newTime: time.Unix(2, 0), - expRecord: newExpRecord(OneSec.MulInt64(10), OneSec.QuoInt64(10)), + expRecord: newExpRecord(OneSec.MulInt64(10), OneSec.QuoInt64(10), geometricTenSecAccum), }, "small starting accumulators": { record: defaultRecord, newTime: time.Unix(2, 0), - expRecord: newExpRecord(oneDec.Add(OneSec.MulInt64(10)), twoDec.Add(OneSec.QuoInt64(10))), + expRecord: newExpRecord(oneDec.Add(OneSec.MulInt64(10)), twoDec.Add(OneSec.QuoInt64(10)), pointFiveDec.Add(geometricTenSecAccum)), }, "larger time interval": { - record: newRecord(poolId, time.Unix(11, 0), sdk.NewDec(10), oneDec, twoDec), + record: newRecord(poolId, time.Unix(11, 0), sdk.NewDec(10), oneDec, twoDec, pointFiveDec), newTime: time.Unix(55, 0), - expRecord: newExpRecord(oneDec.Add(OneSec.MulInt64(44*10)), twoDec.Add(OneSec.MulInt64(44).QuoInt64(10))), + expRecord: newExpRecord(oneDec.Add(OneSec.MulInt64(44*10)), twoDec.Add(OneSec.MulInt64(44).QuoInt64(10)), pointFiveDec.Add(OneSec.MulInt64(44).Mul(logTen))), }, "same time, accumulator should not change": { record: defaultRecord, newTime: time.Unix(1, 0), - expRecord: newExpRecord(oneDec, twoDec), + expRecord: newExpRecord(oneDec, twoDec, pointFiveDec), + }, + "zero spot price - panic": { + record: withPrice0Set(defaultRecord, sdk.ZeroDec()), + newTime: defaultRecord.Time.Add(time.Second), + expectPanic: true, + }, + "spot price of one - geom accumulator 0": { + record: withPrice1Set(withPrice0Set(defaultRecord, sdk.OneDec()), sdk.OneDec()), + newTime: defaultRecord.Time.Add(time.Second), + expRecord: newExpRecord(oneDec.Add(OneSec), twoDec.Add(OneSec), pointFiveDec), }, } @@ -272,8 +290,10 @@ func TestRecordWithUpdatedAccumulators(t *testing.T) { test.expRecord.P0LastSpotPrice = test.record.P0LastSpotPrice test.expRecord.P1LastSpotPrice = test.record.P1LastSpotPrice - gotRecord := twap.RecordWithUpdatedAccumulators(test.record, test.newTime) - require.Equal(t, test.expRecord, gotRecord) + osmoassert.ConditionalPanic(t, test.expectPanic, func() { + gotRecord := twap.RecordWithUpdatedAccumulators(test.record, test.newTime) + require.Equal(t, test.expRecord, gotRecord) + }) }) } } @@ -286,19 +306,19 @@ func TestRecordWithUpdatedAccumulators_ThreeAsset(t *testing.T) { expRecord []types.TwapRecord }{ "accum with zero value": { - record: newThreeAssetRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), zeroDec, zeroDec, zeroDec), + record: newThreeAssetRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), zeroDec, zeroDec, zeroDec, zeroDec, zeroDec, zeroDec), interpolateTime: time.Unix(2, 0), - expRecord: newThreeAssetExpRecord(poolId, OneSec.MulInt64(10), OneSec.QuoInt64(10), OneSec.MulInt64(20)), + expRecord: newThreeAssetExpRecord(poolId, OneSec.MulInt64(10), OneSec.QuoInt64(10), OneSec.MulInt64(20), geometricTenSecAccum, geometricTenSecAccum, OneSec.Mul(logOneOverTen)), }, "small starting accumulators": { - record: newThreeAssetRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), twoDec, oneDec, twoDec), + record: newThreeAssetRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), twoDec, oneDec, twoDec, oneDec, twoDec, oneDec), interpolateTime: time.Unix(2, 0), - expRecord: newThreeAssetExpRecord(poolId, twoDec.Add(OneSec.MulInt64(10)), oneDec.Add(OneSec.QuoInt64(10)), twoDec.Add(OneSec.MulInt64(20))), + expRecord: newThreeAssetExpRecord(poolId, twoDec.Add(OneSec.MulInt64(10)), oneDec.Add(OneSec.QuoInt64(10)), twoDec.Add(OneSec.MulInt64(20)), oneDec.Add(geometricTenSecAccum), twoDec.Add(geometricTenSecAccum), oneDec.Add(OneSec.Mul(logOneOverTen))), }, "larger time interval": { - record: newThreeAssetRecord(poolId, time.Unix(11, 0), sdk.NewDec(10), twoDec, oneDec, twoDec), + record: newThreeAssetRecord(poolId, time.Unix(11, 0), sdk.NewDec(10), twoDec, oneDec, twoDec, oneDec, twoDec, oneDec), interpolateTime: time.Unix(55, 0), - expRecord: newThreeAssetExpRecord(poolId, twoDec.Add(OneSec.MulInt64(44*10)), oneDec.Add(OneSec.MulInt64(44).QuoInt64(10)), twoDec.Add(OneSec.MulInt64(44*20))), + expRecord: newThreeAssetExpRecord(poolId, twoDec.Add(OneSec.MulInt64(44*10)), oneDec.Add(OneSec.MulInt64(44).QuoInt64(10)), twoDec.Add(OneSec.MulInt64(44*20)), oneDec.Add(OneSec.MulInt64(44).Mul(logTen)), twoDec.Add(OneSec.MulInt64(44).Mul(logTen)), oneDec.Add(OneSec.MulInt64(44).Mul(logOneOverTen))), }, } @@ -318,7 +338,7 @@ func TestRecordWithUpdatedAccumulators_ThreeAsset(t *testing.T) { } func (s *TestSuite) TestGetInterpolatedRecord() { - baseRecord := newTwoAssetPoolTwapRecordWithDefaults(baseTime, sdk.OneDec(), sdk.OneDec(), sdk.OneDec()) + baseRecord := newTwoAssetPoolTwapRecordWithDefaults(baseTime, sdk.OneDec(), sdk.OneDec(), sdk.OneDec(), sdk.OneDec().Quo(twoDec)) // all tests occur with updateTime = base time + time.Unix(1, 0) tests := map[string]struct { @@ -329,6 +349,7 @@ func (s *TestSuite) TestGetInterpolatedRecord() { testTime time.Time expectedAccumulator sdk.Dec expectedErr error + expectedLastErrTime time.Time }{ "same time with existing record": { recordsToPreSet: baseRecord, @@ -346,6 +367,16 @@ func (s *TestSuite) TestGetInterpolatedRecord() { // 1(spot price) * 1000(one sec in milli-seconds) expectedAccumulator: baseRecord.P0ArithmeticTwapAccumulator.Add(sdk.NewDec(1000)), }, + "call 1 second after existing record with error": { + recordsToPreSet: withLastErrTime(baseRecord, baseTime), + testPoolId: baseRecord.PoolId, + testDenom0: baseRecord.Asset0Denom, + testDenom1: baseRecord.Asset1Denom, + testTime: baseTime.Add(time.Second), + // 1(spot price) * 1000(one sec in milli-seconds) + expectedAccumulator: baseRecord.P0ArithmeticTwapAccumulator.Add(sdk.NewDec(1000)), + expectedLastErrTime: baseTime.Add(time.Second), + }, "call 1 second before existing record": { recordsToPreSet: baseRecord, testPoolId: baseRecord.PoolId, @@ -392,13 +423,20 @@ func (s *TestSuite) TestGetInterpolatedRecord() { s.Require().Equal(test.recordsToPreSet.P1LastSpotPrice, interpolatedRecord.P1LastSpotPrice) s.Require().Equal(test.expectedAccumulator, interpolatedRecord.P0ArithmeticTwapAccumulator) s.Require().Equal(test.expectedAccumulator, interpolatedRecord.P1ArithmeticTwapAccumulator) + if test.recordsToPreSet.Time.Equal(test.recordsToPreSet.LastErrorTime) { + // last error time updated + s.Require().Equal(test.testTime, interpolatedRecord.LastErrorTime) + } else { + // last error time unchanged + s.Require().Equal(test.recordsToPreSet.LastErrorTime, interpolatedRecord.LastErrorTime) + } } }) } } func (s *TestSuite) TestGetInterpolatedRecord_ThreeAsset() { - baseRecord := newThreeAssetRecord(2, baseTime, sdk.NewDec(10), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + baseRecord := newThreeAssetRecord(2, baseTime, sdk.NewDec(10), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) // all tests occur with updateTime = base time + time.Unix(1, 0) tests := map[string]struct { recordsToPreSet []types.TwapRecord @@ -428,6 +466,31 @@ func (s *TestSuite) TestGetInterpolatedRecord_ThreeAsset() { baseRecord[2].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(20000)), }, }, + "call 1 second after existing record with error": { + recordsToPreSet: []types.TwapRecord{ + withLastErrTime(baseRecord[0], baseTime), + withLastErrTime(baseRecord[1], baseTime), + withLastErrTime(baseRecord[2], baseTime), + }, + testTime: baseTime.Add(time.Second), + // P0 and P1 TwapAccumulators both start at 0 + // A 10 spot price * 1000ms = 10000 + // A 10 spot price * 1000ms = 10000 + // B .1 spot price * 1000ms = 100 + expectedP0Accumulator: []sdk.Dec{ + baseRecord[0].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(10000)), + baseRecord[1].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(10000)), + baseRecord[2].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(100)), + }, + // B .1 spot price * 1000ms = 100 + // C 20 spot price * 1000ms = 20000 + // C 20 spot price * 1000ms = 20000 + expectedP1Accumulator: []sdk.Dec{ + baseRecord[0].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(100)), + baseRecord[1].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(20000)), + baseRecord[2].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(20000)), + }, + }, "call 1 second before existing record": { recordsToPreSet: baseRecord, testTime: baseTime.Add(-time.Second), @@ -462,18 +525,27 @@ func (s *TestSuite) TestGetInterpolatedRecord_ThreeAsset() { s.Require().Equal(test.recordsToPreSet[i].P1LastSpotPrice, interpolatedRecord.P1LastSpotPrice) s.Require().Equal(test.expectedP0Accumulator[i], interpolatedRecord.P0ArithmeticTwapAccumulator) s.Require().Equal(test.expectedP1Accumulator[i], interpolatedRecord.P1ArithmeticTwapAccumulator) + if test.recordsToPreSet[i].Time.Equal(test.recordsToPreSet[i].LastErrorTime) { + // last error time updated + s.Require().Equal(test.testTime, interpolatedRecord.LastErrorTime) + } else { + // last error time unchanged + s.Require().Equal(test.recordsToPreSet[i].LastErrorTime, interpolatedRecord.LastErrorTime) + } } } }) } } -type computeArithmeticTwapTestCase struct { +type computeTwapTestCase struct { startRecord types.TwapRecord endRecord types.TwapRecord + twapTypes []twap.TwapType quoteAsset string expTwap sdk.Dec expErr bool + expPanic bool } type computeThreeAssetArithmeticTwapTestCase struct { @@ -484,58 +556,93 @@ type computeThreeAssetArithmeticTwapTestCase struct { expErr bool } -// TestComputeArithmeticTwap tests ComputeArithmeticTwap on various inputs. +// TestComputeArithmeticTwap tests computeTwap on various inputs. +// TODO: test both arithmetic and geometric twap. // The test vectors are structured by setting up different start and records, // based on time interval, and their accumulator values. // Then an expected TWAP is provided in each test case, to compare against computed. -func TestComputeArithmeticTwap(t *testing.T) { - testCaseFromDeltas := func(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeArithmeticTwapTestCase { - return computeArithmeticTwapTestCase{ - newOneSidedRecord(baseTime, startAccum, true), - newOneSidedRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff), true), - denom0, - expectedTwap, - false, - } - } - testCaseFromDeltasAsset1 := func(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeArithmeticTwapTestCase { - return computeArithmeticTwapTestCase{ - newOneSidedRecord(baseTime, startAccum, false), - newOneSidedRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff), false), - denom1, - expectedTwap, - false, - } - } - tenSecAccum := OneSec.MulInt64(10) - pointOneAccum := OneSec.QuoInt64(10) - tests := map[string]computeArithmeticTwapTestCase{ - "basic: spot price = 1 for one second, 0 init accumulator": { +func TestComputeTwap(t *testing.T) { + tests := map[string]computeTwapTestCase{ + "arithmetic only, basic: spot price = 1 for one second, 0 init accumulator": { startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), endRecord: newOneSidedRecord(tPlusOne, OneSec, true), quoteAsset: denom0, + twapTypes: []twap.TwapType{twap.ArithmeticTwapType}, expTwap: sdk.OneDec(), }, // this test just shows what happens in case the records are reversed. // It should return the correct result, even though this is incorrect internal API usage - "invalid call: reversed records of above": { + "arithmetic only: invalid call: reversed records of above": { startRecord: newOneSidedRecord(tPlusOne, OneSec, true), endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), quoteAsset: denom0, + twapTypes: []twap.TwapType{twap.ArithmeticTwapType}, expTwap: sdk.OneDec(), }, "same record: denom0, end spot price = 0": { startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), quoteAsset: denom0, + twapTypes: []twap.TwapType{twap.ArithmeticTwapType, twap.GeometricTwapType}, expTwap: sdk.ZeroDec(), }, "same record: denom1, end spot price = 1": { startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), quoteAsset: denom1, + twapTypes: []twap.TwapType{twap.ArithmeticTwapType, twap.GeometricTwapType}, + expTwap: sdk.OneDec(), + }, + "arithmetic only: accumulator = 10*OneSec, t=5s. 0 base accum": testCaseFromDeltas( + sdk.ZeroDec(), tenSecAccum, 5*time.Second, sdk.NewDec(2)), + "arithmetic only: accumulator = 10*OneSec, t=100s. 0 base accum (asset 1)": testCaseFromDeltasAsset1(sdk.ZeroDec(), OneSec.MulInt64(10), 100*time.Second, sdk.NewDecWithPrec(1, 1)), + "geometric only: accumulator = log(10)*OneSec, t=5s. 0 base accum": geometricTestCaseFromDeltas0( + sdk.ZeroDec(), geometricTenSecAccum, 5*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(5*1000))), + "geometric only: accumulator = log(10)*OneSec, t=100s. 0 base accum (asset 1)": geometricTestCaseFromDeltas1(sdk.ZeroDec(), geometricTenSecAccum, 100*time.Second, sdk.OneDec().Quo(twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000)))), + } + for name, test := range tests { + for _, twapType := range test.twapTypes { + twapType := twapType + twapTypeStr := "arithmetic" + if twapType == twap.GeometricTwapType { + twapTypeStr = "geometric" + } + + t.Run(fmt.Sprintf("%s - %s", twapTypeStr, name), func(t *testing.T) { + actualTwap, err := twap.ComputeTwap(test.startRecord, test.endRecord, test.quoteAsset, twapType) + require.NoError(t, err) + osmoassert.DecApproxEq(t, test.expTwap, actualTwap, osmomath.GetPowPrecision()) + }) + } + } +} + +// TestComputeArithmeticTwap tests computeArithmeticTwap on various inputs. +// Contrary to computeTwap that handles the cases with zero delta correctly, +// this function should panic in case of zero delta. +func TestComputeArithmeticTwap(t *testing.T) { + pointOneAccum := OneSec.QuoInt64(10) + tests := map[string]computeTwapTestCase{ + "basic: spot price = 1 for one second, 0 init accumulator": { + startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + endRecord: newOneSidedRecord(tPlusOne, OneSec, true), + quoteAsset: denom0, + expTwap: sdk.OneDec(), + }, + // this test just shows what happens in case the records are reversed. + // It should return the correct result, even though this is incorrect internal API usage + "invalid call: reversed records of above": { + startRecord: newOneSidedRecord(tPlusOne, OneSec, true), + endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + quoteAsset: denom0, expTwap: sdk.OneDec(), }, + "same record (zero time delta), division by 0 - panic": { + startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + quoteAsset: denom0, + expPanic: true, + }, "accumulator = 10*OneSec, t=5s. 0 base accum": testCaseFromDeltas( sdk.ZeroDec(), tenSecAccum, 5*time.Second, sdk.NewDec(2)), "accumulator = 10*OneSec, t=3s. 0 base accum": testCaseFromDeltas( @@ -555,13 +662,88 @@ func TestComputeArithmeticTwap(t *testing.T) { } for name, test := range tests { t.Run(name, func(t *testing.T) { - actualTwap, err := twap.ComputeArithmeticTwap(test.startRecord, test.endRecord, test.quoteAsset) - require.Equal(t, test.expTwap, actualTwap) - require.NoError(t, err) + + osmoassert.ConditionalPanic(t, test.expPanic, func() { + actualTwap := twap.ComputeArithmeticTwap(test.startRecord, test.endRecord, test.quoteAsset) + require.Equal(t, test.expTwap, actualTwap) + }) + }) + } +} + +func TestComputeGeometricTwap(t *testing.T) { + tests := map[string]computeTwapTestCase{ + // basic test for both denom with zero start accumulator + "basic denom0: spot price = 1 for one second, 0 init accumulator": { + startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), + endRecord: newOneSidedGeometricRecord(tPlusOne, geometricTenSecAccum), + quoteAsset: denom0, + expTwap: sdk.NewDec(10), + }, + "basic denom1: spot price = 1 for one second, 0 init accumulator": { + startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), + endRecord: newOneSidedGeometricRecord(tPlusOne, geometricTenSecAccum), + quoteAsset: denom1, + expTwap: sdk.OneDec().Quo(sdk.NewDec(10)), + }, + + // basic test for both denom with non-zero start accumulator + "denom0: start accumulator of 10 * 1s, end accumulator 10 * 1s + 20 * 2s = 20": { + startRecord: newOneSidedGeometricRecord(baseTime, geometricTenSecAccum), + endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Second*2), geometricTenSecAccum.Add(OneSec.MulInt64(2).Mul(twap.TwapLog(sdk.NewDec(20))))), + quoteAsset: denom0, + expTwap: sdk.NewDec(20), + }, + "denom1 start accumulator of 10 * 1s, end accumulator 10 * 1s + 20 * 2s = 20": { + startRecord: newOneSidedGeometricRecord(baseTime, geometricTenSecAccum), + endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Second*2), geometricTenSecAccum.Add(OneSec.MulInt64(2).Mul(twap.TwapLog(sdk.NewDec(20))))), + quoteAsset: denom1, + expTwap: sdk.OneDec().Quo(sdk.NewDec(20)), + }, + + // toggle time delta. + "accumulator = log(10)*OneSec, t=5s. 0 base accum": geometricTestCaseFromDeltas0( + sdk.ZeroDec(), geometricTenSecAccum, 5*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(5*1000))), + "accumulator = log(10)*OneSec, t=3s. 0 base accum": geometricTestCaseFromDeltas0( + sdk.ZeroDec(), geometricTenSecAccum, 3*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(3*1000))), + "accumulator = log(10)*OneSec, t=100s. 0 base accum": geometricTestCaseFromDeltas0( + sdk.ZeroDec(), geometricTenSecAccum, 100*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000))), + + // test that base accum has no impact + "accumulator = log(10)*OneSec, t=5s. 10 base accum": geometricTestCaseFromDeltas0( + logTen, geometricTenSecAccum, 5*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(5*1000))), + "accumulator = log(10)*OneSec, t=3s. 10*second base accum": geometricTestCaseFromDeltas0( + OneSec.MulInt64(10).Mul(logTen), geometricTenSecAccum, 3*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(3*1000))), + "accumulator = 10*OneSec, t=100s. .1*second base accum": geometricTestCaseFromDeltas0( + OneSec.MulInt64(10).Mul(logOneOverTen), geometricTenSecAccum, 100*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000))), + + // TODO: this is the highest price we currently support with the given precision bounds. + // Need to choose better base and potentially improve math functions to mitigate. + "price of 1_000_000 for an hour": { + startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), + endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Hour), OneSec.MulInt64(60*60).Mul(twap.TwapLog(sdk.NewDec(1_000_000)))), + quoteAsset: denom0, + expTwap: sdk.NewDec(1_000_000), + }, + // TODO: overflow tests + // - max spot price + // - large time delta + // - both + + // TODO: hand calculated tests + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + osmoassert.ConditionalPanic(t, tc.expPanic, func() { + actualTwap := twap.ComputeGeometricTwap(tc.startRecord, tc.endRecord, tc.quoteAsset) + osmoassert.DecApproxEq(t, tc.expTwap, actualTwap, osmomath.GetPowPrecision()) + }) }) } } +// TODO: split up this test case to cover both arithmetic and geometric twap func TestComputeArithmeticTwap_ThreeAsset(t *testing.T) { testThreeAssetCaseFromDeltas := func(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeThreeAssetArithmeticTwapTestCase { return computeThreeAssetArithmeticTwapTestCase{ @@ -600,7 +782,7 @@ func TestComputeArithmeticTwap_ThreeAsset(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { for i, startRec := range test.startRecord { - actualTwap, err := twap.ComputeArithmeticTwap(startRec, test.endRecord[i], test.quoteAsset[i]) + actualTwap, err := twap.ComputeTwap(startRec, test.endRecord[i], test.quoteAsset[i], twap.ArithmeticTwapType) require.Equal(t, test.expTwap[i], actualTwap) require.NoError(t, err) } @@ -616,7 +798,7 @@ func TestComputeArithmeticTwapWithSpotPriceError(t *testing.T) { record.LastErrorTime = errTime return record } - tests := map[string]computeArithmeticTwapTestCase{ + tests := map[string]computeTwapTestCase{ // should error, since end time may have been used to interpolate this value "errAtEndTime from end record": { startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), @@ -626,13 +808,21 @@ func TestComputeArithmeticTwapWithSpotPriceError(t *testing.T) { expErr: true, }, // should error, since start time may have been used to interpolate this value - "err at StartTime exactly": { + "err at StartTime exactly from end record": { startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), endRecord: newOneSidedRecordWErrorTime(tPlusOne, OneSec, true, baseTime), quoteAsset: denom0, expTwap: sdk.OneDec(), expErr: true, }, + // should error, since start record is erroneous + "err at StartTime exactly from start record": { + startRecord: newOneSidedRecordWErrorTime(baseTime, sdk.ZeroDec(), true, baseTime), + endRecord: newOneSidedRecord(tPlusOne, OneSec, true), + quoteAsset: denom0, + expTwap: sdk.OneDec(), + expErr: true, + }, "err before StartTime": { startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), endRecord: newOneSidedRecordWErrorTime(tPlusOne, OneSec, true, tMinOne), @@ -651,7 +841,7 @@ func TestComputeArithmeticTwapWithSpotPriceError(t *testing.T) { } for name, test := range tests { t.Run(name, func(t *testing.T) { - actualTwap, err := twap.ComputeArithmeticTwap(test.startRecord, test.endRecord, test.quoteAsset) + actualTwap, err := twap.ComputeTwap(test.startRecord, test.endRecord, test.quoteAsset, twap.ArithmeticTwapType) require.Equal(t, test.expTwap, actualTwap) osmoassert.ConditionalError(t, test.expErr, err) }) @@ -667,15 +857,15 @@ func (s *TestSuite) TestPruneRecords() { pool1OlderMin2MsRecord, // deleted pool2OlderMin1MsRecordAB, pool2OlderMin1MsRecordAC, pool2OlderMin1MsRecordBC, // deleted - pool3OlderBaseRecord, // kept as newest under keep period + pool3OlderBaseRecord, // kept as newest under keep period pool4OlderPlus1Record := // kept as newest under keep period - s.createTestRecordsFromTime(baseTime.Add(2 * -recordHistoryKeepPeriod)) + s.createTestRecordsFromTime(baseTime.Add(2 * -recordHistoryKeepPeriod)) pool1Min2MsRecord, // kept as newest under keep period pool2Min1MsRecordAB, pool2Min1MsRecordAC, pool2Min1MsRecordBC, // kept as newest under keep period - pool3BaseRecord, // kept as it is at the keep period boundary + pool3BaseRecord, // kept as it is at the keep period boundary pool4Plus1Record := // kept as it is above the keep period boundary - s.createTestRecordsFromTime(baseTime.Add(-recordHistoryKeepPeriod)) + s.createTestRecordsFromTime(baseTime.Add(-recordHistoryKeepPeriod)) // non-ascending insertion order. recordsToPreSet := []types.TwapRecord{ @@ -1051,7 +1241,7 @@ func (s *TestSuite) TestUpdateRecords() { "multi-asset pool; pre-set at t and t + 1; creates new records": { preSetRecords: []types.TwapRecord{threeAssetRecordAB, threeAssetRecordAC, threeAssetRecordBC, tPlus10sp5ThreeAssetRecordAB, tPlus10sp5ThreeAssetRecordAC, tPlus10sp5ThreeAssetRecordBC}, poolId: threeAssetRecordAB.PoolId, - blockTime: threeAssetRecordAB.Time.Add(time.Second * 11), + blockTime: threeAssetRecordAB.Time.Add(time.Second * 11), spOverrides: []spOverride{ { baseDenom: threeAssetRecordAB.Asset0Denom, @@ -1139,7 +1329,7 @@ func (s *TestSuite) TestUpdateRecords() { "multi-asset pool; pre-set at t and t + 1 with err, large spot price, overwrites error time": { preSetRecords: []types.TwapRecord{threeAssetRecordAB, threeAssetRecordAC, threeAssetRecordBC, withLastErrTime(tPlus10sp5ThreeAssetRecordAB, tPlus10sp5ThreeAssetRecordAB.Time), tPlus10sp5ThreeAssetRecordAC, tPlus10sp5ThreeAssetRecordBC}, poolId: threeAssetRecordAB.PoolId, - blockTime: threeAssetRecordAB.Time.Add(time.Second * 11), + blockTime: threeAssetRecordAB.Time.Add(time.Second * 11), spOverrides: []spOverride{ { baseDenom: threeAssetRecordAB.Asset0Denom, @@ -1147,10 +1337,10 @@ func (s *TestSuite) TestUpdateRecords() { overrideSp: sdk.OneDec(), }, { - baseDenom: threeAssetRecordAB.Asset1Denom, - quoteDenom: threeAssetRecordAB.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), - }, + baseDenom: threeAssetRecordAB.Asset1Denom, + quoteDenom: threeAssetRecordAB.Asset0Denom, + overrideSp: sdk.OneDec().Add(sdk.OneDec()), + }, { baseDenom: threeAssetRecordAC.Asset0Denom, quoteDenom: threeAssetRecordAC.Asset1Denom, @@ -1168,9 +1358,9 @@ func (s *TestSuite) TestUpdateRecords() { overrideSp: sdk.OneDec(), }, { - baseDenom: threeAssetRecordBC.Asset1Denom, - quoteDenom: threeAssetRecordBC.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + baseDenom: threeAssetRecordBC.Asset1Denom, + quoteDenom: threeAssetRecordBC.Asset0Denom, + overrideSp: sdk.OneDec().Add(sdk.OneDec()), }, }, @@ -1189,7 +1379,7 @@ func (s *TestSuite) TestUpdateRecords() { // The new record AB added. { spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()), + spotPriceB: sdk.OneDec().Add(sdk.OneDec()), lastErrorTime: tPlus10sp5ThreeAssetRecordAB.Time, isMostRecent: true, }, @@ -1200,8 +1390,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The original record AC at t + 1. { - spotPriceA: tPlus10sp5ThreeAssetRecordAC.P0LastSpotPrice, - spotPriceB: tPlus10sp5ThreeAssetRecordAC.P1LastSpotPrice, + spotPriceA: tPlus10sp5ThreeAssetRecordAC.P0LastSpotPrice, + spotPriceB: tPlus10sp5ThreeAssetRecordAC.P1LastSpotPrice, }, // The new record AC added. { @@ -1217,14 +1407,14 @@ func (s *TestSuite) TestUpdateRecords() { }, // The original record BC at t + 1. { - spotPriceA: tPlus10sp5ThreeAssetRecordBC.P0LastSpotPrice, - spotPriceB: tPlus10sp5ThreeAssetRecordBC.P1LastSpotPrice, + spotPriceA: tPlus10sp5ThreeAssetRecordBC.P0LastSpotPrice, + spotPriceB: tPlus10sp5ThreeAssetRecordBC.P1LastSpotPrice, }, // The new record BC added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()), - isMostRecent: true, + spotPriceA: sdk.OneDec(), + spotPriceB: sdk.OneDec().Add(sdk.OneDec()), + isMostRecent: true, }, }, }, @@ -1333,10 +1523,10 @@ func (s *TestSuite) TestAfterCreatePool() { s.Require().NoError(err) denoms := osmoutils.CoinsDenoms(tc.poolCoins) - denomPairs0, denomPairs1 := types.GetAllUniqueDenomPairs(denoms) + denomPairs := types.GetAllUniqueDenomPairs(denoms) expectedRecords := []types.TwapRecord{} - for i := 0; i < len(denomPairs0); i++ { - expectedRecord, err := twap.NewTwapRecord(s.App.GAMMKeeper, s.Ctx, poolId, denomPairs0[i], denomPairs1[i]) + for _, denomPair := range denomPairs { + expectedRecord, err := twap.NewTwapRecord(s.App.GAMMKeeper, s.Ctx, poolId, denomPair.Denom0, denomPair.Denom1) s.Require().NoError(err) expectedRecords = append(expectedRecords, expectedRecord) } @@ -1344,21 +1534,21 @@ func (s *TestSuite) TestAfterCreatePool() { // consistency check that the number of records is exactly equal to the number of denompairs allRecords, err := s.twapkeeper.GetAllMostRecentRecordsForPool(s.Ctx, poolId) s.Require().NoError(err) - s.Require().Equal(len(denomPairs0), len(allRecords)) + s.Require().Equal(len(denomPairs), len(allRecords)) s.Require().Equal(len(expectedRecords), len(allRecords)) // check on the correctness of all individual twap records - for i := 0; i < len(denomPairs0); i++ { - actualRecord, err := s.twapkeeper.GetMostRecentRecordStoreRepresentation(s.Ctx, poolId, denomPairs0[i], denomPairs1[i]) + for i, denomPair := range denomPairs { + actualRecord, err := s.twapkeeper.GetMostRecentRecordStoreRepresentation(s.Ctx, poolId, denomPair.Denom0, denomPair.Denom1) s.Require().NoError(err) s.Require().Equal(expectedRecords[i], actualRecord) - actualRecord, err = s.twapkeeper.GetRecordAtOrBeforeTime(s.Ctx, poolId, s.Ctx.BlockTime(), denomPairs0[i], denomPairs1[i]) + actualRecord, err = s.twapkeeper.GetRecordAtOrBeforeTime(s.Ctx, poolId, s.Ctx.BlockTime(), denomPair.Denom0, denomPair.Denom1) s.Require().NoError(err) s.Require().Equal(expectedRecords[i], actualRecord) } - // test that after creating a pool - // has triggered `trackChangedPool`, + // test that after creating a pool + // has triggered `trackChangedPool`, // and that we have the state of price impacted pools. changedPools := s.twapkeeper.GetChangedPools(s.Ctx) s.Require().Equal(1, len(changedPools)) @@ -1366,3 +1556,43 @@ func (s *TestSuite) TestAfterCreatePool() { }) } } + +func testCaseFromDeltas(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { + return computeTwapTestCase{ + newOneSidedRecord(baseTime, startAccum, true), + newOneSidedRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff), true), + []twap.TwapType{twap.ArithmeticTwapType}, + denom0, + expectedTwap, + false, + false, + } +} + +func testCaseFromDeltasAsset1(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { + return computeTwapTestCase{ + newOneSidedRecord(baseTime, startAccum, false), + newOneSidedRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff), false), + []twap.TwapType{twap.ArithmeticTwapType}, + denom1, + expectedTwap, + false, + false, + } +} + +func geometricTestCaseFromDeltas0(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { + return computeTwapTestCase{ + newOneSidedGeometricRecord(baseTime, startAccum), + newOneSidedGeometricRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff)), + []twap.TwapType{twap.GeometricTwapType}, + denom0, + expectedTwap, + false, + false, + } +} + +func geometricTestCaseFromDeltas1(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { + return geometricTestCaseFromDeltas0(startAccum, accumDiff, timeDelta, sdk.OneDec().Quo(expectedTwap)) +} diff --git a/x/twap/migrate_test.go b/x/twap/migrate_test.go index c8568c03bbd..37c7905f1e3 100644 --- a/x/twap/migrate_test.go +++ b/x/twap/migrate_test.go @@ -3,7 +3,7 @@ package twap_test import ( "time" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) func (s *TestSuite) TestMigrateExistingPools() { @@ -31,7 +31,7 @@ func (s *TestSuite) TestMigrateExistingPools() { recentTwapRecords, err := s.twapkeeper.GetAllMostRecentRecordsForPool(s.Ctx, uint64(poolId)) poolDenoms, err := s.App.GAMMKeeper.GetPoolDenoms(s.Ctx, uint64(poolId)) s.Require().NoError(err) - denomPairs, _ := types.GetAllUniqueDenomPairs(poolDenoms) + denomPairs := types.GetAllUniqueDenomPairs(poolDenoms) s.Require().NoError(err) s.Require().Equal(len(denomPairs), len(recentTwapRecords)) diff --git a/x/twap/store.go b/x/twap/store.go index 70f159c3f4b..7a12955e6de 100644 --- a/x/twap/store.go +++ b/x/twap/store.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) type timeTooOldError struct { @@ -68,7 +68,7 @@ func (k Keeper) storeHistoricalTWAP(ctx sdk.Context, twap types.TwapRecord) { // - Suppose pruning param -48 hour // - Suppose there are three records at: -51 hour, -50 hour, and -1hour // If we were to prune everything older than 48 hours, -// we would be left with with only one record at -1 hour, and we wouldn't be able to +// we would be left with only one record at -1 hour, and we wouldn't be able to // get twaps from the [-48 hour, -1 hour] time range. // So, in order to have correct behavior for the desired guarantee, // we keep the newest record that is older than the pruning time. diff --git a/x/twap/store_test.go b/x/twap/store_test.go index 6a7ea8cd25d..6d8b2bea0e4 100644 --- a/x/twap/store_test.go +++ b/x/twap/store_test.go @@ -7,10 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap" + "github.com/osmosis-labs/osmosis/v13/x/twap" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) // TestTrackChangedPool takes a list of poolIds as test cases, and runs one list per block. @@ -162,11 +162,11 @@ func (s *TestSuite) TestGetRecordAtOrBeforeTime() { defaultInputAt := func(t time.Time) getRecordInput { return getRecordInput{1, t, denom0, denom1} } wrongPoolIdInputAt := func(t time.Time) getRecordInput { return getRecordInput{2, t, denom0, denom1} } defaultRevInputAt := func(t time.Time) getRecordInput { return getRecordInput{1, t, denom1, denom0} } - baseRecord := newEmptyPriceRecord(1, baseTime, denom0, denom1) + baseRecord := withPrice0Set(newEmptyPriceRecord(1, baseTime, denom0, denom1), sdk.OneDec()) tMin1 := baseTime.Add(-time.Second) - tMin1Record := newEmptyPriceRecord(1, tMin1, denom0, denom1) + tMin1Record := withPrice0Set(newEmptyPriceRecord(1, tMin1, denom0, denom1), sdk.OneDec()) tPlus1 := baseTime.Add(time.Second) - tPlus1Record := newEmptyPriceRecord(1, tPlus1, denom0, denom1) + tPlus1Record := withPrice0Set(newEmptyPriceRecord(1, tPlus1, denom0, denom1), sdk.OneDec()) tests := map[string]struct { recordsToSet []types.TwapRecord diff --git a/x/twap/twapmodule/module.go b/x/twap/twapmodule/module.go index 77f286bcd7a..a8f32edb886 100644 --- a/x/twap/twapmodule/module.go +++ b/x/twap/twapmodule/module.go @@ -16,11 +16,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/osmosis-labs/osmosis/v12/x/twap" - twapclient "github.com/osmosis-labs/osmosis/v12/x/twap/client" - "github.com/osmosis-labs/osmosis/v12/x/twap/client/grpc" - "github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap" + twapclient "github.com/osmosis-labs/osmosis/v13/x/twap/client" + twapcli "github.com/osmosis-labs/osmosis/v13/x/twap/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/grpc" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) var ( @@ -63,8 +64,7 @@ func (b AppModuleBasic) GetTxCmd() *cobra.Command { } func (b AppModuleBasic) GetQueryCmd() *cobra.Command { - return nil - // return cli.GetQueryCmd() + return twapcli.GetQueryCmd() } // RegisterInterfaces registers interfaces and implementations of the gamm module. @@ -126,7 +126,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // BeginBlock performs a no-op. func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} -// EndBlock performs a no-op. +// EndBlock executes all ABCI EndBlock logic respective to the TWAP module. It +// returns no validator updates. func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { am.k.EndBlock(ctx) return []abci.ValidatorUpdate{} diff --git a/x/twap/types/genesis.go b/x/twap/types/genesis.go index ac47da89bbd..fdd273bcd7b 100644 --- a/x/twap/types/genesis.go +++ b/x/twap/types/genesis.go @@ -81,5 +81,9 @@ func (t TwapRecord) validate() error { if t.P1ArithmeticTwapAccumulator.IsNil() || t.P1ArithmeticTwapAccumulator.IsNegative() { return fmt.Errorf("twap record p1 accumulator cannot be negative, was (%s)", t.P1ArithmeticTwapAccumulator) } + + if t.GeometricTwapAccumulator.IsNil() || t.GeometricTwapAccumulator.IsNegative() { + return fmt.Errorf("twap record geometric accumulator cannot be negative, was (%s)", t.GeometricTwapAccumulator) + } return nil } diff --git a/x/twap/types/genesis.pb.go b/x/twap/types/genesis.pb.go index e4cf597f17a..2fff4f24e6b 100644 --- a/x/twap/types/genesis.pb.go +++ b/x/twap/types/genesis.pb.go @@ -147,32 +147,32 @@ func init() { } var fileDescriptor_3f4bdf49b69bd63c = []byte{ - // 395 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xbd, 0x0e, 0xd3, 0x30, - 0x14, 0x85, 0x63, 0x7e, 0x2a, 0x91, 0x32, 0x45, 0x15, 0xb4, 0x15, 0x4a, 0x43, 0x06, 0xd4, 0xa5, - 0x36, 0x2d, 0x4c, 0x15, 0x53, 0x05, 0xe2, 0x6f, 0xa9, 0x02, 0x13, 0x4b, 0xe4, 0x24, 0xb7, 0xa9, - 0x45, 0x13, 0x5b, 0xb6, 0xd3, 0x92, 0x07, 0x40, 0x62, 0x64, 0xe4, 0x89, 0x50, 0xc7, 0x8e, 0x4c, - 0x05, 0xb5, 0x6f, 0xc0, 0x13, 0xa0, 0xc4, 0x2e, 0x03, 0x2a, 0x5b, 0xae, 0xbe, 0x73, 0x8e, 0x4e, - 0xee, 0xb5, 0x1b, 0x72, 0x55, 0x70, 0xc5, 0x14, 0xd1, 0x3b, 0x2a, 0xc8, 0x76, 0x9a, 0x80, 0xa6, - 0x53, 0x92, 0x43, 0x09, 0x8a, 0x29, 0x2c, 0x24, 0xd7, 0xdc, 0xeb, 0x59, 0x0d, 0x6e, 0x34, 0xd8, - 0x6a, 0x86, 0xbd, 0x9c, 0xe7, 0xbc, 0x15, 0x90, 0xe6, 0xcb, 0x68, 0x87, 0x8f, 0xae, 0xe6, 0x35, - 0x43, 0x2c, 0x21, 0xe5, 0x32, 0xb3, 0xba, 0x41, 0xce, 0x79, 0xbe, 0x01, 0xd2, 0x4e, 0x49, 0xb5, - 0x22, 0xb4, 0xac, 0x2f, 0x28, 0x6d, 0x33, 0x62, 0x93, 0x6d, 0x06, 0x8b, 0xfc, 0x7f, 0x5d, 0x59, - 0x25, 0xa9, 0x66, 0xbc, 0x34, 0x3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xef, 0xfc, 0x38, 0xfb, 0xce, 0x87, 0xc7, 0x39, - 0xd3, 0xeb, 0x2a, 0xc1, 0x29, 0x2f, 0x88, 0xcd, 0x9b, 0x6c, 0x68, 0xa2, 0x2e, 0x03, 0xd9, 0x4e, - 0x67, 0xe4, 0x93, 0x79, 0x09, 0xba, 0x16, 0xa0, 0x92, 0x4e, 0xbb, 0xb1, 0x27, 0x7f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0x34, 0xde, 0xf1, 0x35, 0x76, 0x02, 0x00, 0x00, + // 397 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xbf, 0xce, 0xd3, 0x30, + 0x14, 0xc5, 0x63, 0xfe, 0x54, 0x22, 0x1f, 0x53, 0x54, 0x41, 0xbf, 0x0a, 0xa5, 0x21, 0x03, 0xea, + 0x52, 0x9b, 0xb6, 0x4c, 0x15, 0x53, 0x05, 0xe2, 0xdf, 0x52, 0x05, 0x26, 0x96, 0xc8, 0x49, 0x6e, + 0x53, 0x8b, 0x26, 0xb6, 0x6c, 0xa7, 0x25, 0x0f, 0x80, 0xc4, 0xc8, 0xc8, 0x13, 0xa1, 0x8e, 0x1d, + 0x99, 0x0a, 0x6a, 0xdf, 0x80, 0x27, 0x40, 0x89, 0x5d, 0x06, 0xd4, 0x6f, 0xcb, 0xd5, 0xef, 0x9c, + 0xa3, 0x93, 0x7b, 0xed, 0x86, 0x5c, 0x15, 0x5c, 0x31, 0x45, 0xf4, 0x96, 0x0a, 0xb2, 0x19, 0x27, + 0xa0, 0xe9, 0x98, 0xe4, 0x50, 0x82, 0x62, 0x0a, 0x0b, 0xc9, 0x35, 0xf7, 0xba, 0x56, 0x83, 0x1b, + 0x0d, 0xb6, 0x9a, 0x7e, 0x37, 0xe7, 0x39, 0x6f, 0x05, 0xa4, 0xf9, 0x32, 0xda, 0xfe, 0x93, 0x8b, + 0x79, 0xcd, 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 0x37, 0x73, 0x3b, 0xa2, 0x5d, 0x8b, 0xfd, + 0x83, 0x47, 0x97, 0xed, 0x66, 0x75, 0xd6, 0x6a, 0x1d, 0xf3, 0xb7, 0xbb, 0xa3, 0x8f, 0xf6, 0x47, + 0x1f, 0xfd, 0x3e, 0xfa, 0xe8, 0xdb, 0xc9, 0x77, 0xf6, 0x27, 0xdf, 0xf9, 0x79, 0xf2, 0x9d, 0x8f, + 0x4f, 0x73, 0xa6, 0x57, 0x55, 0x82, 0x53, 0x5e, 0x10, 0x9b, 0x37, 0x5a, 0xd3, 0x44, 0x9d, 0x07, + 0xb2, 0x19, 0x4f, 0xc9, 0x67, 0xf3, 0x12, 0x74, 0x2d, 0x40, 0x25, 0x9d, 0x76, 0x63, 0xd3, 0xbf, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xf4, 0xba, 0xd9, 0x22, 0x76, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/twap/types/genesis_test.go b/x/twap/types/genesis_test.go index 313668b1002..bc65efe03ad 100644 --- a/x/twap/types/genesis_test.go +++ b/x/twap/types/genesis_test.go @@ -28,6 +28,7 @@ var ( P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), } ) @@ -55,6 +56,7 @@ func TestGenesisState_Validate(t *testing.T) { P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), }, { PoolId: basePoolId, @@ -66,6 +68,7 @@ func TestGenesisState_Validate(t *testing.T) { P1LastSpotPrice: sdk.OneDec(), P0ArithmeticTwapAccumulator: sdk.OneDec(), P1ArithmeticTwapAccumulator: sdk.OneDec(), + GeometricTwapAccumulator: sdk.OneDec(), }, }) ) @@ -294,6 +297,23 @@ func TestTWAPRecord_Validate(t *testing.T) { }(), expectedErr: true, }, + "invalid geometric accum: nil": { + twapRecord: func() TwapRecord { + r := TwapRecord{ + PoolId: basePoolId, + Asset0Denom: denom0, + Asset1Denom: denom1, + Height: 3, + Time: tPlusOne.Add(time.Second), + P0LastSpotPrice: sdk.OneDec(), + P1LastSpotPrice: sdk.OneDec(), + P0ArithmeticTwapAccumulator: sdk.OneDec(), + P1ArithmeticTwapAccumulator: sdk.OneDec(), + } + return r + }(), + expectedErr: true, + }, } // make test cases symmetric testCasesSym := map[string]testcase{} diff --git a/x/twap/types/keys.go b/x/twap/types/keys.go index bbc6b8f509b..37ae7627f7b 100644 --- a/x/twap/types/keys.go +++ b/x/twap/types/keys.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/osmoutils" + "github.com/osmosis-labs/osmosis/v13/osmoutils" ) const ( @@ -36,7 +36,7 @@ var ( // format is just pool id | denom1 | denom2 // made for getting most recent key mostRecentTWAPsPrefix = mostRecentTWAPsNoSeparator + KeySeparator - // format is time | pool id | denom1 | denom2 | time + // format is time | pool id | denom1 | denom2 // made for efficiently deleting records by time in pruning HistoricalTWAPTimeIndexPrefix = historicalTWAPTimeIndexNoSeparator + KeySeparator // format is pool id | denom1 | denom2 | time diff --git a/x/twap/types/params.go b/x/twap/types/params.go index e6bc0b96443..ca87df82703 100644 --- a/x/twap/types/params.go +++ b/x/twap/types/params.go @@ -6,7 +6,7 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" ) // Parameter store keys. diff --git a/x/twap/types/twap_record.pb.go b/x/twap/types/twap_record.pb.go index 4a5324e62cc..7faa318b4f0 100644 --- a/x/twap/types/twap_record.pb.go +++ b/x/twap/types/twap_record.pb.go @@ -55,6 +55,7 @@ type TwapRecord struct { P1LastSpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=p1_last_spot_price,json=p1LastSpotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"p1_last_spot_price"` P0ArithmeticTwapAccumulator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=p0_arithmetic_twap_accumulator,json=p0ArithmeticTwapAccumulator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"p0_arithmetic_twap_accumulator"` P1ArithmeticTwapAccumulator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=p1_arithmetic_twap_accumulator,json=p1ArithmeticTwapAccumulator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"p1_arithmetic_twap_accumulator"` + GeometricTwapAccumulator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=geometric_twap_accumulator,json=geometricTwapAccumulator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"geometric_twap_accumulator"` // This field contains the time in which the last spot price error occured. // It is used to alert the caller if they are getting a potentially erroneous // TWAP, due to an unforeseen underlying error. @@ -145,40 +146,41 @@ func init() { } var fileDescriptor_dbf5c78678e601aa = []byte{ - // 523 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xc7, 0x63, 0x1a, 0x5c, 0xba, 0xa1, 0xaa, 0x64, 0x45, 0x60, 0x82, 0x64, 0x07, 0x1f, 0xaa, - 0x70, 0xa8, 0x3f, 0xca, 0x8d, 0x5b, 0xa2, 0x72, 0x00, 0x21, 0x84, 0x4c, 0x4f, 0x70, 0x58, 0xad, - 0xed, 0xad, 0x63, 0x61, 0x67, 0x57, 0xde, 0x4d, 0x4b, 0x5e, 0x81, 0x53, 0x1f, 0xab, 0xc7, 0x1e, - 0x11, 0x07, 0x83, 0x92, 0x1b, 0xc7, 0x3e, 0x01, 0xda, 0x8f, 0x84, 0x26, 0x08, 0x2a, 0xe5, 0x64, - 0xcf, 0xcc, 0x7f, 0x7e, 0x33, 0xb3, 0xb3, 0x36, 0x38, 0x24, 0xac, 0x22, 0xac, 0x60, 0x01, 0xbf, - 0x40, 0x34, 0x38, 0x8f, 0x12, 0xcc, 0x51, 0x24, 0x0d, 0x58, 0xe3, 0x94, 0xd4, 0x99, 0x4f, 0x6b, - 0xc2, 0x89, 0xd5, 0xd5, 0x3a, 0x5f, 0x84, 0x7c, 0xad, 0xeb, 0x75, 0x73, 0x92, 0x13, 0x29, 0x08, - 0xc4, 0x9b, 0xd2, 0xf6, 0x9e, 0xe4, 0x84, 0xe4, 0x25, 0x0e, 0xa4, 0x95, 0x4c, 0xcf, 0x02, 0x34, - 0x99, 0x2d, 0x43, 0xa9, 0xe4, 0x40, 0x95, 0xa3, 0x0c, 0x1d, 0x72, 0x94, 0x15, 0x24, 0x88, 0xe1, - 0x55, 0x23, 0x29, 0x29, 0x26, 0x3a, 0xee, 0x6e, 0x52, 0x79, 0x51, 0x61, 0xc6, 0x51, 0x45, 0x95, - 0xc0, 0xfb, 0x6a, 0x02, 0x70, 0x7a, 0x81, 0x68, 0x2c, 0xfb, 0xb6, 0x1e, 0x83, 0x5d, 0x4a, 0x48, - 0x09, 0x8b, 0xcc, 0x36, 0xfa, 0xc6, 0xa0, 0x1d, 0x9b, 0xc2, 0x7c, 0x9d, 0x59, 0xcf, 0xc0, 0x43, - 0xc4, 0x18, 0xe6, 0x21, 0xcc, 0xf0, 0x84, 0x54, 0xf6, 0xbd, 0xbe, 0x31, 0xd8, 0x8b, 0x3b, 0xca, - 0x77, 0x22, 0x5c, 0x2b, 0x49, 0xa4, 0x25, 0x3b, 0xb7, 0x24, 0x91, 0x92, 0x0c, 0x81, 0x39, 0xc6, - 0x45, 0x3e, 0xe6, 0x76, 0xbb, 0x6f, 0x0c, 0x76,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 0x06, 0x0e, 0xe4, - 0x19, 0xe2, 0xba, 0x26, 0xb5, 0xdc, 0xa0, 0xdd, 0xb9, 0x73, 0xfd, 0x9e, 0x5e, 0xff, 0x23, 0xb5, - 0xfe, 0x0d, 0x80, 0xba, 0x02, 0xfb, 0xc2, 0xfb, 0x4a, 0x38, 0x45, 0xde, 0xe8, 0xcd, 0xd5, 0xdc, - 0x31, 0xae, 0xe7, 0x8e, 0xf1, 0x73, 0xee, 0x18, 0x97, 0x0b, 0xa7, 0x75, 0xbd, 0x70, 0x5a, 0xdf, - 0x16, 0x4e, 0xeb, 0x63, 0x78, 0x6b, 0x0c, 0xfd, 0x51, 0x1f, 0x95, 0x28, 0x61, 0x4b, 0x23, 0x38, - 0x8f, 0x8e, 0x83, 0x2f, 0xea, 0x7f, 0x20, 0x87, 0x4a, 0x4c, 0xd9, 0xd2, 0x8b, 0xdf, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xdf, 0xff, 0x6c, 0x30, 0x2c, 0x04, 0x00, 0x00, + // 539 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x63, 0x1a, 0x52, 0x7a, 0xa1, 0xaa, 0x64, 0x45, 0x60, 0x82, 0x64, 0x87, 0x0c, 0x55, + 0x18, 0xea, 0x1f, 0x74, 0x63, 0x4b, 0x54, 0x06, 0x10, 0x42, 0xc8, 0x74, 0x82, 0xe1, 0x74, 0xb6, + 0xaf, 0x8e, 0x85, 0x9d, 0x3b, 0xdd, 0x5d, 0x5a, 0xf2, 0x5f, 0xf4, 0xcf, 0xea, 0xd8, 0x11, 0x31, + 0x18, 0x94, 0x6c, 0x8c, 0x9d, 0x18, 0xd1, 0xfd, 0x48, 0x68, 0xc2, 0x2f, 0x29, 0x53, 0xf2, 0xde, + 0xfb, 0xbe, 0xcf, 0xf7, 0x3d, 0xfb, 0xc9, 0xe0, 0x90, 0xf0, 0x8a, 0xf0, 0x82, 0x07, 0xe2, 0x02, + 0xd1, 0xe0, 0x3c, 0x4a, 0xb0, 0x40, 0x91, 0x0a, 0x20, 0xc3, 0x29, 0x61, 0x99, 0x4f, 0x19, 0x11, + 0xc4, 0xee, 0x18, 0x9d, 0x2f, 0x4b, 0xbe, 0xd1, 0x75, 0x3b, 0x39, 0xc9, 0x89, 0x12, 0x04, 0xf2, + 0x9f, 0xd6, 0x76, 0x1f, 0xe5, 0x84, 0xe4, 0x25, 0x0e, 0x54, 0x94, 0x4c, 0xcf, 0x02, 0x34, 0x99, + 0x2d, 0x4b, 0xa9, 0xe2, 0x40, 0xdd, 0xa3, 0x03, 0x53, 0x72, 0x75, 0x14, 0x24, 0x88, 0xe3, 0xd5, + 0x20, 0x29, 0x29, 0x26, 0xa6, 0xee, 0x6d, 0x52, 0x45, 0x51, 0x61, 0x2e, 0x50, 0x45, 0xb5, 0xa0, + 0xff, 0xa3, 0x05, 0xc0, 0xe9, 0x05, 0xa2, 0xb1, 0x9a, 0xdb, 0x7e, 0x08, 0x76, 0x29, 0x21, 0x25, + 0x2c, 0x32, 0xc7, 0xea, 0x59, 0x83, 0x66, 0xdc, 0x92, 0xe1, 0xcb, 0xcc, 0x7e, 0x02, 0xee, 0x23, + 0xce, 0xb1, 0x08, 0x61, 0x86, 0x27, 0xa4, 0x72, 0xee, 0xf4, 0xac, 0xc1, 0x5e, 0xdc, 0xd6, 0xb9, + 0x13, 0x99, 0x5a, 0x49, 0x22, 0x23, 0xd9, 0xb9, 0x25, 0x89, 0xb4, 0x64, 0x08, 0x5a, 0x63, 0x5c, + 0xe4, 0x63, 0xe1, 0x34, 0x7b, 0xd6, 0x60, 0x67, 0xf4, 0xf4, 0x7b, 0xed, 0xed, 0xeb, 0x47, 0x06, + 0x75, 0xe1, 0xa6, 0xf6, 0x3a, 0x33, 0x54, 0x95, 0xcf, 0xfb, 0x6b, 0xe9, 0x7e, 0x6c, 0x1a, 0xed, + 0x37, 0xa0, 0x29, 0x77, 0x70, 0xee, 0xf6, 0xac, 0x41, 0xfb, 0x59, 0xd7, 0xd7, 0x0b, 0xfa, 0xcb, + 0x05, 0xfd, 0xd3, 0xe5, 0x82, 0x23, 0xf7, 0xaa, 0xf6, 0x1a, 0x37, 0xb5, 0x67, 0xaf, 0xf1, 0x64, + 0x73, 0xff, 0xf2, 0xab, 0x67, 0xc5, 0x8a, 0x63, 0x7f, 0x00, 0x36, 0x0d, 0x61, 0x89, 0xb8, 0x80, + 0x9c, 0x12, 0x01, 0x29, 0x2b, 0x52, 0xec, 0xb4, 0xe4, 0xec, 0x23, 0x5f, 0x12, 0xbe, 0xd4, 0xde, + 0x61, 0x5e, 0x88, 0xf1, 0x34, 0xf1, 0x53, 0x52, 0x99, 0xc7, 0x6f, 0x7e, 0x8e, 0x78, 0xf6, 0x31, + 0x10, 0x33, 0x8a, 0xb9, 0x7f, 0x82, 0xd3, 0xf8, 0x80, 0x86, 0xaf, 0x11, 0x17, 0xef, 0x28, 0x11, + 0x6f, 0x25, 0x46, 0xc1, 0xa3, 0xdf, 0xe0, 0xbb, 0x5b, 0xc2, 0xa3, 0x75, 0x38, 0x07, 0x2e, 0x0d, + 0x21, 0x62, 0x85, 0x18, 0x57, 0x58, 0x14, 0x29, 0x54, 0x07, 0x88, 0xd2, 0x74, 0x5a, 0x4d, 0x4b, + 0x24, 0x08, 0x73, 0xee, 0x6d, 0x65, 0xf4, 0x98, 0x86, 0xc3, 0x15, 0x54, 0xde, 0xc6, 0xf0, 0x17, + 0x52, 0x99, 0x46, 0xff, 0x34, 0xdd, 0xdb, 0xd2, 0x34, 0xfa, 0xbb, 0x69, 0x09, 0xba, 0x39, 0x26, + 0x15, 0x16, 0xec, 0x4f, 0x86, 0x60, 0x2b, 0x43, 0x67, 0x45, 0xdc, 0x74, 0x3b, 0x03, 0x07, 0xea, + 0x8d, 0x61, 0xc6, 0x08, 0x53, 0xf7, 0xe2, 0xb4, 0xff, 0x7b, 0x6c, 0x7d, 0x73, 0x6c, 0x0f, 0xf4, + 0xb1, 0x6d, 0x00, 0xf4, 0xc1, 0xed, 0xcb, 0xec, 0x0b, 0x99, 0x94, 0x7d, 0xa3, 0x57, 0x57, 0x73, + 0xd7, 0xba, 0x9e, 0xbb, 0xd6, 0xb7, 0xb9, 0x6b, 0x5d, 0x2e, 0xdc, 0xc6, 0xf5, 0xc2, 0x6d, 0x7c, + 0x5e, 0xb8, 0x8d, 0xf7, 0xe1, 0xad, 0x1d, 0xcc, 0x27, 0xe4, 0xa8, 0x44, 0x09, 0x5f, 0x06, 0xc1, + 0x79, 0x74, 0x1c, 0x7c, 0xd2, 0x5f, 0x1f, 0xb5, 0x51, 0xd2, 0x52, 0x23, 0x1d, 0xff, 0x0c, 0x00, + 0x00, 0xff, 0xff, 0xa4, 0x13, 0xe4, 0xcf, 0x9a, 0x04, 0x00, 0x00, } func (m *TwapRecord) Marshal() (dAtA []byte, err error) { @@ -209,6 +211,16 @@ func (m *TwapRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTwapRecord(dAtA, i, uint64(n1)) i-- dAtA[i] = 0x5a + { + size := m.GeometricTwapAccumulator.Size() + i -= size + if _, err := m.GeometricTwapAccumulator.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTwapRecord(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 { size := m.P1ArithmeticTwapAccumulator.Size() i -= size @@ -325,6 +337,8 @@ func (m *TwapRecord) Size() (n int) { n += 1 + l + sovTwapRecord(uint64(l)) l = m.P1ArithmeticTwapAccumulator.Size() n += 1 + l + sovTwapRecord(uint64(l)) + l = m.GeometricTwapAccumulator.Size() + n += 1 + l + sovTwapRecord(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastErrorTime) n += 1 + l + sovTwapRecord(uint64(l)) return n @@ -636,6 +650,40 @@ func (m *TwapRecord) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GeometricTwapAccumulator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTwapRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTwapRecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTwapRecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GeometricTwapAccumulator.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastErrorTime", wireType) diff --git a/x/twap/types/twapmock/amminterface.go b/x/twap/types/twapmock/amminterface.go index 95adfb4dbc6..4b7b408d306 100644 --- a/x/twap/types/twapmock/amminterface.go +++ b/x/twap/types/twapmock/amminterface.go @@ -3,7 +3,7 @@ package twapmock import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/twap/types" + "github.com/osmosis-labs/osmosis/v13/x/twap/types" ) var _ types.AmmInterface = &ProgrammedAmmInterface{} diff --git a/x/twap/types/utils.go b/x/twap/types/utils.go index 2674aa86190..1bd70a1d28f 100644 --- a/x/twap/types/utils.go +++ b/x/twap/types/utils.go @@ -12,31 +12,26 @@ var MaxSpotPrice = sdk.NewDec(2).Power(128).Sub(sdk.OneDec()) // GetAllUniqueDenomPairs returns all unique pairs of denoms, where for every pair // (X, Y), X < Y. -// The pair (X,Y) should only appear once in the list +// The pair (X,Y) should only appear once in the list. Denoms are lexicographically sorted. // Panics if finds duplicate pairs. // // NOTE: Sorts the input denoms slice. -func GetAllUniqueDenomPairs(denoms []string) ([]string, []string) { +func GetAllUniqueDenomPairs(denoms []string) []DenomPair { // get denoms in ascending order sort.Strings(denoms) - numPairs := len(denoms) * (len(denoms) - 1) / 2 - pairGT := make([]string, 0, numPairs) - pairLT := make([]string, 0, numPairs) + denomPairs := []DenomPair{} for i := 0; i < len(denoms); i++ { for j := i + 1; j < len(denoms); j++ { - pairGT = append(pairGT, denoms[i]) - pairLT = append(pairLT, denoms[j]) + if denoms[i] == denoms[j] { + panic("input had duplicated denom") + } + denomPairs = append(denomPairs, DenomPair{Denom0: denoms[i], Denom1: denoms[j]}) } } - // sanity check - for i := 0; i < numPairs; i++ { - if pairGT[i] == pairLT[i] { - panic("input had duplicated denom") - } - } - return pairGT, pairLT + + return denomPairs } // SpotPriceMulDuration returns the spot price multiplied by the time delta, @@ -66,3 +61,9 @@ func LexicographicalOrderDenoms(denom0, denom1 string) (string, string, error) { } return denom0, denom1, nil } + +// DenomPair contains pair of assetA and assetB denoms which belong to a pool. +type DenomPair struct { + Denom0 string + Denom1 string +} diff --git a/x/twap/types/utils_test.go b/x/twap/types/utils_test.go index 082344a332e..b2af7f12959 100644 --- a/x/twap/types/utils_test.go +++ b/x/twap/types/utils_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v12/app/apptesting/osmoassert" - "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting/osmoassert" + "github.com/osmosis-labs/osmosis/v13/x/gamm/types" ) func TestMaxSpotPriceEquality(t *testing.T) { @@ -16,24 +16,22 @@ func TestMaxSpotPriceEquality(t *testing.T) { func TestGetAllUniqueDenomPairs(t *testing.T) { tests := map[string]struct { - denoms []string - wantedPairGT []string - wantedPairLT []string - panics bool + denoms []string + wantedPairs []DenomPair + panics bool }{ - "basic": {[]string{"A", "B"}, []string{"A"}, []string{"B"}, false}, - "basicRev": {[]string{"B", "A"}, []string{"A"}, []string{"B"}, false}, + "basic": {[]string{"A", "B"}, []DenomPair{{"A", "B"}}, false}, + "basicRev": {[]string{"B", "A"}, []DenomPair{{"A", "B"}}, false}, // AB > A - "prefixed": {[]string{"A", "AB"}, []string{"A"}, []string{"AB"}, false}, - "basic-3": {[]string{"A", "B", "C"}, []string{"A", "A", "B"}, []string{"B", "C", "C"}, false}, - "panics": {[]string{"A", "A"}, []string{}, []string{}, true}, + "prefixed": {[]string{"A", "AB"}, []DenomPair{{"A", "AB"}}, false}, + "basic-3": {[]string{"A", "B", "C"}, []DenomPair{{"A", "B"}, {"A", "C"}, {"B", "C"}}, false}, + "panics": {[]string{"A", "A"}, []DenomPair{}, true}, } for name, tt := range tests { t.Run(name, func(t *testing.T) { osmoassert.ConditionalPanic(t, tt.panics, func() { - pairGT, pairLT := GetAllUniqueDenomPairs(tt.denoms) - require.Equal(t, pairGT, tt.wantedPairGT) - require.Equal(t, pairLT, tt.wantedPairLT) + pairs := GetAllUniqueDenomPairs(tt.denoms) + require.Equal(t, pairs, tt.wantedPairs) }) }) } diff --git a/x/txfees/client/cli/query.go b/x/txfees/client/cli/query.go index d09553645ad..f1078d1f4a5 100644 --- a/x/txfees/client/cli/query.go +++ b/x/txfees/client/cli/query.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/txfees/client/cli/query_test.go b/x/txfees/client/cli/query_test.go index 7575d3eb902..95419cd541e 100644 --- a/x/txfees/client/cli/query_test.go +++ b/x/txfees/client/cli/query_test.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) type QueryTestSuite struct { diff --git a/x/txfees/client/cli/tx.go b/x/txfees/client/cli/tx.go index 17bc5581d36..33da28b1053 100644 --- a/x/txfees/client/cli/tx.go +++ b/x/txfees/client/cli/tx.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov/client/cli" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) func NewTxCmd() *cobra.Command { diff --git a/x/txfees/handler.go b/x/txfees/handler.go index f96de8e1d77..ec1649fc410 100644 --- a/x/txfees/handler.go +++ b/x/txfees/handler.go @@ -5,8 +5,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/osmosis-labs/osmosis/v12/x/txfees/keeper" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/keeper" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) func NewUpdateFeeTokenProposalHandler(k keeper.Keeper) govtypes.Handler { diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index 27132f1b24c..5d69d6d7511 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -6,8 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/v12/x/txfees/keeper/txfee_filters" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/keeper/txfee_filters" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) diff --git a/x/txfees/keeper/feedecorator_test.go b/x/txfees/keeper/feedecorator_test.go index 9f2408ef022..d021b736b39 100644 --- a/x/txfees/keeper/feedecorator_test.go +++ b/x/txfees/keeper/feedecorator_test.go @@ -9,8 +9,8 @@ import ( authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/osmosis-labs/osmosis/v12/x/txfees/keeper" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/keeper" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) func (suite *KeeperTestSuite) TestFeeDecorator() { diff --git a/x/txfees/keeper/feetokens.go b/x/txfees/keeper/feetokens.go index f3c589d15e9..12581a6b8dd 100644 --- a/x/txfees/keeper/feetokens.go +++ b/x/txfees/keeper/feetokens.go @@ -2,7 +2,7 @@ package keeper import ( "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/txfees/keeper/feetokens_test.go b/x/txfees/keeper/feetokens_test.go index 10b96ee4194..fb6430f7b86 100644 --- a/x/txfees/keeper/feetokens_test.go +++ b/x/txfees/keeper/feetokens_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/txfees/keeper/genesis.go b/x/txfees/keeper/genesis.go index 48d5e6f6704..35469450bf6 100644 --- a/x/txfees/keeper/genesis.go +++ b/x/txfees/keeper/genesis.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/txfees/keeper/gov.go b/x/txfees/keeper/gov.go index 5016dde4383..c703feab4c6 100644 --- a/x/txfees/keeper/gov.go +++ b/x/txfees/keeper/gov.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) func (k Keeper) HandleUpdateFeeTokenProposal(ctx sdk.Context, p *types.UpdateFeeTokenProposal) error { diff --git a/x/txfees/keeper/grpc_query.go b/x/txfees/keeper/grpc_query.go index bbb04e9129b..66681a19999 100644 --- a/x/txfees/keeper/grpc_query.go +++ b/x/txfees/keeper/grpc_query.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) var _ types.QueryServer = Querier{} diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index 0ee9be07606..3ef8f8671d5 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -3,9 +3,9 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/osmoutils" - epochstypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types" - txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + txfeestypes "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index c1575bb7b71..98ff636eaea 100644 --- a/x/txfees/keeper/hooks_test.go +++ b/x/txfees/keeper/hooks_test.go @@ -7,8 +7,8 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) var defaultPooledAssetAmount = int64(500) diff --git a/x/txfees/keeper/keeper.go b/x/txfees/keeper/keeper.go index 060946efdd4..1b5c6ca9e87 100644 --- a/x/txfees/keeper/keeper.go +++ b/x/txfees/keeper/keeper.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) type Keeper struct { diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index 453073808c1..9b3af3be21d 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -8,10 +8,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" - osmosisapp "github.com/osmosis-labs/osmosis/v12/app" + osmosisapp "github.com/osmosis-labs/osmosis/v13/app" - "github.com/osmosis-labs/osmosis/v12/app/apptesting" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) type KeeperTestSuite struct { diff --git a/x/txfees/keeper/txfee_filters/arb_tx.go b/x/txfees/keeper/txfee_filters/arb_tx.go index 38b611154ab..b85896378ae 100644 --- a/x/txfees/keeper/txfee_filters/arb_tx.go +++ b/x/txfees/keeper/txfee_filters/arb_tx.go @@ -1,7 +1,7 @@ package txfee_filters import ( - gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/txfees/module.go b/x/txfees/module.go index 5eaa0feb922..d48284b29c7 100644 --- a/x/txfees/module.go +++ b/x/txfees/module.go @@ -25,9 +25,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/osmosis-labs/osmosis/v12/x/txfees/client/cli" - "github.com/osmosis-labs/osmosis/v12/x/txfees/keeper" - "github.com/osmosis-labs/osmosis/v12/x/txfees/types" + "github.com/osmosis-labs/osmosis/v13/x/txfees/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/txfees/keeper" + "github.com/osmosis-labs/osmosis/v13/x/txfees/types" ) var ( diff --git a/x/txfees/module_test.go b/x/txfees/module_test.go index 8ccd43ef114..41f1c6c1cd0 100644 --- a/x/txfees/module_test.go +++ b/x/txfees/module_test.go @@ -7,7 +7,7 @@ import ( abcitypes "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - simapp "github.com/osmosis-labs/osmosis/v12/app" + simapp "github.com/osmosis-labs/osmosis/v13/app" ) func TestSetBaseDenomOnInitBlock(t *testing.T) { diff --git a/x/txfees/types/feetoken.pb.go b/x/txfees/types/feetoken.pb.go index 8d45a2b9ede..ae767fb74e2 100644 --- a/x/txfees/types/feetoken.pb.go +++ b/x/txfees/types/feetoken.pb.go @@ -101,9 +101,9 @@ var fileDescriptor_c50689857adfcfe0 = []byte{ 0x28, 0x05, 0x41, 0x55, 0x58, 0xb1, 0xbc, 0x58, 0x20, 0xcf, 0xe8, 0xe4, 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, - 0xf9, 0xb9, 0xfa, 0x50, 0x87, 0xeb, 0xe6, 0x24, 0x26, 0x15, 0xc3, 0x38, 0xfa, 0x65, 0x86, 0x46, + 0xf9, 0xb9, 0xfa, 0x50, 0x87, 0xeb, 0xe6, 0x24, 0x26, 0x15, 0xc3, 0x38, 0xfa, 0x65, 0x86, 0xc6, 0xfa, 0x15, 0x30, 0x2f, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x9d, 0x6e, 0x0c, 0x08, - 0x00, 0x00, 0xff, 0xff, 0x9b, 0x5f, 0xae, 0x31, 0x11, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xbc, 0x3a, 0x8b, 0xb0, 0x11, 0x01, 0x00, 0x00, } func (this *FeeToken) Equal(that interface{}) bool { diff --git a/x/txfees/types/genesis.pb.go b/x/txfees/types/genesis.pb.go index 38e1f54fcd5..769c7eefb3d 100644 --- a/x/txfees/types/genesis.pb.go +++ b/x/txfees/types/genesis.pb.go @@ -98,9 +98,9 @@ var fileDescriptor_4423c18e3d020b37 = []byte{ 0x85, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x21, 0x34, 0x3a, 0xf9, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, - 0x7e, 0xae, 0x3e, 0xd4, 0x58, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x18, 0x47, 0xbf, 0xcc, 0xd0, 0x48, + 0x7e, 0xae, 0x3e, 0xd4, 0x58, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x18, 0x47, 0xbf, 0xcc, 0xd0, 0x58, 0xbf, 0x02, 0xe6, 0xa5, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x47, 0x8c, 0x01, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x9a, 0x9f, 0x18, 0x14, 0x45, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xbd, 0xfa, 0x3d, 0x95, 0x45, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/txfees/types/gov.pb.go b/x/txfees/types/gov.pb.go index 3c72c30a459..04a9544d1eb 100644 --- a/x/txfees/types/gov.pb.go +++ b/x/txfees/types/gov.pb.go @@ -91,9 +91,9 @@ var fileDescriptor_2c4a51bafc82863d = []byte{ 0xe4, 0x19, 0x5e, 0x2c, 0x90, 0x67, 0x74, 0xf2, 0x39, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xa3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, - 0xbd, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x30, 0x8e, 0x7e, 0x99, 0xa1, 0x91, 0x7e, 0x05, 0x2c, 0x04, + 0xbd, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x30, 0x8e, 0x7e, 0x99, 0xa1, 0xb1, 0x7e, 0x05, 0x2c, 0x04, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xe1, 0x66, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0xc6, 0x3c, 0x32, 0x9a, 0xb0, 0x01, 0x00, 0x00, + 0xe1, 0x59, 0x17, 0x1b, 0xb0, 0x01, 0x00, 0x00, } func (this *UpdateFeeTokenProposal) Equal(that interface{}) bool { diff --git a/x/txfees/types/query.pb.go b/x/txfees/types/query.pb.go index a4a414ddea6..4dd1377814f 100644 --- a/x/txfees/types/query.pb.go +++ b/x/txfees/types/query.pb.go @@ -425,8 +425,8 @@ var fileDescriptor_6cbc1b48c44dfdd6 = []byte{ 0x83, 0x3a, 0xf3, 0x09, 0x49, 0x0b, 0xce, 0xfc, 0x22, 0x8a, 0x0b, 0xce, 0xfc, 0x12, 0xa0, 0x8b, 0xcf, 0x3c, 0x41, 0xb4, 0xf2, 0xf2, 0x74, 0x68, 0xa2, 0xb3, 0xa1, 0x89, 0xfe, 0x0c, 0x4d, 0xf4, 0x69, 0x64, 0xa6, 0xce, 0x46, 0x66, 0xea, 0xd7, 0xc8, 0x4c, 0x1d, 0x94, 0xa6, 0x2e, 0xbb, 0xf6, - 0x29, 0xb4, 0x5c, 0x4f, 0x4c, 0x4c, 0x8f, 0x8b, 0x25, 0x76, 0x12, 0x5b, 0xab, 0xcb, 0xef, 0xad, - 0xaa, 0x8f, 0x6c, 0xf9, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x1d, 0x4e, 0x22, 0x1d, 0x06, + 0x29, 0xb4, 0x5c, 0x4f, 0x4c, 0x4c, 0x8f, 0x8b, 0x65, 0x76, 0x12, 0x5b, 0xab, 0xcb, 0xef, 0xad, + 0xaa, 0x8f, 0x6c, 0xf9, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0x78, 0x6b, 0xa3, 0x1d, 0x06, 0x00, 0x00, } diff --git a/x/validator-preference/README.md b/x/valset-pref/README.md similarity index 100% rename from x/validator-preference/README.md rename to x/valset-pref/README.md diff --git a/x/valset-pref/client/query_proto_wrap.go b/x/valset-pref/client/query_proto_wrap.go new file mode 100644 index 00000000000..5100b479e0b --- /dev/null +++ b/x/valset-pref/client/query_proto_wrap.go @@ -0,0 +1,22 @@ +package client + +import ( + "context" + + validatorprefkeeper "github.com/osmosis-labs/osmosis/v13/x/valset-pref" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/client/queryproto" +) + +type Querier struct { + validatorprefkeeper.Keeper +} + +var _ queryproto.QueryServer = Querier{} + +func NewQuerier(k validatorprefkeeper.Keeper) Querier { + return Querier{k} +} + +func (q Querier) UserValidatorPreferences(ctx context.Context, req *queryproto.QueryUserValidatorPreferences) (*queryproto.QueryUserValidatorPreferenceResponse, error) { + return &queryproto.QueryUserValidatorPreferenceResponse{}, nil +} diff --git a/x/validator-preference/client/queryproto/query.pb.go b/x/valset-pref/client/queryproto/query.pb.go similarity index 81% rename from x/validator-preference/client/queryproto/query.pb.go rename to x/valset-pref/client/queryproto/query.pb.go index 3af9d73e681..fe607e3b09e 100644 --- a/x/validator-preference/client/queryproto/query.pb.go +++ b/x/valset-pref/client/queryproto/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/validator-preference/v1beta1/query.proto +// source: osmosis/valset-pref/v1beta1/query.proto package queryproto @@ -9,7 +9,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - types "github.com/osmosis-labs/osmosis/v12/x/validator-preference/types" + types "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -33,14 +33,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Request type for UserValidatorPreferences. type QueryUserValidatorPreferences struct { // user account address - User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } func (m *QueryUserValidatorPreferences) Reset() { *m = QueryUserValidatorPreferences{} } func (m *QueryUserValidatorPreferences) String() string { return proto.CompactTextString(m) } func (*QueryUserValidatorPreferences) ProtoMessage() {} func (*QueryUserValidatorPreferences) Descriptor() ([]byte, []int) { - return fileDescriptor_888a45acbabdd269, []int{0} + return fileDescriptor_9ffbeb4123fe56ae, []int{0} } func (m *QueryUserValidatorPreferences) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,7 +78,7 @@ func (m *QueryUserValidatorPreferenceResponse) Reset() { *m = QueryUserV func (m *QueryUserValidatorPreferenceResponse) String() string { return proto.CompactTextString(m) } func (*QueryUserValidatorPreferenceResponse) ProtoMessage() {} func (*QueryUserValidatorPreferenceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_888a45acbabdd269, []int{1} + return fileDescriptor_9ffbeb4123fe56ae, []int{1} } func (m *QueryUserValidatorPreferenceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -108,38 +108,38 @@ func (m *QueryUserValidatorPreferenceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryUserValidatorPreferenceResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*QueryUserValidatorPreferences)(nil), "osmosis.validatorpreference.v1beta1.QueryUserValidatorPreferences") - proto.RegisterType((*QueryUserValidatorPreferenceResponse)(nil), "osmosis.validatorpreference.v1beta1.QueryUserValidatorPreferenceResponse") + proto.RegisterType((*QueryUserValidatorPreferences)(nil), "osmosis.valsetpref.v1beta1.QueryUserValidatorPreferences") + proto.RegisterType((*QueryUserValidatorPreferenceResponse)(nil), "osmosis.valsetpref.v1beta1.QueryUserValidatorPreferenceResponse") } func init() { - proto.RegisterFile("osmosis/validator-preference/v1beta1/query.proto", fileDescriptor_888a45acbabdd269) -} - -var fileDescriptor_888a45acbabdd269 = []byte{ - // 338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xc8, 0x2f, 0xce, 0xcd, - 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x4b, 0xcc, 0xc9, 0x4c, 0x49, 0x2c, 0xc9, 0x2f, 0xd2, 0x2d, 0x28, - 0x4a, 0x4d, 0x4b, 0x2d, 0x4a, 0xcd, 0x4b, 0x4e, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, - 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x86, 0xea, - 0x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, 0xb5, 0x4e, 0x59, 0x27, 0x1e, 0xca, 0x31, 0x9c, - 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, - 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4f, 0x7a, 0x66, 0x49, 0x46, 0x69, - 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0xcc, 0x54, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x84, 0x15, 0x86, 0x46, - 0xfa, 0x15, 0xd8, 0x2d, 0x4a, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0x81, 0xa4, 0x51, 0x70, 0xba, 0x48, - 0x62, 0x03, 0x53, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0xbd, 0xf5, 0xa9, 0xdd, 0x02, - 0x00, 0x00, + proto.RegisterFile("osmosis/valset-pref/v1beta1/query.proto", fileDescriptor_9ffbeb4123fe56ae) +} + +var fileDescriptor_9ffbeb4123fe56ae = []byte{ + // 341 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcd, 0x4a, 0x3b, 0x31, + 0x14, 0xc5, 0x27, 0xff, 0xbf, 0x1f, 0x98, 0xee, 0x06, 0x17, 0xc3, 0xa0, 0xb1, 0x14, 0xd1, 0x6e, + 0x9a, 0xd0, 0x76, 0xd5, 0x9d, 0xd4, 0x17, 0xd0, 0x82, 0x0a, 0xee, 0x32, 0xed, 0xed, 0x38, 0x30, + 0x9d, 0x8c, 0xb9, 0x69, 0x51, 0x44, 0x04, 0x9f, 0x40, 0xf0, 0xa1, 0xec, 0xb2, 0xe2, 0xc6, 0x95, + 0x68, 0xeb, 0x83, 0x48, 0xe7, 0x83, 0x2a, 0xd8, 0x59, 0xb8, 0x4a,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0xaa, 0xf6, 0x9e, 0x28, 0x9a, 0xc8, 0x4d, 0xf6, 0xa6, 0xb7, 0x6d, 0x39, 0xfe, 0x60, + 0xd6, 0x78, 0xca, 0xc8, 0x64, 0xca, 0xc8, 0xfb, 0x94, 0x91, 0x87, 0x19, 0xb3, 0x26, 0x33, 0x66, + 0xbd, 0xce, 0x98, 0x75, 0x7e, 0xe8, 0x07, 0xe6, 0x62, 0xe8, 0xf1, 0xae, 0x1a, 0xe4, 0x7a, 0xb5, + 0x50, 0x7a, 0xb8, 0x10, 0xaf, 0x37, 0xc5, 0xd5, 0x0f, 0x8b, 0x6e, 0x18, 0x40, 0x64, 0xd2, 0xcf, + 0x96, 0x8c, 0xdc, 0x5b, 0x4b, 0x96, 0xe6, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x54, 0xf1, + 0xbe, 0x9d, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -168,7 +168,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) UserValidatorPreferences(ctx context.Context, in *QueryUserValidatorPreferences, opts ...grpc.CallOption) (*QueryUserValidatorPreferenceResponse, error) { out := new(QueryUserValidatorPreferenceResponse) - err := c.cc.Invoke(ctx, "/osmosis.validatorpreference.v1beta1.Query/UserValidatorPreferences", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.valsetpref.v1beta1.Query/UserValidatorPreferences", in, out, opts...) if err != nil { return nil, err } @@ -203,7 +203,7 @@ func _Query_UserValidatorPreferences_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.validatorpreference.v1beta1.Query/UserValidatorPreferences", + FullMethod: "/osmosis.valsetpref.v1beta1.Query/UserValidatorPreferences", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).UserValidatorPreferences(ctx, req.(*QueryUserValidatorPreferences)) @@ -212,7 +212,7 @@ func _Query_UserValidatorPreferences_Handler(srv interface{}, ctx context.Contex } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "osmosis.validatorpreference.v1beta1.Query", + ServiceName: "osmosis.valsetpref.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -221,7 +221,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/validator-preference/v1beta1/query.proto", + Metadata: "osmosis/valset-pref/v1beta1/query.proto", } func (m *QueryUserValidatorPreferences) Marshal() (dAtA []byte, err error) { @@ -244,10 +244,10 @@ func (m *QueryUserValidatorPreferences) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if len(m.User) > 0 { - i -= len(m.User) - copy(dAtA[i:], m.User) - i = encodeVarintQuery(dAtA, i, uint64(len(m.User))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0xa } @@ -308,7 +308,7 @@ func (m *QueryUserValidatorPreferences) Size() (n int) { } var l int _ = l - l = len(m.User) + l = len(m.Address) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -367,7 +367,7 @@ func (m *QueryUserValidatorPreferences) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -395,7 +395,7 @@ func (m *QueryUserValidatorPreferences) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.User = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/validator-preference/client/queryproto/query.pb.gw.go b/x/valset-pref/client/queryproto/query.pb.gw.go similarity index 92% rename from x/validator-preference/client/queryproto/query.pb.gw.go rename to x/valset-pref/client/queryproto/query.pb.gw.go index 00172683446..c79a1f8f501 100644 --- a/x/validator-preference/client/queryproto/query.pb.gw.go +++ b/x/valset-pref/client/queryproto/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: osmosis/validator-preference/v1beta1/query.proto +// source: osmosis/valset-pref/v1beta1/query.proto /* Package queryproto is a reverse proxy. @@ -44,15 +44,15 @@ func request_Query_UserValidatorPreferences_0(ctx context.Context, marshaler run _ = err ) - val, ok = pathParams["user"] + val, ok = pathParams["address"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") } - protoReq.User, err = runtime.String(val) + protoReq.Address, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } msg, err := client.UserValidatorPreferences(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -71,15 +71,15 @@ func local_request_Query_UserValidatorPreferences_0(ctx context.Context, marshal _ = err ) - val, ok = pathParams["user"] + val, ok = pathParams["address"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") } - protoReq.User, err = runtime.String(val) + protoReq.Address, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } msg, err := server.UserValidatorPreferences(ctx, &protoReq) @@ -181,7 +181,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_UserValidatorPreferences_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"osmosis", "validator-preference", "v1beta1", "user"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_UserValidatorPreferences_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"osmosis", "valset-pref", "v1beta1", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/valset-pref/keeper.go b/x/valset-pref/keeper.go new file mode 100644 index 00000000000..10896eb0223 --- /dev/null +++ b/x/valset-pref/keeper.go @@ -0,0 +1,53 @@ +package keeper + +import ( + "fmt" + + "github.com/tendermint/tendermint/libs/log" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/gogo/protobuf/proto" + "github.com/osmosis-labs/osmosis/v13/osmoutils" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" +) + +type Keeper struct { + storeKey sdk.StoreKey + paramSpace paramtypes.Subspace + stakingKeeper types.StakingInterface +} + +func NewKeeper(storeKey sdk.StoreKey, + paramSpace paramtypes.Subspace, + stakingKeeper types.StakingInterface, +) Keeper { + return Keeper{ + storeKey: storeKey, + paramSpace: paramSpace, + stakingKeeper: stakingKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) SetValidatorSetPreferences(ctx sdk.Context, delegator string, validators types.ValidatorSetPreferences) { + store := ctx.KVStore(k.storeKey) + osmoutils.MustSet(store, []byte(delegator), &validators) +} + +func (k Keeper) GetValidatorSetPreference(ctx sdk.Context, delegator string) (types.ValidatorSetPreferences, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get([]byte(delegator)) + if bz == nil { + return types.ValidatorSetPreferences{}, false + } + var valsetPref types.ValidatorSetPreferences + if err := proto.Unmarshal(bz, &valsetPref); err != nil { + return types.ValidatorSetPreferences{}, false + } + + return valsetPref, true +} diff --git a/x/valset-pref/keeper_test.go b/x/valset-pref/keeper_test.go new file mode 100644 index 00000000000..69e445795c2 --- /dev/null +++ b/x/valset-pref/keeper_test.go @@ -0,0 +1,52 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" + "github.com/stretchr/testify/suite" +) + +type KeeperTestSuite struct { + apptesting.KeeperTestHelper +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.Setup() +} + +// SetupMultipleValidators setups "numValidator" validators and returns their address in string +func (suite *KeeperTestSuite) SetupMultipleValidators(numValidator int) []string { + valAddrs := []string{} + for i := 0; i < numValidator; i++ { + valAddr := suite.SetupValidator(stakingtypes.Bonded) + valAddrs = append(valAddrs, valAddr.String()) + } + return valAddrs +} + +func (suite *KeeperTestSuite) PrepareDelegateToValidatorSet() []types.ValidatorPreference { + valAddrs := suite.SetupMultipleValidators(3) + valPreferences := []types.ValidatorPreference{ + { + ValOperAddress: valAddrs[0], + Weight: sdk.NewDecWithPrec(5, 1), + }, + { + ValOperAddress: valAddrs[1], + Weight: sdk.NewDecWithPrec(3, 1), + }, + { + ValOperAddress: valAddrs[2], + Weight: sdk.NewDecWithPrec(2, 1), + }, + } + return valPreferences +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/x/valset-pref/msg_server.go b/x/valset-pref/msg_server.go new file mode 100644 index 00000000000..cc6a226424d --- /dev/null +++ b/x/valset-pref/msg_server.go @@ -0,0 +1,50 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" +) + +type msgServer struct { + keeper *Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper *Keeper) types.MsgServer { + return &msgServer{ + keeper: keeper, + } +} + +var _ types.MsgServer = msgServer{} + +func (server msgServer) SetValidatorSetPreference(goCtx context.Context, msg *types.MsgSetValidatorSetPreference) (*types.MsgSetValidatorSetPreferenceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + err := server.keeper.SetupValidatorSetPreference(ctx, msg.Delegator, msg.Preferences) + if err != nil { + return nil, err + } + + setMsg := types.ValidatorSetPreferences{ + Preferences: msg.Preferences, + } + + server.keeper.SetValidatorSetPreferences(ctx, msg.Delegator, setMsg) + return &types.MsgSetValidatorSetPreferenceResponse{}, nil +} + +func (server msgServer) DelegateToValidatorSet(goCtx context.Context, msg *types.MsgDelegateToValidatorSet) (*types.MsgDelegateToValidatorSetResponse, error) { + return &types.MsgDelegateToValidatorSetResponse{}, nil +} + +func (server msgServer) UndelegateFromValidatorSet(goCtx context.Context, msg *types.MsgUndelegateFromValidatorSet) (*types.MsgUndelegateFromValidatorSetResponse, error) { + return &types.MsgUndelegateFromValidatorSetResponse{}, nil +} + +func (server msgServer) WithdrawDelegationRewards(goCtx context.Context, msg *types.MsgWithdrawDelegationRewards) (*types.MsgWithdrawDelegationRewardsResponse, error) { + return &types.MsgWithdrawDelegationRewardsResponse{}, nil +} diff --git a/x/valset-pref/msg_server_test.go b/x/valset-pref/msg_server_test.go new file mode 100644 index 00000000000..ed930727181 --- /dev/null +++ b/x/valset-pref/msg_server_test.go @@ -0,0 +1,126 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + valPref "github.com/osmosis-labs/osmosis/v13/x/valset-pref" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" +) + +func (suite *KeeperTestSuite) TestSetValidatorSetPreference() { + suite.SetupTest() + + // setup 3 validators + valAddrs := suite.SetupMultipleValidators(3) + + tests := []struct { + name string + delegator sdk.AccAddress + preferences []types.ValidatorPreference + expectPass bool + }{ + { + name: "creation of new validator set", + delegator: sdk.AccAddress([]byte("addr1---------------")), + preferences: []types.ValidatorPreference{ + { + ValOperAddress: valAddrs[0], + Weight: sdk.NewDecWithPrec(5, 1), + }, + { + ValOperAddress: valAddrs[1], + Weight: sdk.NewDecWithPrec(3, 1), + }, + { + ValOperAddress: valAddrs[2], + Weight: sdk.NewDecWithPrec(2, 1), + }, + }, + expectPass: true, + }, + { + name: "update 2 validator weights but leave the 3rd one as is", + delegator: sdk.AccAddress([]byte("addr1---------------")), + preferences: []types.ValidatorPreference{ + { + ValOperAddress: valAddrs[0], + Weight: sdk.NewDecWithPrec(5, 1), + }, + { + ValOperAddress: valAddrs[1], + Weight: sdk.NewDecWithPrec(4, 1), + }, + { + ValOperAddress: valAddrs[2], + Weight: sdk.NewDecWithPrec(1, 1), + }, + }, + expectPass: true, + }, + { + name: "update existing validator with same valAddr and weights", + delegator: sdk.AccAddress([]byte("addr1---------------")), + preferences: []types.ValidatorPreference{ + { + ValOperAddress: valAddrs[0], + Weight: sdk.NewDecWithPrec(5, 1), + }, + { + ValOperAddress: valAddrs[1], + Weight: sdk.NewDecWithPrec(4, 1), + }, + { + ValOperAddress: valAddrs[2], + Weight: sdk.NewDecWithPrec(1, 1), + }, + }, + expectPass: false, + }, + { + name: "update existing validator with same valAddr but different weights", + delegator: sdk.AccAddress([]byte("addr1---------------")), + preferences: []types.ValidatorPreference{ + { + ValOperAddress: valAddrs[0], + Weight: sdk.NewDecWithPrec(1, 1), + }, + { + ValOperAddress: valAddrs[1], + Weight: sdk.NewDecWithPrec(2, 1), + }, + { + ValOperAddress: valAddrs[2], + Weight: sdk.NewDecWithPrec(7, 1), + }, + }, + expectPass: true, + }, + { + name: "create validator set with unknown validator address", + delegator: sdk.AccAddress([]byte("addr1---------------")), + preferences: []types.ValidatorPreference{ + { + ValOperAddress: "addr1---------------", + Weight: sdk.NewDec(1), + }, + }, + expectPass: false, + }, + } + + for _, test := range tests { + suite.Run(test.name, func() { + // setup message server + msgServer := valPref.NewMsgServerImpl(suite.App.ValidatorSetPreferenceKeeper) + c := sdk.WrapSDKContext(suite.Ctx) + + // call the create validator set preference + _, err := msgServer.SetValidatorSetPreference(c, types.NewMsgSetValidatorSetPreference(test.delegator, test.preferences)) + if test.expectPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + + }) + } +} diff --git a/x/valset-pref/types/codec.go b/x/valset-pref/types/codec.go new file mode 100644 index 00000000000..995b19f8034 --- /dev/null +++ b/x/valset-pref/types/codec.go @@ -0,0 +1,31 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgSetValidatorSetPreference{}, "osmosis/valset-pref/MsgSetValidatorSetPreference", nil) + cdc.RegisterConcrete(&MsgDelegateToValidatorSet{}, "osmosis/valset-pref/MsgDelegateToValidatorSet", nil) + cdc.RegisterConcrete(&MsgUndelegateFromValidatorSet{}, "osmosis/valset-pref/MsgUndelegateFromValidatorSet", nil) + cdc.RegisterConcrete(&MsgWithdrawDelegationRewards{}, "osmosis/valset-pref/MsgWithdrawDelegationRewards", nil) +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgSetValidatorSetPreference{}, + &MsgDelegateToValidatorSet{}, + &MsgUndelegateFromValidatorSet{}, + &MsgWithdrawDelegationRewards{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/valset-pref/types/expected_interfaces.go b/x/valset-pref/types/expected_interfaces.go new file mode 100644 index 00000000000..7a54060e1d2 --- /dev/null +++ b/x/valset-pref/types/expected_interfaces.go @@ -0,0 +1,17 @@ +package types + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// StakingInterface expected staking keeper. +type StakingInterface interface { + GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) + Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares sdk.Dec, err error) + GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) + Undelegate(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec) (time.Time, error) +} diff --git a/x/valset-pref/types/keys.go b/x/valset-pref/types/keys.go new file mode 100644 index 00000000000..24347ccf83e --- /dev/null +++ b/x/valset-pref/types/keys.go @@ -0,0 +1,15 @@ +package types + +var ( + // ModuleName defines the module name + ModuleName = "validatorsetpreference" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // KeyPrefixValidatorSet defines prefix key for validator set. + KeyPrefixValidatorSet = []byte{0x01} + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName +) diff --git a/x/valset-pref/types/msgs.go b/x/valset-pref/types/msgs.go new file mode 100644 index 00000000000..482a707bcb3 --- /dev/null +++ b/x/valset-pref/types/msgs.go @@ -0,0 +1,176 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/osmosis-labs/osmosis/v13/osmoutils" +) + +// constants +const ( + TypeMsgSetValidatorSetPreference = "set_validator_set_preference" +) + +var _ sdk.Msg = &MsgSetValidatorSetPreference{} + +// NewMsgCreateValidatorSetPreference creates a msg to create a validator-set preference. +func NewMsgSetValidatorSetPreference(delegator sdk.AccAddress, preferences []ValidatorPreference) *MsgSetValidatorSetPreference { + return &MsgSetValidatorSetPreference{ + Delegator: delegator.String(), + Preferences: preferences, + } +} + +func (m MsgSetValidatorSetPreference) Type() string { return TypeMsgSetValidatorSetPreference } +func (m MsgSetValidatorSetPreference) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Delegator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid delegator address (%s)", err) + } + + totalWeight := sdk.ZeroDec() + validatorAddrs := []string{} + for _, validator := range m.Preferences { + _, err := sdk.ValAddressFromBech32(validator.ValOperAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid validator address (%s)", err) + } + + totalWeight = totalWeight.Add(validator.Weight) + validatorAddrs = append(validatorAddrs, validator.ValOperAddress) + } + + // check that all the validator address are unique + containsDuplicate := osmoutils.ContainsDuplicate(validatorAddrs) + if containsDuplicate { + return fmt.Errorf("The validator operator address are duplicated") + } + + // check if the total validator distribution weights equal 1 + if !totalWeight.Equal(sdk.OneDec()) { + return fmt.Errorf("The weights allocated to the validators do not add up to 1, Got: %d", totalWeight) + } + + return nil +} + +func (m MsgSetValidatorSetPreference) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners takes a create validator-set message and returns the delegator in a byte array. +func (m MsgSetValidatorSetPreference) GetSigners() []sdk.AccAddress { + delegator, _ := sdk.AccAddressFromBech32(m.Delegator) + return []sdk.AccAddress{delegator} +} + +// constants +const ( + TypeMsgDelegateToValidatorSet = "delegate_to_validator_set" +) + +var _ sdk.Msg = &MsgDelegateToValidatorSet{} + +// NewMsgMsgStakeToValidatorSet creates a msg to stake to a validator set. +func NewMsgMsgStakeToValidatorSet(delegator sdk.AccAddress, coin sdk.Coin) *MsgDelegateToValidatorSet { + return &MsgDelegateToValidatorSet{ + Delegator: delegator.String(), + Coin: coin, + } +} + +func (m MsgDelegateToValidatorSet) Type() string { return TypeMsgDelegateToValidatorSet } +func (m MsgDelegateToValidatorSet) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Delegator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + if !m.Coin.IsValid() { + return fmt.Errorf("The stake coin is not valid") + } + + return nil +} + +func (m MsgDelegateToValidatorSet) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgDelegateToValidatorSet) GetSigners() []sdk.AccAddress { + delegator, _ := sdk.AccAddressFromBech32(m.Delegator) + return []sdk.AccAddress{delegator} +} + +// constants +const ( + TypeMsgUndelegateFromValidatorSet = "undelegate_from_validator_set" +) + +var _ sdk.Msg = &MsgUndelegateFromValidatorSet{} + +// NewMsgMsgStakeToValidatorSet creates a msg to stake to a validator. +func NewMsgUndelegateFromValidatorSet(delegator sdk.AccAddress, coin sdk.Coin) *MsgUndelegateFromValidatorSet { + return &MsgUndelegateFromValidatorSet{ + Delegator: delegator.String(), + Coin: coin, + } +} + +func (m MsgUndelegateFromValidatorSet) Type() string { return TypeMsgUndelegateFromValidatorSet } +func (m MsgUndelegateFromValidatorSet) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Delegator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + if !m.Coin.IsValid() { + return fmt.Errorf("The stake coin is not valid") + } + + return nil +} + +func (m MsgUndelegateFromValidatorSet) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgUndelegateFromValidatorSet) GetSigners() []sdk.AccAddress { + delegator, _ := sdk.AccAddressFromBech32(m.Delegator) + return []sdk.AccAddress{delegator} +} + +// constants +const ( + TypeMsgWithdrawDelegationRewards = "withdraw_delegation_rewards" +) + +var _ sdk.Msg = &MsgWithdrawDelegationRewards{} + +// NewMsgMsgStakeToValidatorSet creates a msg to stake to a validator. +func NewMsgWithdrawDelegationRewards(delegator sdk.AccAddress) *MsgWithdrawDelegationRewards { + return &MsgWithdrawDelegationRewards{ + Delegator: delegator.String(), + } +} + +func (m MsgWithdrawDelegationRewards) Type() string { return TypeMsgWithdrawDelegationRewards } +func (m MsgWithdrawDelegationRewards) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Delegator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + return nil +} + +func (m MsgWithdrawDelegationRewards) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgWithdrawDelegationRewards) GetSigners() []sdk.AccAddress { + delegator, _ := sdk.AccAddressFromBech32(m.Delegator) + return []sdk.AccAddress{delegator} +} diff --git a/x/valset-pref/types/msgs_test.go b/x/valset-pref/types/msgs_test.go new file mode 100644 index 00000000000..4d09a5d8609 --- /dev/null +++ b/x/valset-pref/types/msgs_test.go @@ -0,0 +1,157 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + appParams "github.com/osmosis-labs/osmosis/v13/app/params" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" +) + +func TestMsgSetValidatorSetPreference(t *testing.T) { + appParams.SetAddressPrefixes() + addr1, invalidAddr := apptesting.GenerateTestAddrs() + + tests := []struct { + name string + msg types.MsgSetValidatorSetPreference + expectPass bool + }{ + { + name: "proper msg", + msg: types.MsgSetValidatorSetPreference{ + Delegator: addr1, + Preferences: []types.ValidatorPreference{ + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", + Weight: sdk.NewDecWithPrec(5, 1), + }, + { + ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", + Weight: sdk.NewDecWithPrec(3, 1), + }, + { + ValOperAddress: "osmovaloper1gqsr38e4zteekwr6kq5se5jpadafqmcfyz8jds", + Weight: sdk.NewDecWithPrec(2, 1), + }, + }, + }, + expectPass: true, + }, + { + name: "duplicate validator msg", + msg: types.MsgSetValidatorSetPreference{ + Delegator: addr1, + Preferences: []types.ValidatorPreference{ + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", + Weight: sdk.NewDecWithPrec(6, 1), + }, + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", + Weight: sdk.NewDecWithPrec(4, 1), + }, + { + ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", + Weight: sdk.NewDecWithPrec(2, 1), + }, + }, + }, + expectPass: false, + }, + { + name: "invalid delegator", + msg: types.MsgSetValidatorSetPreference{ + Delegator: invalidAddr, + Preferences: []types.ValidatorPreference{ + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", + Weight: sdk.NewDec(1), + }, + }, + }, + expectPass: false, + }, + { + name: "invalid validator address", + msg: types.MsgSetValidatorSetPreference{ + Delegator: addr1, + Preferences: []types.ValidatorPreference{ + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxay", // invalid address + Weight: sdk.NewDecWithPrec(2, 1), + }, + { + ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", + Weight: sdk.NewDecWithPrec(2, 1), + }, + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", + Weight: sdk.NewDecWithPrec(6, 1), + }, + }, + }, + expectPass: false, + }, + { + name: "weights > 1", + msg: types.MsgSetValidatorSetPreference{ + Delegator: addr1, + Preferences: []types.ValidatorPreference{ + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", + Weight: sdk.NewDecWithPrec(5, 1), + }, + { + ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", + Weight: sdk.NewDecWithPrec(3, 1), + }, + { + ValOperAddress: "osmovaloper1gqsr38e4zteekwr6kq5se5jpadafqmcfyz8jds", + Weight: sdk.NewDecWithPrec(3, 1), + }, + }, + }, + expectPass: false, + }, + { + name: "weights < 1", + msg: types.MsgSetValidatorSetPreference{ + Delegator: addr1, + Preferences: []types.ValidatorPreference{ + { + ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", + Weight: sdk.NewDecWithPrec(2, 1), + }, + { + ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", + Weight: sdk.NewDecWithPrec(2, 1), + }, + { + ValOperAddress: "osmovaloper1gqsr38e4zteekwr6kq5se5jpadafqmcfyz8jds", + Weight: sdk.NewDecWithPrec(2, 1), + }, + }, + }, + expectPass: false, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + if test.expectPass { + require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) + require.Equal(t, test.msg.Type(), "set_validator_set_preference") + signers := test.msg.GetSigners() + require.Equal(t, len(signers), 1) + require.Equal(t, signers[0].String(), addr1) + } else { + require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) + } + }) + } + +} diff --git a/x/validator-preference/types/state.pb.go b/x/valset-pref/types/state.pb.go similarity index 82% rename from x/validator-preference/types/state.pb.go rename to x/valset-pref/types/state.pb.go index 467994f7447..c201765676b 100644 --- a/x/validator-preference/types/state.pb.go +++ b/x/valset-pref/types/state.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/validator-preference/v1beta1/state.proto +// source: osmosis/valset-pref/v1beta1/state.proto package types @@ -42,7 +42,7 @@ func (m *ValidatorPreference) Reset() { *m = ValidatorPreference{} } func (m *ValidatorPreference) String() string { return proto.CompactTextString(m) } func (*ValidatorPreference) ProtoMessage() {} func (*ValidatorPreference) Descriptor() ([]byte, []int) { - return fileDescriptor_2f4199f1be974865, []int{0} + return fileDescriptor_d3010474a5b89fce, []int{0} } func (m *ValidatorPreference) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -84,7 +84,7 @@ func (m *ValidatorSetPreferences) Reset() { *m = ValidatorSetPreferences func (m *ValidatorSetPreferences) String() string { return proto.CompactTextString(m) } func (*ValidatorSetPreferences) ProtoMessage() {} func (*ValidatorSetPreferences) Descriptor() ([]byte, []int) { - return fileDescriptor_2f4199f1be974865, []int{1} + return fileDescriptor_d3010474a5b89fce, []int{1} } func (m *ValidatorSetPreferences) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -114,39 +114,39 @@ func (m *ValidatorSetPreferences) XXX_DiscardUnknown() { var xxx_messageInfo_ValidatorSetPreferences proto.InternalMessageInfo func init() { - proto.RegisterType((*ValidatorPreference)(nil), "osmosis.validatorpreference.v1beta1.ValidatorPreference") - proto.RegisterType((*ValidatorSetPreferences)(nil), "osmosis.validatorpreference.v1beta1.ValidatorSetPreferences") + proto.RegisterType((*ValidatorPreference)(nil), "osmosis.valsetpref.v1beta1.ValidatorPreference") + proto.RegisterType((*ValidatorSetPreferences)(nil), "osmosis.valsetpref.v1beta1.ValidatorSetPreferences") } func init() { - proto.RegisterFile("osmosis/validator-preference/v1beta1/state.proto", fileDescriptor_2f4199f1be974865) + proto.RegisterFile("osmosis/valset-pref/v1beta1/state.proto", fileDescriptor_d3010474a5b89fce) } -var fileDescriptor_2f4199f1be974865 = []byte{ - // 358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4b, 0xfb, 0x30, - 0x18, 0xc6, 0x9b, 0xfd, 0x61, 0xf0, 0xef, 0x40, 0xa4, 0x0a, 0x1b, 0x53, 0xd2, 0x51, 0x41, 0x76, - 0x59, 0xe2, 0xe6, 0x45, 0x3c, 0xe9,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, 0xed, 0x23, 0x31, - 0xf7, 0x3d, 0x5f, 0x0d, 0x1e, 0x6d, 0xe2, 0xf0, 0x21, 0x75, 0xd2, 0x6c, 0xf9, 0xd2, 0x92, 0xee, - 0x03, 0x55, 0xa3, 0x08, 0x24, 0x39, 0x03, 0xa7, 0x97, 0xd3, 0xd6, 0x2b, 0xd2, 0xab, 0x85, 0xcd, - 0x6b, 0x50, 0x4b, 0xa7, 0xd2, 0x88, 0xf5, 0xca, 0xb2, 0x19, 0xb2, 0x56, 0x6a, 0xfc, 0x6b, 0x56, - 0x3a, 0x47, 0xe4, 0x0f, 0x1d, 0x23, 0x6b, 0x92, 0x77, 0xeb, 0x0b, 0x8b, 0xf3, 0xc4, 0x34, 0xb2, - 0x8c, 0x2b, 0xd2, 0x56, 0x6f, 0xf5, 0xa1, 0xee, 0xdd, 0xf8, 0x0b, 0x6b, 0xe3, 0x29, 0x46, 0x93, - 0x29, 0x46, 0x9f, 0x53, 0x8c, 0x5e, 0x66, 0x58, 0x9b, 0xcc, 0xb0, 0xf6, 0x3e, 0xc3, 0xda, 0xed, - 0xc9, 0x4a, 0xc2, 0xdc, 0x4a, 0x2b, 0x60, 0xb6, 0xa4, 0xc5, 0xec, 0xdb, 0x1d, 0xfa, 0xbc, 0xfe, - 0x07, 0xa4, 0xf9, 0xed, 0x72, 0x3a, 0xa1, 0xc3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x10, 0xdc, - 0x3d, 0x1c, 0x2e, 0x02, 0x00, 0x00, +var fileDescriptor_d3010474a5b89fce = []byte{ + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xcf, 0x4a, 0xeb, 0x40, + 0x18, 0xc5, 0x93, 0x5e, 0x28, 0xdc, 0x14, 0x44, 0xa2, 0xd0, 0x12, 0x25, 0x29, 0x59, 0x68, 0x37, + 0x9d, 0xa1, 0x76, 0x21, 0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x7b, 0xcf, 0x9c, 0x83, 0x30, + 0x52, 0xa3, 0x07, 0x0f, 0xf9, 0x2c, 0xc6, 0x7e, 0x1e, 0xa9, 0x5c, 0xda, 0x32, 0xb8, 0xc7, 0x6a, + 0xcc, 0x41, 0xa2, 0x33, 0xf0, 0xfb, 0xa5, 0xda, 0x7d, 0xd6, 0x8d, 0xfa, 0xca, 0xe6, 0x35, 0xa8, + 0xb5, 0x53, 0x69, 0xc6, 0x46, 0x8d, 0xaf, 0x8f, 0x8d, 0x4a, 0xf3, 0x5f, 0xab, 0x76, 0x84, 0xd1, + 0xdf, 0x1f, 0x85, 0x7e, 0x09, 0xdc, 0xb3, 0x96, 0xce, 0x16, 0x99, 0x63, 0x16, 0xd1, 0x36, 0x26, + 0xba, 0xfd, 0xcd, 0xf9, 0xbd, 0x9b, 0xc9, 0xa7, 0xad, 0x4d, 0x66, 0xb6, 0x3e, 0x9d, 0xd9, 0xfa, + 0xc7, 0xcc, 0xd6, 0x5f, 0xe6, 0xb6, 0x36, 0x9d, 0xdb, 0xda, 0xdb, 0xdc, 0xd6, 0xee, 0x8e, 0x37, + 0x82, 0x95, 0x0e, 0xda, 0x94, 0x78, 0x12, 0xaf, 0x0a, 0xee, 0x74, 0xf1, 0xd3, 0xb7, 0x9a, 0xf3, + 0xb4, 0x5e, 0x35, 0xef, 0xa3, 0xfb, 0x15, 0x00, 0x00, 0xff, 0xff, 0x49, 0x52, 0x21, 0x32, 0x0a, + 0x02, 0x00, 0x00, } func (m *ValidatorPreference) Marshal() (dAtA []byte, err error) { diff --git a/x/validator-preference/types/tx.pb.go b/x/valset-pref/types/tx.pb.go similarity index 89% rename from x/validator-preference/types/tx.pb.go rename to x/valset-pref/types/tx.pb.go index f1450087091..3def496dfe2 100644 --- a/x/validator-preference/types/tx.pb.go +++ b/x/valset-pref/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/validator-preference/v1beta1/tx.proto +// source: osmosis/valset-pref/v1beta1/tx.proto package types @@ -41,7 +41,7 @@ func (m *MsgSetValidatorSetPreference) Reset() { *m = MsgSetValidatorSet func (m *MsgSetValidatorSetPreference) String() string { return proto.CompactTextString(m) } func (*MsgSetValidatorSetPreference) ProtoMessage() {} func (*MsgSetValidatorSetPreference) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{0} + return fileDescriptor_daa95be02b2fc560, []int{0} } func (m *MsgSetValidatorSetPreference) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -91,7 +91,7 @@ func (m *MsgSetValidatorSetPreferenceResponse) Reset() { *m = MsgSetVali func (m *MsgSetValidatorSetPreferenceResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetValidatorSetPreferenceResponse) ProtoMessage() {} func (*MsgSetValidatorSetPreferenceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{1} + return fileDescriptor_daa95be02b2fc560, []int{1} } func (m *MsgSetValidatorSetPreferenceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -136,7 +136,7 @@ func (m *MsgDelegateToValidatorSet) Reset() { *m = MsgDelegateToValidato func (m *MsgDelegateToValidatorSet) String() string { return proto.CompactTextString(m) } func (*MsgDelegateToValidatorSet) ProtoMessage() {} func (*MsgDelegateToValidatorSet) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{2} + return fileDescriptor_daa95be02b2fc560, []int{2} } func (m *MsgDelegateToValidatorSet) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -186,7 +186,7 @@ func (m *MsgDelegateToValidatorSetResponse) Reset() { *m = MsgDelegateTo func (m *MsgDelegateToValidatorSetResponse) String() string { return proto.CompactTextString(m) } func (*MsgDelegateToValidatorSetResponse) ProtoMessage() {} func (*MsgDelegateToValidatorSetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{3} + return fileDescriptor_daa95be02b2fc560, []int{3} } func (m *MsgDelegateToValidatorSetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -230,7 +230,7 @@ func (m *MsgUndelegateFromValidatorSet) Reset() { *m = MsgUndelegateFrom func (m *MsgUndelegateFromValidatorSet) String() string { return proto.CompactTextString(m) } func (*MsgUndelegateFromValidatorSet) ProtoMessage() {} func (*MsgUndelegateFromValidatorSet) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{4} + return fileDescriptor_daa95be02b2fc560, []int{4} } func (m *MsgUndelegateFromValidatorSet) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +280,7 @@ func (m *MsgUndelegateFromValidatorSetResponse) Reset() { *m = MsgUndele func (m *MsgUndelegateFromValidatorSetResponse) String() string { return proto.CompactTextString(m) } func (*MsgUndelegateFromValidatorSetResponse) ProtoMessage() {} func (*MsgUndelegateFromValidatorSetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{5} + return fileDescriptor_daa95be02b2fc560, []int{5} } func (m *MsgUndelegateFromValidatorSetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -320,7 +320,7 @@ func (m *MsgWithdrawDelegationRewards) Reset() { *m = MsgWithdrawDelegat func (m *MsgWithdrawDelegationRewards) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawDelegationRewards) ProtoMessage() {} func (*MsgWithdrawDelegationRewards) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{6} + return fileDescriptor_daa95be02b2fc560, []int{6} } func (m *MsgWithdrawDelegationRewards) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -363,7 +363,7 @@ func (m *MsgWithdrawDelegationRewardsResponse) Reset() { *m = MsgWithdra func (m *MsgWithdrawDelegationRewardsResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawDelegationRewardsResponse) ProtoMessage() {} func (*MsgWithdrawDelegationRewardsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fa9fa79f914b826d, []int{7} + return fileDescriptor_daa95be02b2fc560, []int{7} } func (m *MsgWithdrawDelegationRewardsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -393,56 +393,56 @@ func (m *MsgWithdrawDelegationRewardsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgWithdrawDelegationRewardsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgSetValidatorSetPreference)(nil), "osmosis.validatorpreference.v1beta1.MsgSetValidatorSetPreference") - proto.RegisterType((*MsgSetValidatorSetPreferenceResponse)(nil), "osmosis.validatorpreference.v1beta1.MsgSetValidatorSetPreferenceResponse") - proto.RegisterType((*MsgDelegateToValidatorSet)(nil), "osmosis.validatorpreference.v1beta1.MsgDelegateToValidatorSet") - proto.RegisterType((*MsgDelegateToValidatorSetResponse)(nil), "osmosis.validatorpreference.v1beta1.MsgDelegateToValidatorSetResponse") - proto.RegisterType((*MsgUndelegateFromValidatorSet)(nil), "osmosis.validatorpreference.v1beta1.MsgUndelegateFromValidatorSet") - proto.RegisterType((*MsgUndelegateFromValidatorSetResponse)(nil), "osmosis.validatorpreference.v1beta1.MsgUndelegateFromValidatorSetResponse") - proto.RegisterType((*MsgWithdrawDelegationRewards)(nil), "osmosis.validatorpreference.v1beta1.MsgWithdrawDelegationRewards") - proto.RegisterType((*MsgWithdrawDelegationRewardsResponse)(nil), "osmosis.validatorpreference.v1beta1.MsgWithdrawDelegationRewardsResponse") + proto.RegisterType((*MsgSetValidatorSetPreference)(nil), "osmosis.valsetpref.v1beta1.MsgSetValidatorSetPreference") + proto.RegisterType((*MsgSetValidatorSetPreferenceResponse)(nil), "osmosis.valsetpref.v1beta1.MsgSetValidatorSetPreferenceResponse") + proto.RegisterType((*MsgDelegateToValidatorSet)(nil), "osmosis.valsetpref.v1beta1.MsgDelegateToValidatorSet") + proto.RegisterType((*MsgDelegateToValidatorSetResponse)(nil), "osmosis.valsetpref.v1beta1.MsgDelegateToValidatorSetResponse") + proto.RegisterType((*MsgUndelegateFromValidatorSet)(nil), "osmosis.valsetpref.v1beta1.MsgUndelegateFromValidatorSet") + proto.RegisterType((*MsgUndelegateFromValidatorSetResponse)(nil), "osmosis.valsetpref.v1beta1.MsgUndelegateFromValidatorSetResponse") + proto.RegisterType((*MsgWithdrawDelegationRewards)(nil), "osmosis.valsetpref.v1beta1.MsgWithdrawDelegationRewards") + proto.RegisterType((*MsgWithdrawDelegationRewardsResponse)(nil), "osmosis.valsetpref.v1beta1.MsgWithdrawDelegationRewardsResponse") } func init() { - proto.RegisterFile("osmosis/validator-preference/v1beta1/tx.proto", fileDescriptor_fa9fa79f914b826d) -} - -var fileDescriptor_fa9fa79f914b826d = []byte{ - // 530 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x8b, 0xd3, 0x40, - 0x1c, 0xed, 0x6c, 0x55, 0xd8, 0xe9, 0x45, 0xc2, 0x22, 0x6d, 0xd0, 0xb4, 0x66, 0xd5, 0xed, 0xa5, - 0x19, 0x1b, 0x2f, 0xe2, 0x41, 0x34, 0xca, 0x82, 0x42, 0x41, 0xb2, 0xfe, 0x81, 0x3d, 0x08, 0x93, - 0x66, 0xcc, 0x06, 0xdb, 0x4c, 0xc9, 0x6f, 0xec, 0xee, 0x7e, 0x0b, 0x3f, 0x82, 0x57, 0x45, 0xd8, - 0x83, 0x5f, 0x62, 0xf1, 0xb4, 0x47, 0x4f, 0x55, 0xda, 0x6f, 0xb0, 0x9f, 0x40, 0x92, 0x4c, 0x27, - 0x3d, 0x6c, 0x6a, 0x68, 0xdd, 0x53, 0x0b, 0xf3, 0x7b, 0xef, 0xf7, 0x5e, 0xde, 0x1b, 0x06, 0x77, - 0x38, 0x0c, 0x39, 0x84, 0x40, 0xc6, 0x74, 0x10, 0xfa, 0x54, 0xf0, 0xb8, 0x33, 0x8a, 0xd9, 0x07,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03, 0xfd, 0x99, 0x1a, 0xe8, 0xf3, 0xcc, - 0xa8, 0x9c, 0xcd, 0x8c, 0xca, 0xaf, 0x99, 0x51, 0xd9, 0x7f, 0xb2, 0x70, 0x3f, 0xe5, 0xba, 0xce, - 0x80, 0x7a, 0x40, 0xd4, 0xe3, 0xd1, 0xb5, 0xc9, 0xd1, 0xc5, 0x4f, 0x48, 0x7a, 0x7b, 0xbd, 0x6b, - 0xe9, 0xdb, 0xf1, 0xe0, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x83, 0x26, 0x47, 0xf9, 0x06, - 0x00, 0x00, + proto.RegisterFile("osmosis/valset-pref/v1beta1/tx.proto", fileDescriptor_daa95be02b2fc560) +} + +var fileDescriptor_daa95be02b2fc560 = []byte{ + // 531 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4d, 0x8b, 0xd3, 0x40, + 0x18, 0xee, 0x6c, 0x17, 0x61, 0xa7, 0x17, 0x09, 0x8b, 0xb4, 0x41, 0xd3, 0x1a, 0x57, 0xdb, 0x4b, + 0x33, 0xb4, 0x8b, 0xf8, 0x01, 0x82, 0x56, 0xf1, 0x56, 0xd0, 0xac, 0x1f, 0xe0, 0x41, 0x98, 0x34, + 0xef, 0x66, 0x83, 0x49, 0x26, 0x64, 0xc6, 0xfd, 0xf8, 0x13, 0xe2, 0x4d, 0xf0, 0x27, 0x78, 0xf1, + 0xe0, 0x2f, 0xf0, 0xb6, 0xc7, 0x3d, 0x7a, 0xaa, 0xd2, 0x1e, 0xbc, 0xef, 0x2f, 0x90, 0x7c, 0xec, + 0x6c, 0x05, 0x27, 0x81, 0xe0, 0x9e, 0x5a, 0x98, 0xe7, 0x79, 0xde, 0xe7, 0xc9, 0xfb, 0xcc, 0xe0, + 0x2d, 0xc6, 0x43, 0xc6, 0x7d, 0x4e, 0xf6, 0x69, 0xc0, 0x41, 0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, 0x5e, 0x18, 0xe8, 0x64, 0x61, 0xa0, 0x5f, 0x0b, 0x03, 0x7d, 0x5c, + 0x1a, 0x8d, 0x93, 0xa5, 0xd1, 0xf8, 0xb1, 0x34, 0x1a, 0x6f, 0xee, 0xac, 0xdc, 0xab, 0x62, 0xca, + 0x30, 0xa0, 0x0e, 0x27, 0xf2, 0x89, 0x1f, 0x6d, 0x93, 0xc3, 0xbf, 0x1e, 0xfa, 0xec, 0xb2, 0x39, + 0x97, 0xb2, 0x17, 0x7e, 0xfb, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xc6, 0xbb, 0x74, 0x84, + 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -482,7 +482,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) SetValidatorSetPreference(ctx context.Context, in *MsgSetValidatorSetPreference, opts ...grpc.CallOption) (*MsgSetValidatorSetPreferenceResponse, error) { out := new(MsgSetValidatorSetPreferenceResponse) - err := c.cc.Invoke(ctx, "/osmosis.validatorpreference.v1beta1.Msg/SetValidatorSetPreference", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.valsetpref.v1beta1.Msg/SetValidatorSetPreference", in, out, opts...) if err != nil { return nil, err } @@ -491,7 +491,7 @@ func (c *msgClient) SetValidatorSetPreference(ctx context.Context, in *MsgSetVal func (c *msgClient) DelegateToValidatorSet(ctx context.Context, in *MsgDelegateToValidatorSet, opts ...grpc.CallOption) (*MsgDelegateToValidatorSetResponse, error) { out := new(MsgDelegateToValidatorSetResponse) - err := c.cc.Invoke(ctx, "/osmosis.validatorpreference.v1beta1.Msg/DelegateToValidatorSet", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.valsetpref.v1beta1.Msg/DelegateToValidatorSet", in, out, opts...) if err != nil { return nil, err } @@ -500,7 +500,7 @@ func (c *msgClient) DelegateToValidatorSet(ctx context.Context, in *MsgDelegateT func (c *msgClient) UndelegateFromValidatorSet(ctx context.Context, in *MsgUndelegateFromValidatorSet, opts ...grpc.CallOption) (*MsgUndelegateFromValidatorSetResponse, error) { out := new(MsgUndelegateFromValidatorSetResponse) - err := c.cc.Invoke(ctx, "/osmosis.validatorpreference.v1beta1.Msg/UndelegateFromValidatorSet", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.valsetpref.v1beta1.Msg/UndelegateFromValidatorSet", in, out, opts...) if err != nil { return nil, err } @@ -509,7 +509,7 @@ func (c *msgClient) UndelegateFromValidatorSet(ctx context.Context, in *MsgUndel func (c *msgClient) WithdrawDelegationRewards(ctx context.Context, in *MsgWithdrawDelegationRewards, opts ...grpc.CallOption) (*MsgWithdrawDelegationRewardsResponse, error) { out := new(MsgWithdrawDelegationRewardsResponse) - err := c.cc.Invoke(ctx, "/osmosis.validatorpreference.v1beta1.Msg/WithdrawDelegationRewards", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.valsetpref.v1beta1.Msg/WithdrawDelegationRewards", in, out, opts...) if err != nil { return nil, err } @@ -564,7 +564,7 @@ func _Msg_SetValidatorSetPreference_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.validatorpreference.v1beta1.Msg/SetValidatorSetPreference", + FullMethod: "/osmosis.valsetpref.v1beta1.Msg/SetValidatorSetPreference", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).SetValidatorSetPreference(ctx, req.(*MsgSetValidatorSetPreference)) @@ -582,7 +582,7 @@ func _Msg_DelegateToValidatorSet_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.validatorpreference.v1beta1.Msg/DelegateToValidatorSet", + FullMethod: "/osmosis.valsetpref.v1beta1.Msg/DelegateToValidatorSet", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).DelegateToValidatorSet(ctx, req.(*MsgDelegateToValidatorSet)) @@ -600,7 +600,7 @@ func _Msg_UndelegateFromValidatorSet_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.validatorpreference.v1beta1.Msg/UndelegateFromValidatorSet", + FullMethod: "/osmosis.valsetpref.v1beta1.Msg/UndelegateFromValidatorSet", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).UndelegateFromValidatorSet(ctx, req.(*MsgUndelegateFromValidatorSet)) @@ -618,7 +618,7 @@ func _Msg_WithdrawDelegationRewards_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.validatorpreference.v1beta1.Msg/WithdrawDelegationRewards", + FullMethod: "/osmosis.valsetpref.v1beta1.Msg/WithdrawDelegationRewards", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).WithdrawDelegationRewards(ctx, req.(*MsgWithdrawDelegationRewards)) @@ -627,7 +627,7 @@ func _Msg_WithdrawDelegationRewards_Handler(srv interface{}, ctx context.Context } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "osmosis.validatorpreference.v1beta1.Msg", + ServiceName: "osmosis.valsetpref.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -648,7 +648,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/validator-preference/v1beta1/tx.proto", + Metadata: "osmosis/valset-pref/v1beta1/tx.proto", } func (m *MsgSetValidatorSetPreference) Marshal() (dAtA []byte, err error) { diff --git a/x/valset-pref/validator_set.go b/x/valset-pref/validator_set.go new file mode 100644 index 00000000000..daf0f0dc081 --- /dev/null +++ b/x/valset-pref/validator_set.go @@ -0,0 +1,89 @@ +package keeper + +import ( + "fmt" + "sort" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" +) + +func (k Keeper) SetupValidatorSetPreference(ctx sdk.Context, delegator string, preferences []types.ValidatorPreference) error { + // check if a user already has a validator-set created + existingValidators, found := k.GetValidatorSetPreference(ctx, delegator) + if found { + // check if the new preferences is the same as the existing preferences + isEqual := k.IsValidatorSetEqual(preferences, existingValidators.Preferences) + if isEqual { + return fmt.Errorf("The preferences (validator and weights) are the same") + } + } + + // checks that all the validators exist on chain + isValid := k.IsPreferenceValid(ctx, preferences) + if !isValid { + return fmt.Errorf("The validator preference list is not valid") + } + + return nil +} + +// GetValAddrAndVal checks if the validator address is valid and the validator provided exists on chain. +func (k Keeper) getValAddrAndVal(ctx sdk.Context, valOperAddress string) (sdk.ValAddress, stakingtypes.Validator, error) { + valAddr, err := sdk.ValAddressFromBech32(valOperAddress) + if err != nil { + return nil, stakingtypes.Validator{}, fmt.Errorf("validator address not formatted") + } + + validator, found := k.stakingKeeper.GetValidator(ctx, valAddr) + if !found { + return nil, stakingtypes.Validator{}, fmt.Errorf("validator not found %s", validator) + } + + return valAddr, validator, nil +} + +// IsPreferenceValid loops through the validator preferences and checks its existence and validity. +func (k Keeper) IsPreferenceValid(ctx sdk.Context, preferences []types.ValidatorPreference) bool { + for _, val := range preferences { + _, _, err := k.getValAddrAndVal(ctx, val.ValOperAddress) + if err != nil { + return false + } + } + return true +} + +// IsValidatorSetEqual returns true if the two preferences are equal. +func (k Keeper) IsValidatorSetEqual(newPreferences, existingPreferences []types.ValidatorPreference) bool { + var isEqual bool + // check if the two validator-set length are equal + if len(newPreferences) != len(existingPreferences) { + return false + } + + // sort the new validator-set + sort.Slice(newPreferences, func(i, j int) bool { + return newPreferences[i].ValOperAddress < newPreferences[j].ValOperAddress + }) + + // sort the existing validator-set + sort.Slice(existingPreferences, func(i, j int) bool { + return existingPreferences[i].ValOperAddress < existingPreferences[j].ValOperAddress + }) + + // make sure that both valAddress and weights cannot be the same in the new val-set + // if we just find one difference between two sets we can guarantee that they are different + for i := range newPreferences { + if newPreferences[i].ValOperAddress != existingPreferences[i].ValOperAddress || + !newPreferences[i].Weight.Equal(existingPreferences[i].Weight) { + isEqual = false + break + } else { + isEqual = true + } + } + + return isEqual +} diff --git a/x/valset-pref/valpref-module/module.go b/x/valset-pref/valpref-module/module.go new file mode 100644 index 00000000000..36ec64bc5d4 --- /dev/null +++ b/x/valset-pref/valpref-module/module.go @@ -0,0 +1,189 @@ +package validator_preference + +import ( + "context" + "encoding/json" + "fmt" + "math/rand" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + + keeper "github.com/osmosis-labs/osmosis/v13/x/valset-pref" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + validatorprefclient "github.com/osmosis-labs/osmosis/v13/x/valset-pref/client" + "github.com/osmosis-labs/osmosis/v13/x/valset-pref/client/queryproto" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.Codec +} + +func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types. +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return nil +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + return nil +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + queryproto.RegisterQueryHandlerClient(context.Background(), mux, queryproto.NewQueryClient(clientCtx)) //nolint:errcheck +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return nil +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the capability module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the x/valset-pref module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { + return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName) + } +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper)) + queryproto.RegisterQueryServer(cfg.QueryServer(), validatorprefclient.NewQuerier(am.keeper)) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + return nil +} + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ___________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the pool-incentives module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +} + +// ProposalContents doesn't return any content functions for governance proposals. +func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { + return []simtypes.WeightedProposalContent{} +} + +// RandomizedParams creates randomized pool-incentives param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return nil +} + +// RegisterStoreDecoder registers a decoder for supply module's types. +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +} + +// WeightedOperations returns the all the module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} + +func (am AppModule) ConsensusVersion() uint64 { + return 1 +}