Skip to content

Commit

Permalink
chore(amm): roll-back swapOut change
Browse files Browse the repository at this point in the history
* to preclude any difference from documented behavior fro `swapOut`
  keep using the direct implementation for now
  • Loading branch information
dtribble committed Apr 19, 2022
1 parent c34ff19 commit 2b33b8b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/run-protocol/src/vpool-xyk-amm/swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ export const makeMakeSwapInvitation = (zcf, provideVPool) => {

// trade with a stated amount out.
const swapOut = seat => {
// The offer's amountOut is a minimum; the offeredAmountIn is a max.
assertProposalShape(seat, {
give: { In: null },
want: { Out: null },
});
const {
want: { Out: stopAfter },
give: { In: amountIn },
want: { Out: amountOut },
} = seat.getProposal();
return swapIn(seat, { stopAfter });
const pool = provideVPool(amountIn.brand, amountOut.brand).internalFacet;
const prices = pool.getPriceForOutput(amountIn, amountOut);
return pool.allocateGainsAndLosses(seat, prices);
};

const makeSwapInInvitation = () =>
Expand Down

0 comments on commit 2b33b8b

Please sign in to comment.