-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: chainlink oracle adapter #1006
base: master
Are you sure you want to change the base?
Conversation
Crate versions that have not been updated:
Crate versions that have been updated:
Runtime version has been increased. |
@@ -121,6 +121,8 @@ impl Get<Multiplier> for TransactionPaymentMultiplier { | |||
} | |||
} | |||
|
|||
pub const USDT: AssetId = 10u32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would not be better to read this from asset registry based on Location? Similarly what we have for DOT so
pub struct DotAssetId;
impl Get<AssetId> for DotAssetId {
fn get() -> AssetId {
let invalid_id =
pallet_asset_registry::Pallet::<crate::Runtime>::next_asset_id().defensive_unwrap_or(AssetId::MAX);
match pallet_asset_registry::Pallet::<crate::Runtime>::location_to_asset(DOT_ASSET_LOCATION) {
Some(asset_id) => asset_id,
None => invalid_id,
}
}
}
} | ||
} | ||
|
||
impl<QuoteAsset, Runtime> ChainlinkOraclePrecompile<QuoteAsset, Runtime> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i probably dont get what Chainlink is doing, but why is this Chainlink specific? Do we do anything with the official Chainlink oracle network?
|
||
/// Encoding is 7 bytes for precompile prefix 0x00000000000001, | ||
/// followed by 1 byte for encoded OraclePeriod enum, 8 bytes for Source, and 4 bytes for AssetId. | ||
pub fn encode_evm_address(asset_id: AssetId, period: OraclePeriod, source: Source) -> Option<EvmAddress> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could do an invariant test for this to make sure it never panics?
})?; | ||
|
||
// use Router to get a route | ||
let price = if source == [0; 8] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make a constant for this magic number [0;8]
, like EMPTY_SOURCE
or so
exit_status: pallet_evm::ExitError::Other("Decimals not available".into()), | ||
})?; | ||
|
||
// use Router to get a route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// use Router to get a route | |
// In case of empty source, we retrieve onchain route |
Fixes #993