mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-25 23:27:41 +03:00
Strictest / tests / minor improvements
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// import { ethers } from 'ethers';
|
||||
import Orion from '../Orion';
|
||||
import OrionAnalytics from '../services/OrionAnalytics';
|
||||
import { ReferralSystem } from '../services/ReferralSystem';
|
||||
|
||||
39
src/__tests__/exchangeContract.test.ts
Normal file
39
src/__tests__/exchangeContract.test.ts
Normal 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,
|
||||
});
|
||||
});
|
||||
});
|
||||
39
src/__tests__/pools.test.ts
Normal file
39
src/__tests__/pools.test.ts
Normal 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,
|
||||
});
|
||||
});
|
||||
});
|
||||
103
src/__tests__/trading.test.ts
Normal file
103
src/__tests__/trading.test.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user