-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9af7bcf
commit e61e2f8
Showing
15 changed files
with
451 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 +1,6 @@ | ||
[package] | ||
name = "ref-exchange" | ||
version = "1.9.3" | ||
version = "1.9.4" | ||
authors = ["Illia Polosukhin <[email protected]>"] | ||
edition = "2018" | ||
publish = false | ||
|
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use crate::*; | ||
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; | ||
use crate::utils::u128_dec_format; | ||
|
||
#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize)] | ||
#[serde(crate = "near_sdk::serde")] | ||
#[cfg_attr(not(target_arch = "wasm32"), derive(Debug))] | ||
pub struct DegenPoolLimitInfo { | ||
#[serde(with = "u128_dec_format")] | ||
pub tvl_limit: u128 | ||
} | ||
|
||
#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize)] | ||
#[serde(crate = "near_sdk::serde")] | ||
#[cfg_attr(not(target_arch = "wasm32"), derive(Debug))] | ||
pub enum VDegenPoolLimitInfo { | ||
Current(DegenPoolLimitInfo), | ||
} | ||
|
||
impl From<VDegenPoolLimitInfo> for DegenPoolLimitInfo { | ||
fn from(v: VDegenPoolLimitInfo) -> Self { | ||
match v { | ||
VDegenPoolLimitInfo::Current(c) => c, | ||
} | ||
} | ||
} | ||
|
||
impl From<DegenPoolLimitInfo> for VDegenPoolLimitInfo { | ||
fn from(c: DegenPoolLimitInfo) -> Self { | ||
VDegenPoolLimitInfo::Current(c) | ||
} | ||
} | ||
|
||
#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize)] | ||
#[serde(crate = "near_sdk::serde")] | ||
#[cfg_attr(not(target_arch = "wasm32"), derive(Debug))] | ||
pub enum VPoolLimitInfo { | ||
DegenPoolLimit(VDegenPoolLimitInfo) | ||
} | ||
|
||
impl VPoolLimitInfo { | ||
pub fn get_degen_pool_limit(self) -> DegenPoolLimitInfo { | ||
match self { | ||
VPoolLimitInfo::DegenPoolLimit(l) => l.into(), | ||
} | ||
} | ||
} | ||
|
||
pub fn read_pool_limit_from_storage() -> UnorderedMap<u64, VPoolLimitInfo> { | ||
if let Some(content) = env::storage_read(POOL_LIMIT.as_bytes()) { | ||
UnorderedMap::try_from_slice(&content).expect("deserialize pool limit info failed.") | ||
} else { | ||
UnorderedMap::new(StorageKey::PoolLimit) | ||
} | ||
} | ||
|
||
pub fn write_pool_limit_to_storage(pool_limit: UnorderedMap<u64, VPoolLimitInfo>) { | ||
env::storage_write( | ||
POOL_LIMIT.as_bytes(), | ||
&pool_limit.try_to_vec().unwrap(), | ||
); | ||
} |
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
Oops, something went wrong.