8000 Lp shade swap by DrPresident · Pull Request #213 · securesecrets/shade · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Lp shade swap #213

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c16913c
merged
DrPresident May 10, 2022
e909d53
rough LP token contract, needs integration with shadeswap
DrPresident May 11, 2022
58777fc
mostly there, needs actual shadeswap integration
DrPresident May 12, 2022
720c013
beginning treasury ensemble
DrPresident May 12, 2022
d35e1f7
Merge remote-tracking branch 'origin/dev' into lp-shade-swap
DrPresident May 12, 2022
04db970
integration env setup, need to execute a few more things
DrPresident May 12, 2022
7490ce3
added dao harnesses
DrPresident May 12, 2022
639d5b0
Update dao.drawio
DrPresident May 13, 2022
cb436c9
Update dao.drawio
DrPresident May 13, 2022
49f5218
Update dao.drawio
DrPresident May 13, 2022
12020ea
Update dao.drawio
DrPresident May 13, 2022
cac9b8b
added reserves to adapter
DrPresident May 13, 2022
1ab6e39
some updates to things
DrPresident May 13, 2022
5326e0c
added make <package>
DrPresident May 13, 2022
58fd2cb
contract harness now working
DrPresident May 13, 2022
8a7ed96
Update dao.drawio
DrPresident May 13, 2022
f5ed77c
Merge remote-tracking branch 'origin/dev' into lp-shade-swap
DrPresident May 13, 2022
5a7bd3d
refactored for changes
DrPresident May 13, 2022
e594b5f
updated treasury rebalance and started move of treasury.accounts to t…
DrPresident May 16, 2022
3b36aeb
all builds are release
DrPresident May 16, 2022
26ef261
harness issue seems to be fixed
DrPresident May 16, 2022
8073307
updated integration tests
DrPresident May 16, 2022
8d60d44
ws removal
DrPresident May 16, 2022
be195bc
todo: factor in holders to unbond/claim/recv
DrPresident May 16, 2022
242aa49
governance update
DrPresident May 16, 2022
61f557b
governance test update
DrPresident May 16, 2022
dd0dfe8
moved accounts in treasury to treasury manager holders
DrPresident May 19, 2022
bb959e3
treasury/manager/scrtstaking building with refactor
DrPresident May 19, 2022
74aea3e
updated treasury integration for changes
DrPresident May 19, 2022
96d2973
small change
DrPresident May 24, 2022
e614567
basic manager test, needs some query work on manager
DrPresident May 24, 2022
019a3f5
Merge branch 'dev' into lp-shade-swap
DrPresident Jun 1, 2022
1ef5374
added commented 2nd test
DrPresident May 24, 2022
f7a333d
added mock sienna harness
DrPresident Jun 10, 2022
cb5e192
updated sky
DrPresident Jun 13, 2022
f664689
some adjustments to get sky building
DrPresident Jun 14, 2022
6305648
removed dead tests
DrPresident Jun 14, 2022
a69fc34
fadroma adjustment
DrPresident Jun 14, 2022
c382539
some conflicts resolved
DrPresident Jun 16, 2022
ff2e88f
Merge remote-tracking branch 'origin/dev' into lp-shade-swap
DrPresident Jun 16, 2022
6cf777a
fixes
DrPresident Jun 16, 2022
5b9ee1b
added package building
DrPresident Jun 16, 2022
de42269
network_integration fixes
DrPresident Jun 16, 2022
e50ea06
fixde snip20 harness
DrPresident Jun 16, 2022
ab57374
Merge branch 'dev' into lp-shade-swap
DrPresident Jun 16, 2022
cd969ca
reverted to snip20-reference-impl
DrPresident Jun 16, 2022
e8eb394
fixes
DrPresident Jun 16, 2022
0f7ef7a
Merge branch 'dev' into lp-shade-swap
DrPresident Jun 16, 2022
4fba727
harness adjustment
DrPresident Jun 16, 2022
1d3eaec
updated import
DrPresident Jun 17, 2022
ca559b1
reverted harness
DrPresident Jun 17, 2022
f485013
again some more reverts and fixes
DrPresident Jun 17, 2022
a6c9815
govt fix
DrPresident Jun 17, 2022
0e205b7
revert
DrPresident Jun 17, 2022
fcd56d3
checkout snip20
DrPresident Jun 21, 2022
88e70c4
tests rework for breaking changes
DrPresident Jun 21, 2022
331b308
test update
DrPresident Jun 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
CARGO_TERM_COLOR: always

jobs:
find_contracts: # Job that list subdirectories
find-contracts: # Job that list subdirectories
runs-on: ubuntu-latest
outputs:
dir: ${{ steps.set-dirs.outputs.dir }}
Expand All @@ -15,12 +15,42 @@ jobs:
- id: set-dirs
run: echo "::set-output name=dir::$(find ./contracts/ -name Cargo.toml | jq -R -s -c 'split("\n")[:-1]')"

build:
build-contracts:
runs-on: ubuntu-latest
needs: [find_contracts] # Depends on previous job
needs: [find-contracts] # Depends on previous job
strategy:
matrix:
dir: ${{fromJson(needs.find_contracts.outputs.dir)}} # List matrix strategy from directories dynamically
dir: ${{fromJson(needs.find-contracts.outputs.dir)}} # List matrix strategy from directories dynamically
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown

- uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --release --target wasm32-unknown-unknown --manifest-path=${{matrix.dir}}

find-packages: # Job that list subdirectories
runs-on: ubuntu-latest
outputs:
dir: ${{ steps.set-dirs.outputs.dir }}
steps:
- uses: actions/checkout@v2
- id: set-dirs
run: echo "::set-output name=dir::$(find ./packages/ -name Cargo.toml | jq -R -s -c 'split("\n")[:-1]')"

build-packages:
runs-on: ubuntu-latest
needs: [find-packages] # Depends on previous job
strategy:
matrix:
dir: ${{fromJson(needs.find-packages.outputs.dir)}} # List matrix strategy from directories dynamically
steps:
- uses: actions/checkout@v2
with:
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ members = [
"contracts/oracle",
"contracts/sky",

"contracts/snip20-reference-impl",

# DAO
# - Core
"contracts/treasury",
"contracts/treasury_manager",
# - Adapters
"contracts/scrt_staking",
"contracts/rewards_emission",
"contracts/lp_shade_swap",

"contracts/snip20_staking",

# Mock contracts
"contracts/mock_band",
"contracts/mock_secretswap_pair",
Expand Down
4 changes: 2 additions & 2 deletions contracts/governance/src/tests/handle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn set_config_msg() {
code_hash: snip20.code_hash,
}),
)
.unwrap();
.unwrap().instance;

chain
.execute(
Expand Down Expand Up @@ -114,7 +114,7 @@ fn reject_disable_config_tokens() {
code_hash: snip20.code_hash,
}),
)
.unwrap();
.unwrap().instance;

chain
.execute(
Expand Down
6 changes: 3 additions & 3 deletions contracts/governance/src/tests/handle/proposal/funding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn init_funding_governance_with_proposal() -> StdResult<(
address: "funding_token".into(),
code_hash: snip20.code_hash,
}),
)?;
)?.instance;

// Register governance
let gov = chain.register(Box::new(Governance));
Expand Down Expand Up @@ -106,7 +106,7 @@ fn init_funding_governance_with_proposal() -> StdResult<(
address: "gov".into(),
code_hash: gov.code_hash,
}),
)?;
)?.instance;

chain.execute(
&governance::HandleMsg::AssemblyProposal {
Expand Down Expand Up @@ -309,7 +309,7 @@ fn fake_funding_token() {
code_hash: snip20.code_hash.clone(),
}),
)
.unwrap();
.unwrap().instance;

chain
.execute(
Expand Down
12 changes: 6 additions & 6 deletions contracts/governance/src/tests/handle/proposal/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn init_voting_governance_with_proposal() -> StdResult<(
address: "token".into(),
code_hash: snip20.code_hash,
}),
)?;
)?.instance;

let stkd_tkn = chain.register(Box::new(Snip20Staking));
let stkd_tkn = chain.instantiate(
Expand All @@ -87,7 +87,7 @@ fn init_voting_governance_with_proposal() -> StdResult<(
address: "staked_token".into(),
code_hash: stkd_tkn.code_hash,
}),
)?;
)?.instance;

// Stake tokens
chain.execute(
Expand Down Expand Up @@ -181,7 +181,7 @@ fn init_voting_governance_with_proposal() -> StdResult<(
address: "gov".into(),
code_hash: gov.code_hash,
}),
)?;
)?.instance;

chain.execute(
&governance::HandleMsg::AssemblyProposal {
Expand Down Expand Up @@ -1238,7 +1238,7 @@ fn vote_count_percentage() {
code_hash: snip20.code_hash,
}),
)
.unwrap();
.unwrap().instance;

let stkd_tkn = chain.register(Box::new(Snip20Staking));
let stkd_tkn = chain
Expand Down Expand Up @@ -1267,7 +1267,7 @@ fn vote_count_percentage() {
code_hash: stkd_tkn.code_hash,
}),
)
.unwrap();
.unwrap().instance;

// Stake tokens
chain
Expand Down Expand Up @@ -1369,7 +1369,7 @@ fn vote_count_percentage() {
code_hash: gov.code_hash,
}),
)
.unwrap();
.unwrap().instance;

chain
.execute(
Expand Down
5 changes: 3 additions & 2 deletions contracts/governance/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn init_governance(
address: "gov".into(),
code_hash: gov.code_hash,
}),
)?;
)?.instance;

Ok((chain, gov))
}
Expand Down Expand Up @@ -102,7 +102,8 @@ pub fn gov_msg_proposal(
padding: None,
},
MockEnv::new(sender, gov.clone()),
)
)?;
Ok(())
}

pub fn get_assembly_msgs(
Expand Down
5 changes: 5 additions & 0 deletions contracts/lp_shade_swap/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
unit-test = "test --lib --features backtraces"
integration-test = "test --test integration"
schema = "run --example schema"
52 changes: 52 additions & 0 deletions contracts/lp_shade_swap/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: 2.1

jobs:
build:
docker:
- image: rust:1.43.1
steps:
- checkout
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Add wasm32 target
command: rustup target add wasm32-unknown-unknown
- run:
name: Build
command: cargo wasm --locked
- run:
name: Unit tests
env: RUST_BACKTRACE=1
command: cargo unit-test --locked
- run:
name: Integration tests
command: cargo integration-test --locked
- run:
name: Format source code
command: cargo fmt
- run:
name: Build and run schema generator
command: cargo schema --locked
- run:
name: Ensure checked-in source code and schemas are up-to-date
command: |
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
- save_cache:
paths:
- /usr/local/cargo/registry
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- target/wasm32-unknown-unknown/release/.fingerprint
- target/wasm32-unknown-unknown/release/build
- target/wasm32-unknown-unknown/release/deps
key: v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
41 changes: 41 additions & 0 deletions contracts/lp_shade_swap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "lp_shade_swap"
version = "0.1.0"
authors = ["Jack Swenson <jacksonswenson22@gmail.com>"]
edition = "2018"

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]
default = []
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
debug-print = ["cosmwasm-std/debug-print"]

[dependencies]
cosmwasm-std = { version = "0.10", package = "secret-cosmwasm-std", features = [
"staking",
] }
cosmwasm-storage = { version = "0.10", package = "secret-cosmwasm-storage" }
cosmwasm-schema = "0.10.1"
secret-toolkit = { version = "0.2" }
cosmwasm-math-compat = { path = "../../packages/cosmwasm_math_compat" }
shade-protocol = { version = "0.1.0", path = "../../packages/shade_protocol", features = [
"lp_shade_swap",
"treasury",
"math",
"dex",
] }
schemars = "0.7"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
snafu = { version = "0.6.3" }
68 changes: 68 additions & 0 deletions contracts/lp_shade_swap/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.PHONY: check
check:
cargo check

.PHONY: clippy
clippy:
cargo clippy

PHONY: test
test: unit-test

.PHONY: unit-test
unit-test:
cargo test

# This is a local build with debug-prints activated. Debug prints only show up
# in the local development chain (see the `start-server` command below)
# and mainnet won't accept contracts built with the feature enabled.
.PHONY: build _build
build: _build compress-wasm
_build:
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --features="debug-print"

# This is a build suitable for uploading to mainnet.
# Calls to `debug_print` get removed by the compiler.
.PHONY: build-mainnet _build-mainnet
build-mainnet: _build-mainnet compress-wasm
_build-mainnet:
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown

# like build-mainnet, but slower and more deterministic
.PHONY: build-mainnet-reproducible
build-mainnet-reproducible:
docker run --rm -v "$$(pwd)":/contract \
--mount type=volume,source="$$(basename "$$(pwd)")_cache",target=/contract/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
enigmampc/secret-contract-optimizer:1.0.3

.PHONY: compress-wasm
compress-wasm:
cp ./target/wasm32-unknown-unknown/release/*.wasm ./contract.wasm
@## The following line is not necessary, may work only on linux (extra size optimization)
@# wasm-opt -Os ./contract.wasm -o ./contract.wasm
cat ./contract.wasm | gzip -9 > ./contract.wasm.gz

.PHONY: schema
schema:
cargo run --example schema

# Run local development chain with four funded accounts (named a, b, c, and d)
.PHONY: start-server
start-server: # CTRL+C to stop
docker run -it --rm \
-p 26657:26657 -p 26656:26656 -p 1317:1317 \
-v $$(pwd):/root/code \
--name secretdev enigmampc/secret-network-sw-dev:v1.0.4-3

# This relies on running `start-server` in another console
# You can run other commands on the secretcli inside the dev image
# by using `docker exec secretdev secretcli`.
.PHONY: store-contract-local
store-contract-local:
docker exec secretdev secretcli tx compute store -y --from a --gas 1000000 /root/code/contract.wasm.gz

.PHONY: clean
clean:
cargo clean
-rm -f ./contract.wasm ./contract.wasm.gz
Loading
0