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

Commit

Permalink
fix: added new asset swapper (#316)
Browse files Browse the repository at this point in the history
* added new asset swapper

* added quote requstor tetss
  • Loading branch information
PirosB3 authored Aug 11, 2020
1 parent 7bd6d4d commit 029a58a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
},
"dependencies": {
"@0x/assert": "^3.0.4",
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.6.0-e6367f07f",
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.6.0-ece93fed7",
"@0x/connect": "^6.0.4",
"@0x/contract-addresses": "^4.11.0",
"@0x/contract-wrappers": "^13.7.0",
Expand Down
18 changes: 18 additions & 0 deletions test/rfqt_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// tslint:disable:max-file-line-count
import { ERC20BridgeSource, rfqtMocker, SignedOrder } from '@0x/asset-swapper';
import { quoteRequestorHttpClient } from '@0x/asset-swapper/lib/src/utils/quote_requestor';
import { ContractAddresses } from '@0x/contract-addresses';
import { WETH9Contract } from '@0x/contract-wrappers';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
Expand Down Expand Up @@ -158,6 +159,7 @@ describe(SUITE_NAME, () => {
expect(responseJson.orders.length).to.equal(1);
expect(responseJson.orders[0]).to.eql(signedOrder);
},
quoteRequestorHttpClient,
);
});
it('should not include an RFQ-T order when intentOnFilling === false', async () => {
Expand Down Expand Up @@ -188,6 +190,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
it('should not include an RFQ-T order when intentOnFilling is omitted', async () => {
Expand Down Expand Up @@ -275,6 +278,7 @@ describe(SUITE_NAME, () => {
expect(responseJson.orders.length).to.equal(1);
expect(responseJson.orders[0]).to.eql(signedOrder);
},
quoteRequestorHttpClient,
);
});
it('should fail when bad api key used', async () => {
Expand Down Expand Up @@ -356,6 +360,7 @@ describe(SUITE_NAME, () => {
expect(responseJson.sellAmount).to.equal('100000000000000000');
expect(responseJson.sources).to.deep.include.members([{ name: '0x', proportion: '1' }]);
},
quoteRequestorHttpClient,
);
});
it('should fail silently when RFQ-T provider gives an error response', async () => {
Expand All @@ -380,6 +385,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
});
Expand Down Expand Up @@ -417,6 +423,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
});
Expand Down Expand Up @@ -475,6 +482,7 @@ describe(SUITE_NAME, () => {
expect(responseJson.orders.length).to.equal(1);
expect(responseJson.orders[0]).to.eql(ganacheZrxWethOrder1);
},
quoteRequestorHttpClient,
);
});
it('should not include an RFQ-T order when intentOnFilling === false', async () => {
Expand Down Expand Up @@ -505,6 +513,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
it('should not include an RFQ-T order when intentOnFilling is omitted', async () => {
Expand Down Expand Up @@ -535,6 +544,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
it('should succeed when includedSources is RFQT', async () => {
Expand All @@ -557,6 +567,7 @@ describe(SUITE_NAME, () => {
expect(responseJson.orders.length).to.equal(1);
expect(responseJson.orders[0]).to.eql(ganacheZrxWethOrder1);
},
quoteRequestorHttpClient,
);
});
it('should not succeed when includedSources is RFQT and no taker address is specified', async () => {
Expand All @@ -576,6 +587,7 @@ describe(SUITE_NAME, () => {
.expect(HttpStatus.BAD_REQUEST)
.expect('Content-Type', /json/);
},
quoteRequestorHttpClient,
);
});
it('should fail when taker address is not supplied', async () => {
Expand Down Expand Up @@ -633,6 +645,7 @@ describe(SUITE_NAME, () => {
expect(responseJson.orders.length).to.equal(1);
expect(responseJson.orders[0]).to.eql(ganacheZrxWethOrder1);
},
quoteRequestorHttpClient,
);
});
it('should fail when bad api key used', async () => {
Expand Down Expand Up @@ -666,6 +679,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
it('should fail validation when taker can not actually fill', async () => {
Expand All @@ -689,6 +703,7 @@ describe(SUITE_NAME, () => {
.expect(HttpStatus.BAD_REQUEST)
.expect('Content-Type', /json/);
},
quoteRequestorHttpClient,
);
});
it('should get an indicative quote from an RFQ-T provider', async () => {
Expand All @@ -714,6 +729,7 @@ describe(SUITE_NAME, () => {
expect(responseJson.sellAmount).to.equal('100000000000000000');
expect(responseJson.sources).to.deep.include.members([{ name: '0x', proportion: '1' }]);
},
quoteRequestorHttpClient,
);
});
it('should fail silently when RFQ-T provider gives an error response', async () => {
Expand All @@ -738,6 +754,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
});
Expand Down Expand Up @@ -773,6 +790,7 @@ describe(SUITE_NAME, () => {
expect(validationErrors.length).to.eql(1);
expect(validationErrors[0].reason).to.eql('INSUFFICIENT_ASSET_LIQUIDITY');
},
quoteRequestorHttpClient,
);
});
});
Expand Down
16 changes: 13 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
lodash "^4.17.11"
valid-url "^1.0.9"

"@0x/asset-swapper@0xProject/gitpkg-registry#0x-asset-swapper-v4.6.0-e6367f07f":
"@0x/asset-swapper@0xProject/gitpkg-registry#0x-asset-swapper-v4.6.0-ece93fed7":
version "4.6.0"
resolved "https://codeload.github.com/0xProject/gitpkg-registry/tar.gz/1d995d0e5cb1f76864a3a2bc1a43b520f4587678"
resolved "https://codeload.github.com/0xProject/gitpkg-registry/tar.gz/df94aa37686361deb6de82945c37d011c2232974"
dependencies:
"@0x/assert" "^3.0.9"
"@0x/contract-addresses" "^4.11.0"
Expand All @@ -46,7 +46,7 @@
"@0x/quote-server" "^2.0.2"
"@0x/utils" "^5.5.1"
"@0x/web3-wrapper" "^7.2.0"
"@balancer-labs/sor" "^0.3.0"
"@balancer-labs/sor" "0.3.2"
axios "^0.19.2"
axios-mock-adapter "^1.18.1"
decimal.js "^10.2.0"
Expand Down Expand Up @@ -718,6 +718,16 @@
dependencies:
regenerator-runtime "^0.13.4"

"@balancer-labs/[email protected]":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@balancer-labs/sor/-/sor-0.3.2.tgz#b05c63a07031c2ea13ed0d2670f5105cfaa40523"
integrity sha512-wmYmTm/zhnRPd/OaqzJJGo9mRIp4PvNNS/AG0EVWJmLmZvYkm2sl6/dBL3KC88rub9duVQr2M8BHCosseFuGLw==
dependencies:
bignumber.js "^9.0.0"
ethers "^4.0.39"
isomorphic-fetch "^2.2.1"
typescript "^3.8.3"

"@balancer-labs/sor@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@balancer-labs/sor/-/sor-0.3.0.tgz#c221225d9a3d1791ebfc3c566f7a76843bca98fa"
Expand Down

0 comments on commit 029a58a

Please sign in to comment.