aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline
diff options
context:
space:
mode:
authorXianny <8582774+xianny@users.noreply.github.com>2019-01-11 05:07:52 +0800
committerGitHub <noreply@github.com>2019-01-11 05:07:52 +0800
commita5b7a351609a5e6689bb97990216153f64302462 (patch)
treec5a3c0299c491737c869929e372d6c0318c11f73 /packages/pipeline
parent53fc860d6190c19f13c451eb89dd5c0c1cdcd1f4 (diff)
downloaddexon-sol-tools-a5b7a351609a5e6689bb97990216153f64302462.tar
dexon-sol-tools-a5b7a351609a5e6689bb97990216153f64302462.tar.gz
dexon-sol-tools-a5b7a351609a5e6689bb97990216153f64302462.tar.bz2
dexon-sol-tools-a5b7a351609a5e6689bb97990216153f64302462.tar.lz
dexon-sol-tools-a5b7a351609a5e6689bb97990216153f64302462.tar.xz
dexon-sol-tools-a5b7a351609a5e6689bb97990216153f64302462.tar.zst
dexon-sol-tools-a5b7a351609a5e6689bb97990216153f64302462.zip
upgrade to ddex api v3 (#1507)
Diffstat (limited to 'packages/pipeline')
-rw-r--r--packages/pipeline/migrations/1547153875669-UpdateDDexAPIToV3.ts21
-rw-r--r--packages/pipeline/src/data_sources/ddex/index.ts3
-rw-r--r--packages/pipeline/src/parsers/ddex_orders/index.ts10
-rw-r--r--packages/pipeline/test/parsers/ddex_orders/index_test.ts13
4 files changed, 31 insertions, 16 deletions
diff --git a/packages/pipeline/migrations/1547153875669-UpdateDDexAPIToV3.ts b/packages/pipeline/migrations/1547153875669-UpdateDDexAPIToV3.ts
new file mode 100644
index 000000000..957af4941
--- /dev/null
+++ b/packages/pipeline/migrations/1547153875669-UpdateDDexAPIToV3.ts
@@ -0,0 +1,21 @@
+import { MigrationInterface, QueryRunner } from 'typeorm';
+
+export class UpdateDDexAPIToV31547153875669 implements MigrationInterface {
+ public async up(queryRunner: QueryRunner): Promise<any> {
+ await queryRunner.query(`
+ UPDATE raw.token_orderbook_snapshots
+ SET quote_asset_symbol='WETH'
+ WHERE quote_asset_symbol='ETH' AND
+ source='ddex';
+ `);
+ }
+
+ public async down(queryRunner: QueryRunner): Promise<any> {
+ await queryRunner.query(`
+ UPDATE raw.token_orderbook_snapshots
+ SET quote_asset_symbol='ETH'
+ WHERE quote_asset_symbol='WETH' AND
+ source='ddex';
+ `);
+ }
+}
diff --git a/packages/pipeline/src/data_sources/ddex/index.ts b/packages/pipeline/src/data_sources/ddex/index.ts
index 2bbd8c29b..7ef92b90f 100644
--- a/packages/pipeline/src/data_sources/ddex/index.ts
+++ b/packages/pipeline/src/data_sources/ddex/index.ts
@@ -1,6 +1,6 @@
import { fetchAsync, logUtils } from '@0x/utils';
-const DDEX_BASE_URL = 'https://api.ddex.io/v2';
+const DDEX_BASE_URL = 'https://api.ddex.io/v3';
const ACTIVE_MARKETS_URL = `${DDEX_BASE_URL}/markets`;
const NO_AGGREGATION_LEVEL = 3; // See https://docs.ddex.io/#get-orderbook
const ORDERBOOK_ENDPOINT = `/orderbook?level=${NO_AGGREGATION_LEVEL}`;
@@ -23,7 +23,6 @@ export interface DdexMarket {
baseTokenDecimals: number;
baseTokenAddress: string;
minOrderSize: string;
- maxOrderSize: string;
pricePrecision: number;
priceDecimals: number;
amountDecimals: number;
diff --git a/packages/pipeline/src/parsers/ddex_orders/index.ts b/packages/pipeline/src/parsers/ddex_orders/index.ts
index eeb9c9d5b..562f894ab 100644
--- a/packages/pipeline/src/parsers/ddex_orders/index.ts
+++ b/packages/pipeline/src/parsers/ddex_orders/index.ts
@@ -58,14 +58,12 @@ export function parseDdexOrder(
tokenOrder.orderType = orderType;
tokenOrder.price = price;
- // ddex currently confuses quote and base assets.
- // We switch them here to maintain our internal consistency.
- tokenOrder.baseAssetSymbol = ddexMarket.quoteToken;
- tokenOrder.baseAssetAddress = ddexMarket.quoteTokenAddress;
+ tokenOrder.baseAssetSymbol = ddexMarket.baseToken;
+ tokenOrder.baseAssetAddress = ddexMarket.baseTokenAddress;
tokenOrder.baseVolume = amount;
- tokenOrder.quoteAssetSymbol = ddexMarket.baseToken;
- tokenOrder.quoteAssetAddress = ddexMarket.baseTokenAddress;
+ tokenOrder.quoteAssetSymbol = ddexMarket.quoteToken;
+ tokenOrder.quoteAssetAddress = ddexMarket.quoteTokenAddress;
tokenOrder.quoteVolume = price.times(amount);
return tokenOrder;
}
diff --git a/packages/pipeline/test/parsers/ddex_orders/index_test.ts b/packages/pipeline/test/parsers/ddex_orders/index_test.ts
index f30e86b02..d6f69e090 100644
--- a/packages/pipeline/test/parsers/ddex_orders/index_test.ts
+++ b/packages/pipeline/test/parsers/ddex_orders/index_test.ts
@@ -25,7 +25,6 @@ describe('ddex_orders', () => {
baseTokenDecimals: 2,
baseTokenAddress: '0xb45df06e38540a675fdb5b598abf2c0dbe9d6b81',
minOrderSize: '0.1',
- maxOrderSize: '1000',
pricePrecision: 1,
priceDecimals: 1,
amountDecimals: 0,
@@ -39,14 +38,12 @@ describe('ddex_orders', () => {
expected.observedTimestamp = observedTimestamp;
expected.orderType = OrderType.Bid;
expected.price = new BigNumber(0.5);
- // ddex currently confuses base and quote assets.
- // Switch them to maintain our internal consistency.
- expected.baseAssetSymbol = 'ABC';
- expected.baseAssetAddress = '0x0000000000000000000000000000000000000000';
- expected.baseVolume = new BigNumber(10);
- expected.quoteAssetSymbol = 'DEF';
- expected.quoteAssetAddress = '0xb45df06e38540a675fdb5b598abf2c0dbe9d6b81';
+ expected.quoteAssetSymbol = 'ABC';
+ expected.quoteAssetAddress = '0x0000000000000000000000000000000000000000';
expected.quoteVolume = new BigNumber(5);
+ expected.baseAssetSymbol = 'DEF';
+ expected.baseAssetAddress = '0xb45df06e38540a675fdb5b598abf2c0dbe9d6b81';
+ expected.baseVolume = new BigNumber(10);
const actual = parseDdexOrder(ddexMarket, observedTimestamp, orderType, source, ddexOrder);
expect(actual).deep.equal(expected);