Skip to content
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

depositor v1 #7

Merged
merged 21 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
[workspace.package]
edition = "2021"
license = "BSD-3"
rust-version = "1.67"
rust-version = "1.66"
version = "0.1.0"

[profile.release]
Expand Down Expand Up @@ -42,6 +42,7 @@ cw-fifo = { path = "packages/cw-fifo" }

covenant-clock = { path = "contracts/clock" }
covenant-clock-tester = { path = "contracts/clock-tester" }
covenant-depositor = { path = "contracts/depositor" }

# dev-dependencies
cw-multi-test = "0.16"
Expand Down
6 changes: 6 additions & 0 deletions contracts/depositor/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib --features backtraces"
integration-test = "test --test integration"
schema = "run --example schema"
83 changes: 83 additions & 0 deletions contracts/depositor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[package]
name = "stride-depositor"
version = "0.0.1"
edition = "2021"
authors = ["benskey [email protected]"]
description = "Depositor module for stride covenant"
license = "BSD-3"

exclude = [
"contract.wasm",
"hash.txt",
]

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = 3
debug = true
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-schema = "1.2.1"
cosmwasm-std = { version = "1.2.4", features = ["ibc3"] }
cw-storage-plus = "1.0.1"
cw-utils = "1.0.1"
cw2 = "1.0.1"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
thiserror = "1.0.31"
# the sha2 version here is the same as the one used by
# cosmwasm-std. when bumping cosmwasm-std, this should also be
# updated. to find cosmwasm_std's sha function:
# ```cargo tree --package cosmwasm-std```
sha2 = "0.10.6"
neutron-sdk = { git = "https://github.com/neutron-org/neutron-sdk", default-features = false, version = "0.5.0" }
cosmos-sdk-proto = { version = "0.14.0", default-features = false }
protobuf = { version = "3.2.0", features = ["with-bytes"] }
schemars = "0.8.10"
serde-json-wasm = { version = "0.4.1" }
base64 = "0.13.0"
prost = "0.11"
prost-types = "0.11"
bech32 = "0.9.0"

# cosmwasm-schema = { workspace = true }
# cosmwasm-std = { workspace = true }
# cw-storage-plus = { workspace = true }
# serde = { workspace = true }
# cw2 = { workspace = true }
# thiserror = { workspace = true }
# cw-multi-test = { workspace = true }
# neutron-sdk = { workspace = true }
# cosmos-sdk-proto = { workspace = true }
# protobuf = { workspace = true }
# schemars = { workspace = true }
# prost = { workspace = true }
# prost-types = { workspace = true }
# serde-json-wasm = { workspace = true }


# # the sha2 version here is the same as the one used by
# # cosmwasm-std. when bumping cosmwasm-std, this should also be
# # updated. to find cosmwasm_std's sha function:
# # ```cargo tree --package cosmwasm-std```
# sha2 = { workspace = true }

# dev-dependencies
[dev-dependencies]
cw-multi-test = "0.16.2"
anyhow = { version = "1.0.51" }
# cw-multi-test = { workspace = true }
# anyhow = { workspace = true }
29 changes: 29 additions & 0 deletions contracts/depositor/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Copyright 2023 Timewave

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 11 additions & 0 deletions contracts/depositor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Depositor

This module is the depositor in stride-covenant system.
It is responsible for the following tasks:
1. Instantiating an ICA on gaia
1. Transfering Atom from gaia ICA to itself via IBC
1. Splitting the available Atom in half and funding the LP and LS modules

The contract determines the next actions to take purely based on its own state.
After receiving a `tick: {}` message from the clock, it attempts to advance the state.

22 changes: 22 additions & 0 deletions contracts/depositor/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use cosmwasm_schema::{export_schema, remove_schemas, schema_for};
use stride_depositor::msg::{InstantiateMsg, ExecuteMsg, QueryMsg};
use neutron_sdk::bindings::query::QueryInterchainAccountAddressResponse;
use neutron_sdk::sudo::msg::SudoMsg;
use std::env::current_dir;
use std::fs::create_dir_all;

fn main() {
let mut out_dir = current_dir().unwrap();
out_dir.push("schema");
create_dir_all(&out_dir).unwrap();
remove_schemas(&out_dir).unwrap();

export_schema(&schema_for!(InstantiateMsg), &out_dir);
export_schema(&schema_for!(SudoMsg), &out_dir);
export_schema(&schema_for!(QueryMsg), &out_dir);
export_schema(&schema_for!(ExecuteMsg), &out_dir);
export_schema(
&schema_for!(QueryInterchainAccountAddressResponse),
&out_dir,
);
}
32 changes: 32 additions & 0 deletions contracts/depositor/schema/execute_msg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExecuteMsg",
"oneOf": [
{
"type": "object",
"required": [
"tick"
],
"properties": {
"tick": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"received"
],
"properties": {
"received": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
48 changes: 48 additions & 0 deletions contracts/depositor/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "InstantiateMsg",
"type": "object",
"required": [
"atom_receiver",
"clock_address",
"st_atom_receiver"
],
"properties": {
"atom_receiver": {
"$ref": "#/definitions/WeightedReceiver"
},
"clock_address": {
"$ref": "#/definitions/Addr"
},
"st_atom_receiver": {
"$ref": "#/definitions/WeightedReceiver"
}
},
"additionalProperties": false,
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
},
"WeightedReceiver": {
"type": "object",
"required": [
"address",
"amount"
],
"properties": {
"address": {
"type": "string"
},
"amount": {
"$ref": "#/definitions/Uint128"
}
},
"additionalProperties": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "QueryInterchainAccountAddressResponse",
"type": "object",
"required": [
"interchain_account_address"
],
"properties": {
"interchain_account_address": {
"description": "*interchain_account_address** is a interchain account address on the remote chain",
"type": "string"
}
}
}
45 changes: 45 additions & 0 deletions contracts/depositor/schema/query_msg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "QueryMsg",
"oneOf": [
{
"type": "object",
"required": [
"st_atom_receiver"
],
"properties": {
"st_atom_receiver": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"atom_receiver"
],
"properties": {
"atom_receiver": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"clock_address"
],
"properties": {
"clock_address": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
Loading