This repository was archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Helper method for pricing a base currency in a quote currency #8
Merged
+859
−30
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
3d911bb
Add method for getting twap
a0c2261
initial implementation, seems to work
3563003
minor
5a3b993
minor
1896da1
refactor
b735842
found bad case
422145e
use u128
c49ce56
working on it
8b96d3b
clarify
8213597
cleanup
45a8ebc
more cleanup
dcb5053
pretty sure i need this
3fc33c7
better
f556164
merge
0b8f7dd
bad merge
564dd9c
no println
8e1a5ca
adding solana tx stuff
f076bb4
change approach a bit
3cd3ecf
Merge branch 'other_helper' into test_infra
44254db
this seems to work
acb2f23
comment
4536f0c
cleanup
74faf19
refactor
50bd93b
refactor
e0f8a43
initial implementation of mul
be58b99
exponent
d41524b
tests for normalize
6a6f185
tests for normalize
830a7da
negative numbers in div
87ac025
handle negative numbers
670392b
comments
a640066
stuff
7e06597
cleanup
033001a
unused
1506f81
minor
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,2 @@ | ||
| [target.bpfel-unknown-unknown.dependencies.std] | ||
| features = [] |
This file contains hidden or 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 hidden or 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,16 @@ | ||
| //! Program entrypoint | ||
|
|
||
| #![cfg(not(feature = "no-entrypoint"))] | ||
|
|
||
| use solana_program::{ | ||
| account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey, | ||
| }; | ||
|
|
||
| entrypoint!(process_instruction); | ||
| fn process_instruction( | ||
| program_id: &Pubkey, | ||
| accounts: &[AccountInfo], | ||
| instruction_data: &[u8], | ||
| ) -> ProgramResult { | ||
| crate::processor::process_instruction(program_id, accounts, instruction_data) | ||
| } |
This file contains hidden or 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 @@ | ||
| //! Program instructions, used for end-to-end testing and instruction counts | ||
|
|
||
| use { | ||
| crate::id, | ||
| borsh::{BorshDeserialize, BorshSerialize}, | ||
| solana_program::instruction::Instruction, | ||
| crate::PriceConf, | ||
| }; | ||
|
|
||
| /// Instructions supported by the pyth-client program, used for testing and | ||
| /// instruction counts | ||
| #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, PartialEq)] | ||
| pub enum PythClientInstruction { | ||
| Divide { | ||
| numerator: PriceConf, | ||
| denominator: PriceConf, | ||
| }, | ||
| Multiply { | ||
| x: PriceConf, | ||
| y: PriceConf, | ||
| }, | ||
| /// Don't do anything for comparison | ||
| /// | ||
| /// No accounts required for this instruction | ||
| Noop, | ||
| } | ||
|
|
||
| pub fn divide(numerator: PriceConf, denominator: PriceConf) -> Instruction { | ||
| Instruction { | ||
| program_id: id(), | ||
| accounts: vec![], | ||
| data: PythClientInstruction::Divide { numerator, denominator } | ||
| .try_to_vec() | ||
| .unwrap(), | ||
| } | ||
| } | ||
|
|
||
| pub fn multiply(x: PriceConf, y: PriceConf) -> Instruction { | ||
| Instruction { | ||
| program_id: id(), | ||
| accounts: vec![], | ||
| data: PythClientInstruction::Multiply { x, y } | ||
| .try_to_vec() | ||
| .unwrap(), | ||
| } | ||
| } | ||
|
|
||
| /// Noop instruction for comparison purposes | ||
| pub fn noop() -> Instruction { | ||
| Instruction { | ||
| program_id: id(), | ||
| accounts: vec![], | ||
| data: PythClientInstruction::Noop.try_to_vec().unwrap(), | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should also offer to return an enum