Skip to content

Commit 5669b57

Browse files
authored
Add timestamps (#21)
1 parent aa68750 commit 5669b57

File tree

14 files changed

+145
-64
lines changed

14 files changed

+145
-64
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,31 @@
1111

1212

1313
# Deployments
14+
The migrations' folder holds the scripts for deploying the contracts categorized by type and chain.
15+
16+
You can use either Hardhat or Truffle to compile and deploy the contracts.
17+
18+
#### Hardhat
19+
20+
- Run `npx hardhat run --network <network> </migrations/hardhat/<chain>/<.js file>`
21+
22+
#### Truffle
1423

1524
- Modify the script prefixed with `1-` to specify which contract you would like to deploy.
1625
- Run the migration with `truffle migrate --network <network_listed_in_config> --reset`
1726

1827
# Testing
1928

20-
- Run npx hardhat node --fork YOUR_HTTPS_PROVIDER
29+
- Run `npx hardhat node --fork YOUR_HTTPS_PROVIDER`
2130
- Open a new terminal and set the WebSocketProvider to consume `http://127.0.0.1/8545`
22-
- Run the scripts and watch the terminal with the running chain.
31+
- Run `npx hardhat run --network localhost </migrations/hardhat/<chain>/<.js file>`
32+
- Start the program with `node ./`
33+
- Run the scripts provided by selected `Local` in the prompt.
34+
35+
*Note* Make sure the services provided are using the `http://127.0.0.1/8545` websocket url.
36+
[Example](https://github.com/AfriaDev/DefiTerminal/blob/master/program/utils/monitor/ethereum/prices/kyber/kyberPriceMonitor.js#L43)
37+
38+
39+
- Pending Hardhat test scripts
40+
41+

program/lib/interactive/binance/interactive/arbitrage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function startInteractiveArbitrage() {
88
{type: 'list', name: 'buyingExchange', message: 'Exchange You Will Buy From', choices: arbitrageActions.exchanges},
99
{type: 'list', name: 'sellingExchange', message: 'Exchange You Will Sell At', choices: arbitrageActions.exchanges},
1010
{type: 'list', name: 'network', message: 'Target Network', choices: arbitrageActions.networks},
11-
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount'},
11+
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount (WBNB)'},
1212
];
1313

1414
inquirer

program/lib/interactive/binance/interactive/monitor/interactive/arbitrage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function startInteractiveArbitrageMonitor() {
1010
{type: 'list', name: 'buyingExchange', message: 'Exchange You Will Buy From', choices: arbitrageActions.exchanges},
1111
{type: 'list', name: 'sellingExchange', message: 'Exchange You Will Sell At', choices: arbitrageActions.exchanges},
1212
{type: 'list', name: 'network', message: 'Target Network', choices: arbitrageActions.networks},
13-
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount'},
13+
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount(WBNB)'},
1414
];
1515

1616
inquirer

program/lib/interactive/ethereum/interactive/arbitrage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function startInteractiveArbitrage() {
88
{type: 'list', name: 'buyingExchange', message: 'Exchange You Will Buy From', choices: arbitrageActions.exchanges},
99
{type: 'list', name: 'sellingExchange', message: 'Exchange You Will Sell At', choices: arbitrageActions.exchanges},
1010
{type: 'list', name: 'network', message: 'Target Network', choices: arbitrageActions.networks},
11-
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount'},
11+
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount (WETH)'},
1212
];
1313

1414
inquirer

program/lib/interactive/ethereum/interactive/monitor/interactive/arbitrage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function startInteractiveArbitrageMonitor() {
99
{type: 'list', name: 'buyingExchange', message: 'Exchange You Will Buy From', choices: arbitrageActions.exchanges},
1010
{type: 'list', name: 'sellingExchange', message: 'Exchange You Will Sell At', choices: arbitrageActions.exchanges},
1111
{type: 'list', name: 'network', message: 'Target Network', choices: arbitrageActions.networks},
12-
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount'},
12+
{type: 'input', name: 'borrowAmount', message: 'Borrow Amount(WETH)'},
1313
];
1414

1515
inquirer

program/utils/arbitrage/binance/ApeBakeryArbitrage.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ require('dotenv').config();
22
const Web3 = require('web3');
33
const BigNumber = require('bignumber.js');
44
const {mainnet} = require('../../addresses')
5+
const pad = require("pad");
6+
const colors = require("colors");
7+
const moment = require("moment");
58

69

710
process.on('message', function (data) {
@@ -63,7 +66,6 @@ async function arbitrage(data) {
6366

6467
const shiftedWBNBBorrowAmount = web3.utils.toBN(web3.utils.toWei(borrowAmount))
6568

66-
console.log(shiftedWBNBBorrowAmount.toString() );
6769
// get BUSD AMOUNT
6870
const rawApeBUSDValue = await apeswap.router.methods
6971
.getAmountsOut(shiftedWBNBBorrowAmount,
@@ -203,6 +205,8 @@ async function arbitrage(data) {
203205

204206
if (bakeryToApeWBNBProfit > 0 && bakeryToApeWBNBProfit > apeToBakeryWBNBProfit) {
205207
console.log("Arb opportunity found!");
208+
console.log(pad(colors.yellow('Current Time:'), 30),
209+
moment().format('ll') + ' ' + moment().format('LTS'));
206210
console.log(`Flashloan WBNB on Bakeryswap at ${bakeryWBNBResults.buy} `);
207211
console.log(`Sell WBNB on Apeswap at ${apeWBNBResults.sell} `);
208212
console.log(`Expected profit: ${bakeryToApeWBNBProfit} WBNB`);
@@ -232,6 +236,8 @@ async function arbitrage(data) {
232236
}
233237
if (apeToBakeryWBNBProfit > 0 && apeToBakeryWBNBProfit > bakeryToApeWBNBProfit) {
234238
console.log("Arb opportunity found!");
239+
console.log(pad(colors.yellow('Current Time:'), 30),
240+
moment().format('ll') + ' ' + moment().format('LTS'));
235241
console.log(`Buy WBNB from Apeswap at ${apeWBNBResults.buy} `);
236242
console.log(`Sell WBNB from BakerySwap at ${bakeryWBNBResults.sell}`);
237243
console.log(`Expected profit: ${apeToBakeryWBNBProfit} WBNB`);
@@ -261,6 +267,8 @@ async function arbitrage(data) {
261267
}
262268
if (bakeryToApeBUSDProfit > 0 && bakeryToApeBUSDProfit > apeToBakeryBUSDProfit) {
263269
console.log("Arb opportunity found!");
270+
console.log(pad(colors.yellow('Current Time:'), 30),
271+
moment().format('ll') + ' ' + moment().format('LTS'));
264272
console.log(`Flashloan BUSD on Bakeryswap at ${bakeryBUSDResults.buy} `);
265273
console.log(`Sell BUSD on ApeSwap at ${apeBUSDResults.sell} `);
266274
console.log(`Expected profit: ${bakeryToApeBUSDProfit} BUSD`);
@@ -290,6 +298,8 @@ async function arbitrage(data) {
290298
}
291299
if (apeToBakeryBUSDProfit > 0 && apeToBakeryBUSDProfit > bakeryToApeBUSDProfit) {
292300
console.log("Arb opportunity found!");
301+
console.log(pad(colors.yellow('Current Time:'), 30),
302+
moment().format('ll') + ' ' + moment().format('LTS'));
293303
console.log(`Flashloan BUSD on Apeswap at ${apeBUSDResults.buy} `);
294304
console.log(`Sell BUSD on Bakeryswap at ${bakeryBUSDResults.sell} `);
295305
console.log(`Expected profit: ${apeToBakeryBUSDProfit} BUSD`);

program/utils/arbitrage/binance/ApePancakeArbitrage.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ require('dotenv').config();
22
const Web3 = require('web3');
33
const BigNumber = require('bignumber.js');
44
const {mainnet} = require('../../addresses')
5+
const pad = require("pad");
6+
const colors = require("colors");
7+
const moment = require("moment");
58

69

710
process.on('message', function (data) {
@@ -63,7 +66,6 @@ async function arbitrage(data) {
6366

6467
const shiftedWBNBBorrowAmount = web3.utils.toBN(web3.utils.toWei(borrowAmount))
6568

66-
console.log(shiftedWBNBBorrowAmount.toString() );
6769
// get BUSD AMOUNT
6870
const rawApeBUSDValue = await apeswap.router.methods
6971
.getAmountsOut(shiftedWBNBBorrowAmount,
@@ -89,7 +91,7 @@ async function arbitrage(data) {
8991

9092

9193
// Set x Borrow Amount BNB / y BUSD Borrow Amount
92-
const bUSDBorrowAmount = (Number(shiftedPancakeBUSDValue.toString()));
94+
const bUSDBorrowAmount = (Number(shiftedApeBUSDValue.toString()));
9395
const shiftedBUSDBorrowAmount = new BigNumber(bUSDBorrowAmount).shiftedBy(stableToken.decimals);
9496

9597

@@ -202,7 +204,11 @@ async function arbitrage(data) {
202204
//console.log(apeToPancakeBUSDProfit)
203205

204206
if (pancakeToApeWBNBProfit > 0 && pancakeToApeWBNBProfit > apeToPancakeWBNBProfit) {
207+
205208
console.log("Arb opportunity found!");
209+
console.log(pad(colors.yellow('Current Time:'), 30),
210+
moment().format('ll') + ' ' + moment().format('LTS'));
211+
206212
console.log(`Flashloan WBNB on Pancakeswap at ${pancakeWBNBResults.buy} `);
207213
console.log(`Sell WBNB on Apeswap at ${apeWBNBResults.sell} `);
208214
console.log(`Expected profit: ${pancakeToApeWBNBProfit} WBNB`);
@@ -232,6 +238,8 @@ async function arbitrage(data) {
232238
}
233239
if (apeToPancakeWBNBProfit > 0 && apeToPancakeWBNBProfit > pancakeToApeWBNBProfit) {
234240
console.log("Arb opportunity found!");
241+
console.log(pad(colors.yellow('Current Time:'), 30),
242+
moment().format('ll') + ' ' + moment().format('LTS'));
235243
console.log(`Buy WBNB from Apeswap at ${apeWBNBResults.buy} `);
236244
console.log(`Sell WBNB from PancakeSwap at ${pancakeWBNBResults.sell}`);
237245
console.log(`Expected profit: ${apeToPancakeWBNBProfit} WBNB`);
@@ -261,6 +269,8 @@ async function arbitrage(data) {
261269
}
262270
if (pancakeToApeBUSDProfit > 0 && pancakeToApeBUSDProfit > apeToPancakeBUSDProfit) {
263271
console.log("Arb opportunity found!");
272+
console.log(pad(colors.yellow('Current Time:'), 30),
273+
moment().format('ll') + ' ' + moment().format('LTS'));
264274
console.log(`Flashloan BUSD on Pancakeswap at ${pancakeBUSDResults.buy} `);
265275
console.log(`Sell BUSD on ApeSwap at ${apeBUSDResults.sell} `);
266276
console.log(`Expected profit: ${pancakeToApeBUSDProfit} BUSD`);
@@ -290,6 +300,8 @@ async function arbitrage(data) {
290300
}
291301
if (apeToPancakeBUSDProfit > 0 && apeToPancakeBUSDProfit > pancakeToApeBUSDProfit) {
292302
console.log("Arb opportunity found!");
303+
console.log(pad(colors.yellow('Current Time:'), 30),
304+
moment().format('ll') + ' ' + moment().format('LTS'));
293305
console.log(`Flashloan BUSD on Apeswap at ${apeBUSDResults.buy} `);
294306
console.log(`Sell BUSD on Pancakeswap at ${pancakeBUSDResults.sell} `);
295307
console.log(`Expected profit: ${apeToPancakeBUSDProfit} BUSD`);

program/utils/arbitrage/binance/BakeryApeArbitrage.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ require('dotenv').config();
22
const Web3 = require('web3');
33
const BigNumber = require('bignumber.js');
44
const {mainnet} = require('../../addresses')
5+
const pad = require("pad");
6+
const colors = require("colors");
7+
const moment = require("moment");
58

69

710
process.on('message', function (data) {
@@ -63,7 +66,6 @@ async function arbitrage(data) {
6366

6467
const shiftedWBNBBorrowAmount = web3.utils.toBN(web3.utils.toWei(borrowAmount))
6568

66-
console.log(shiftedWBNBBorrowAmount.toString() );
6769
// get BUSD AMOUNT
6870
const rawBakeryBUSDValue = await bakeryswap.router.methods
6971
.getAmountsOut(shiftedWBNBBorrowAmount,
@@ -203,6 +205,8 @@ async function arbitrage(data) {
203205

204206
if (apeToBakeryWBNBProfit > 0 && apeToBakeryWBNBProfit > bakeryToApeWBNBProfit) {
205207
console.log("Arb opportunity found!");
208+
console.log(pad(colors.yellow('Current Time:'), 30),
209+
moment().format('ll') + ' ' + moment().format('LTS'));
206210
console.log(`Flashloan WBNB on Apeswap at ${apeWBNBResults.buy} `);
207211
console.log(`Sell WBNB on Bakeryswap at ${bakeryWBNBResults.sell} `);
208212
console.log(`Expected profit: ${apeToBakeryWBNBProfit} WBNB`);
@@ -232,6 +236,8 @@ async function arbitrage(data) {
232236
}
233237
if (bakeryToApeWBNBProfit > 0 && bakeryToApeWBNBProfit > apeToBakeryWBNBProfit) {
234238
console.log("Arb opportunity found!");
239+
console.log(pad(colors.yellow('Current Time:'), 30),
240+
moment().format('ll') + ' ' + moment().format('LTS'));
235241
console.log(`Buy WBNB from Bakeryswap at ${bakeryWBNBResults.buy} `);
236242
console.log(`Sell WBNB from ApeSwap at ${apeWBNBResults.sell}`);
237243
console.log(`Expected profit: ${bakeryToApeWBNBProfit} WBNB`);
@@ -261,6 +267,8 @@ async function arbitrage(data) {
261267
}
262268
if (apeToBakeryBUSDProfit > 0 && apeToBakeryBUSDProfit > bakeryToApeBUSDProfit) {
263269
console.log("Arb opportunity found!");
270+
console.log(pad(colors.yellow('Current Time:'), 30),
271+
moment().format('ll') + ' ' + moment().format('LTS'));
264272
console.log(`Flashloan BUSD on Apeswap at ${apeBUSDResults.buy} `);
265273
console.log(`Sell BUSD on BakerySwap at ${bakeryBUSDResults.sell} `);
266274
console.log(`Expected profit: ${apeToBakeryBUSDProfit} BUSD`);
@@ -290,6 +298,8 @@ async function arbitrage(data) {
290298
}
291299
if (bakeryToApeBUSDProfit > 0 && bakeryToApeBUSDProfit > apeToBakeryBUSDProfit) {
292300
console.log("Arb opportunity found!");
301+
console.log(pad(colors.yellow('Current Time:'), 30),
302+
moment().format('ll') + ' ' + moment().format('LTS'));
293303
console.log(`Flashloan BUSD on Bakeryswap at ${bakeryBUSDResults.buy} `);
294304
console.log(`Sell BUSD on Apeswap at ${apeBUSDResults.sell} `);
295305
console.log(`Expected profit: ${bakeryToApeBUSDProfit} BUSD`);

program/utils/arbitrage/binance/BakeryPancakeArbitrage.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ require('dotenv').config();
22
const Web3 = require('web3');
33
const BigNumber = require('bignumber.js');
44
const {mainnet} = require('../../addresses')
5+
const pad = require("pad");
6+
const colors = require("colors");
7+
const moment = require("moment");
58

69

710
process.on('message', function (data) {
@@ -61,7 +64,6 @@ async function arbitrage(data) {
6164
console.log(`New block received. Block # ${block.number}`);
6265

6366

64-
const shiftedWBNBBorrowAmount = web3.utils.toBN(web3.utils.toWei(borrowAmount))
6567

6668
console.log(shiftedWBNBBorrowAmount.toString() );
6769
// get BUSD AMOUNT
@@ -203,6 +205,8 @@ async function arbitrage(data) {
203205

204206
if (pancakeToBakeryWBNBProfit > 0 && pancakeToBakeryWBNBProfit > bakeryToPancakeWBNBProfit) {
205207
console.log("Arb opportunity found!");
208+
console.log(pad(colors.yellow('Current Time:'), 30),
209+
moment().format('ll') + ' ' + moment().format('LTS'));
206210
console.log(`Flashloan WBNB on Pancakeswap at ${pancakeWBNBResults.buy} `);
207211
console.log(`Sell WBNB on Bakeryswap at ${bakeryWBNBResults.sell} `);
208212
console.log(`Expected profit: ${pancakeToBakeryWBNBProfit} WBNB`);
@@ -232,6 +236,8 @@ async function arbitrage(data) {
232236
}
233237
if (bakeryToPancakeWBNBProfit > 0 && bakeryToPancakeWBNBProfit > pancakeToBakeryWBNBProfit) {
234238
console.log("Arb opportunity found!");
239+
console.log(pad(colors.yellow('Current Time:'), 30),
240+
moment().format('ll') + ' ' + moment().format('LTS'));
235241
console.log(`Buy WBNB from Bakeryswap at ${bakeryWBNBResults.buy} `);
236242
console.log(`Sell WBNB from PancakeSwap at ${pancakeWBNBResults.sell}`);
237243
console.log(`Expected profit: ${bakeryToPancakeWBNBProfit} WBNB`);
@@ -261,6 +267,8 @@ async function arbitrage(data) {
261267
}
262268
if (pancakeToBakeryBUSDProfit > 0 && pancakeToBakeryBUSDProfit > bakeryToPancakeBUSDProfit) {
263269
console.log("Arb opportunity found!");
270+
console.log(pad(colors.yellow('Current Time:'), 30),
271+
moment().format('ll') + ' ' + moment().format('LTS'));
264272
console.log(`Flashloan BUSD on Pancakeswap at ${pancakeBUSDResults.buy} `);
265273
console.log(`Sell BUSD on BakerySwap at ${bakeryBUSDResults.sell} `);
266274
console.log(`Expected profit: ${pancakeToBakeryBUSDProfit} BUSD`);
@@ -290,6 +298,8 @@ async function arbitrage(data) {
290298
}
291299
if (bakeryToPancakeBUSDProfit > 0 && bakeryToPancakeBUSDProfit > pancakeToBakeryBUSDProfit) {
292300
console.log("Arb opportunity found!");
301+
console.log(pad(colors.yellow('Current Time:'), 30),
302+
moment().format('ll') + ' ' + moment().format('LTS'));
293303
console.log(`Flashloan BUSD on Bakeryswap at ${bakeryBUSDResults.buy} `);
294304
console.log(`Sell BUSD on Pancakeswap at ${pancakeBUSDResults.sell} `);
295305
console.log(`Expected profit: ${bakeryToPancakeBUSDProfit} BUSD`);

program/utils/arbitrage/binance/PancakeApeArbitrage.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ require('dotenv').config();
22
const Web3 = require('web3');
33
const BigNumber = require('bignumber.js');
44
const {mainnet} = require('../../addresses')
5+
const pad = require("pad");
6+
const colors = require("colors");
7+
const moment = require("moment");
58

69

710
process.on('message', function (data) {
@@ -61,7 +64,6 @@ async function arbitrage(data) {
6164
console.log(`New block received. Block # ${block.number}`);
6265

6366

64-
const shiftedWBNBBorrowAmount = web3.utils.toBN(web3.utils.toWei(borrowAmount))
6567

6668
console.log(shiftedWBNBBorrowAmount.toString() );
6769
// get BUSD AMOUNT
@@ -203,6 +205,8 @@ async function arbitrage(data) {
203205

204206
if (apeToPancakeWBNBProfit > 0 && apeToPancakeWBNBProfit > pancakeToApeWBNBProfit) {
205207
console.log("Arb opportunity found!");
208+
console.log(pad(colors.yellow('Current Time:'), 30),
209+
moment().format('ll') + ' ' + moment().format('LTS'));
206210
console.log(`Flashloan WBNB on Apeswap at ${apeWBNBResults.buy} `);
207211
console.log(`Sell WBNB on Pancakeswap at ${pancakeWBNBResults.sell} `);
208212
console.log(`Expected profit: ${apeToPancakeWBNBProfit} WBNB`);
@@ -232,6 +236,8 @@ async function arbitrage(data) {
232236
}
233237
if (pancakeToApeWBNBProfit > 0 && pancakeToApeWBNBProfit > apeToPancakeWBNBProfit) {
234238
console.log("Arb opportunity found!");
239+
console.log(pad(colors.yellow('Current Time:'), 30),
240+
moment().format('ll') + ' ' + moment().format('LTS'));
235241
console.log(`Buy WBNB from Pancakeswap at ${pancakeWBNBResults.buy} `);
236242
console.log(`Sell WBNB from ApeSwap at ${apeWBNBResults.sell}`);
237243
console.log(`Expected profit: ${pancakeToApeWBNBProfit} WBNB`);
@@ -261,6 +267,8 @@ async function arbitrage(data) {
261267
}
262268
if (apeToPancakeBUSDProfit > 0 && apeToPancakeBUSDProfit > pancakeToApeBUSDProfit) {
263269
console.log("Arb opportunity found!");
270+
console.log(pad(colors.yellow('Current Time:'), 30),
271+
moment().format('ll') + ' ' + moment().format('LTS'));
264272
console.log(`Flashloan BUSD on Apeswap at ${apeBUSDResults.buy} `);
265273
console.log(`Sell BUSD on PancakeSwap at ${pancakeBUSDResults.sell} `);
266274
console.log(`Expected profit: ${apeToPancakeBUSDProfit} BUSD`);
@@ -290,6 +298,8 @@ async function arbitrage(data) {
290298
}
291299
if (pancakeToApeBUSDProfit > 0 && pancakeToApeBUSDProfit > apeToPancakeBUSDProfit) {
292300
console.log("Arb opportunity found!");
301+
console.log(pad(colors.yellow('Current Time:'), 30),
302+
moment().format('ll') + ' ' + moment().format('LTS'));
293303
console.log(`Flashloan BUSD on Pancakeswap at ${pancakeBUSDResults.buy} `);
294304
console.log(`Sell BUSD on Apeswap at ${apeBUSDResults.sell} `);
295305
console.log(`Expected profit: ${pancakeToApeBUSDProfit} BUSD`);

0 commit comments

Comments
 (0)