Skip to content

Commit

Permalink
Merge pull request #3 from halotrade-zone/add-lp_token_decimals
Browse files Browse the repository at this point in the history
Update instantiation of LP token's decimals
  • Loading branch information
hoanm authored Apr 18, 2023
2 parents c3ae8e4 + 00d6144 commit e26a032
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions contracts/halo-factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub fn execute_create_pair(
lp_token_info: LPTokenInfo {
lp_token_name: lp_token_info.lp_token_name,
lp_token_symbol: lp_token_info.lp_token_symbol,
lp_token_decimals: lp_token_info.lp_token_decimals,
},
})?,
}),
Expand Down
14 changes: 12 additions & 2 deletions contracts/halo-factory/src/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ fn create_pair() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_mAAPL_LP".to_string(),
lp_token_symbol: "uusd_mAAPL_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -191,7 +192,8 @@ fn create_pair() {
commission_rate: Decimal256::from_str("0.003").unwrap(),
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_mAAPL_LP".to_string(),
lp_token_symbol: "uusd_mAAPL_LP".to_string()
lp_token_symbol: "uusd_mAAPL_LP".to_string(),
lp_token_decimals: None,
},
})
.unwrap(),
Expand Down Expand Up @@ -239,6 +241,7 @@ fn create_pair() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_mAAPL_LP".to_string(),
lp_token_symbol: "uusd_mAAPL_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -283,6 +286,7 @@ fn create_pair_native_token_and_ibc_token() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_ibc/HASH_LP".to_string(),
lp_token_symbol: "uusd_ibc/HASH_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -312,7 +316,8 @@ fn create_pair_native_token_and_ibc_token() {
commission_rate: Decimal256::from_str("0.003").unwrap(),
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_ibc/HASH_LP".to_string(),
lp_token_symbol: "uusd_ibc/HASH_LP".to_string()
lp_token_symbol: "uusd_ibc/HASH_LP".to_string(),
lp_token_decimals: None,
},
})
.unwrap(),
Expand Down Expand Up @@ -367,6 +372,7 @@ fn fail_to_create_same_pair() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_uusd_LP".to_string(),
lp_token_symbol: "uusd_uusd_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -402,6 +408,7 @@ fn fail_to_create_pair_with_unactive_denoms() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_uxxx_LP".to_string(),
lp_token_symbol: "uusd_uxxx_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -437,6 +444,7 @@ fn fail_to_create_pair_with_invalid_denom() {
lp_token_info: LPTokenInfo {
lp_token_name: "uluna_xxx_LP".to_string(),
lp_token_symbol: "uluna_xxx_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -482,6 +490,7 @@ fn fail_to_create_pair_with_unknown_token() {
lp_token_info: LPTokenInfo {
lp_token_name: "uluna_xxx_LP".to_string(),
lp_token_symbol: "uluna_xxx_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -527,6 +536,7 @@ fn fail_to_create_pair_with_unknown_ibc_token() {
lp_token_info: LPTokenInfo {
lp_token_name: "uluna_ibc/HA_LP".to_string(),
lp_token_symbol: "uluna_ibc/HA_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down
2 changes: 1 addition & 1 deletion contracts/halo-pair/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn instantiate(
msg: to_binary(&TokenInstantiateMsg {
name: msg.lp_token_info.clone().lp_token_name,
symbol: msg.lp_token_info.lp_token_symbol,
decimals: 6,
decimals: msg.lp_token_info.lp_token_decimals.unwrap_or(6),
initial_balances: vec![],
mint: Some(MinterResponse {
minter: env.contract.address.to_string(),
Expand Down
7 changes: 6 additions & 1 deletion contracts/halo-pair/src/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn proper_initialization() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_asset0000_lp".to_string(),
lp_token_symbol: "uusd_asset0000_lp".to_string(),
lp_token_decimals: Some(18),
},
};

Expand All @@ -57,7 +58,7 @@ fn proper_initialization() {
msg: to_binary(&TokenInstantiateMsg {
name: "uusd_asset0000_lp".to_string(),
symbol: "uusd_asset0000_lp".to_string(),
decimals: 6,
decimals: 18,
initial_balances: vec![],
mint: Some(MinterResponse {
minter: MOCK_CONTRACT_ADDR.to_string(),
Expand Down Expand Up @@ -249,6 +250,7 @@ fn provide_liquidity() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_asset0000_LP".to_string(),
lp_token_symbol: "uusd_asset0000_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -739,6 +741,7 @@ fn withdraw_liquidity() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_asset0000_LP".to_string(),
lp_token_symbol: "uusd_asset0000_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -1066,6 +1069,7 @@ fn try_token_to_native() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_asset0000_LP".to_string(),
lp_token_symbol: "uusd_asset0000_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down Expand Up @@ -1508,6 +1512,7 @@ fn test_query_pool() {
lp_token_info: LPTokenInfo {
lp_token_name: "uusd_asset0000_LP".to_string(),
lp_token_symbol: "uusd_asset0000_LP".to_string(),
lp_token_decimals: None,
},
};

Expand Down
2 changes: 1 addition & 1 deletion contracts/halo-router/src/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod tests {
use haloswap::factory::{
ExecuteMsg as FactoryExecuteMsg, NativeTokenDecimalsResponse, QueryMsg as FactoryQueryMsg,
};

use haloswap::pair::Cw20HookMsg;
// Mock information for CW20 token contract
const MOCK_1000_HALO_TOKEN_AMOUNT: u128 = 1_000_000_000;
Expand Down Expand Up @@ -174,6 +173,7 @@ mod tests {
lp_token_info: LPTokenInfo {
lp_token_name: "aura-HALO".to_string(),
lp_token_symbol: "aura-HALO".to_string(),
lp_token_decimals: None,
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/haloswap/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,5 @@ impl PairInfoRaw {
pub struct LPTokenInfo {
pub lp_token_name: String,
pub lp_token_symbol: String,
pub lp_token_decimals: Option<u8>,
}

0 comments on commit e26a032

Please sign in to comment.