Skip to content

Commit

Permalink
chore: integrate with renaming of calcSwapInPrices/calcSwapOutPrices
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Sep 30, 2021
1 parent bc5042d commit 7b769ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions packages/zoe/src/contracts/vpool-xyk-amm/doublePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { AmountMath } from '@agoric/ertp';
import { assert, details as X } from '@agoric/assert';
import { makeFeeRatio } from '../constantProduct/calcFees';
import {
calcSwapInPrices,
calcSwapOutPrices,
pricesForStatedInput,
pricesForStatedOutput,
} from '../constantProduct/calcSwapPrices.js';

// Price calculations and swap using a pair of pools. Both pools map between RUN
Expand Down Expand Up @@ -85,21 +85,21 @@ export const makeDoublePool = (
// less.
// Notice that in the second call, the original amountOut is used, and in
// the third call, the original amountIn is used.
const interimInpoolPrices = calcSwapInPrices(
const interimInpoolPrices = pricesForStatedInput(
amountIn,
inAllocation,
emptyCentralAmount,
protocolFeeRatio,
centralFeeRatio,
);
const outPoolPrices = calcSwapInPrices(
const outPoolPrices = pricesForStatedInput(
interimInpoolPrices.swapperGets,
outAllocation,
amountOut,
protocolFeeRatio,
makeFeeRatio(poolFee, amountOut.brand),
);
const finalInPoolPrices = calcSwapOutPrices(
const finalInPoolPrices = pricesForStatedOutput(
amountIn,
inAllocation,
outPoolPrices.swapperGives,
Expand Down Expand Up @@ -142,21 +142,21 @@ export const makeDoublePool = (
// Notice that the amountIn parameter to the first call to swapOutPrice
// specifies an empty amount. This is interpreted as "no limit", which is
// necessary since we can't guess a reasonable maximum of the central token.
const interimOutpoolPrices = calcSwapOutPrices(
const interimOutpoolPrices = pricesForStatedOutput(
emptyCentralAmount,
outAllocation,
amountOut,
protocolFeeRatio,
centralFeeRatio,
);
const inpoolPrices = calcSwapOutPrices(
const inpoolPrices = pricesForStatedOutput(
amountIn,
inAllocation,
interimOutpoolPrices.swapperGets,
protocolFeeRatio,
makeFeeRatio(poolFee, amountIn.brand),
);
const finalOutpoolPrices = calcSwapInPrices(
const finalOutpoolPrices = pricesForStatedInput(
inpoolPrices.swapperGives,
outAllocation,
amountOut,
Expand Down
8 changes: 4 additions & 4 deletions packages/zoe/src/contracts/vpool-xyk-amm/singlePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { Far } from '@agoric/marshal';
import { makeFeeRatio } from '../constantProduct/calcFees';
import {
calcSwapInPrices,
calcSwapOutPrices,
pricesForStatedInput,
pricesForStatedOutput,
} from '../constantProduct/calcSwapPrices.js';

/**
Expand Down Expand Up @@ -48,7 +48,7 @@ export const makeSinglePool = (zcf, pool, protocolFee, poolFee, feeSeat) => {
};

const getPriceForInput = (amountIn, amountOut) => {
return calcSwapInPrices(
return pricesForStatedInput(
amountIn,
getPools(),
amountOut,
Expand All @@ -63,7 +63,7 @@ export const makeSinglePool = (zcf, pool, protocolFee, poolFee, feeSeat) => {
};

const getPriceForOutput = (amountIn, amountOut) => {
return calcSwapOutPrices(
return pricesForStatedOutput(
amountIn,
getPools(),
amountOut,
Expand Down

0 comments on commit 7b769ac

Please sign in to comment.