aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/index.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-09-27 07:42:48 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-12-05 06:24:06 +0800
commit9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac (patch)
tree85afc226768cf0d2c0568b2db263b950831e7032 /packages/pipeline/src/index.ts
parent71a015f2aa32fedd3d3c5e9d5a3fa4eb272b2852 (diff)
downloaddexon-sol-tools-9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac.tar
dexon-sol-tools-9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac.tar.gz
dexon-sol-tools-9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac.tar.bz2
dexon-sol-tools-9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac.tar.lz
dexon-sol-tools-9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac.tar.xz
dexon-sol-tools-9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac.tar.zst
dexon-sol-tools-9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac.zip
Add preliminary support for scraping orders from SRA endpoints (no pagination, only RR support for now)
Diffstat (limited to 'packages/pipeline/src/index.ts')
-rw-r--r--packages/pipeline/src/index.ts30
1 files changed, 26 insertions, 4 deletions
diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts
index 07ab1d991..3e8434e3d 100644
--- a/packages/pipeline/src/index.ts
+++ b/packages/pipeline/src/index.ts
@@ -1,19 +1,28 @@
-import * as R from 'ramda';
+import { HttpClient } from '@0xproject/connect';
import 'reflect-metadata';
-import { createConnection } from 'typeorm';
+import { Connection, createConnection } from 'typeorm';
import { Etherscan } from './data_sources/etherscan';
import { parseExchangeEvents } from './data_types/events/exchange_events';
+import { parseSraOrders } from './data_types/sra_order';
import { ExchangeCancelEvent } from './entities/ExchangeCancelEvent';
import { ExchangeCancelUpToEvent } from './entities/ExchangeCancelUpToEvent';
import { ExchangeFillEvent } from './entities/ExchangeFillEvent';
+import { SraOrder } from './entities/SraOrder';
import { config } from './ormconfig';
const etherscan = new Etherscan(process.env.ETHERSCAN_API_KEY as string);
const EXCHANGE_ADDRESS = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b';
+let connection: Connection;
+
(async () => {
- const connection = await createConnection(config);
+ connection = await createConnection(config);
+ await getExchangeEventsAsync();
+ await getSraOrdersAsync();
+})();
+
+async function getExchangeEventsAsync(): Promise<void> {
const fillRepository = connection.getRepository(ExchangeFillEvent);
const cancelRepository = connection.getRepository(ExchangeCancelEvent);
const cancelUpToRepository = connection.getRepository(ExchangeCancelUpToEvent);
@@ -32,4 +41,17 @@ const EXCHANGE_ADDRESS = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b';
(await cancelRepository.count()) +
(await cancelUpToRepository.count())} total events`,
);
-})();
+}
+
+async function getSraOrdersAsync(): Promise<void> {
+ const orderRepository = connection.getRepository(SraOrder);
+ console.log(`found ${await orderRepository.count()} existing orders`);
+
+ const connect = new HttpClient('https://api.radarrelay.com/0x/v2');
+ const rawOrders = await connect.getOrdersAsync();
+ const orders = parseSraOrders(rawOrders);
+ for (const order of orders) {
+ order.save();
+ }
+ console.log(`now there are ${await orderRepository.count()} total orders`);
+}