-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--- Please provide a general summary of your changes in the title above --> <!-- Give an estimate of the time you spent on this PR in terms of work days. Did you spend 0.5 days on this PR or rather 2 days? --> Time spent on this PR: ## Pull request type <!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Resolves #<Issue number> ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - - - <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1169) <!-- Reviewable:end -->
- Loading branch information
Showing
17 changed files
with
450 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ lint: | |
paths: [poetry.lock] | ||
- linters: [ALL] | ||
paths: | ||
- cairo1_contracts | ||
- logs* | ||
- lib* | ||
- resources* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scarb 0.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Code generated by scarb DO NOT EDIT. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "alexandria_data_structures" | ||
version = "0.1.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4#46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4" | ||
|
||
[[package]] | ||
name = "alexandria_math" | ||
version = "0.2.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4#46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4" | ||
dependencies = [ | ||
"alexandria_data_structures", | ||
] | ||
|
||
[[package]] | ||
name = "alexandria_sorting" | ||
version = "0.1.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4#46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4" | ||
|
||
[[package]] | ||
name = "alexandria_storage" | ||
version = "0.2.0" | ||
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=92c3c1b4ac35a4a56c14abe992814581aee875a8#92c3c1b4ac35a4a56c14abe992814581aee875a8" | ||
|
||
[[package]] | ||
name = "cubit" | ||
version = "1.2.0" | ||
source = "git+https://github.com/influenceth/cubit?rev=2ccb2536dffa3f15ebd38b755c1be65fde1eab0c#2ccb2536dffa3f15ebd38b755c1be65fde1eab0c" | ||
|
||
[[package]] | ||
name = "mock_pragma" | ||
version = "0.1.0" | ||
dependencies = [ | ||
"pragma", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin" | ||
version = "0.7.0" | ||
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.7.0#bb8c56817577b66cea9f18a241fe59726db42dd5" | ||
|
||
[[package]] | ||
name = "pragma" | ||
version = "1.0.0" | ||
source = "git+https://github.com/astraly-labs/pragma-oracle?tag=v1.0.5#71e762dcb725b95a4a4966190219bca8380bc823" | ||
dependencies = [ | ||
"alexandria_data_structures", | ||
"alexandria_math", | ||
"alexandria_sorting", | ||
"alexandria_storage", | ||
"cubit", | ||
"openzeppelin", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "mock_pragma" | ||
version = "0.1.0" | ||
edition = "2023_10" | ||
|
||
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html | ||
|
||
[dependencies] | ||
starknet = "2.2.0" | ||
pragma = { git = "https://github.com/astraly-labs/pragma-oracle", tag = "v1.0.5" } | ||
|
||
[[target.starknet-contract]] | ||
casm = true | ||
casm-add-pythonic-hints = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod mock_pragma_oracle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
use pragma::entry::structs::{DataType, PragmaPricesResponse}; | ||
|
||
#[starknet::interface] | ||
trait IOracle<TContractState> { | ||
fn get_data_median(self: @TContractState, data_type: DataType) -> PragmaPricesResponse; | ||
} | ||
|
||
#[starknet::interface] | ||
trait IMockPragmaOracle<TContractState> { | ||
fn set_price( | ||
ref self: TContractState, | ||
pair_id: felt252, | ||
price: u128, | ||
decimals: u32, | ||
last_updated_timestamp: u64, | ||
num_sources_aggregated: u32, | ||
); | ||
} | ||
|
||
#[starknet::contract] | ||
mod MockPragmaOracle { | ||
use starknet::ContractAddress; | ||
use pragma::entry::structs::{DataType, PragmaPricesResponse}; | ||
|
||
use super::{IOracle, IMockPragmaOracle}; | ||
|
||
#[storage] | ||
struct Storage { | ||
pair_id: felt252, | ||
price: u128, | ||
decimals: u32, | ||
last_updated_timestamp: u64, | ||
num_sources_aggregated: u32 | ||
} | ||
|
||
//! Must be compatible with Cairo 2.2.0 | ||
#[external(v0)] | ||
impl IPragmaOracleImpl of IOracle<ContractState> { | ||
fn get_data_median(self: @ContractState, data_type: DataType) -> PragmaPricesResponse { | ||
match data_type { | ||
DataType::SpotEntry => { | ||
PragmaPricesResponse { | ||
price: self.price.read(), | ||
decimals: self.decimals.read(), | ||
last_updated_timestamp: self.last_updated_timestamp.read(), | ||
num_sources_aggregated: self.num_sources_aggregated.read(), | ||
expiration_timestamp: Option::None, | ||
} | ||
}, | ||
DataType::FutureEntry => { | ||
PragmaPricesResponse { | ||
price: self.price.read(), | ||
decimals: self.decimals.read(), | ||
last_updated_timestamp: self.last_updated_timestamp.read(), | ||
num_sources_aggregated: self.num_sources_aggregated.read(), | ||
expiration_timestamp: Option::Some( | ||
self.last_updated_timestamp.read() + 1000 | ||
), | ||
} | ||
}, | ||
DataType::GenericEntry => { | ||
PragmaPricesResponse { | ||
price: self.price.read(), | ||
decimals: self.decimals.read(), | ||
last_updated_timestamp: self.last_updated_timestamp.read(), | ||
num_sources_aggregated: self.num_sources_aggregated.read(), | ||
expiration_timestamp: Option::None, | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[external(v0)] | ||
impl IMockPragmaOracleImpl of IMockPragmaOracle<ContractState> { | ||
fn set_price( | ||
ref self: ContractState, | ||
pair_id: felt252, | ||
price: u128, | ||
decimals: u32, | ||
last_updated_timestamp: u64, | ||
num_sources_aggregated: u32 | ||
) { | ||
self.pair_id.write(pair_id); | ||
self.price.write(price); | ||
self.decimals.write(decimals); | ||
self.last_updated_timestamp.write(last_updated_timestamp); | ||
self.num_sources_aggregated.write(num_sources_aggregated); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.