Skip to content

Commit d7f629a

Browse files
committed
cargo fmt
1 parent 3898b52 commit d7f629a

File tree

22 files changed

+430
-373
lines changed

22 files changed

+430
-373
lines changed

contracts/liquidity_book/lb_factory/src/error.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
use bin_helper::BinError;
66
use cosmwasm_std::Addr;
77
use fee_helper::FeeError;
8-
use math::liquidity_configurations::LiquidityConfigurationsError;
9-
use math::u128x128_math::U128x128MathError;
10-
use math::u256x256_math::U256x256MathError;
8+
use math::{
9+
liquidity_configurations::LiquidityConfigurationsError,
10+
u128x128_math::U128x128MathError,
11+
u256x256_math::U256x256MathError,
12+
};
1113
use oracle_helper::OracleError;
1214
use pair_parameter_helper::PairParametersError;
1315
use shade_protocol::lb_libraries::{
14-
bin_helper, fee_helper, math, oracle_helper, pair_parameter_helper,
16+
bin_helper,
17+
fee_helper,
18+
math,
19+
oracle_helper,
20+
pair_parameter_helper,
1521
};
1622

1723
#[derive(thiserror::Error, Debug)]
@@ -76,7 +82,9 @@ pub enum LBFactoryError {
7682
#[error("Flash loan fee is already {fee}!")]
7783
SameFlashLoanFee { fee: u8 },
7884

79-
#[error("LBPair safety check failed. {lb_pair_implementation} factory address does not match this one!")]
85+
#[error(
86+
"LBPair safety check failed. {lb_pair_implementation} factory address does not match this one!"
87+
)]
8088
LBPairSafetyCheckFailed { lb_pair_implementation: Addr },
8189

8290
#[error("LB implementation is already set to code ID {lb_implementation}!")]

contracts/liquidity_book/lb_factory/src/state.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ use tokens::TokenType;
1010
use shade_protocol::lb_libraries::{pair_parameter_helper, tokens, types};
1111
use types::{Bytes32, ContractInstantiationInfo};
1212

13-
use crate::prelude::*;
14-
use crate::types::{LBPair, LBPairInformation, NextPairKey};
13+
use crate::{
14+
prelude::*,
15+
types::{LBPair, LBPairInformation, NextPairKey},
16+
};
1517

1618
pub const CONFIG: Item<State> = Item::new("config");
1719
pub static EPHEMERAL_STORAGE_KEY: &[u8] = b"ephemeral_storage";

contracts/liquidity_book/lb_pair/src/error.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ use bin_helper::BinError;
66
use cosmwasm_std::{StdError, Uint128};
77
use ethnum::U256;
88
use fee_helper::FeeError;
9-
use math::liquidity_configurations::LiquidityConfigurationsError;
10-
use math::u128x128_math::U128x128MathError;
11-
use math::u256x256_math::U256x256MathError;
9+
use math::{
10+
liquidity_configurations::LiquidityConfigurationsError,
11+
u128x128_math::U128x128MathError,
12+
u256x256_math::U256x256MathError,
13+
};
1214
use oracle_helper::OracleError;
1315
use pair_parameter_helper::PairParametersError;
1416
use shade_protocol::lb_libraries::{
15-
bin_helper, fee_helper, math, oracle_helper, pair_parameter_helper,
17+
bin_helper,
18+
fee_helper,
19+
math,
20+
oracle_helper,
21+
pair_parameter_helper,
1622
};
1723

1824
#[derive(thiserror::Error, Debug)]
@@ -65,7 +71,9 @@ pub enum LBPairError {
6571
#[error("Zero amount for bin id: {id}")]
6672
ZeroAmount { id: u32 },
6773

68-
#[error("Zero amounts out for bin id: {id} amount to burn: {amount_to_burn} total supply: {total_supply} ")]
74+
#[error(
75+
"Zero amounts out for bin id: {id} amount to burn: {amount_to_burn} total supply: {total_supply} "
76+
)]
6977
ZeroAmountsOut {
7078
id: u32,
7179
// bin_reserves: [u8; 32],
@@ -146,14 +154,18 @@ pub enum LBPairError {
146154
#[error("Id overflows. Id: {id}")]
147155
IdOverflows { id: u32 },
148156

149-
#[error("Amount left unswapped. : Amount Left In: {amount_left_in}, Total Amount: {total_amount}, swapped_amount: {swapped_amount}")]
157+
#[error(
158+
"Amount left unswapped. : Amount Left In: {amount_left_in}, Total Amount: {total_amount}, swapped_amount: {swapped_amount}"
159+
)]
150160
AmountInLeft {
151161
amount_left_in: Uint128,
152162
total_amount: Uint128,
153163
swapped_amount: Uint128,
154164
},
155165

156-
#[error("Id slippage caught. Active id desired: {active_id_desired}, Id slippage: {id_slippage}, Active id: {active_id}")]
166+
#[error(
167+
"Id slippage caught. Active id desired: {active_id_desired}, Id slippage: {id_slippage}, Active id: {active_id}"
168+
)]
157169
IdSlippageCaught {
158170
active_id_desired: u32,
159171
id_slippage: u32,
@@ -166,7 +178,9 @@ pub enum LBPairError {
166178
token_y: String,
167179
bin_step: u16,
168180
},
169-
#[error("Amount slippage caught. AmountXMin: {amount_x_min}, AmountX: {amount_x}, AmountYMin: {amount_y_min}, AmountY: {amount_y}")]
181+
#[error(
182+
"Amount slippage caught. AmountXMin: {amount_x_min}, AmountX: {amount_x}, AmountYMin: {amount_y_min}, AmountY: {amount_y}"
183+
)]
170184
AmountSlippageCaught {
171185
amount_x_min: Uint128,
172186
amount_x: Uint128,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

contracts/liquidity_book/lb_token/src/contract.rs

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,34 @@ use secret_toolkit::{
3030
use crate::{
3131
receiver::Snip1155ReceiveMsg,
3232
state::{
33-
balances_r, balances_w, blockinfo_r, blockinfo_w, contr_conf_r, contr_conf_w,
33+
balances_r,
34+
balances_w,
35+
blockinfo_r,
36+
blockinfo_w,
37+
contr_conf_r,
38+
contr_conf_w,
3439
get_receiver_hash,
3540
permissions::{
36-
list_owner_permission_keys, may_load_any_permission, new_permission, update_permission,
41+
list_owner_permission_keys,
42+
may_load_any_permission,
43+
new_permission,
44+
update_permission,
3745
},
38-
set_receiver_hash, tkn_info_r, tkn_info_w, tkn_tot_supply_r, tkn_tot_supply_w,
46+
set_receiver_hash,
47+
tkn_info_r,
48+
tkn_info_w,
49+
tkn_tot_supply_r,
50+
tkn_tot_supply_w,
3951
txhistory::{
40-
append_new_owner, get_txs, may_get_current_owner, store_burn, store_mint,
52+
append_new_owner,
53+
get_txs,
54+
may_get_current_owner,
55+
store_burn,
56+
store_mint,
4157
store_transfer,
4258
},
43-
PREFIX_REVOKED_PERMITS, RESPONSE_BLOCK_SIZE,
59+
PREFIX_REVOKED_PERMITS,
60+
RESPONSE_BLOCK_SIZE,
4461
},
4562
};
4663

@@ -51,12 +68,21 @@ use shade_protocol::{
5168
metadata::Metadata,
5269
permissions::{Permission, PermissionKey},
5370
state_structs::{
54-
ContractConfig, CurateTokenId, OwnerBalance, StoredTokenInfo, TknConfig, TokenAmount,
71+
ContractConfig,
72+
CurateTokenId,
73+
OwnerBalance,
74+
StoredTokenInfo,
75+
TknConfig,
76+
TokenAmount,
5577
TokenInfoMsg,
5678
},
5779
},
5880
liquidity_book::lb_token::{
59-
ExecuteAnswer, ExecuteMsg, InstantiateMsg, ResponseStatus::Success, SendAction,
81+
ExecuteAnswer,
82+
ExecuteMsg,
83+
InstantiateMsg,
84+
ResponseStatus::Success,
85+
SendAction,
6086
TransferAction,
6187
},
6288
};
@@ -181,20 +207,15 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S
181207
msg,
182208
memo,
183209
padding: _,
184-
} => try_send(
185-
deps,
186-
env,
187-
info,
188-
SendAction {
189-
token_id,
190-
from,
191-
recipient,
192-
recipient_code_hash,
193-
amount,
194-
msg,
195-
memo,
196-
},
197-
),
210+
} => try_send(deps, env, info, SendAction {
211+
token_id,
212+
from,
213+
recipient,
214+
recipient_code_hash,
215+
amount,
216+
msg,
217+
memo,
218+
}),
198219
ExecuteMsg::BatchSend {
199220
actions,
200221
padding: _,

contracts/liquidity_book/lb_token/src/state/mod.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ pub mod txhistory;
55
use cosmwasm_std::{to_binary, Addr, BlockInfo, StdError, StdResult, Storage, Uint256};
66

77
use cosmwasm_storage::{
8-
bucket, bucket_read, singleton, singleton_read, Bucket, PrefixedStorage, ReadonlyBucket,
9-
ReadonlyPrefixedStorage, ReadonlySingleton, Singleton,
8+
bucket,
9+
bucket_read,
10+
singleton,
11+
singleton_read,
12+
Bucket,
13+
PrefixedStorage,
14+
ReadonlyBucket,
15+
ReadonlyPrefixedStorage,
16+
ReadonlySingleton,
17+
Singleton,
1018
};
1119

1220
use shade_protocol::lb_libraries::lb_token::{
@@ -106,14 +114,11 @@ fn permission_w<'a>(
106114
token_id: &'a str,
107115
) -> Bucket<'a, Permission> {
108116
let owner_bin = to_binary(owner).unwrap();
109-
Bucket::multilevel(
110-
storage,
111-
&[
112-
PREFIX_PERMISSIONS,
113-
owner_bin.as_slice(),
114-
token_id.as_bytes(),
115-
],
116-
)
117+
Bucket::multilevel(storage, &[
118+
PREFIX_PERMISSIONS,
119+
owner_bin.as_slice(),
120+
token_id.as_bytes(),
121+
])
117122
}
118123
/// private functions.
119124
/// To read permission. key is to be [`owner`, `token_id`, `allowed_addr`]
@@ -124,14 +129,11 @@ fn permission_r<'a>(
124129
token_id: &'a str,
125130
) -> ReadonlyBucket<'a, Permission> {
126131
let owner_bin = to_binary(owner).unwrap();
127-
ReadonlyBucket::multilevel(
128-
storage,
129-
&[
130-
PREFIX_PERMISSIONS,
131-
owner_bin.as_slice(),
132-
token_id.as_bytes(),
133-
],
134-
)
132+
ReadonlyBucket::multilevel(storage, &[
133+
PREFIX_PERMISSIONS,
134+
owner_bin.as_slice(),
135+
token_id.as_bytes(),
136+
])
135137
}
136138
#[cfg(test)]
137139
pub fn perm_r<'a>(
@@ -140,14 +142,11 @@ pub fn perm_r<'a>(
140142
token_id: &'a str,
141143
) -> ReadonlyBucket<'a, Permission> {
142144
let owner_bin = to_binary(owner).unwrap();
143-
ReadonlyBucket::multilevel(
144-
storage,
145-
&[
146-
PREFIX_PERMISSIONS,
147-
owner_bin.as_slice(),
148-
token_id.as_bytes(),
149-
],
150-
)
145+
ReadonlyBucket::multilevel(storage, &[
146+
PREFIX_PERMISSIONS,
147+
owner_bin.as_slice(),
148+
token_id.as_bytes(),
149+
])
151150
}
152151

153152
/////////////////////////////////////////////////////////////////////////////////

contracts/liquidity_book/lb_token/src/state/save_load_functions.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
use std::{
2-
any::type_name,
3-
// collections::HashSet,
4-
};
1+
use std::any::type_name;
52

63
use serde::{de::DeserializeOwned, Serialize};
74

8-
use cosmwasm_std::{
9-
Storage,
10-
StdResult, StdError,
11-
};
12-
13-
use secret_toolkit::{
14-
serialization::{Json, Serde}, //Bincode2
15-
};
5+
use cosmwasm_std::{StdError, StdResult, Storage};
166

7+
use secret_toolkit::serialization::{Json, Serde};
178

189
// /////////////////////////////////////////////////////////////////////////////////
1910
// // Save and load functions
@@ -27,11 +18,7 @@ use secret_toolkit::{
2718
/// * `storage` - a mutable reference to the storage this item should go to
2819
/// * `key` - a byte slice representing the key to access the stored item
2920
/// * `value` - a reference to the item to store
30-
pub fn json_save<T: Serialize>(
31-
storage: &mut dyn Storage,
32-
key: &[u8],
33-
value: &T,
34-
) -> StdResult<()> {
21+
pub fn json_save<T: Serialize>(storage: &mut dyn Storage, key: &[u8], value: &T) -> StdResult<()> {
3522
storage.set(key, &Json::serialize(value)?);
3623
Ok(())
3724
}
@@ -69,4 +56,3 @@ pub fn json_load<T: DeserializeOwned>(storage: &dyn Storage, key: &[u8]) -> StdR
6956
// None => Ok(None),
7057
// }
7158
// }
72-

0 commit comments

Comments
 (0)