-
Notifications
You must be signed in to change notification settings - Fork 51
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 #25 from Anchor-Protocol/feat/astroport
[Feature]: Astroport migration
- Loading branch information
Showing
26 changed files
with
938 additions
and
168 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
## 0.2.0 | ||
## 0.3.0 | ||
Astroport support for collector and staking contracts. | ||
|
||
## 0.2.0 | ||
Columbus-5 upgrade compatible version release. |
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
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,4 +1,5 @@ | ||
pub mod contract; | ||
pub mod migration; | ||
pub mod state; | ||
|
||
#[cfg(test)] | ||
|
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,38 @@ | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::state::{store_config, Config, KEY_CONFIG}; | ||
use cosmwasm_std::{CanonicalAddr, Decimal, StdResult, Storage}; | ||
use cosmwasm_storage::ReadonlySingleton; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] | ||
pub struct LegacyConfig { | ||
pub gov_contract: CanonicalAddr, // collected rewards receiver | ||
pub terraswap_factory: CanonicalAddr, // astroport factory contract | ||
pub anchor_token: CanonicalAddr, // anchor token address | ||
pub distributor_contract: CanonicalAddr, // distributor contract to sent back rewards | ||
pub reward_factor: Decimal, // reward distribution rate to gov contract, left rewards sent back to distributor contract | ||
} | ||
|
||
fn read_legacy_config(storage: &dyn Storage) -> StdResult<LegacyConfig> { | ||
ReadonlySingleton::new(storage, KEY_CONFIG).load() | ||
} | ||
|
||
pub fn migrate_config( | ||
storage: &mut dyn Storage, | ||
astroport_factory: CanonicalAddr, | ||
max_spread: Decimal, | ||
) -> StdResult<()> { | ||
let legacy_config: LegacyConfig = read_legacy_config(storage)?; | ||
|
||
store_config( | ||
storage, | ||
&Config { | ||
gov_contract: legacy_config.gov_contract, | ||
astroport_factory, | ||
anchor_token: legacy_config.anchor_token, | ||
reward_factor: legacy_config.reward_factor, | ||
max_spread: Some(max_spread), | ||
}, | ||
) | ||
} |
Oops, something went wrong.