Skip to content
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(swap): handle swap rate v3 #1082

Merged
merged 14 commits into from
Dec 12, 2024
Merged

feat(swap): handle swap rate v3 #1082

merged 14 commits into from
Dec 12, 2024

Conversation

zoheb391
Copy link
Contributor

@zoheb391 zoheb391 commented Nov 18, 2024

I've tested this against perseverance and did not find any discrepancies except for DCA with boost. But since boost will change in 1.7.2 i think we can ignore that for now. (there is an open PR to add boost to this RPC)

closes WEB-1640

@zoheb391 zoheb391 requested a review from a team as a code owner November 18, 2024 15:48
@codecov-commenter
Copy link

codecov-commenter commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.04%. Comparing base (54fb4bb) to head (28b6b5d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1082   +/-   ##
=======================================
  Coverage   87.04%   87.04%           
=======================================
  Files         100      100           
  Lines        1351     1351           
  Branches      207      207           
=======================================
  Hits         1176     1176           
  Misses        166      166           
  Partials        9        9           
Flag Coverage Δ
sdk 96.76% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jerryafr jerryafr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Comment on lines -70 to -52
/* eslint-disable no-param-reassign */
const adjustDcaQuote = ({
dcaQuoteParams,
dcaQuote,
originalDepositAmount,
}: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my precious 😢

packages/swap/src/utils/getPoolQuote.ts Outdated Show resolved Hide resolved
@@ -29,34 +28,32 @@ export default async function getPoolQuote<T extends QuoteType>({
limitOrders?: LimitOrders;
boostFeeBps?: number;
pools: Pool[];
quoteType: T;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we keep this, the ts will deduce the quote type that has been returned, otherwise we should remove the generic parameter and update the return type

packages/swap/src/routes/v2/quote.ts Show resolved Hide resolved
Comment on lines 178 to 187
dcaQuoteParams &&
getPoolQuote({
...quoteArgs,
depositAmount: dcaQuoteParams.chunkSize + ingressFeeSurcharge,
quoteType: 'DCA',
dcaChunks: dcaQuoteParams.numberOfChunks,
dcaParams,
}),
dcaQuoteParams &&
estimatedBoostFeeBps &&
getPoolQuote({
...dcaQuoteArgs,
boostFeeBps: estimatedBoostFeeBps,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably check at this point that we have > 1 chunk and not request a quote if we don't

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could do the check when setting dcaParams initially

.multipliedBy((dcaQuoteParams.numberOfChunks - 1) / dcaQuoteParams.numberOfChunks)
.toFixed(0),
)
: 0n;

const [dcaQuoteResult, dcaBoostedQuoteResult] = await Promise.allSettled([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess we could add this to the Promise.allSettled above now

Copy link
Contributor

@niklasnatter niklasnatter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes look good to me! would be nice to compare the results against mainnet just to be safe

@zoheb391
Copy link
Contributor Author

the changes look good to me! would be nice to compare the results against mainnet just to be safe

unfortunately can't do that right now because the RPC cannot be queried on mainnet. have to wait for the nodes to update.

@zoheb391 zoheb391 merged commit c57282d into main Dec 12, 2024
21 checks passed
@zoheb391 zoheb391 deleted the feat/swap-rate-v3 branch December 12, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants