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

Treasury adapters #204

Merged
merged 54 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
58dbe75
roughed out adapter interface, applied to scrt_staking
DrPresident Mar 14, 2022
22c1398
treasury updates for rewards tracking
DrPresident Mar 14, 2022
2247013
working, was a gas issue
DrPresident Mar 17, 2022
dd010b5
treasury building, need finance_manager & unbonding logic
DrPresident Mar 22, 2022
3ab7db0
treasury rework
DrPresident Mar 23, 2022
e92a33d
minor fix
DrPresident Mar 23, 2022
2b88dfc
registering managers on treasury
DrPresident Mar 24, 2022
be57484
finance manager rebalance very rough
DrPresident Mar 24, 2022
f2d911e
adapter balance fn
DrPresident Mar 29, 2022
6122eb2
Added dao.drawio
DrPresident Apr 7, 2022
a1306e3
Update dao.drawio
DrPresident Apr 7, 2022
db21cbc
a little more done
DrPresident Apr 5, 2022
9ff561b
imported cargo features
DrPresident Apr 7, 2022
6621e88
scrt staking tested and working
DrPresident Apr 8, 2022
5e31277
commented tx hash print
DrPresident Apr 11, 2022
29d4300
updated make clean to remove lock files
DrPresident Apr 11, 2022
83f2bac
removed unbonding logic from 'update'
DrPresident Apr 11, 2022
ac4962b
PoC working, need manager unbonding
DrPresident Apr 19, 2022
408070e
needs rebalance threshold on treasury, otherwise appears to be workin…
DrPresident Apr 19, 2022
bfffdfb
starting on accounts for staking, moved treasury to an adapter
DrPresident Apr 22, 2022
42609bc
finance -> farming manager
DrPresident Apr 22, 2022
d26581c
started rewards emissions
DrPresident Apr 25, 2022
54922d2
removed unusude stuff
DrPresident Apr 25, 2022
a9c501b
rough start on rewards_emission
DrPresident Apr 27, 2022
0bf089b
apparently never committed the mock pairs
DrPresident Apr 27, 2022
ca12592
emissions building needs testing
DrPresident Apr 27, 2022
4ba60e1
added some queries to treasury and roughed out readme
DrPresident Apr 27, 2022
0c82aaf
removed commented
DrPresident Apr 27, 2022
47d7491
tweaks
DrPresident Apr 27, 2022
0b0e604
removed empty adapter query funcs
DrPresident May 2, 2022
8f651a7
Merge branch 'dev' into treasury-adapters
DrPresident May 2, 2022
01086f0
mint local deploy script
DrPresident May 2, 2022
b10c632
merge fix
DrPresident May 2, 2022
e6493ba
fixed dependencies
DrPresident May 2, 2022
1e6c872
switch uint
DrPresident May 2, 2022
b99a7b1
updated uint
DrPresident May 2, 2022
333c404
added some rough readme's
DrPresident May 3, 2022
d339708
oracle uint
DrPresident May 3, 2022
e9a66b7
mint fix
DrPresident May 3, 2022
f8647bb
added basic ensemble test for mint
DrPresident May 3, 2022
322c163
moved tests around
DrPresident May 4, 2022
88467b9
Update contracts/oracle/src/query.rs
DrPresident May 4, 2022
56e5363
Update contracts/mint/src/handle.rs
DrPresident May 4, 2022
62e047e
Update contracts/mint/Cargo.toml
DrPresident May 4, 2022
0bf13d9
tweaked imports
DrPresident May 4, 2022
a7ab4ec
Update packages/shade_protocol/src/dex.rs
DrPresident May 4, 2022
bdc7f47
features
DrPresident May 4, 2022
0fa052c
revert broken change
DrPresident May 4, 2022
f1527bb
fadroma dep change
DrPresident May 4, 2022
857fdb1
fadroma v100
DrPresident May 9, 2022
dd20e95
Update contracts/oracle/src/query.rs
DrPresident May 9, 2022
080ba02
v100 to 100
DrPresident May 9, 2022
6f0654f
fadroma 22.1.0
DrPresident May 9, 2022
355d4f9
branch v100
DrPresident May 9, 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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[submodule "contracts/shd_staking"]
path = contracts/shd_staking
url = https://github.com/securesecrets/SPIP-STKN-0
branch = staking-implementation
branch = staking-implementation
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ members = [
"contracts/governance",
"contracts/mint",
"contracts/mint_router",
"contracts/treasury",
"contracts/oracle",
"contracts/snip20",
"contracts/shd_staking",

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

"contracts/shd_staking",

# Mock contracts
"contracts/mock_band",
Expand Down
3 changes: 2 additions & 1 deletion contractlib/secretlib/secretlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def run_command_compute_hash(command):

try:
txhash = json.loads(out)["txhash"]
# print(txhash)
#print(txhash)

except Exception as e:
# print(out)
raise e
Expand Down
15 changes: 7 additions & 8 deletions contracts/mint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ 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 = [
"mint",
"oracle",
"band",
"dex",
] }
shade-protocol = { version = "0.1.0", path = "../../packages/shade_protocol", features = [ "mint", "oracle", "band", "dex", ] }
schemars = "0.7"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
snafu = { version = "0.6.3" }
mockall = "0.10.2"
mockall_double = "0.2.0"
chrono = "0.4.19"

DrPresident marked this conversation as resolved.
Show resolved Hide resolved
[dev-dependencies]
fadroma = { version = "^22.1.0", git = "https://github.com/hackbg/fadroma.git" }
snip20-reference-impl = { version = "0.1.0", path = "../../contracts/snip20" }
oracle = { version = "0.1.0", path = "../../contracts/oracle" }
mock_band = { version = "0.1.0", path = "../../contracts/mock_band" }
21 changes: 20 additions & 1 deletion contracts/mint/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,24 @@ pub fn calculate_mint(
}
}

/*
pub fn calculate_fee_curve(
// "Centered"
base_fee: Uint128,
// How far off from where we want (abs(desired_price - cur_price))
price_skew: Uint128,
// skew we should never reach (where fee maxes out)
asymptote: Uint128,
) -> Uint128 {

/* aggressiveness is how sharply it turns up at the asymptote
* speed is the overall speed of increase
* how to include asymptote to push the threshold before acceleration?
* y = (x + speed) ^ (2 * aggressiveness)
*/
}
*/

pub fn calculate_portion(amount: Uint128, portion: Uint128) -> Uint128 {
/* amount: total amount sent to burn (uSSCRT/uSILK/uSHD)
* portion: percent * 10^18 e.g. 5_320_000_000_000_000_000 = 5.32% = .0532
Expand All @@ -507,5 +525,6 @@ fn oracle<S: Storage, A: Api, Q: Querier>(
config.oracle.code_hash,
config.oracle.address,
)?;
Ok(answer.rate)

Ok(Uint128::from(answer.rate))
}
3 changes: 0 additions & 3 deletions contracts/mint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ pub mod handle;
pub mod query;
pub mod state;

#[cfg(test)]
mod test;

#[cfg(target_arch = "wasm32")]
mod wasm {
use super::contract;
Expand Down
6 changes: 4 additions & 2 deletions contracts/mint/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ pub fn mint<S: Storage, A: Api, Q: Querier>(
offer_asset: HumanAddr,
amount: Uint128,
) -> StdResult<QueryAnswer> {

let native_asset = native_asset_r(&deps.storage).load()?;

match assets_r(&deps.storage).may_load(offer_asset.to_string().as_bytes())? {
Some(asset) => {
let fee = calculate_portion(amount, asset.fee);
let amount = mint_amount(deps, amount.checked_sub(fee)?, &asset, &native_asset)?;
//let fee = calculate_portion(amount, asset.fee);
//let amount = mint_amount(deps, amount.checked_sub(fee)?, &asset, &native_asset)?;
let amount = mint_amount(deps, amount, &asset, &native_asset)?;
Ok(QueryAnswer::Mint {
asset: native_asset.contract,
amount,
Expand Down
Loading