-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: stargate integration #374
base: main
Are you sure you want to change the base?
Conversation
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.
good work in general, left some comments, stargate supports solana, better to think how to support it now
Co-authored-by: 0xh3rman <[email protected]>
Co-authored-by: 0xh3rman <[email protected]>
async fn fetch_quote_data(&self, quote: &SwapQuote, _provider: Arc<dyn AlienProvider>, _data: FetchQuoteData) -> Result<SwapQuoteData, SwapperError> { | ||
let pool = self.client.get_pool_by_asset_id("e.request.from_asset)?; | ||
let route_data: StargateRouteData = serde_json::from_str("e.data.routes.first().unwrap().route_data).map_err(|_| SwapperError::InvalidRoute)?; | ||
let send_calldata = self.client.send( |
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 send_calldata = self.client.send( | |
let calldata = self.client.send( |
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.
done
&Address::from_str(route_data.refund_address.as_str()).unwrap(), | ||
); | ||
|
||
let mut value_to_send = route_data.fee.nativeFee; |
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.
I would recommend using:
let fee = if quote.request.from_asset.is_native() { route_data.fee.nativeFee } else { 0 }
let value = route_data.send_param.amountLD + fee
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.
Always try to avoid using mut
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.
done
} | ||
|
||
let pool = self.client.get_pool_by_asset_id(&request.from_asset)?; | ||
let mut send_param = self.client.build_send_param(request)?; |
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 avoid using mut? create function that would calculate all the data for you instead and return a struct
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.
Here we have 2 steps:
Build initial send params and request oft quote
Update initial send params and request send quote
I improved code style based on comment
let from_asset = &request.from_asset; | ||
let to_asset = &request.to_asset; | ||
|
||
if from_asset.chain == to_asset.chain { |
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.
no need check chains, we have function on the higher level to check for 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.
Removed
#310
Bridge token transfer
USDT (BNB) -> USDT (OP)
https://bscscan.com/tx/0x110134e6abbd89b5133aa49c6be00f0e8f60eb9cc4d8841f2d3ee42ab82f5528
ETH (Base) -> ETH (OP)
https://basescan.org/tx/0x7ce7a2ff0fb0098810110d8321a498377d0746b147c8020d46620003462bf363
USDC (OP) -> USDC (Avalance)
https://optimistic.etherscan.io/tx/0x38429bdd5345639d074b1bc5c39e7550e3ab1684eb18e7087582ec0be8ea3949
Add referral fee (via compose)
Add unit / integration test