11#[starknet:: component]
22pub mod AssetsComponent {
3- use starknet :: SyscallResultTrait ;
4- use RolesComponent :: InternalTrait as RolesInternalTrait ;
3+ use RolesComponent :: InternalTrait as RolesInternalTrait ;
54 use core :: cmp :: min;
65 use core :: hash :: Hash ;
76 use core :: iter :: {IntoIterator , Iterator };
@@ -25,11 +24,6 @@ use RolesComponent::InternalTrait as RolesInternalTrait;
2524 UNSORTED_RISK_FACTOR_TIERS , ZERO_MAX_FUNDING_INTERVAL , ZERO_MAX_FUNDING_RATE ,
2625 ZERO_MAX_ORACLE_PRICE , ZERO_MAX_PRICE_INTERVAL ,
2726 };
28- use starknet :: storage_access :: {
29- StorageBaseAddress , Store , storage_address_from_base, storage_address_from_base_and_offset,
30- };
31- use starknet :: syscalls :: {storage_read_syscall, storage_write_syscall};
32- use starknet :: {ContractAddress , SyscallResult };
3327 use perpetuals :: core :: components :: assets :: events;
3428 use perpetuals :: core :: components :: assets :: interface :: IAssets ;
3529 use perpetuals :: core :: components :: operator_nonce :: OperatorNonceComponent ;
@@ -45,22 +39,25 @@ use RolesComponent::InternalTrait as RolesInternalTrait;
4539 };
4640 use perpetuals :: core :: types :: risk_factor :: {RiskFactor , RiskFactorTrait };
4741 use starknet :: storage :: {
48- Map , Mutable , MutableVecTrait , StorageAsPath , StorageAsPointer , StorageMapReadAccess ,
49- StorageMapWriteAccess , StoragePath , StoragePathEntry , StoragePointer0Offset ,
50- StoragePointerReadAccess , StoragePointerWriteAccess , Vec , VecTrait , StorableStoragePointerReadAccess , StoragePathUpdateTrait
42+ IntoIterRange , Map , Mutable , MutableVecTrait , StorableStoragePointerReadAccess ,
43+ StorageAsPath , StorageAsPointer , StorageMapReadAccess , StorageMapWriteAccess , StoragePath ,
44+ StoragePathEntry , StoragePathMutableConversion , StoragePathUpdateTrait ,
45+ StoragePointer0Offset , StoragePointerReadAccess , StoragePointerWriteAccess , Vec , VecTrait ,
5146 };
52- use starknet :: storage :: {
53- IntoIterRange ,
54- StoragePathMutableConversion
47+ use starknet :: storage_access :: {
48+ StorageBaseAddress , Store , storage_address_from_base, storage_address_from_base_and_offset,
5549 };
50+ use starknet :: syscalls :: {storage_read_syscall, storage_write_syscall};
51+ use starknet :: {ContractAddress , SyscallResult , SyscallResultTrait };
5652 use starkware_utils :: components :: pausable :: PausableComponent ;
5753 use starkware_utils :: components :: pausable :: PausableComponent :: InternalTrait as PausableInternal ;
5854 use starkware_utils :: components :: roles :: RolesComponent ;
5955 use starkware_utils :: constants :: {MINUTE , TWO_POW_128 , TWO_POW_32 , TWO_POW_40 };
6056 use starkware_utils :: math :: abs :: Abs ;
6157 use starkware_utils :: signature :: stark :: {PublicKey , validate_stark_signature};
6258 use starkware_utils :: storage :: iterable_map :: {
63- IterableMap , IterableMapIntoIterImpl , IterableMapReadAccessImpl , IterableMapWriteAccessImpl , IterableMapTrait ,
59+ IterableMap , IterableMapIntoIterImpl , IterableMapReadAccessImpl , IterableMapTrait ,
60+ IterableMapWriteAccessImpl ,
6461 };
6562 use starkware_utils :: storage :: utils :: {AddToStorage , SubFromStorage };
6663 use starkware_utils :: time :: time :: {Time , TimeDelta , Timestamp };
@@ -525,9 +522,12 @@ use RolesComponent::InternalTrait as RolesInternalTrait;
525522 self : @ ComponentState <TContractState >, synthetic_id : AssetId ,
526523 ) -> Price {
527524 let entry = self . synthetic_timely_data. pointer (key : synthetic_id );
528- let price = storage_read_syscall (0 , storage_address_from_base_and_offset (entry . __storage_pointer_address__ , 2 )). unwrap_syscall ();
529- let x : u64 = price . try_into (). unwrap ();
530- x . into ()
525+ let price = storage_read_syscall (
526+ 0 , storage_address_from_base_and_offset (entry . __storage_pointer_address__, 2 ),
527+ )
528+ . unwrap_syscall ();
529+ let price : u64 = price . try_into (). unwrap ();
530+ price . into ()
531531 }
532532
533533 /// Get the risk factor of a synthetic asset.
@@ -545,7 +545,9 @@ use RolesComponent::InternalTrait as RolesInternalTrait;
545545 price : Price ,
546546 ) -> RiskFactor {
547547 let entry = self . synthetic_config. entry (synthetic_id );
548- let risk_factor_first_tier_boundary = entry . risk_factor_first_tier_boundary. read (); // read 1
548+ let risk_factor_first_tier_boundary = entry
549+ . risk_factor_first_tier_boundary
550+ . read (); // read 1
549551
550552 let asset_risk_factor_tiers = self . risk_factor_tiers. entry (synthetic_id );
551553 let synthetic_value : u128 = price . mul (rhs : balance ). abs ();
@@ -560,15 +562,19 @@ use RolesComponent::InternalTrait as RolesInternalTrait;
560562 )
561563 };
562564 let con_index : u64 = index . try_into (). expect (' INDEX_SHOULD_NEVER_OVERFLOW' );
563- let risk_factor_entry : StoragePath <RiskFactor > = asset_risk_factor_tiers . update (con_index );
565+ let risk_factor_entry : StoragePath <RiskFactor > = asset_risk_factor_tiers
566+ . update (con_index );
564567 risk_factor_entry . read ()
565568 }
566569
567570 fn get_funding_index (
568571 self : @ ComponentState <TContractState >, synthetic_id : AssetId ,
569572 ) -> FundingIndex {
570573 let entry = self . synthetic_timely_data. pointer (key : synthetic_id );
571- let funding_index = storage_read_syscall (0 , storage_address_from_base_and_offset (entry . __storage_pointer_address__ , 4 )). unwrap_syscall ();
574+ let funding_index = storage_read_syscall (
575+ 0 , storage_address_from_base_and_offset (entry . __storage_pointer_address__, 4 ),
576+ )
577+ . unwrap_syscall ();
572578 let x : i64 = funding_index . try_into (). unwrap ();
573579 x . into ()
574580 }
0 commit comments