Skip to content

Commit cc7d85a

Browse files
authored
Merge pull request #210 from quasar-finance/main-strategy
Main strategy Rebased branch
2 parents 2444ef1 + 7ad6686 commit cc7d85a

File tree

182 files changed

+4738
-9218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+4738
-9218
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Golang
2525
uses: actions/setup-go@v3
2626
with:
27-
go-version: 1.18
27+
go-version: 1.19
2828
env:
2929
GOOS: ${{ matrix.targetos }}
3030
GOARCH: ${{ matrix.arch }}

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Golang
1919
uses: actions/setup-go@v3
2020
with:
21-
go-version: 1.18
21+
go-version: 1.19
2222
- name: Display go version
2323
run: go version
2424
- name: Go lint
@@ -38,6 +38,6 @@ jobs:
3838
- name: Show versions
3939
run: rustc -V && cargo -V
4040
- name: Rust lint
41-
run: cd smart-contracts && RUSTFLAGS="-Dwarnings" cargo clippy --workspace -- -D warnings
41+
run: cd smart-contracts && RUSTFLAGS="-Dwarnings" cargo clippy --workspace -- -D warnings
4242
- name: Rust format check
4343
run: cd smart-contracts && cargo fmt --all -- --check

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Golang
1919
uses: actions/setup-go@v3
2020
with:
21-
go-version: 1.18
21+
go-version: 1.19
2222
- name: Display go version
2323
run: go version
2424
- name: Run all tests
@@ -43,8 +43,8 @@ jobs:
4343
# uses: docker://cosmwasm/rust-optimizer:0.12.6
4444
# with:
4545
# args: >-
46-
# --rm -v "$(pwd)":/code
47-
# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target
46+
# --rm -v "$(pwd)":/code
47+
# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target
4848
# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry
4949
- name: Compile wasm code
5050
run: cd smart-contracts && 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
@@ -59,7 +59,7 @@ jobs:
5959
- name: Setup Golang
6060
uses: actions/setup-go@v3
6161
with:
62-
go-version: 1.18
62+
go-version: 1.19
6363
- name: Display go version
6464
run: go version
6565
- name: Build Docker Image

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ node_modules/
1515
vue/
1616

1717
smart-contracts/**/artifacts
18-
smart-contracts/**/target
18+
**/target
1919
local_testnet_run-*nodes/

Dockerfile

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
# syntax=docker/dockerfile:1
22

33
ARG GO_VERSION="1.19"
4-
ARG RUNNER_IMAGE="gcr.io/distroless/static"
4+
ARG RUNNER_IMAGE="ubuntu"
55

66
# --------------------------------------------------------
77
# Builder
88
# --------------------------------------------------------
99

10-
FROM golang:${GO_VERSION}-alpine as builder
10+
FROM golang:${GO_VERSION}-buster as builder
1111

12-
RUN apk add --no-cache \
13-
git \
14-
ca-certificates \
15-
build-base \
16-
linux-headers
1712

1813
# Download go dependencies
1914
WORKDIR /quasar
@@ -22,13 +17,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
2217
--mount=type=cache,target=/root/go/pkg/mod \
2318
go mod download
2419

25-
# Cosmwasm - Download correct libwasmvm version
26-
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
27-
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \
28-
-O /lib/libwasmvm_muslc.a && \
29-
# verify checksum
30-
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
31-
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1)
20+
3221

3322
# Copy the remaining files
3423
COPY . .
@@ -37,9 +26,7 @@ COPY . .
3726
# force it to use static lib (from above) not standard libgo_cosmwasm.so file
3827
# then log output of file /quasar/build/quasarnoded
3928
# then ensure static linking
40-
RUN --mount=type=cache,target=/root/.cache/go-build \
41-
--mount=type=cache,target=/root/go/pkg/mod \
42-
LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build
29+
RUN go build -o build/quasarnoded ./cmd/quasarnoded
4330

4431
# --------------------------------------------------------
4532
# Runner

Makefile

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,6 @@ MOCKSDIR = $(CURDIR)/testutil/mock
1212

1313
export GO111MODULE = on
1414

15-
# process build tags
16-
17-
build_tags = netgo
18-
ifeq ($(LEDGER_ENABLED),true)
19-
ifeq ($(OS),Windows_NT)
20-
GCCEXE = $(shell where gcc.exe 2> NUL)
21-
ifeq ($(GCCEXE),)
22-
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
23-
else
24-
build_tags += ledger
25-
endif
26-
else
27-
UNAME_S = $(shell uname -s)
28-
ifeq ($(UNAME_S),OpenBSD)
29-
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
30-
else
31-
GCC = $(shell command -v gcc 2> /dev/null)
32-
ifeq ($(GCC),)
33-
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
34-
else
35-
build_tags += ledger
36-
endif
37-
endif
38-
endif
39-
endif
40-
41-
ifeq (cleveldb,$(findstring cleveldb,$(QUASAR_BUILD_OPTIONS)))
42-
build_tags += gcc
43-
else ifeq (rocksdb,$(findstring rocksdb,$(QUASAR_BUILD_OPTIONS)))
44-
build_tags += gcc
45-
endif
46-
build_tags += $(BUILD_TAGS)
47-
build_tags := $(strip $(build_tags))
4815

4916
whitespace :=
5017
whitespace += $(whitespace)
@@ -59,11 +26,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=quasar \
5926
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
6027
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
6128

62-
ifeq (cleveldb,$(findstring cleveldb,$(QUASAR_BUILD_OPTIONS)))
63-
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
64-
else ifeq (rocksdb,$(findstring rocksdb,$(QUASAR_BUILD_OPTIONS)))
65-
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
66-
endif
29+
6730
ifeq (,$(findstring nostrip,$(QUASAR_BUILD_OPTIONS)))
6831
ldflags += -w -s
6932
endif
@@ -90,7 +53,7 @@ BUILD_TARGETS := build install
9053
build: BUILD_ARGS=-o $(BUILDDIR)/
9154

9255
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
93-
GOWORK=off go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/quasarnoded
56+
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/quasarnoded
9457

9558
$(BUILDDIR)/:
9659
mkdir -p $(BUILDDIR)/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# LP-strategy demo
2+
3+
## Introduction
4+
The LP strategy demo shows how to test the current version of the LP-strategy. This current version only executes the actual strategy part of the LP-strategy, meaning sending tokens to osmosis, joining a pool through join-swap extern-amount-in and locking the tokens.
5+
6+
## setup
7+
To get this demo working, at the minimum a local [osmosis](https://github.com/osmosis-labs/osmosis) release >= v13 such as the [13.1.2](https://github.com/osmosis-labs/osmosis/releases/tag/v13.1.2) release, the local quasarnoded contained in this repo and the [go relayer](https://github.com/cosmos/relayer/releases/tag/v2.1.2). Optionally, if packet forwarding needs to be tested aswell, a local chain of that token is also needed. Most logical is to try this with [gaiad](https://github.com/cosmos/gaia/releases/tag/v7.1.0) for uatom.
8+
9+
## execution
10+
the `run_all.sh` script sets up the local chains, and starts to run the go relayer. The current setup of the go relayer assumes that a local gaiad instance is running. Through `create_and_execute_contract.sh`, a contract is setup and a channel between the contract and the ica host on osmosis is made. The contract is now ready to be interacted with.
11+
12+
## what's where
13+
The contract currently provides 2 entry points: `TransferJoinLock` and `DepositAndLockTokens`; `TransferJoinLock` is the entrypoint as expected to be used and called by the bookkeeping vault. `DepositAndLockTokens` allows for more parameters to be set by the caller. This message does not trigger a transfer. Eventually this will be removed and replaced with better testing setups.
14+
15+
Internally, after one of the two initial execute messages is called, an ibc packet is dispatched, the sequence number is saved and an enum is saved. On the ibc ack, the original message's enum is looked up in the contracts state and a new ibc message is dispatched. The message are done in the following order. ibc_transfer -> join_pool_extern_swap_amount_in -> lock_tokens. ibc acks to transfer messages are provided by our local transfer decorator, found in `decorators/ibc_transfer_wasm_decorator.go`

demos/orion-manual-demo/cosmos_localnet.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/zsh
1+
#!/bin/sh
22

33
# Configure variables
44
BINARY=gaiad

demos/orion-manual-demo/create_and_execute_contract.sh

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ RPC="http://127.0.0.1:26659"
77
NODE="--node $RPC"
88
TXFLAG="$NODE --chain-id $CHAIN_ID --gas-prices 10$FEE_DENOM --gas auto --gas-adjustment 1.3"
99
echo $NODE
10-
# the callback_address is the address of the orion module
11-
INIT='{"callback_address":"quasar14yjkz7yxapuee3d7qkhwzlumwrarayfh0pycxc"}'
12-
MSG='{"register_ica_on_zone":{"zone_id":"osmosis"}}'
10+
# lock_period is 60 for 60 sec, in prod should be at least: 60 sec/min * 60 min/hr * 24hr * 14days "1209600"
11+
# pool_id is hardcoded to 1 for this testing setup, expected to be done by the instantiater on local/testnet
12+
# pool_denom should be looked up and hardcoded aswell
13+
# base_denom: base_denom should be the denom of the token on osmosos, for now uosmo
14+
# local_denom: the denom of the token used locally, in this testing case: the denom of the path transfer/channel-1/uosmo
15+
# quote_denom is the denom other denom in the pool, stake for now
16+
INIT='{"lock_period":60,"pool_id":1,"pool_denom":"gamm/pool/1","base_denom":"uosmo","local_denom":"ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B","quote_denom":"stake","return_source_channel":"channel-0","transfer_channel":"channel-1"}'
1317

1418
cd ../../smart-contracts
1519

1620
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
1721

1822
echo "Running store code"
19-
RES=$(quasarnoded tx wasm store artifacts/intergamm_bindings_test.wasm --from alice --keyring-backend test -y --output json -b block $TXFLAG)
23+
RES=$(quasarnoded tx wasm store artifacts/lp_strategy.wasm --from alice --keyring-backend test -y --output json -b block $TXFLAG)
2024
CODE_ID=$(echo $RES | jq -r '.logs[0].events[-1].attributes[0].value')
2125
echo "Got CODE_ID = $CODE_ID"
2226

@@ -26,7 +30,26 @@ OUT=$(quasarnoded tx wasm instantiate $CODE_ID "$INIT" --from alice --keyring-ba
2630
ADDR=$(quasarnoded query wasm list-contract-by-code $CODE_ID --output json $NODE | jq -r '.contracts[0]')
2731
echo "Got address of deployed contract = $ADDR"
2832

29-
echo "Executing register ica message... ('$MSG')"
30-
quasarnoded tx wasm execute $ADDR "$MSG" -y --from alice --keyring-backend test --gas-prices 10$FEE_DENOM --gas auto --gas-adjustment 1.3 $NODE --chain-id $CHAIN_ID
33+
rly transact channel quasar_osmosis --src-port "wasm.$ADDR" --dst-port icqhost --order unordered --version icq-1 --override
34+
rly transact channel quasar_osmosis --src-port "wasm.$ADDR" --dst-port icahost --order ordered --version '{"version":"ics27-1","encoding":"proto3","tx_type":"sdk_multi_msg","controller_connection_id":"connection-1","host_connection_id":"connection-0"}' --override
3135

36+
QMSG='{"channels": {}}'
37+
CADDR=$(quasarnoded query wasm contract-state smart $ADDR "$QMSG" --output json | jq '.data.channels[] | select(.counterparty_endpoint.port_id=="icahost").channel_type.ica.counter_party_address')
38+
CCHAN=$(quasarnoded query wasm contract-state smart $ADDR "$QMSG" --output json | jq '.data.channels[] | select(.counterparty_endpoint.port_id=="icahost").id')
39+
40+
41+
AMOUNT="100000uosmo"
42+
HOME_OSMOSIS=$HOME/.osmosis
43+
# echo $CADDR
44+
# echo "preloading the ICA address with $AMOUNT to play around with"
45+
BANKTX=$(printf 'osmosisd tx bank send bob %s %s -y --keyring-backend test --node tcp://localhost:26679 --chain-id osmosis --gas 583610 --home %s' $CADDR $AMOUNT $HOME_OSMOSIS)
46+
echo $BANKTX
47+
# $BANKTX
48+
49+
# BONDMSG='{"bond": {"id": "my-id"}}'
50+
# BOND=$(printf 'quasarnoded tx wasm execute %s '%s' -y --from alice --keyring-backend test --gas-prices 10uqsr --gas auto --gas-adjustment 1.3 --node http://127.0.0.1:26659 --chain-id quasar --amount 1000ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817\n' $ADDR $BONDMSG)
51+
52+
# echo "bonding tokens, to replay: "
53+
# echo $BOND
54+
# $BOND
3255
cd -

demos/orion-manual-demo/hermes_config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Specify the verbosity for the relayer logging output. Default: 'info'
55
# Valid options are 'error', 'warn', 'info', 'debug', 'trace'.
6-
log_level = 'debug'
6+
log_level = 'info'
77

88

99
# Specify the mode to be used by the relayer. [Required]

0 commit comments

Comments
 (0)