Skip to content

Conversation

@Luivatra
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 24, 2026 20:22
@changeset-bot
Copy link

changeset-bot bot commented Jan 24, 2026

⚠️ No Changeset found

Latest commit: d8d1137

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the getPrice method in SundaeUtils to properly account for decimal differences between assets and introduces price inversion for exotic (non-ADA) pairs. Previously, the method returned a simple ratio of reserves without decimal adjustment. The new implementation uses AssetAmount to normalize values by their decimals, ensuring accurate price calculations across assets with different decimal places.

Changes:

  • Updated SundaeUtils.getPrice() to use decimal-aware AssetAmount calculations for constant product pools
  • Added price inversion logic for exotic pairs (non-ADA pairs return assetB/assetA instead of assetA/assetB)
  • Refactored CLI code to use the centralized SundaeUtils.getPrice() method instead of duplicating price calculation logic
  • Added comprehensive test coverage for various pool types including v1, v3, exotic pairs, same-decimal assets, and stableswap pools

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/core/src/Utilities/SundaeUtils.class.ts Core implementation: adds decimal-aware price calculation using AssetAmount and introduces price inversion for exotic pairs
packages/core/src/Utilities/tests/SundaeUtils.class.test.ts Comprehensive test suite covering ADA pairs, exotic pairs, same-decimal assets, and stableswap pools with various scenarios
packages/cli/src/menus/pool.ts Refactored to use centralized SundaeUtils.getPrice() method, removing duplicate price calculation logic and StableSwapsPool import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +595 to +603
// Create AssetAmounts to handle decimal normalization
const assetAmountA = new AssetAmount<IAssetAmountMetadata>(
pool.liquidity.aReserve,
pool.assetA,
);
const assetAmountB = new AssetAmount<IAssetAmountMetadata>(
pool.liquidity.bReserve,
pool.assetB,
);
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The AssetAmount instances are created at the beginning of the function but are not used when processing stableswap pools. Consider moving the AssetAmount creation into the constant product pool branch to avoid unnecessary object instantiation for stableswap pools.

Copilot uses AI. Check for mistakes.
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.

3 participants