From 2258908b619a5c914ee38956c9c29d00ec597e77 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Wed, 17 Jan 2024 17:21:55 +0200 Subject: [PATCH] wip: find the claimed rewards --- contracts/alliance-lp-hub/src/contract.rs | 84 +++++-- contracts/alliance-lp-hub/src/models.rs | 2 + contracts/alliance-lp-hub/src/state.rs | 2 +- .../alliance-lp-hub/src/tests/helpers.rs | 1 + .../alliance-lp-hub/src/tests/instantiate.rs | 2 + .../alliance-lp-hub/src/tests/rewards.rs | 232 ++++++++++++++---- packages/alliance-protocol/src/error.rs | 3 + 7 files changed, 262 insertions(+), 64 deletions(-) diff --git a/contracts/alliance-lp-hub/src/contract.rs b/contracts/alliance-lp-hub/src/contract.rs index da3d0f7..e9c8f18 100644 --- a/contracts/alliance-lp-hub/src/contract.rs +++ b/contracts/alliance-lp-hub/src/contract.rs @@ -18,6 +18,7 @@ use cw_asset::{Asset, AssetInfo, AssetInfoKey, AssetInfoUnchecked}; use cw_utils::parse_instantiate_response_data; use std::str::FromStr; use std::{collections::HashSet, env}; +use terra_proto_rs::cosmos::evidence; use terra_proto_rs::{ alliance::alliance::{MsgClaimDelegationRewards, MsgDelegate, MsgRedelegate, MsgUndelegate}, cosmos::base::v1beta1::Coin, @@ -39,6 +40,7 @@ const CONTRACT_NAME: &str = "crates.io:terra-alliance-lp-hub"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); const CREATE_REPLY_ID: u64 = 1; const CLAIM_REWARD_ERROR_REPLY_ID: u64 = 2; +const CLAIM_ASTRO_REWARD_REPLY_ID: u64 = 3; #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { @@ -55,6 +57,7 @@ pub fn instantiate( set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let governance_address = deps.api.addr_validate(msg.governance.as_str())?; let controller_address = deps.api.addr_validate(msg.controller.as_str())?; + deps.api.addr_validate(msg.astro_reward_denom.as_str())?; let astro_incentives_address = deps .api .addr_validate(msg.astro_incentives_address.as_str())?; @@ -69,6 +72,7 @@ pub fn instantiate( let config = Config { governance: governance_address, controller: controller_address, + astro_reward_denom: msg.astro_reward_denom, fee_collector: fee_collector_address, astro_incentives: astro_incentives_address, alliance_token_denom: "".to_string(), @@ -152,9 +156,13 @@ fn modify_assets( } else { let asset_key = AssetInfoKey::from(asset.asset_info.clone()); WHITELIST.save(deps.storage, asset_key.clone(), &Decimal::zero())?; - ASSET_REWARD_RATE.update(deps.storage, asset_key, |asset_reward_rate| -> StdResult<_> { - Ok(asset_reward_rate.unwrap_or(AssetRewardRate::zero())) - })?; + ASSET_REWARD_RATE.update( + deps.storage, + asset_key, + |asset_reward_rate| -> StdResult<_> { + Ok(asset_reward_rate.unwrap_or(AssetRewardRate::zero())) + }, + )?; attrs.extend_from_slice(&[("asset".to_string(), asset.asset_info.to_string())]); } } @@ -387,7 +395,8 @@ fn _claim_reward( if let Ok(user_reward_rate) = user_reward_rate { let user_staked = BALANCES.load(storage, (user.clone(), asset_key.clone()))?; - let rewards = ((asset_reward_rate.alliance_reward_rate - user_reward_rate.alliance_reward_rate) + let rewards = ((asset_reward_rate.alliance_reward_rate + - user_reward_rate.alliance_reward_rate) * Decimal::from_atomics(user_staked, 0)?) .to_uint_floor(); if rewards.is_zero() { @@ -534,7 +543,11 @@ fn update_rewards(deps: DepsMut, env: Env, info: MessageInfo) -> Result sent balance - TEMP_BALANCE.save(deps.storage, &(contract_balance - sent_balance))?; + TEMP_BALANCE.save( + deps.storage, + AssetInfoKey::from(AssetInfo::Native(config.reward_denom.to_string())), + &(contract_balance - sent_balance), + )?; let validators = VALIDATORS.load(deps.storage)?; let alliance_sub_msg: Vec = validators .iter() @@ -558,9 +571,7 @@ fn update_rewards(deps: DepsMut, env: Env, info: MessageInfo) -> Result = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: astro_incentives.to_string(), - msg: to_json_binary(&ExecuteAstroMsg::ClaimRewards { + msg: to_json_binary(&ExecuteAstroMsg::ClaimRewards { lp_tokens: lp_tokens_list, })?, funds: vec![], }); - return Ok(Some(SubMsg::reply_on_error(msg, CLAIM_REWARD_ERROR_REPLY_ID))) + return Ok(Some(SubMsg::reply_always(msg, CLAIM_REWARD_ERROR_REPLY_ID))); } Ok(None) @@ -624,7 +635,10 @@ fn update_reward_callback( // and not pooled together and shared let reward_asset = AssetInfo::native(config.reward_denom.clone()); let current_balance = reward_asset.query_balance(&deps.querier, env.contract.address)?; - let previous_balance = TEMP_BALANCE.load(deps.storage)?; + let previous_balance = TEMP_BALANCE.load( + deps.storage, + AssetInfoKey::from(AssetInfo::Native(config.reward_denom.to_string())), + )?; let rewards_collected = current_balance - previous_balance; let whitelist: StdResult> = WHITELIST @@ -645,7 +659,10 @@ fn update_reward_callback( if !unallocated_rewards.is_zero() { res = res.add_message(BankMsg::Send { to_address: config.fee_collector.to_string(), - amount: vec![CwCoin::new(unallocated_rewards.u128(), config.reward_denom)], + amount: vec![CwCoin::new( + unallocated_rewards.u128(), + config.reward_denom.clone(), + )], }) } } else { @@ -670,12 +687,16 @@ fn update_reward_callback( if rate_to_update > Decimal::zero() { ASSET_REWARD_RATE.update(deps.storage, asset_key.clone(), |rate| -> StdResult<_> { let mut reward_rate = rate.unwrap_or(AssetRewardRate::zero()); - reward_rate.alliance_reward_rate = reward_rate.alliance_reward_rate + rate_to_update; + reward_rate.alliance_reward_rate = + reward_rate.alliance_reward_rate + rate_to_update; Ok(reward_rate) })?; } } - TEMP_BALANCE.remove(deps.storage); + TEMP_BALANCE.remove( + deps.storage, + AssetInfoKey::from(AssetInfo::Native(config.reward_denom.to_string())), + ); Ok(res) } @@ -808,10 +829,45 @@ pub fn reply( CLAIM_REWARD_ERROR_REPLY_ID => { Ok(Response::new().add_attributes(vec![("action", "claim_reward_error")])) } + CLAIM_ASTRO_REWARD_REPLY_ID => reply_astro_rewards(deps, reply), _ => Err(ContractError::InvalidReplyId(reply.id)), } } +// Example of a response https://terrasco.pe/testnet/tx/EC20D82F519B8B76EBFF1DDB75592330CA5A1CACE21943B22BAA4F46468AB5E7 +fn reply_astro_rewards( + deps: DepsMut, + reply: Reply, +) -> Result, ContractError> { + let config = CONFIG.load(deps.storage)?; + let result = reply.result.unwrap(); + let event = result + .events + .iter() + .find(|event| event.ty == "wasm") + .ok_or_else(|| StdError::generic_err("cannot find `wasm` event"))?; + + let first_attr = event.attributes[0].clone(); + let event_key = first_attr.key.clone(); + let even_value = first_attr.value.clone(); + + if event_key != "_contract_address" && even_value != config.astro_incentives { + return Err(ContractError::InvalidContractCallback( + event_key, even_value, + )); + } + + for attr in event.attributes.clone() { + if attr.key == "claimed_position" { + // TODO : find the claimed_rewards + } + + + } + + Ok(Response::new().add_attributes(vec![("action", "reply_astro_rewards")])) +} + // Controller is used to perform administrative operations that deals with delegating the virtual // tokens to the expected validators fn is_controller(info: &MessageInfo, config: &Config) -> Result<(), ContractError> { diff --git a/contracts/alliance-lp-hub/src/models.rs b/contracts/alliance-lp-hub/src/models.rs index a47e20e..843b961 100644 --- a/contracts/alliance-lp-hub/src/models.rs +++ b/contracts/alliance-lp-hub/src/models.rs @@ -19,6 +19,7 @@ pub struct Config { pub alliance_token_denom: String, pub alliance_token_supply: Uint128, pub reward_denom: String, + pub astro_reward_denom: String } #[cw_serde] @@ -28,6 +29,7 @@ pub struct InstantiateMsg { pub fee_collector_address: String, pub astro_incentives_address: String, pub reward_denom: String, + pub astro_reward_denom: String, } #[cw_serde] diff --git a/contracts/alliance-lp-hub/src/state.rs b/contracts/alliance-lp-hub/src/state.rs index 99cf0c4..25a5fb4 100644 --- a/contracts/alliance-lp-hub/src/state.rs +++ b/contracts/alliance-lp-hub/src/state.rs @@ -17,4 +17,4 @@ pub const USER_ASSET_REWARD_RATE: Map<(Addr, AssetInfoKey), AssetRewardRate> = Map::new("user_asset_reward_rate"); pub const UNCLAIMED_REWARDS: Map<(Addr, AssetInfoKey), AssetUnclaimedRewards> = Map::new("unclaimed_rewards"); -pub const TEMP_BALANCE: Item = Item::new("temp_balance"); +pub const TEMP_BALANCE: Map = Map::new("temp_balance"); diff --git a/contracts/alliance-lp-hub/src/tests/helpers.rs b/contracts/alliance-lp-hub/src/tests/helpers.rs index 56be3c5..4d28ab4 100644 --- a/contracts/alliance-lp-hub/src/tests/helpers.rs +++ b/contracts/alliance-lp-hub/src/tests/helpers.rs @@ -27,6 +27,7 @@ pub fn setup_contract(deps: DepsMut) -> Response { astro_incentives_address : "astro_incentives".to_string(), controller: "controller".to_string(), reward_denom: "uluna".to_string(), + astro_reward_denom: "uastro".to_string(), }; instantiate(deps, env, info, init_msg).unwrap() } diff --git a/contracts/alliance-lp-hub/src/tests/instantiate.rs b/contracts/alliance-lp-hub/src/tests/instantiate.rs index fd69241..078b858 100644 --- a/contracts/alliance-lp-hub/src/tests/instantiate.rs +++ b/contracts/alliance-lp-hub/src/tests/instantiate.rs @@ -40,6 +40,7 @@ fn test_setup_contract() { fee_collector: Addr::unchecked("collector_address"), astro_incentives: Addr::unchecked("astro_incentives"), reward_denom: "uluna".to_string(), + astro_reward_denom: "uastro".to_string(), alliance_token_denom: "".to_string(), alliance_token_supply: Uint128::new(0), } @@ -111,6 +112,7 @@ fn test_reply_create_token() { controller: Addr::unchecked("controller"), fee_collector: Addr::unchecked("collector_address"), astro_incentives: Addr::unchecked("astro_incentives"), + astro_reward_denom: "uastro".to_string(), reward_denom: "uluna".to_string(), alliance_token_denom: "factory/cosmos2contract/ualliancelp".to_string(), alliance_token_supply: Uint128::new(1000000000000), diff --git a/contracts/alliance-lp-hub/src/tests/rewards.rs b/contracts/alliance-lp-hub/src/tests/rewards.rs index a4a32f8..5df9953 100644 --- a/contracts/alliance-lp-hub/src/tests/rewards.rs +++ b/contracts/alliance-lp-hub/src/tests/rewards.rs @@ -1,16 +1,18 @@ use crate::contract::execute; use crate::models::{ExecuteMsg, ModifyAsset, PendingRewardsRes}; -use crate::state::{ASSET_REWARD_RATE, TEMP_BALANCE, TOTAL_BALANCES, USER_ASSET_REWARD_RATE, VALIDATORS, WHITELIST}; +use crate::state::{ + ASSET_REWARD_RATE, TEMP_BALANCE, TOTAL_BALANCES, USER_ASSET_REWARD_RATE, VALIDATORS, WHITELIST, +}; use crate::tests::helpers::{ - claim_rewards, query_all_rewards, query_rewards, set_alliance_asset, setup_contract, stake, - unstake, modify_asset, DENOM, + claim_rewards, modify_asset, query_all_rewards, query_rewards, set_alliance_asset, + setup_contract, stake, unstake, DENOM, }; use cosmwasm_std::testing::{mock_dependencies_with_balance, mock_env, mock_info}; use cosmwasm_std::{ coin, coins, to_json_binary, Addr, BankMsg, Binary, CosmosMsg, Decimal, Response, SubMsg, Uint128, WasmMsg, }; -use cw_asset::{AssetInfo, AssetInfoKey, Asset}; +use cw_asset::{Asset, AssetInfo, AssetInfoKey}; use std::collections::HashSet; use terra_proto_rs::alliance::alliance::MsgClaimDelegationRewards; use terra_proto_rs::traits::Message; @@ -59,7 +61,12 @@ fn test_update_rewards() { })) ] ); - let prev_balance = TEMP_BALANCE.load(deps.as_ref().storage).unwrap(); + let prev_balance = TEMP_BALANCE + .load( + deps.as_ref().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + ) + .unwrap(); assert_eq!(prev_balance, Uint128::new(1000000)); } @@ -85,7 +92,12 @@ fn test_update_rewards_with_funds_sent() { ExecuteMsg::UpdateRewards {}, ) .unwrap(); - let prev_balance = TEMP_BALANCE.load(deps.as_ref().storage).unwrap(); + let prev_balance = TEMP_BALANCE + .load( + deps.as_ref().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + ) + .unwrap(); assert_eq!(res.messages.len(), 3); assert_eq!(prev_balance, Uint128::new(1000000)); } @@ -112,11 +124,33 @@ fn update_reward_callback() { .unwrap(); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &Decimal::percent(10), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &Decimal::percent(60), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aMONKEY".to_string())), + &Decimal::percent(30), + ) .unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), &Decimal::percent(10)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), &Decimal::percent(60)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aMONKEY".to_string())), &Decimal::percent(30)).unwrap(); let res = execute( deps.as_mut(), @@ -181,10 +215,26 @@ fn update_reward_callback_with_unallocated() { .unwrap(); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &Decimal::percent(10), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &Decimal::percent(60), + ) .unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), &Decimal::percent(10)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), &Decimal::percent(60)).unwrap(); let res = execute( deps.as_mut(), @@ -192,7 +242,7 @@ fn update_reward_callback_with_unallocated() { mock_info("cosmos2contract", &[]), ExecuteMsg::UpdateRewardsCallback {}, ) - .unwrap(); + .unwrap(); let a_whale_rate = ASSET_REWARD_RATE .load( @@ -233,21 +283,35 @@ fn claim_user_rewards() { set_alliance_asset(deps.as_mut()); modify_asset( deps.as_mut(), - Vec::from([ - ModifyAsset{ - asset_info: AssetInfo::Native("aWHALE".to_string()), - delete: false, - } - ]), + Vec::from([ModifyAsset { + asset_info: AssetInfo::Native("aWHALE".to_string()), + delete: false, + }]), ); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), &Decimal::percent(50)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), &Decimal::percent(50)).unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); stake(deps.as_mut(), "user1", 1000000, "aWHALE"); stake(deps.as_mut(), "user2", 4000000, "aWHALE"); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) .unwrap(); execute( deps.as_mut(), @@ -349,7 +413,11 @@ fn claim_user_rewards() { deps.querier .update_balance("cosmos2contract", vec![coin(1900000 + 100000, "uluna")]); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1900000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1900000), + ) .unwrap(); execute( deps.as_mut(), @@ -382,21 +450,35 @@ fn claim_user_rewards_after_staking() { set_alliance_asset(deps.as_mut()); modify_asset( deps.as_mut(), - Vec::from([ - ModifyAsset{ - asset_info: AssetInfo::Native("aWHALE".to_string()), - delete: false, - } - ]), + Vec::from([ModifyAsset { + asset_info: AssetInfo::Native("aWHALE".to_string()), + delete: false, + }]), ); stake(deps.as_mut(), "user1", 1000000, "aWHALE"); stake(deps.as_mut(), "user2", 4000000, "aWHALE"); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), &Decimal::percent(50)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), &Decimal::percent(50)).unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) .unwrap(); execute( deps.as_mut(), @@ -445,24 +527,40 @@ fn claim_rewards_after_staking_and_unstaking() { modify_asset( deps.as_mut(), Vec::from([ - ModifyAsset{ + ModifyAsset { asset_info: AssetInfo::Native("aWHALE".to_string()), delete: false, }, - ModifyAsset{ + ModifyAsset { asset_info: AssetInfo::Native("bWHALE".to_string()), delete: false, - } + }, ]), ); stake(deps.as_mut(), "user1", 1000000, "aWHALE"); stake(deps.as_mut(), "user2", 4000000, "aWHALE"); stake(deps.as_mut(), "user2", 1000000, "bWHALE"); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), &Decimal::percent(50)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), &Decimal::percent(50)).unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) .unwrap(); execute( deps.as_mut(), @@ -487,7 +585,11 @@ fn claim_rewards_after_staking_and_unstaking() { // Accrue rewards again TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) .unwrap(); execute( deps.as_mut(), @@ -527,24 +629,40 @@ fn claim_rewards_after_rebalancing_emissions() { modify_asset( deps.as_mut(), Vec::from([ - ModifyAsset{ + ModifyAsset { asset_info: AssetInfo::Native("aWHALE".to_string()), delete: false, }, - ModifyAsset{ + ModifyAsset { asset_info: AssetInfo::Native("bWHALE".to_string()), delete: false, - } + }, ]), ); stake(deps.as_mut(), "user1", 1000000, "aWHALE"); stake(deps.as_mut(), "user2", 1000000, "bWHALE"); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), &Decimal::percent(50)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), &Decimal::percent(50)).unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &Decimal::percent(50), + ) + .unwrap(); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) .unwrap(); execute( deps.as_mut(), @@ -554,11 +672,27 @@ fn claim_rewards_after_rebalancing_emissions() { ) .unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), &Decimal::percent(100)).unwrap(); - WHITELIST.save(deps.as_mut().storage, AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), &Decimal::percent(0)).unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &Decimal::percent(100), + ) + .unwrap(); + WHITELIST + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &Decimal::percent(0), + ) + .unwrap(); TEMP_BALANCE - .save(deps.as_mut().storage, &Uint128::new(1000000)) + .save( + deps.as_mut().storage, + AssetInfoKey::from(AssetInfo::Native("uluna".to_string())), + &Uint128::new(1000000), + ) .unwrap(); execute( deps.as_mut(), diff --git a/packages/alliance-protocol/src/error.rs b/packages/alliance-protocol/src/error.rs index 74560ba..c188eab 100644 --- a/packages/alliance-protocol/src/error.rs +++ b/packages/alliance-protocol/src/error.rs @@ -44,4 +44,7 @@ pub enum ContractError { #[error("Invalid total distribution: {0}")] InvalidTotalDistribution(Decimal), + + #[error("Invalid contract callback with key: {0} and type: {1}")] + InvalidContractCallback(String, String), }