-
Notifications
You must be signed in to change notification settings - Fork 24
sSCRT staking #120
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
sSCRT staking #120
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c6e2547
rough
e19f1f4
renamed some things
3c7dfb7
building
a35f30a
switch snip20 to permit branch
e2939e9
mocked up treasury interface, building, needs testing
c7bf0a3
added scrt_staking to makefile
d47eab9
updated toml
2239a0a
basic sending/staking working, needs collection/undbonding testing
dd07856
Merge remote-tracking branch 'origin/dev' into sscrt_staking
9c780e1
working for staking and unbonding, need claim testing & unit tests
3504bfc
rm cargo lock
f410bf0
added headings for readme
983a836
removed unused and reorganized
453eea1
admin only unbond
730100a
fixed goof
57a7bfa
owner to admin
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[submodule "contracts/snip20"] | ||
path = contracts/snip20 | ||
url = git@github.com:enigmampc/snip20-reference-impl.git | ||
branch = master | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
[package] | ||
name = "scrt_staking" | ||
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"] | ||
|
||
[profile.release] | ||
opt-level = 3 | ||
debug = false | ||
rpath = false | ||
lto = true | ||
debug-assertions = false | ||
codegen-units = 1 | ||
panic = 'abort' | ||
incremental = false | ||
overflow-checks = true | ||
|
||
[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-schema = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" } | ||
cosmwasm-std = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print", features = ["staking"] } | ||
|
||
cosmwasm-storage = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" } | ||
secret-toolkit = { git = "https://github.com/enigmampc/secret-toolkit", branch = "debug-print"} | ||
shade-protocol = { version = "0.1.0", path = "../../packages/shade_protocol" } | ||
schemars = "0.7" | ||
serde = { version = "1.0.103", default-features = false, features = ["derive"] } | ||
snafu = { version = "0.6.3" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# sSCRT Staking Contract | ||
* [Introduction](#Introduction) | ||
* [Sections](#Sections) | ||
* [Init](#Init) | ||
* [Admin](#Admin) | ||
* Messages< 10000 /td> | ||
* [UpdateConfig](#UpdateConfig) | ||
* [Receive](#Receive) | ||
* [Unbond](#Unbond) | ||
* [Claim](#Claim) | ||
* Queries | ||
* [GetConfig](#GetConfig) | ||
* [Delegations](#Delegations) | ||
* [Delegation](#Delegation) | ||
# Introduction | ||
The sSCRT Staking contract receives sSCRT, redeems it for SCRT, then stakes it with a validator that falls within the criteria it has been configured with. The configured `treasury` will receive all funds from claiming rewards/unbonding. | ||
|
||
# Sections | ||
|
||
## Init | ||
##### Request | ||
|Name |Type |Description | optional | | ||
|----------|----------|-------------------------------------------------------------------------------------------------------------------|----------| | ||
|owner | HumanAddr | contract owner/admin; a valid bech32 address; | ||
|treasury | HumanAddre | contract designated to receive all outgoing funds | ||
|sscrt | Contract | sSCRT Snip-20 contract to accept for redemption/staking, all other funds will error | ||
|validator_bounds | ValidatorBounds | criteria defining an acceptable validator to stake with | ||
|
||
## Admin | ||
|
||
### Messages | ||
#### UpdateConfig | ||
Updates the given values | ||
##### Request | ||
|Name |Type |Description | optional | | ||
|----------|----------|-------------------------------------------------------------------------------------------------------------------|----------| | ||
|owner | HumanAddr | contract owner/admin; a valid bech32 address; | ||
|treasury | HumanAddre | contract designated to receive all outgoing funds | ||
|sscrt | Contract | sSCRT Snip-20 contract to accept for redemption/staking, all other funds will error | ||
|validator_bounds | ValidatorBounds | criteria defining an acceptable validator to stake with | ||
|
||
##### Response | ||
```json | ||
{ | ||
"update_config": { | ||
"status": "success" | ||
} | ||
} | ||
``` | ||
|
||
|
||
### Queries | ||
|
||
#### GetConfig | ||
Gets the contract's configuration variables | ||
##### Response | ||
```json | ||
{ | ||
"config": { | ||
"config": { | ||
"owner": "Owner address", | ||
} | ||
} | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# stable | ||
newline_style = "unix" | ||
hard_tabs = false | ||
tab_spaces = 4 | ||
|
||
# unstable... should we require `rustup run nightly cargo fmt` ? | ||
# or just update the style guide when they are stable? | ||
#fn_single_line = true | ||
#format_code_in_doc_comments = true | ||
#overflow_delimited_expr = true | ||
#reorder_impl_items = true | ||
#struct_field_align_threshold = 20 | ||
#struct_lit_single_line = true | ||
#report_todo = "Always" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.