-
Notifications
You must be signed in to change notification settings - Fork 7
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
apy #945
base: main
Are you sure you want to change the base?
apy #945
Conversation
This reverts commit 79f5f40.
- fix tests
crates/subgraph/src/types/impls.rs
Outdated
/// Calculates the trade's O/I ratio (inverse) | ||
pub fn inverse_ratio(&self) -> Result<U256, PerformanceError> { | ||
let (input, output) = self.scale_18_io()?; | ||
if output.is_zero() && input.is_zero() { |
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.
divide by zero is an error
crates/subgraph/src/types/impls.rs
Outdated
let (input, output) = self.scale_18_io()?; | ||
if output.is_zero() && input.is_zero() { | ||
Ok(U256::ZERO) | ||
} else if input.is_zero() { |
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.
divide by zero is error
} | ||
|
||
#[test] | ||
fn test_inverse_ratio() { |
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.
you added if cases in the inverse ratio fn and didn't test them
crates/subgraph/src/types/impls.rs
Outdated
let (input, output) = self.scale_18_io()?; | ||
if output.is_zero() && input.is_zero() { | ||
Ok(U256::ZERO) | ||
} else if output.is_zero() { |
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.
divide by zero is error
crates/subgraph/src/types/impls.rs
Outdated
/// Calculates the trade's I/O ratio | ||
pub fn ratio(&self) -> Result<U256, PerformanceError> { | ||
let (input, output) = self.scale_18_io()?; | ||
if output.is_zero() && input.is_zero() { |
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.
divide by zero is error
|
||
#[test] | ||
fn test_ratio() { | ||
let result = get_trade().ratio().unwrap(); |
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.
if cases in the fn not covered in tests
crates/subgraph/src/types/impls.rs
Outdated
self.input_vault_balance_change | ||
.vault | ||
.token | ||
.decimals |
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.
this fallback logic for decimals should be an impl and reused, i can just see someone falling back to 0
somewhere in the app and this falling back to 18
and that being inconsistent across the app, this code duplication on the decimal handling needs to be centralised somewhere in the codebase
pub fn scale_18(&self) -> Result<VaultVolume, PerformanceError> { | ||
let token_decimals: u8 = self | ||
.token | ||
.decimals |
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.
as below
* @param valueDecimals - The bigint string value decimals point | ||
* @param decimalPoint - (optional) The number of digits to keep after "." in final result, defaults to valueDecimals | ||
*/ | ||
export function bigintStringToPercentage( |
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.
missing tests
tauri-app/src/lib/services/time.ts
Outdated
export const TIME_DELTA_30_DAYS = TIME_DELTA_24_HOURS * 30; | ||
export const TIME_DELTA_1_YEAR = TIME_DELTA_24_HOURS * 365; | ||
|
||
export function nowTimestamp(): number { |
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.
usually with time, because it's non deterministic, we'd have a function that handles times, and then we would pass "now" to it, then a single "now" can be used consistently across upstream scopes
Motivation
resolves #908
Solution
Checks
By submitting this for review, I'm confirming I've done the following: