From c9b551d2229124d218440d9fcb9fdf40d12727c0 Mon Sep 17 00:00:00 2001 From: Pranay Baldev Date: Tue, 26 Apr 2022 10:58:07 +0530 Subject: [PATCH 1/2] add missing weighting factor --- src/pricemodels/osmosis.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pricemodels/osmosis.ts b/src/pricemodels/osmosis.ts index c31b831..0603d72 100644 --- a/src/pricemodels/osmosis.ts +++ b/src/pricemodels/osmosis.ts @@ -15,9 +15,9 @@ export function returnAmount(inputCoin: EmerisTransactions.AbstractAmount, pool: const balanceA = new BigNumber(pool.balanceA); const balanceB = new BigNumber(pool.balanceB); const weightingFactor = isReverse ? pool.weightB / pool.weightA : pool.weightA / pool.weightB; - const effectivePrice = isReverse ? balanceB.plus(inputAmount.multipliedBy(2)).dividedBy(balanceA) : balanceA.plus(inputAmount.multipliedBy(2)).dividedBy(balanceB.multipliedBy(weightingFactor)); + const effectivePrice = isReverse ? balanceB.plus(inputAmount.multipliedBy(2)).dividedBy(balanceA.multipliedBy(weightingFactor)) : balanceA.plus(inputAmount.multipliedBy(2)).dividedBy(balanceB.multipliedBy(weightingFactor)); const effectiveAmount = inputAmount.dividedBy(effectivePrice); const returnAmount = effectiveAmount.minus(effectiveAmount.multipliedBy(pool.swapFeeRate/ 2)); const returnDenom = isReverse ? pool.denomA.denom : pool.denomB.denom; return { amount: returnAmount.toString().split('.')[0], denom: returnDenom }; -} \ No newline at end of file +} From 6dabacbf24906da7855e392146eff985e3e43449 Mon Sep 17 00:00:00 2001 From: Pranay Baldev Date: Tue, 26 Apr 2022 11:00:17 +0530 Subject: [PATCH 2/2] Update gravity.ts --- src/pricemodels/gravity.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pricemodels/gravity.ts b/src/pricemodels/gravity.ts index f4506cb..94848c1 100644 --- a/src/pricemodels/gravity.ts +++ b/src/pricemodels/gravity.ts @@ -14,9 +14,9 @@ export function returnAmount(inputCoin: EmerisTransactions.AbstractAmount, pool: const balanceA = new BigNumber(pool.balanceA); const balanceB = new BigNumber(pool.balanceB); const weightingFactor = isReverse ? pool.weightB / pool.weightA : pool.weightA / pool.weightB; - const effectivePrice = isReverse ? balanceB.plus(inputAmount.multipliedBy(2)).dividedBy(balanceA) : balanceA.plus(inputAmount.multipliedBy(2)).dividedBy(balanceB.multipliedBy(weightingFactor)); + const effectivePrice = isReverse ? balanceB.plus(inputAmount.multipliedBy(2)).dividedBy(balanceA.multipliedBy(weightingFactor)) : balanceA.plus(inputAmount.multipliedBy(2)).dividedBy(balanceB.multipliedBy(weightingFactor)); const effectiveAmount = inputAmount.dividedBy(effectivePrice); const returnAmount = effectiveAmount.minus(effectiveAmount.multipliedBy(pool.swapFeeRate/ 2)); const returnDenom = isReverse ? pool.denomA.denom : pool.denomB.denom; return { amount: returnAmount.toString().split('.')[0], denom: returnDenom }; -} \ No newline at end of file +}