Strictest / tests / minor improvements

This commit is contained in:
Aleksandr Kraiz
2023-02-17 17:31:35 +04:00
parent 11c8348ee9
commit 2c24f71453
39 changed files with 566 additions and 128 deletions

View File

@@ -1,4 +1,3 @@
// import { ethers } from 'ethers';
import Orion from '../Orion';
import OrionAnalytics from '../services/OrionAnalytics';
import { ReferralSystem } from '../services/ReferralSystem';

View File

@@ -0,0 +1,39 @@
import { ethers } from 'ethers';
import Orion from '../Orion';
const privateKey = process.env['PRIVATE_KEY'];
if (privateKey === undefined) throw new Error('Private key is required');
jest.setTimeout(30000);
describe('Transfers', () => {
test('Deposit ORN', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
await bscUnit.exchange.deposit({
asset: 'ORN',
amount: 20,
signer: wallet,
});
});
test('Withdraw ORN', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
await bscUnit.exchange.withdraw({
asset: 'ORN',
amount: 20,
signer: wallet,
});
});
});

View File

@@ -0,0 +1,39 @@
import { ethers } from 'ethers';
import Orion from '../Orion';
const privateKey = process.env['PRIVATE_KEY']
if (privateKey === undefined) throw new Error('Private key is required');
jest.setTimeout(30000);
describe('Pools', () => {
test('Add liquidity ORN', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
await bscUnit.farmingManager.addLiquidity({
amountAsset: 'ORN',
poolName: 'ORN-USDT',
amount: 20,
signer: wallet,
});
});
test('Remove liquidity ORN', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
await bscUnit.farmingManager.removeAllLiquidity({
poolName: 'ORN-USDT',
signer: wallet,
});
});
});

View File

@@ -0,0 +1,103 @@
import { ethers } from 'ethers';
import Orion from '../Orion';
import swapMarket from '../OrionUnit/Exchange/swapMarket';
const privateKey = process.env['PRIVATE_KEY']
if (privateKey === undefined) throw new Error('Private key is required');
jest.setTimeout(240000);
describe('Spot trading', () => {
test('Sell. Simple', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
const result = await swapMarket({
assetIn: 'ORN',
assetOut: 'USDT',
amount: 20,
type: 'exactSpend',
signer: wallet,
feeAsset: 'USDT',
orionUnit: bscUnit,
slippagePercent: 1,
// options: {
// logger: console.log
// }
})
await result.wait();
});
test('Buy. Simple', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
const result = await bscUnit.exchange.swapMarket({
assetIn: 'USDT',
assetOut: 'ORN',
amount: 20,
type: 'exactReceive',
signer: wallet,
feeAsset: 'USDT',
slippagePercent: 1,
// options: {
// logger: console.log
// }
})
await result.wait();
});
test('Buy. Complex', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
const result = await bscUnit.exchange.swapMarket({
assetIn: 'USDT',
assetOut: 'BNB',
amount: 40,
type: 'exactSpend',
signer: wallet,
feeAsset: 'USDT',
slippagePercent: 1,
// options: {
// logger: console.log
// }
})
await result.wait();
});
test('Sell. Complex', async () => {
const orion = new Orion('testing');
const bscUnit = orion.getUnit('bsc');
const wallet = new ethers.Wallet(
privateKey,
bscUnit.provider
);
const result = await bscUnit.exchange.swapMarket({
assetIn: 'BNB',
assetOut: 'ETH',
amount: 0.01,
type: 'exactReceive',
signer: wallet,
feeAsset: 'USDT',
slippagePercent: 1,
// options: {
// logger: console.log
// }
});
await result.wait();
});
});