Skip to content
Permalink
Browse files

Initial Commit

  • Loading branch information...
piavgh committed Mar 13, 2019
0 parents commit 589e8efd503ff1e384f1af15a147a971168999a6
@@ -0,0 +1,30 @@
/logs/*

.DS_Store
.vscode
.idea
.vendor-new
*.[56789ao]
*.a[56789o]
*.so
*.pyc
._*
.nfs.*
[56789a].out
*~
*.orig
*.rej
*.exe
.*.swp
core
*.cgo*.go
*.cgo*.c
.vscode/
vendor/

/utils/datadir/*

/node_modules
package-lock.json
yarn.lock
utils/addresses.json
@@ -0,0 +1,37 @@
const MongoClient = require('mongodb').MongoClient
const { DB_NAME, mongoUrl } = require('./utils/config')
const create = async () => {
const client = await MongoClient.connect(
mongoUrl,
{ useNewUrlParser: true },
)
console.log('Creating accounts collection')
const db = client.db(DB_NAME)
try {
await db.createCollection('accounts', {
validator: {
$jsonSchema: {
bsonType: 'object',
required: ['address'],
properties: {
address: {
bsonType: 'string',
},
tokenBalances: {
bsonType: 'object',
},
isBlocked: {
bsonType: 'bool',
},
},
},
},
})
} catch (e) {
console.log(e)
} finally {
client.close()
}
}

create()
@@ -0,0 +1,48 @@
const MongoClient = require('mongodb').MongoClient
const { DB_NAME, mongoUrl } = require('./utils/config')
const create = async () => {
const client = await MongoClient.connect(
mongoUrl,
{ useNewUrlParser: true },
)
console.log('Creating config collection')
const db = client.db(DB_NAME)
try {
await db.createCollection('config', {
validator: {
$jsonSchema: {
bsonType: 'object',
required: ['key'],
properties: {
key: {
bsonType: 'string',
},
value: {
bsonType: [
'int',
'long',
'string',
'array',
'bool',
'date',
'object',
],
},
createdAt: {
bsonType: 'date',
},
updatedAt: {
bsonType: 'date',
},
},
},
},
})
} catch (e) {
console.log(e)
} finally {
client.close()
}
}

create()
@@ -0,0 +1,85 @@
const MongoClient = require('mongodb').MongoClient
const { DB_NAME, mongoUrl } = require('./utils/config')

const create = async () => {
const client = await MongoClient.connect(mongoUrl, { useNewUrlParser: true })
console.log('Creating orders collection')
const db = client.db(DB_NAME)
try {
await db.createCollection('orders', {
validator: {
$jsonSchema: {
bsonType: 'object',
required: [
'baseToken',
'quoteToken',
'amount',
'pricepoint',
'userAddress',
'exchangeAddress',
'filledAmount',
],
properties: {
baseToken: {
bsonType: 'string',
},
quoteToken: {
bsonType: 'string',
},
filledAmount: {
bsonType: 'string',
},
amount: {
bsonType: 'string',
},
pricepoint: {
bsonType: 'string',
},
makeFee: {
bsonType: 'string',
},
takeFee: {
bsonType: 'string',
},
side: {
bsonType: 'string',
},
status: {
bsonType: 'string',
},
exchangeAddress: {
bsonType: 'string',
},
userAddress: {
bsonType: 'string',
},
signature: {
bsonType: 'object',
},
nonce: {
bsonType: 'string',
},
pairName: {
bsonType: 'string',
},
hash: {
bsonType: 'string',
},
createdAt: {
bsonType: 'date',
},
updatedAt: {
bsonType: 'date',
},
},
},
},
})
} catch (e) {
console.log(e)
} finally {
client.close()
}
}

create()
@@ -0,0 +1,66 @@
const MongoClient = require('mongodb').MongoClient
const { DB_NAME, mongoUrl } = require('./utils/config')
const create = async () => {
const client = await MongoClient.connect(
mongoUrl,
{ useNewUrlParser: true },
)
const db = client.db(DB_NAME)
console.log('Creating pairs collection')
try {
await db.createCollection('pairs', {
validator: {
$jsonSchema: {
bsonType: 'object',
required: ['baseTokenAddress', 'quoteTokenAddress'],
properties: {
baseTokenSymbol: {
bsonType: 'string',
description: 'must be a a string and is not required',
},
baseTokenAddress: {
bsonType: 'string',
description: 'must be a string and is required',
},
baseTokenDecimals: {
bsonType: 'int',
},
quoteTokenSymbol: {
bsonType: 'string',
description: 'must be a string and is required',
},
quoteTokenAddress: {
bsonType: 'string',
description: 'must be a string and is required',
},
quoteTokenDecimals: {
bsonType: 'int',
},
active: {
bsonType: 'bool',
description: 'must be a boolean and is not required',
},
makeFee: {
bsonType: 'string',
},
takeFee: {
bsonType: 'string',
},
createdAt: {
bsonType: 'date',
},
updatedAt: {
bsonType: 'date',
},
},
},
},
})
} catch (e) {
console.log(e)
} finally {
client.close()
}
}

create()
@@ -0,0 +1,50 @@
const MongoClient = require('mongodb').MongoClient
const { DB_NAME, mongoUrl } = require('./utils/config')
const create = async () => {
const client = await MongoClient.connect(
mongoUrl,
{ useNewUrlParser: true },
)
console.log('Creating tokens collection')
const db = client.db(DB_NAME)
try {
await db.createCollection('tokens', {
validator: {
$jsonSchema: {
bsonType: 'object',
required: ['symbol', 'contractAddress', 'decimals'],
properties: {
symbol: {
bsonType: 'string',
description: 'must be a string and is required',
},
contractAddress: {
bsonType: 'string',
},
quote: {
bsonType: 'bool',
},
decimals: {
bsonType: 'int',
},
usd: {
bsonType: 'string'
},
createdAt: {
bsonType: 'date',
},
updatedAt: {
bsonType: 'date',
},
},
},
},
})
} catch (e) {
console.log(e)
} finally {
client.close()
}
}

create()
@@ -0,0 +1,74 @@
const MongoClient = require('mongodb').MongoClient
const { DB_NAME, mongoUrl } = require('./utils/config')

const create = async () => {
const client = await MongoClient.connect(mongoUrl, { useNewUrlParser: true })
console.log('Creating trades collection')
const db = client.db(DB_NAME)
try {
await db.createCollection('trades', {
validator: {
$jsonSchema: {
bsonType: 'object',
required: [
'baseToken',
'quoteToken',
'amount',
'maker',
'taker',
],
properties: {
amount: {
bsonType: 'string',
},
pricepoint: {
bsonType: 'string',
},
status: {
bsonType: 'string',
},
maker: {
bsonType: 'string',
},
taker: {
bsonType: 'string',
},
takerOrderHash: {
bsonType: 'string',
},
makerOrderHash: {
bsonType: 'string',
},
hash: {
bsonType: 'string',
},
txHash: {
bsonType: 'string',
},
pairName: {
bsonType: 'string',
},
baseToken: {
bsonType: 'string',
},
quoteToken: {
bsonType: 'string',
},
createdAt: {
bsonType: 'date',
},
updatedAt: {
bsonType: 'date',
},
},
},
},
})
} catch (e) {
console.log(e)
} finally {
client.close()
}
}

create()
Oops, something went wrong.

0 comments on commit 589e8ef

Please sign in to comment.
You can’t perform that action at this time.