Struct pallet_oracle::pallet::Pallet
source · pub struct Pallet<T>(_);
Expand description
The pallet implementing the on-chain logic.
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn confirm_swap(
origin: OriginFor<T>,
request_id: Hash,
market_makers: Vec<SwapConfirmation>
) -> DispatchResultWithPostInfo
pub fn confirm_swap(
origin: OriginFor<T>,
request_id: Hash,
market_makers: Vec<SwapConfirmation>
) -> DispatchResultWithPostInfo
Oracle have confirmation and confirm the trade.
request_id
: Unique request ID.market_makers
: Vector ofSwapConfirmation
who represent the allocation of multiple source.
Emits SwapProcessed
event when successful.
Weight: O(1)
sourcepub fn cancel_swap(
origin: OriginFor<T>,
request_id: Hash
) -> DispatchResultWithPostInfo
pub fn cancel_swap(
origin: OriginFor<T>,
request_id: Hash
) -> DispatchResultWithPostInfo
Oracle cancel a swap request and release remaining funds
request_id
: Unique request ID.
Emits SwapCancelled
event when successful.
Weight: O(1)
sourcepub fn set_account_id(
origin: OriginFor<T>,
new_account_id: T::AccountId
) -> DispatchResultWithPostInfo
pub fn set_account_id(
origin: OriginFor<T>,
new_account_id: T::AccountId
) -> DispatchResultWithPostInfo
Oracle change the account ID who can confirm trade.
Make sure to have access to the account_id
otherwise
only root
will be able to update the oracle account.
new_account_id
: The new Oracle account id.
Emits AccountChanged
event when successful.
Weight: O(1)
sourcepub fn set_status(
origin: OriginFor<T>,
is_enabled: bool
) -> DispatchResultWithPostInfo
pub fn set_status(
origin: OriginFor<T>,
is_enabled: bool
) -> DispatchResultWithPostInfo
Change Oracle status.
is_enabled
: Is the oracle enabled?
Emits StatusChanged
event when successful.
Weight: O(1)
sourcepub fn update_assets_value(
origin: OriginFor<T>,
value: Vec<(AssetId, Balance)>
) -> DispatchResultWithPostInfo
pub fn update_assets_value(
origin: OriginFor<T>,
value: Vec<(AssetId, Balance)>
) -> DispatchResultWithPostInfo
Update assets values.
value
: How many TDFY required for 1 Asset.
The value should be formatted with TDFY decimals (12)
Example:
If the Bitcoin price is 0.001815 BTC (for 1 TDFY) You get 550.9641873278 TDFY for 1 BTC
The value should be: vec![(2, 550_964_187_327_800)]
If the ETH price is 0.03133 ETH (for 1 TDFY) You get 31.9182891796999 TDFY for 1 ETH
The value sent should be: vec![(4, 31_918_289_179_699)]
If the USDT price is 33.650000 USDT (for 1 TDFY) You get 0.029717682000 TDFY for 1 USDT
The value sent should be: vec![(4, 29_717_682_020)]
Weight: O(1)
sourcepub fn add_market_maker(
origin: OriginFor<T>,
account_id: T::AccountId
) -> DispatchResultWithPostInfo
pub fn add_market_maker(
origin: OriginFor<T>,
account_id: T::AccountId
) -> DispatchResultWithPostInfo
Add market maker to the local storage
Emits StatusChanged
event when successful.
Weight: O(1)
sourcepub fn remove_market_maker(
origin: OriginFor<T>,
account_id: T::AccountId
) -> DispatchResultWithPostInfo
pub fn remove_market_maker(
origin: OriginFor<T>,
account_id: T::AccountId
) -> DispatchResultWithPostInfo
Remove market maker to the local storage
delete_orders
: Should we delete all existing swaps on chain for this user?
Emits StatusChanged
event when successful.
Weight: O(1)
sourcepub fn add_market_pair(
origin: OriginFor<T>,
market_pair: MarketPair
) -> DispatchResultWithPostInfo
pub fn add_market_pair(
origin: OriginFor<T>,
market_pair: MarketPair
) -> DispatchResultWithPostInfo
Add a new market pair to be supported
market_pair
: Market pair
Emits MarketPairAdded
event when successful.
sourcepub fn remove_market_pair(
origin: OriginFor<T>,
market_pair: MarketPair
) -> DispatchResultWithPostInfo
pub fn remove_market_pair(
origin: OriginFor<T>,
market_pair: MarketPair
) -> DispatchResultWithPostInfo
Remove a market pair from the supported list
market_pair
: Market pair
Emits MarketPairRemoved
event when successful.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn swaps<KArg>(k: KArg) -> Option<Swap<T::AccountId, T::BlockNumber>>where
KArg: EncodeLike<Hash>,
pub fn swaps<KArg>(k: KArg) -> Option<Swap<T::AccountId, T::BlockNumber>>where
KArg: EncodeLike<Hash>,
Mapping of pending Swaps
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn account_swaps<KArg>(
k: KArg
) -> Option<BoundedVec<(Hash, SwapStatus), T::SwapLimitByAccount>>where
KArg: EncodeLike<T::AccountId>,
pub fn account_swaps<KArg>(
k: KArg
) -> Option<BoundedVec<(Hash, SwapStatus), T::SwapLimitByAccount>>where
KArg: EncodeLike<T::AccountId>,
Mapping of pending Swaps by AccountId
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn supported_market_pairs(
) -> BoundedVec<MarketPair, T::SupportedMarketPairsLimit>
pub fn supported_market_pairs(
) -> BoundedVec<MarketPair, T::SupportedMarketPairsLimit>
Set of swap market pairs
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn market_makers<KArg>(k: KArg) -> Option<bool>where
KArg: EncodeLike<T::AccountId>,
pub fn market_makers<KArg>(k: KArg) -> Option<bool>where
KArg: EncodeLike<T::AccountId>,
Set of active market makers
Trait Implementations§
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
source§fn current_storage_version() -> StorageVersion
fn current_storage_version() -> StorageVersion
source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
source§impl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_initialize(_now: T::BlockNumber) -> Weight
fn on_initialize(_now: T::BlockNumber) -> Weight
source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
on_finalize
).
Implement to have something happen using the remaining weight.
Will not fire if the remaining weight is 0.
Return the weight used, the hook will subtract it from current weight used
and pass the result to the next on_idle
hook if it exists. Read moresource§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
source§fn integrity_test()
fn integrity_test()
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
source§impl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
source§fn offchain_worker(n: <T as Config>::BlockNumber)
fn offchain_worker(n: <T as Config>::BlockNumber)
source§impl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_finalize(n: <T as Config>::BlockNumber)
fn on_finalize(n: <T as Config>::BlockNumber)
source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
source§impl<T: Config> OnIdle<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnIdle<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
remaining_weight
to make sure it is high enough to allow for
your pallet’s extra computation. Read moresource§impl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
source§impl<T: Config> OracleExt<<T as Config>::AccountId, <T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OracleExt<<T as Config>::AccountId, <T as Config>::BlockNumber> for Pallet<T>
source§fn is_oracle_enabled() -> bool
fn is_oracle_enabled() -> bool
source§fn is_market_maker(account_id: T::AccountId) -> Result<bool, DispatchError>
fn is_market_maker(account_id: T::AccountId) -> Result<bool, DispatchError>
source§fn add_new_swap_in_queue(
account_id: T::AccountId,
asset_id_from: CurrencyId,
amount_from: Balance,
asset_id_to: CurrencyId,
amount_to: Balance,
block_number: T::BlockNumber,
extrinsic_hash: [u8; 32],
is_market_maker: bool,
swap_type: SwapType,
slippage: Permill
) -> Result<(Hash, Swap<T::AccountId, T::BlockNumber>), DispatchError>
fn add_new_swap_in_queue(
account_id: T::AccountId,
asset_id_from: CurrencyId,
amount_from: Balance,
asset_id_to: CurrencyId,
amount_to: Balance,
block_number: T::BlockNumber,
extrinsic_hash: [u8; 32],
is_market_maker: bool,
swap_type: SwapType,
slippage: Permill
) -> Result<(Hash, Swap<T::AccountId, T::BlockNumber>), DispatchError>
source§fn remove_swap_from_queue(
requester: T::AccountId,
request_id: Hash
) -> Result<(), DispatchError>
fn remove_swap_from_queue(
requester: T::AccountId,
request_id: Hash
) -> Result<(), DispatchError>
source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T: Config> PalletsInfoAccess for Pallet<T>
impl<T: Config> PalletsInfoAccess for Pallet<T>
source§impl<T: Config> StorageInfoTrait for Pallet<T>
impl<T: Config> StorageInfoTrait for Pallet<T>
fn storage_info() -> Vec<StorageInfo> ⓘ
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey> ⓘ
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey> ⓘ
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation. Read moreimpl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresource§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresource§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
source§impl<T> PalletVersionToStorageVersionHelper for Twhere
T: GetStorageVersion + PalletInfoAccess,
impl<T> PalletVersionToStorageVersionHelper for Twhere
T: GetStorageVersion + PalletInfoAccess,
fn migrate(db_weight: &RuntimeDbWeight) -> Weight
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.