Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
FIXES return both buyAmount and sellAmount in metatx price endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kimpers committed May 19, 2020
1 parent 6150a9f commit 9581199
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/services/meta_transaction_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export class MetaTransactionService {

const response: CalculateMetaTransactionPriceResponse = {
takerAddress,
sellAmount,
buyAmount,
buyAmount: makerAssetAmount,
sellAmount: totalTakerAssetAmount,
price,
swapQuote,
sources: serviceUtils.convertSourceBreakdownToArray(swapQuote.sourceBreakdown),
Expand Down
14 changes: 11 additions & 3 deletions test/meta_transaction_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ describe(SUITE_NAME, () => {

context('success tests', () => {
let meshUtils: MeshTestUtils;
const price = '1';
const sellAmount = calculateSellAmount(buyAmount, price);

beforeEach(async () => {
await blockchainLifecycle.startAsync();
Expand Down Expand Up @@ -240,8 +242,9 @@ describe(SUITE_NAME, () => {
expect(response.type).to.be.eq('application/json');
expect(response.status).to.be.eq(HttpStatus.OK);
expect(response.body).to.be.deep.eq({
price: '1',
price,
buyAmount,
sellAmount,
sellTokenAddress,
buyTokenAddress,
sources: liquiditySources0xOnly,
Expand All @@ -262,8 +265,9 @@ describe(SUITE_NAME, () => {
expect(response.type).to.be.eq('application/json');
expect(response.status).to.be.eq(HttpStatus.OK);
expect(response.body).to.be.deep.eq({
price: '1',
price,
buyAmount,
sellAmount,
sellTokenAddress,
buyTokenAddress,
sources: liquiditySources0xOnly,
Expand All @@ -273,7 +277,9 @@ describe(SUITE_NAME, () => {
it('should show the price of the combination of the two orders in Mesh', async () => {
const validationResults = await meshUtils.addOrdersWithPricesAsync([1, 2]);
expect(validationResults.rejected.length, 'mesh should not reject any orders').to.be.eq(0);
const largeOrderPrice = '1.5';
const largeBuyAmount = DEFAULT_MAKER_ASSET_AMOUNT.times(2).toString();
const largeSellAmount = calculateSellAmount(largeBuyAmount, largeOrderPrice);
const route = constructRoute({
baseRoute: `${META_TRANSACTION_PATH}/price`,
queryParams: {
Expand All @@ -286,8 +292,9 @@ describe(SUITE_NAME, () => {
expect(response.type).to.be.eq('application/json');
expect(response.status).to.be.eq(HttpStatus.OK);
expect(response.body).to.be.deep.eq({
price: '1.5',
price: largeOrderPrice,
buyAmount: largeBuyAmount,
sellAmount: largeSellAmount,
sellTokenAddress,
buyTokenAddress,
sources: liquiditySources0xOnly,
Expand Down Expand Up @@ -540,6 +547,7 @@ describe(SUITE_NAME, () => {
expect(response.body).to.be.deep.eq({
price,
buyAmount,
sellAmount,
sellTokenAddress,
buyTokenAddress,
sources: liquiditySources0xOnly,
Expand Down

0 comments on commit 9581199

Please sign in to comment.