Skip to content

Commit

Permalink
updated gelotto logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kakucodes committed Sep 25, 2023
1 parent dd7db8c commit 69bf5e8
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 86 deletions.
49 changes: 29 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ osmosis-std = "0.15.3"
osmosis-helpers = { path = "./packages/osmosis-helpers" }
mars-red-bank-types = "1.0.0"
white-whale = { git = "https://github.com/White-Whale-Defi-Platform/white-whale-core.git", tag = "v1.4.0-juno-1-token_factory-hotfix" }
cw-grant-spec = { git = "https://github.com/kakucodes/authzpp", version = "0.2.8" }
withdraw-rewards-tax-grant = { git = "https://github.com/kakucodes/authzpp", version = "0.2.8", features = [
cw-grant-spec = { git = "https://github.com/kakucodes/authzpp", version = "0.3.0" }
withdraw-rewards-tax-grant = { git = "https://github.com/kakucodes/authzpp", version = "0.3.0", features = [
"library",
] }
balance-token-swap = { git = "https://github.com/racoon-supply-rac/balance-dao", features = [
Expand Down
8 changes: 4 additions & 4 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
8032c00d1bc5438650487915ec86cf0db7af06c1d2798cf4b823a037ea08a965 ymos_junostake_outpost-aarch64.wasm
331cc7e898b5c0d5ca0c3ecaf378d9aea4bbb36c7287ce85da88246ec862fe88 ymos_osmostake_outpost-aarch64.wasm
580f63b0ecb63f4f8be78377e0f727e14425960b13d9c56cbfd9c780ec2127ff ymos_wyndlp_outpost-aarch64.wasm
d81db2de63bdfbf8009984cab42aa2962efd928d4e6ad6215356b2207ccd007c ymos_wyndstake_outpost-aarch64.wasm
d26be698bc6bca9d9f9a05eda7ddcf367369c5c175ea8fd4dfdbd2435b368a12 ymos_junostake_outpost-aarch64.wasm
cfb1e2be9e9e271ad643869b71c7d6df444a40073e3fccd2dd70205b180d9d58 ymos_osmostake_outpost-aarch64.wasm
a3ec74002651467cebbb21ff6350fdfbf1a03ed9fe5f8f2fa5ddb8c24eb270bc ymos_wyndlp_outpost-aarch64.wasm
6e5154145e5bb72e56e5650abc989aef2860dc4bb336e8197cbafa1abde385c9 ymos_wyndstake_outpost-aarch64.wasm
8 changes: 4 additions & 4 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a63b9f658d4419fd9c1017629aec4e0c95440a337377e263791e4a11d12b5d24 target/wasm32-unknown-unknown/release/ymos_osmostake_outpost.wasm
342b937dfb5cf2646d279e86a44039fdbb7329f45c6fef764b8d8fbee11e68c9 target/wasm32-unknown-unknown/release/ymos_wyndlp_outpost.wasm
8027b11bffe5f7d377566c978838df52b18949a9a17f965a2cd7dc2f01d1e97e target/wasm32-unknown-unknown/release/ymos_wyndstake_outpost.wasm
3e2824dd971a386e3ae3a9ddbd94acd5ee04229b5aa78b73f5b31c87e739896a target/wasm32-unknown-unknown/release/ymos_junostake_outpost.wasm
cbee1a0abe7286f5541f321bf0511275f0fb1ad27a9d4eed97bb49bffcb57a9c target/wasm32-unknown-unknown/release/ymos_junostake_outpost.wasm
11699dcb6df4dc542dacf8a7ada1d8b8ff3ec17e0b49bb2d5ef449f144af9dde target/wasm32-unknown-unknown/release/ymos_osmostake_outpost.wasm
a767b44fbc25c17e59dfa4afafcdf8bffaf564f3b381bdf2a521d93b2800813e target/wasm32-unknown-unknown/release/ymos_wyndlp_outpost.wasm
cc1d25c11d65937e9b2f77fb1ad1597401d11222697d12a6a1fd1d633ec04746 target/wasm32-unknown-unknown/release/ymos_wyndstake_outpost.wasm
Binary file modified artifacts/ymos_junostake_outpost-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/ymos_osmostake_outpost-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/ymos_wyndlp_outpost-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/ymos_wyndstake_outpost-aarch64.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions contracts/junostake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ bond-router = { workspace = true }
cw-grant-spec = { workspace = true }
cw-orch = { workspace = true, optional = true }


[dev-dependencies]
cw-multi-test = { workspace = true }
43 changes: 38 additions & 5 deletions contracts/junostake/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use std::iter;

use cosmos_sdk_proto::cosmos::{bank::v1beta1::MsgSend, base::v1beta1::Coin, staking::v1beta1::MsgDelegate};
use cosmwasm_std::{to_binary, Addr, Attribute, Decimal, DepsMut, Env, MessageInfo, QuerierWrapper, Response, Uint128};
use cosmwasm_std::{
coin, to_binary, Addr, Attribute, Decimal, DepsMut, Env, MessageInfo, QuerierWrapper, Response, Uint128,
};
use outpost_utils::{
comp_prefs::DestinationAction,
helpers::{calculate_compound_amounts, is_authorized_compounder, prefs_sum_to_one, sum_coins},
juno_comp_prefs::{
JunoCompPrefs, JunoDestinationProject, JunoLsd, RacoonBetExec, RacoonBetGame, SparkIbcFund, WyndLPBondingPeriod,
WyndStakingBondingPeriod,
GelottoExecute, JunoCompPrefs, JunoDestinationProject, JunoLsd, RacoonBetExec, RacoonBetGame, SparkIbcFund,
WyndLPBondingPeriod, WyndStakingBondingPeriod,
},
msg_gen::{create_exec_contract_msg, create_exec_msg, CosmosProtoMsg},
};
Expand Down Expand Up @@ -291,8 +293,39 @@ pub fn prefs_to_msgs(
],
})
}
JunoDestinationProject::GelottoLottery { .. } => {
unimplemented!("gelotto")
JunoDestinationProject::GelottoLottery { lottery, lucky_phrase } => {
// 25k ujuno per ticket
let tickets_to_buy = comp_token_amount / Uint128::from(25_000u128);
Ok(DestProjectMsgs {
msgs: vec![CosmosProtoMsg::ExecuteContract(create_exec_contract_msg(
lottery.get_lottery_address(&project_addresses.destination_projects.gelotto.clone()),
target_address,
&GelottoExecute::SenderBuySeed {
referrer: Some(Addr::unchecked(project_addresses.take_rate_addr.clone())),
count: u128::from(tickets_to_buy) as u16,
seed: lucky_phrase,
},
Some(vec![Coin {
amount: (tickets_to_buy * Uint128::from(25_000u128)).into(),
denom: staking_denom.clone(),
}]),
)?)],
sub_msgs: vec![],
attributes: vec![
Attribute {
key: "subaction".to_string(),
value: "gelotto lottery".to_string(),
},
Attribute {
key: "lottery".to_string(),
value: lottery.to_string(),
},
Attribute {
key: "tickets".to_string(),
value: tickets_to_buy.to_string(),
},
],
})
}
JunoDestinationProject::RacoonBet { game } => {
// can't use racoon bet unless the value of the play is at least $1 usdc
Expand Down
99 changes: 82 additions & 17 deletions contracts/junostake/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{Addr, Decimal, Deps, QuerierWrapper, StdResult, Uint128};
use cw_grant_spec::grantable_trait::{GrantStructure, Grantable};
use cosmwasm_std::{coin, Addr, Decimal, Deps, QuerierWrapper, StdResult, Uint128};
use cw_grant_spec::grantable_trait::{dedupe_grant_reqs, GrantStructure, Grantable};
use cw_grant_spec::grants::{
ContractExecutionAuthorizationFilter, ContractExecutionAuthorizationLimit, ContractExecutionSetting, GrantRequirement,
GrantType, StakeAuthorizationPolicy, StakeAuthorizationType, StakeAuthorizationValidators,
Expand Down Expand Up @@ -182,9 +182,26 @@ pub fn gen_comp_pref_grants(
grantee: grantee.clone(),
expiration,
}],
JunoDestinationProject::GelottoLottery { lottery, lucky_phrase } => unimplemented!(),
JunoDestinationProject::SendTokens { denom: _denom, address } => vec![
JunoDestinationProject::GelottoLottery {
lottery,
lucky_phrase: _lucky_phrase,
} => vec![GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
contract_addr: Addr::unchecked(
lottery.get_lottery_address(&project_addresses.destination_projects.gelotto),
),
limit: ContractExecutionAuthorizationLimit::default(),
filter: ContractExecutionAuthorizationFilter::AcceptedMessageKeysFilter {
keys: vec!["sender_buy_seed".to_string()],
},
}]),
granter: granter.clone(),
grantee: grantee.clone(),
expiration,
}],
JunoDestinationProject::SendTokens { denom, address } => vec![
// general multihop swap
// TODO: this grant isn't needed if we're swapping to juno
GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
contract_addr: Addr::unchecked(project_addresses.destination_projects.wynd.multihop.clone()),
Expand All @@ -198,14 +215,30 @@ pub fn gen_comp_pref_grants(
expiration,
},
// send to the given user
GrantRequirement::GrantSpec {
grant_type: GrantType::SendAuthorization {
spend_limit: None,
allow_list: Some(vec![Addr::unchecked(address.clone())]),
match denom {
// if it's a native denom we need a send authorization
AssetInfo::Native(denom) => GrantRequirement::GrantSpec {
grant_type: GrantType::SendAuthorization {
spend_limit: Some(vec![coin(u128::MAX, denom)]),
allow_list: Some(vec![Addr::unchecked(address.clone())]),
},
granter: granter.clone(),
grantee: grantee.clone(),
expiration,
},
// if it's a cw20 then we need a contract execution authorization on the cw20 contract
AssetInfo::Token(contract_addr) => GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
contract_addr: Addr::unchecked(contract_addr),
limit: ContractExecutionAuthorizationLimit::default(),
filter: ContractExecutionAuthorizationFilter::AcceptedMessageKeysFilter {
keys: vec!["send".to_string()],
},
}]),
granter: granter.clone(),
grantee: grantee.clone(),
expiration,
},
granter: granter.clone(),
grantee: grantee.clone(),
expiration,
},
],
JunoDestinationProject::MintLsd { lsd_type } => vec![GrantRequirement::GrantSpec {
Expand All @@ -226,7 +259,7 @@ pub fn gen_comp_pref_grants(
grantee: grantee.clone(),
expiration,
}],
JunoDestinationProject::WhiteWhaleSatellite { asset } => vec![
JunoDestinationProject::WhiteWhaleSatellite { asset: _asset } => vec![
// general multihop swap
GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
Expand Down Expand Up @@ -254,7 +287,37 @@ pub fn gen_comp_pref_grants(
expiration,
},
],
JunoDestinationProject::WyndStaking { bonding_period } => vec![],
JunoDestinationProject::WyndStaking {
bonding_period: _bonding_period,
} => vec![
// pair swap for JUNO to WYND
GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
contract_addr: Addr::unchecked(project_addresses.destination_projects.wynd.juno_wynd_pair.clone()),
limit: ContractExecutionAuthorizationLimit::default(),
filter: ContractExecutionAuthorizationFilter::AcceptedMessageKeysFilter {
keys: vec!["swap".to_string()],
},
}]),
granter: granter.clone(),
grantee: grantee.clone(),
expiration,
},
// send wynd to the staking contract and stake the tokens
// TODO: lock down the sending and the delegation further
GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
contract_addr: Addr::unchecked(project_addresses.destination_projects.wynd.cw20.clone()),
limit: ContractExecutionAuthorizationLimit::default(),
filter: ContractExecutionAuthorizationFilter::AcceptedMessageKeysFilter {
keys: vec!["send".to_string(), "delegate".to_string()],
},
}]),
granter: granter.clone(),
grantee: grantee.clone(),
expiration,
},
],
JunoDestinationProject::RacoonBet { game } => vec![GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
contract_addr: Addr::unchecked(project_addresses.destination_projects.racoon_bet.game.clone()),
Expand All @@ -271,7 +334,9 @@ pub fn gen_comp_pref_grants(
grantee: grantee.clone(),
expiration,
}],
JunoDestinationProject::TokenSwap { target_denom } => vec![
JunoDestinationProject::TokenSwap {
target_denom: _target_denom,
} => vec![
// general multihop swap
GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
Expand All @@ -288,7 +353,7 @@ pub fn gen_comp_pref_grants(
],
JunoDestinationProject::WyndLp {
contract_address,
bonding_period,
bonding_period: _bonding_period,
} => vec![
// general multihop swap
GrantRequirement::GrantSpec {
Expand Down Expand Up @@ -318,7 +383,7 @@ pub fn gen_comp_pref_grants(
expiration,
},
],
JunoDestinationProject::SparkIbcCampaign { fund } => vec![
JunoDestinationProject::SparkIbcCampaign { fund: _fund } => vec![
// general multihop swap
GrantRequirement::GrantSpec {
grant_type: GrantType::ContractExecutionAuthorization(vec![ContractExecutionSetting {
Expand Down Expand Up @@ -349,5 +414,5 @@ pub fn gen_comp_pref_grants(
}
});

Ok(grant_specs.collect())
Ok(dedupe_grant_reqs(grant_specs.collect()))
}
Loading

0 comments on commit 69bf5e8

Please sign in to comment.