-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from astroport-fi/stt-proxy
[ADDITION] STT Staking Proxy
- Loading branch information
Showing
19 changed files
with
1,396 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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" | ||
wasm-debug = "build --target wasm32-unknown-unknown" | ||
unit-test = "test --lib" | ||
schema = "run --example schema" |
This file contains 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,34 @@ | ||
[package] | ||
name = "generator-proxy-to-stt" | ||
version = "0.0.0" | ||
authors = ["_astromartian"] | ||
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] | ||
# for more explicit tests, cargo test --features=backtraces | ||
backtraces = ["cosmwasm-std/backtraces"] | ||
|
||
[dependencies] | ||
cosmwasm-std = { version = "0.16.0" } | ||
cosmwasm-bignumber = "2.2.0" | ||
cw-storage-plus = "0.8.0" | ||
schemars = "0.8.1" | ||
serde = { version = "1.0.125", default-features = false, features = ["derive"] } | ||
thiserror = { version = "1.0.24" } | ||
cw2 = "0.8.0" | ||
cw20 = "0.8.0" | ||
astroport-generator-proxy = { path = "../../packages/astroport_generator_proxy", default-features = false, version = "1.0.0"} | ||
|
||
[dev-dependencies] | ||
cosmwasm-schema = { version = "0.16.0" } |
This file contains 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,122 @@ | ||
# Generator Proxy to STT LP Staking Rewards | ||
|
||
The generator proxy contract interacts with the STT LP staking contract (the Astroport dual rewards feature). | ||
|
||
StarTerra LP Staking contract implementation: https://github.com/starterra/app-smart-contracts/blob/develop-col5/contracts/staking/src/contract.rs | ||
|
||
The staking via proxy guide is [here](https://miro.medium.com/max/1400/0*8hn2NSnZJZTa9YGV). | ||
|
||
--- | ||
|
||
## InstantiateMsg | ||
|
||
Inits with required contract addresses for depositing and reward distribution. | ||
|
||
```json | ||
{ | ||
"generator_contract_addr": "terra...", | ||
"pair_addr": "terra...", | ||
"lp_token_addr": "terra...", | ||
"reward_contract_addr": "terra...", | ||
"reward_token_addr": "terra..." | ||
} | ||
``` | ||
|
||
## ExecuteMsg | ||
|
||
### `receive` | ||
|
||
CW20 receive msg. | ||
|
||
```json | ||
{ | ||
"receive": { | ||
"sender": "terra...", | ||
"amount": "123", | ||
"msg": "<base64_encoded_json_string>" | ||
} | ||
} | ||
``` | ||
|
||
### `update_rewards` | ||
|
||
Updates token proxy rewards. | ||
|
||
```json | ||
{ | ||
"update_rewards": {} | ||
} | ||
``` | ||
|
||
### `send_rewards` | ||
|
||
Sends token rewards amount for given address. | ||
|
||
```json | ||
{ | ||
"send_rewards": { | ||
"account": "terra...", | ||
"amount": "123" | ||
} | ||
} | ||
``` | ||
|
||
### `withdraw` | ||
|
||
Withdraws token rewards amount for given address. | ||
|
||
```json | ||
{ | ||
"withdraw": { | ||
"account": "terra...", | ||
"amount": "123" | ||
} | ||
} | ||
``` | ||
|
||
### `emergency_withdraw` | ||
|
||
Withdraws token rewards amount for given address. | ||
|
||
```json | ||
{ | ||
"emergency_withdraw": { | ||
"account": "terra...", | ||
"amount": "123" | ||
} | ||
} | ||
``` | ||
|
||
## QueryMsg | ||
|
||
All query messages are described below. A custom struct is defined for each query response. | ||
|
||
### `deposit` | ||
|
||
Returns deposited/staked token amount. | ||
|
||
```json | ||
{ | ||
"deposit": {} | ||
} | ||
``` | ||
|
||
### `reward` | ||
|
||
Gives token proxy reward amount. | ||
|
||
```json | ||
{ | ||
"reward": {} | ||
} | ||
``` | ||
|
||
### `pending_token` | ||
|
||
Gives token proxy reward pending amount. | ||
|
||
```json | ||
{ | ||
"pending_token": {} | ||
} | ||
``` |
This file contains 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,21 @@ | ||
use std::env::current_dir; | ||
use std::fs::create_dir_all; | ||
|
||
use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; | ||
|
||
use astroport_generator_proxy::generator_proxy::{ | ||
Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, | ||
}; | ||
|
||
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!(ExecuteMsg), &out_dir); | ||
export_schema(&schema_for!(Cw20HookMsg), &out_dir); | ||
export_schema(&schema_for!(QueryMsg), &out_dir); | ||
export_schema(&schema_for!(MigrateMsg), &out_dir); | ||
} |
This file contains 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,18 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Cw20HookMsg", | ||
"oneOf": [ | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"deposit" | ||
], | ||
"properties": { | ||
"deposit": { | ||
"type": "object" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
] | ||
} |
This file contains 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,136 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "ExecuteMsg", | ||
"oneOf": [ | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"receive" | ||
], | ||
"properties": { | ||
"receive": { | ||
"$ref": "#/definitions/Cw20ReceiveMsg" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"update_rewards" | ||
], | ||
"properties": { | ||
"update_rewards": { | ||
"type": "object" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"send_rewards" | ||
], | ||
"properties": { | ||
"send_rewards": { | ||
"type": "object", | ||
"required": [ | ||
"account", | ||
"amount" | ||
], | ||
"properties": { | ||
"account": { | ||
"$ref": "#/definitions/Addr" | ||
}, | ||
"amount": { | ||
"$ref": "#/definitions/Uint128" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"withdraw" | ||
], | ||
"properties": { | ||
"withdraw": { | ||
"type": "object", | ||
"required": [ | ||
"account", | ||
"amount" | ||
], | ||
"properties": { | ||
"account": { | ||
"$ref": "#/definitions/Addr" | ||
}, | ||
"amount": { | ||
"$ref": "#/definitions/Uint128" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"emergency_withdraw" | ||
], | ||
"properties": { | ||
"emergency_withdraw": { | ||
"type": "object", | ||
"required": [ | ||
"account", | ||
"amount" | ||
], | ||
"properties": { | ||
"account": { | ||
"$ref": "#/definitions/Addr" | ||
}, | ||
"amount": { | ||
"$ref": "#/definitions/Uint128" | ||
} | ||
} | ||
} | ||
}, | ||
"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" | ||
}, | ||
"Binary": { | ||
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>", | ||
"type": "string" | ||
}, | ||
"Cw20ReceiveMsg": { | ||
"description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", | ||
"type": "object", | ||
"required": [ | ||
"amount", | ||
"msg", | ||
"sender" | ||
], | ||
"properties": { | ||
"amount": { | ||
"$ref": "#/definitions/Uint128" | ||
}, | ||
"msg": { | ||
"$ref": "#/definitions/Binary" | ||
}, | ||
"sender": { | ||
"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" | ||
} | ||
} | ||
} |
This file contains 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,29 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "InstantiateMsg", | ||
"type": "object", | ||
"required": [ | ||
"generator_contract_addr", | ||
"lp_token_addr", | ||
"pair_addr", | ||
"reward_contract_addr", | ||
"reward_token_addr" | ||
], | ||
"properties": { | ||
"generator_contract_addr": { | ||
"type": "string" | ||
}, | ||
"lp_token_addr": { | ||
"type": "string" | ||
}, | ||
"pair_addr": { | ||
"type": "string" | ||
}, | ||
"reward_contract_addr": { | ||
"type": "string" | ||
}, | ||
"reward_token_addr": { | ||
"type": "string" | ||
} | ||
} | ||
} |
Oops, something went wrong.