generated from apollodao/apollo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support other reward token types
- Loading branch information
1 parent
09c7aef
commit d2dbb4c
Showing
7 changed files
with
168 additions
and
85 deletions.
There are no files selected for viewing
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
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
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
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
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
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 |
---|---|---|
@@ -1,17 +1,52 @@ | ||
use cosmwasm_schema::cw_serde; | ||
use cw_dex::astroport::AstroportPool; | ||
use cw_storage_plus::Item; | ||
use cw_vault_standard::VaultContract; | ||
|
||
use crate::config::Config; | ||
use crate::ContractError; | ||
|
||
/// An enum representing different types of reward tokens | ||
#[cw_serde] | ||
pub enum RewardType { | ||
/// The reward token is a vault token | ||
Vault { | ||
/// The vault contract | ||
vault: VaultContract, | ||
/// The Astroport pool that the vault holds liquidity in | ||
pool: AstroportPool, | ||
}, | ||
/// The reward token is an Astroport LP token | ||
LP(AstroportPool), | ||
/// The reward token is a native coin | ||
Coin(String), | ||
} | ||
|
||
impl RewardType { | ||
pub fn into_pool(self) -> Result<AstroportPool, ContractError> { | ||
match self { | ||
RewardType::Vault { vault: _, pool } => Ok(pool), | ||
RewardType::LP(pool) => Ok(pool), | ||
RewardType::Coin(_) => { | ||
Err(ContractError::generic_err( | ||
"Cannot redeem vault tokens from coin reward", | ||
)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/// Stores the contract's config | ||
pub const CONFIG: Item<Config> = Item::new("config"); | ||
|
||
/// Stores the Astroport pool in which rewards are being held | ||
pub const REWARD_POOL: Item<AstroportPool> = Item::new("reward_pool"); | ||
/// Stores the reward token that this contract is distributing | ||
pub const REWARD_TOKEN: Item<RewardType> = Item::new("reward_token"); | ||
|
||
// /// Stores the Astroport pool in which rewards are being held | ||
// pub const REWARD_POOL: Item<AstroportPool> = Item::new("reward_pool"); | ||
|
||
/// Stores the vault contract in which rewards are being held | ||
pub const REWARD_VAULT: Item<VaultContract> = Item::new("reward_vault"); | ||
// /// Stores the vault contract in which rewards are being held | ||
// pub const REWARD_VAULT: Item<VaultContract> = Item::new("reward_vault"); | ||
|
||
/// Stores the last timestamp that rewards were distributed | ||
pub const LAST_DISTRIBUTED: Item<u64> = Item::new("last_distributed"); |
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