-
Notifications
You must be signed in to change notification settings - Fork 1
feat: example code to sign & send Orders #44
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
base: anna/filler-ex
Are you sure you want to change the base?
Conversation
anna-carroll
commented
May 1, 2025
•
edited
Loading
edited
- construct a simple example Order
- sign the Order
- send the Order
a32f71c
to
c042ebe
Compare
/// Empty main to silence clippy. | ||
fn main() {} |
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.
let's put the main fn at the bottom
fn token_amount(amount: u64, decimals: u32) -> U256 { | ||
U256::from(amount * 10u64.pow(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.
Use ParseUnits
from alloy::primitives
to perform this conversion—no need to implement yourself
// input is 1 USDC on the rollup | ||
let input = Input { token: self.ru_usdc_address, amount: one_usdc }; | ||
|
||
// output is 1 USDC on the host chain | ||
let output = Output { | ||
token: self.host_usdc_address, | ||
amount: one_usdc, | ||
chainId: self.host_chain_id as u32, | ||
recipient: self.signer.address(), | ||
}; |
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.
unrelated to this pr, but i still think we should have builder types for these so we don't have to declare them like this
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.
agree, I started working on that code already but was prioritizing this first
|
||
/// Get an example Order which swaps 1 USDC on the rollup for 1 USDC on the host. | ||
fn example_order(&self) -> Order { | ||
let usdc_decimals: u32 = 6; |
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.
let's make this a const
at the top
/// Get an example Order which swaps 1 USDC on the rollup for 1 USDC on the host. | ||
fn example_order(&self) -> Order { | ||
let usdc_decimals: u32 = 6; | ||
let one_usdc = token_amount(1, usdc_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.
why are we calculating this at all? it could be a file-level const const ONE_USDC = uint!(1_000_000_U256);