diff --git a/js/package.json b/js/package.json
index e6dc333..eecfa83 100644
--- a/js/package.json
+++ b/js/package.json
@@ -29,7 +29,7 @@
},
"scripts": {
"client": "PORT=3001 FAST_REFRESH=false react-scripts start",
- "server": "node -r dotenv/config --trace-warnings --max-old-space-size=13958 server/main.js 2>&1 | tee /tmp/cryptoecon.log",
+ "server": "node -r dotenv/config --trace-warnings --max-old-space-size=32768 server/main.js 2>&1 | tee /tmp/cryptoecon.log",
"dev": "node -r dotenv/config --max-old-space-size=16384 server/main.js",
"test-process": "node -r dotenv/config --trace-warnings --max-old-space-size=16384 ./server/worker/process.childprocess.test.js",
"refresh-lm-snapshot": "source .env && curl -H 'Content-Type: application/json' -H \"$HEADER_SECRET\" -X POST -d '{\"query\": \"query GetSnapshot { snapshots_new(limit: 1 order_by: {id: desc}) { snapshot_data } }\"}' $SNAPSHOT_URL -o ./snapshots/snapshot_lm_latest.trash.json",
diff --git a/js/server/config.js b/js/server/config.js
index d818c47..7f7f616 100644
--- a/js/server/config.js
+++ b/js/server/config.js
@@ -39,7 +39,7 @@ const config = {
DEPOSITS_ALLOWED_DURATION_MS,
MULTIPLIER_MATURITY: 864, // 4 months in in 200minute intervals,
NUMBER_OF_INTERVALS_TO_RUN: REWARD_ACCRUAL_DURATION_INTERVAL_COUNT + 864, // duration of bucket drain + duration to latest possible multiplier maturity
- REWARD_ACCRUAL_DURATION_INTERVAL_COUNT,
+ REWARD_ACCRUAL_DURATION_INTERVAL_COUNT
};
module.exports = config;
diff --git a/js/server/loaders/loadLiquidityMinersSnapshot.js b/js/server/loaders/loadLiquidityMinersSnapshot.js
index 0721590..231a70a 100644
--- a/js/server/loaders/loadLiquidityMinersSnapshot.js
+++ b/js/server/loaders/loadLiquidityMinersSnapshot.js
@@ -46,11 +46,11 @@ const { getDatabase } = require('./getDatabase');
// }
// };
-const getSQLQueryByNetwork = (network) => {
+const getSQLQueryByNetwork = network => {
network = network ? network.toLowerCase() : network;
switch (network) {
case TESTNET: {
- return getDatabase().transaction(async (tx) => {
+ return getDatabase().transaction(async tx => {
const snapshots_new = await tx.many(
slonik.sql`select snapshot_data from snapshots_new_dev ORDER BY created_at DESC LIMIT 1`
);
@@ -64,13 +64,13 @@ const getSQLQueryByNetwork = (network) => {
data: {
snapshots_new,
snapshots_lm_claims,
- snapshots_lm_dispensation,
- },
+ snapshots_lm_dispensation
+ }
};
});
}
default: {
- return getDatabase().transaction(async (tx) => {
+ return getDatabase().transaction(async tx => {
const snapshots_new = tx.many(
slonik.sql`select * from snapshots_lm_rf rf where rf.snapshot_time = (select max(snapshot_time) from snapshots_lm_rf)`
);
@@ -92,8 +92,8 @@ const getSQLQueryByNetwork = (network) => {
data: {
snapshots_new: snapshotsNewLoaded,
snapshots_lm_claims: await snapshots_lm_claims,
- snapshots_lm_dispensation: await snapshots_lm_dispensation,
- },
+ snapshots_lm_dispensation: await snapshots_lm_dispensation
+ }
};
});
}
diff --git a/js/server/main.js b/js/server/main.js
index a01185f..8acbdd1 100644
--- a/js/server/main.js
+++ b/js/server/main.js
@@ -8,23 +8,25 @@ const { ProcessingHandler } = require('./worker');
const {
DEVNET,
MAINNET,
- TESTNET,
+ TESTNET
} = require('./constants/snapshot-source-names');
const {
GET_LM_DISPENSATION_JOB,
- GET_VS_DISPENSATION_JOB,
+ GET_VS_DISPENSATION_JOB
} = require('./constants/action-names');
const moment = require('moment');
const { encrypt, decrypt } = require('./util/encrypt');
const {
- createGenericDispensationJob,
+ createGenericDispensationJob
} = require('./util/createGenericDispensationJob');
if (process.env.DATABASE_URL) {
const encrypted = encrypt(process.env.DATABASE_URL);
require('fs').writeFileSync('./DATABASE_URL.enc', encrypted.encryptedData);
} else {
- const dburlEnc = require('fs').readFileSync('./DATABASE_URL.enc').toString();
+ const dburlEnc = require('fs')
+ .readFileSync('./DATABASE_URL.enc')
+ .toString();
const data = decrypt(dburlEnc);
process.env.DATABASE_URL = data;
}
@@ -61,12 +63,12 @@ let createTestnetHandler = () => {
};
const processingHandlers = {
[MAINNET]: ProcessingHandler.init(MAINNET),
- get [DEVNET]() {
+ get [DEVNET] () {
return createTestnetHandler();
},
- get [TESTNET]() {
+ get [TESTNET] () {
return createTestnetHandler();
- },
+ }
};
// const processingHandler = BackgroundProcessor.startAsMainProcess();
@@ -164,7 +166,7 @@ app.get('/api/lm', async (req, res, next) => {
const timeIndex = getTimeIndex(req.query.timestamp);
responseJSON = await processingHandler.dispatch('GET_LM_USER_DATA', {
address,
- timeIndex,
+ timeIndex
});
break;
}
@@ -226,7 +228,7 @@ app.get('/api/vs', async (req, res, next) => {
const timeIndex = getTimeIndex(req.query.timestamp);
responseJSON = await processingHandler.dispatch('GET_VS_USER_DATA', {
address,
- timeIndex,
+ timeIndex
});
break;
}
diff --git a/js/server/process.js b/js/server/process.js
index 9a5f5c6..6b9d0e6 100644
--- a/js/server/process.js
+++ b/js/server/process.js
@@ -3,41 +3,42 @@ const {
remapLMAddresses,
getLMTimeseriesFinalIndex,
createClaimEvents,
- createDispensationEvents,
+ createDispensationEvents
} = require('./util/lm-util');
const {
remapVSAddresses,
- getVSTimeseriesFinalIndex,
+ getVSTimeseriesFinalIndex
} = require('./util/vs-util');
const { processVSGlobalState } = require('./process-vs');
const {
EVENT_INTERVAL_MINUTES,
- NUMBER_OF_INTERVALS_TO_RUN,
+ NUMBER_OF_INTERVALS_TO_RUN
} = require('./config');
const { GlobalTimestampState } = require('./types');
const {
VALIDATOR_STAKING,
- LIQUIDITY_MINING,
+ LIQUIDITY_MINING
} = require('./constants/reward-program-types');
const { mockMinerClaims, mockMinerDispensations } = require('./mock');
-exports.getProcessedLMData = (snapshotLM) => {
+exports.getProcessedLMData = snapshotLM => {
let {
snapshots_new: [{ snapshot_data: minerSnapshotData }],
snapshots_lm_claims: [{ snapshot_data: claimsSnapshotData = {} } = {}],
snapshots_lm_dispensation: [
- { snapshot_data: dispensationsSnapshotData = {} } = {},
- ] = [],
+ { snapshot_data: dispensationsSnapshotData = {} } = {}
+ ] = []
} = snapshotLM.data;
- const snapshotTimeseriesFinalIndex =
- getLMTimeseriesFinalIndex(minerSnapshotData);
+ const snapshotTimeseriesFinalIndex = getLMTimeseriesFinalIndex(
+ minerSnapshotData
+ );
if (process.env.MOCK_DATA_ENABLED === 'true') {
claimsSnapshotData = mockMinerClaims(snapshotLM).claimsSnapshotData;
- dispensationsSnapshotData =
- mockMinerDispensations(claimsSnapshotData).dispensationsSnapshotData;
+ dispensationsSnapshotData = mockMinerDispensations(claimsSnapshotData)
+ .dispensationsSnapshotData;
}
const claimEventsByUserByTimestamp = createClaimEvents(claimsSnapshotData);
@@ -57,13 +58,13 @@ exports.getProcessedLMData = (snapshotLM) => {
);
};
-exports.getProcessedVSData = (snapshotVS) => {
+exports.getProcessedVSData = snapshotVS => {
let {
snapshots_validators: [{ snapshot_data: validatorSnapshotData }],
snapshots_vs_claims: [{ snapshot_data: claimsSnapshotData = {} } = {}],
snapshots_vs_dispensation: [
- { snapshot_data: dispensationsSnapshotData = {} } = {},
- ] = [],
+ { snapshot_data: dispensationsSnapshotData = {} } = {}
+ ] = []
} = snapshotVS.data;
const snapshotTimeseriesFinalIndex = getVSTimeseriesFinalIndex(
@@ -78,7 +79,7 @@ exports.getProcessedVSData = (snapshotVS) => {
console.time('remapVS');
const { userEventsByTimestamp } = remapVSAddresses(validatorSnapshotData);
console.timeEnd('remapVS');
- function getCurrentCommissionRate(validatorStakeAddress, stateIndex) {
+ function getCurrentCommissionRate (validatorStakeAddress, stateIndex) {
const validatorCommissionData =
validatorSnapshotData[validatorStakeAddress].commission;
const commissionIndex =
@@ -101,10 +102,10 @@ exports.getProcessedVSData = (snapshotVS) => {
const cacheEnabled = false;
const history = {
[VALIDATOR_STAKING]: {},
- [LIQUIDITY_MINING]: {},
+ [LIQUIDITY_MINING]: {}
};
-function processUserEventsByTimestamp(
+function processUserEventsByTimestamp (
userEventsByTimestamp,
getCurrentCommissionRate = (address, stateIndex) => 0,
rewardProgramType,
@@ -134,7 +135,7 @@ function processUserEventsByTimestamp(
lastGlobalState,
timestamp,
userEvents,
- (address) => getCurrentCommissionRate(address, i),
+ address => getCurrentCommissionRate(address, i),
rewardProgramType,
isSimulatedFutureInterval,
claimEventsByUser,
diff --git a/js/src/App.js b/js/src/App.js
index 615e3e2..81dbb99 100644
--- a/js/src/App.js
+++ b/js/src/App.js
@@ -767,6 +767,7 @@ class App extends React.Component {
>
+
diff --git a/js/src/api.js b/js/src/api.js
index 16d9492..c8b19bd 100644
--- a/js/src/api.js
+++ b/js/src/api.js
@@ -1,7 +1,6 @@
import { networks } from './config';
const serverURL = (() => {
let environment = process.env.REACT_APP_DEPLOYMENT_TAG;
- // environment = 'devnet';
switch (environment) {
case 'production':
return 'https://api-cryptoeconomics.sifchain.finance/api';
@@ -23,9 +22,16 @@ function handleFailedRequest () {
window.location.reload();
}, 3000);
}
+const getUrl = network => {
+ let url = serverURL;
+ if (networks.MAINNET_SNAPSHOTS_V2_BETA === network) {
+ url = 'http://ec2-3-138-153-106.us-east-2.compute.amazonaws.com/api';
+ }
+ return url;
+};
export const fetchUsers = (type, network) => {
return window
- .fetch(`${serverURL}/${type}?key=users`, {
+ .fetch(`${getUrl(network)}/${type}?key=users`, {
headers: getSnapshotNetworkHeaders(network)
})
.then(response => response.json())
@@ -35,7 +41,7 @@ export const fetchUsers = (type, network) => {
export const fetchUserData = (address, type, timestamp, network) => {
return window
.fetch(
- `${serverURL}/${type}?key=userData&address=${address}${
+ `${getUrl(network)}/${type}?key=userData&address=${address}${
timestamp ? `×tamp=${new Date(timestamp).toISOString()}` : ``
}`,
{
@@ -48,16 +54,19 @@ export const fetchUserData = (address, type, timestamp, network) => {
export const fetchUserTimeSeriesData = (address, type, network) => {
return window
- .fetch(`${serverURL}/${type}?key=userTimeSeriesData&address=${address}`, {
- headers: getSnapshotNetworkHeaders(network)
- })
+ .fetch(
+ `${getUrl(network)}/${type}?key=userTimeSeriesData&address=${address}`,
+ {
+ headers: getSnapshotNetworkHeaders(network)
+ }
+ )
.then(response => response.json())
.catch(handleFailedRequest);
};
export const fetchStack = (type, network) => {
return window
- .fetch(`${serverURL}/${type}?key=stack`, {
+ .fetch(`${getUrl(network)}/${type}?key=stack`, {
headers: getSnapshotNetworkHeaders(network)
})
.then(response => response.json())
diff --git a/js/src/config.js b/js/src/config.js
index 9483b87..9099964 100644
--- a/js/src/config.js
+++ b/js/src/config.js
@@ -3,7 +3,8 @@ const config = {
networks: {
MAINNET: 'mainnet',
DEVNET: 'devnet',
- TESTNET: 'testnet'
+ TESTNET: 'testnet',
+ MAINNET_SNAPSHOTS_V2_BETA: 'snapshots_v2_mainnet'
},
RECENT_ADDRESS_LIST_STORAGE_KEY: '__recent-address-list'
};