-
Notifications
You must be signed in to change notification settings - Fork 69
add swap sim example #90
base: development
Are you sure you want to change the base?
Conversation
Not sure why the test suite is failing, I didn't touch any code that should affect those tests. Regarding rustfmt fail, I adjusted the doc lines to conform to rustfmt line size |
Ran |
examples/calculate-price.rs
Outdated
async fn main() -> Result<(), Box<dyn Error>> { | ||
// load rpc endpoint from local environment | ||
let rpc_endpoint = std::env::var("ETHEREUM_MAINNET_ENDPOINT") | ||
.expect("Could not get ETHEREUM_MAINNET_ENDPOINT"); |
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.
Since you are using Box, you can just use ?
instead of expect()
.
examples/calculate-price.rs
Outdated
provider.clone(), | ||
) | ||
.await // use ? at end of await?? | ||
.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.
Lets use ?
instead of unwrap()
examples/calculate-price.rs
Outdated
provider.clone(), | ||
); | ||
|
||
let current_block = provider.get_block_number().await.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.
Same thing here, lets use ?
examples/calculate-price.rs
Outdated
.block(current_block) | ||
.call() | ||
.await | ||
.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.
Same as above, use ?
instead.
examples/calculate-price.rs
Outdated
|
||
let float_price_b = pool.calculate_price(pool.token_b); | ||
|
||
dbg!(pool); |
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.
Can you remove the dbg!()
from this?
examples/sim-swap.rs
Outdated
async fn main() -> Result<(), Box<dyn Error>> { | ||
// load rpc endpoint from local environment | ||
let rpc_endpoint = std::env::var("ETHEREUM_MAINNET_ENDPOINT") | ||
.expect("Could not get ETHEREUM_MAINNET_ENDPOINT"); |
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.
Same as in the calculate-price
example, lets use ?
everywhere instead of unwrap()
or expect()
.
src/pool/mod.rs
Outdated
@@ -40,14 +47,16 @@ impl Pool { | |||
} | |||
} | |||
|
|||
/// Returns the fee percentage associated with the pool. |
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.
Can we reword this to "Returns the fee associated with the pool, represented as a percentage?
Thanks for making this PR! I think we should probably separate the docs into a separate PR. I think that there are a few places where some additional information and rewording could be useful, but we can get the examples merged in once the changes requested are made. |
test_swap_sim
test into an example file