mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Bump deps
This commit is contained in:
2010
package-lock.json
generated
2010
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@@ -47,12 +47,12 @@
|
||||
"@types/socket.io-client": "1.4.33",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"@types/ws": "^8.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
||||
"@typescript-eslint/parser": "^5.51.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
||||
"@typescript-eslint/parser": "^5.52.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-loader": "^8.2.5",
|
||||
"concurrently": "^7.0.0",
|
||||
"eslint": "^8.33.0",
|
||||
"babel-loader": "^9.1.2",
|
||||
"concurrently": "^7.6.0",
|
||||
"eslint": "^8.34.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-config-standard-with-typescript": "^34.0.0",
|
||||
@@ -60,9 +60,9 @@
|
||||
"eslint-plugin-n": "^15.6.1",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"http-terminator": "^3.2.0",
|
||||
"husky": "^7.0.4",
|
||||
"husky": "^8.0.3",
|
||||
"is-ci": "^3.0.1",
|
||||
"jest": "^29.4.2",
|
||||
"jest": "^29.4.3",
|
||||
"ts-jest": "^29.0.5",
|
||||
"ts-loader": "^9.4.2",
|
||||
"typescript": "^4.9.5",
|
||||
@@ -80,18 +80,18 @@
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"ethers": "^5.6.2",
|
||||
"express": "^4.18.2",
|
||||
"isomorphic-unfetch": "^3.1.0",
|
||||
"isomorphic-unfetch": "^4.0.2",
|
||||
"isomorphic-ws": "^5.0.0",
|
||||
"just-clone": "^6.2.0",
|
||||
"merge-anything": "^5.1.4",
|
||||
"neverthrow": "^4.3.1",
|
||||
"neverthrow": "^6.0.0",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"tiny-invariant": "^1.3.1",
|
||||
"ts-is-present": "^1.2.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"uuid": "^9.0.0",
|
||||
"ws": "^8.12.0",
|
||||
"zod": "^3.20.2"
|
||||
"ws": "^8.12.1",
|
||||
"zod": "^3.20.6"
|
||||
},
|
||||
"homepage": "https://github.com/orionprotocol/sdk#readme",
|
||||
"files": [
|
||||
|
||||
@@ -23,6 +23,7 @@ export type SwapMarketParams = {
|
||||
signer: ethers.Signer
|
||||
orionUnit: OrionUnit
|
||||
options?: {
|
||||
// rounding?: 'up' | 'down' TODO
|
||||
poolOnly?: boolean
|
||||
instantSettlement?: boolean
|
||||
logger?: (message: string) => void
|
||||
@@ -34,12 +35,14 @@ export type SwapMarketParams = {
|
||||
}
|
||||
|
||||
type AggregatorOrder = {
|
||||
amountOut: number
|
||||
through: 'aggregator'
|
||||
id: string
|
||||
wait: () => Promise<z.infer<typeof orderSchema>>
|
||||
}
|
||||
|
||||
type PoolSwap = {
|
||||
amountOut: number
|
||||
through: 'orion_pool'
|
||||
txHash: string
|
||||
wait: (confirmations?: number | undefined) => Promise<ethers.providers.TransactionReceipt>
|
||||
@@ -165,7 +168,7 @@ export default async function swapMarket({
|
||||
|
||||
if (qtyPrecisionBN.lt(qtyDecimalPlaces)) {
|
||||
throw new Error(
|
||||
`Actual amount decimal places (${qtyDecimalPlaces}) is greater than max allowed decimal places (${qtyPrecisionBN.toString()}) on pair ${baseAssetName}-${quoteAssetName}`
|
||||
`Actual amount decimal places (${qtyDecimalPlaces}) is greater than max allowed decimal places (${qtyPrecisionBN.toString()}) on pair ${baseAssetName}-${quoteAssetName}.`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -297,6 +300,7 @@ export default async function swapMarket({
|
||||
const swapThroughOrionPoolTxResponse = await signer.sendTransaction(unsignedSwapThroughOrionPoolTx);
|
||||
options?.logger?.(`Transaction sent. Tx hash: ${swapThroughOrionPoolTxResponse.hash}`);
|
||||
return {
|
||||
amountOut: swapInfo.amountOut,
|
||||
wait: swapThroughOrionPoolTxResponse.wait,
|
||||
through: 'orion_pool',
|
||||
txHash: swapThroughOrionPoolTxResponse.hash,
|
||||
@@ -413,6 +417,7 @@ export default async function swapMarket({
|
||||
options?.logger?.(`Order placed. Order id: ${orderId}`);
|
||||
|
||||
return {
|
||||
amountOut: swapInfo.amountOut,
|
||||
wait: () => new Promise<z.infer<typeof orderSchema>>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
reject(new Error('Timeout'))
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('Spot trading', () => {
|
||||
bscUnit.provider
|
||||
);
|
||||
|
||||
const result = await bscUnit.exchange.swapMarket({
|
||||
const resultExactSpend = await bscUnit.exchange.swapMarket({
|
||||
assetIn: 'USDT',
|
||||
assetOut: 'BNB',
|
||||
amount: 40,
|
||||
@@ -75,29 +75,32 @@ describe('Spot trading', () => {
|
||||
// logger: console.log
|
||||
// }
|
||||
})
|
||||
await result.wait();
|
||||
});
|
||||
await resultExactSpend.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({
|
||||
const resultExactReceive = await bscUnit.exchange.swapMarket({
|
||||
assetIn: 'BNB',
|
||||
assetOut: 'ETH',
|
||||
amount: 0.01,
|
||||
assetOut: 'BTC',
|
||||
amount: resultExactSpend.amountOut.toPrecision(3),
|
||||
type: 'exactSpend',
|
||||
signer: wallet,
|
||||
feeAsset: 'USDT',
|
||||
slippagePercent: 1,
|
||||
options: {
|
||||
logger: console.log
|
||||
}
|
||||
});
|
||||
await resultExactReceive.wait();
|
||||
|
||||
// Return back to USDT
|
||||
const returnBackUsdt = await bscUnit.exchange.swapMarket({
|
||||
amount: 40,
|
||||
assetIn: 'BTC',
|
||||
assetOut: 'USDT',
|
||||
type: 'exactReceive',
|
||||
signer: wallet,
|
||||
feeAsset: 'USDT',
|
||||
slippagePercent: 1,
|
||||
// options: {
|
||||
// logger: console.log
|
||||
// }
|
||||
});
|
||||
await result.wait();
|
||||
await returnBackUsdt.wait();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user