Merge branch 'refs/heads/main' into feat/OP-4308-cross-chain-swap

# Conflicts:
#	package-lock.json
#	package.json
This commit is contained in:
TheJuze
2024-06-11 17:46:21 +03:00
27 changed files with 43 additions and 246 deletions

9
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@orionprotocol/sdk",
"version": "0.23.0-rc0",
"version": "0.23.0-rc1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@orionprotocol/sdk",
"version": "0.23.0-rc0",
"version": "0.23.0-rc1",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
@@ -2423,7 +2423,10 @@
"node_modules/@orionprotocol/contracts": {
"version": "1.23.4-rc",
"resolved": "https://registry.npmjs.org/@orionprotocol/contracts/-/contracts-1.23.4-rc.tgz",
"integrity": "sha512-Cd5oMVZzMuQbOqbVBnwUbLXr6jpwOq4MtwoLo/l6T1BxWh/s1hKF8VuIvUJgGbzI0HEg3AGa1DCT4chwe9721Q=="
"integrity": "sha512-Cd5oMVZzMuQbOqbVBnwUbLXr6jpwOq4MtwoLo/l6T1BxWh/s1hKF8VuIvUJgGbzI0HEg3AGa1DCT4chwe9721Q==",
"workspaces": [
"packages/*"
]
},
"node_modules/@sinclair/typebox": {
"version": "0.27.8",

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.23.0-rc0",
"version": "0.23.0-rc1",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -1,7 +1,7 @@
import { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import clone from 'just-clone';
import { ERC20__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { ERC20__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import { APPROVE_ERC20_GAS_LIMIT, NATIVE_CURRENCY_PRECISION } from './constants/index.js';
import type {
AggregatedBalanceRequirement, ApproveFix, Asset, BalanceIssue, BalanceRequirement, Source,

View File

@@ -1,6 +1,6 @@
import { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import getBalances from '../../utils/getBalances.js';
import BalanceGuard from '../../BalanceGuard.js';
import getAvailableSources from '../../utils/getAvailableFundsSources.js';

View File

@@ -1,4 +1,4 @@
import { SwapExecutor__factory, AeroPool__factory } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js"
import { SwapExecutor__factory, AeroPool__factory } from "@orionprotocol/contracts/lib/ethers-v6/index.js"
import { type BigNumberish, JsonRpcProvider } from "ethers"
import { SafeArray } from "../../../utils/safeGetters.js"
import { addCallParams } from "./utils.js"

View File

@@ -2,7 +2,7 @@ import {
SwapExecutor__factory,
CurveRegistry__factory,
ERC20__factory,
} from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js";
} from "@orionprotocol/contracts/lib/ethers-v6/index.js";
import { MaxUint256, type BigNumberish, type JsonRpcProvider } from "ethers";
import { addCallParams, pathCallWithBalance } from "./utils.js";
import type { SingleSwap } from "../../../types.js";

View File

@@ -1,4 +1,4 @@
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js"
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6/index.js"
import type { BigNumberish, AddressLike } from "ethers"
import { type CallParams, addCallParams } from "./utils.js"

View File

@@ -1,4 +1,4 @@
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js"
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6/index.js"
import type { BigNumberish, AddressLike } from "ethers"
import { type CallParams, addCallParams } from "./utils.js"

View File

@@ -1,4 +1,4 @@
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js"
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6/index.js"
import { SafeArray } from "../../../utils/safeGetters.js"
import { type BytesLike, type BigNumberish, concat, ethers, toBeHex } from "ethers"
import { addCallParams } from "./utils.js"

View File

@@ -1,4 +1,4 @@
import { SwapExecutor__factory, UniswapV3Pool__factory } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js"
import { SwapExecutor__factory, UniswapV3Pool__factory } from "@orionprotocol/contracts/lib/ethers-v6/index.js"
import { type BigNumberish , ethers, JsonRpcProvider } from "ethers"
import { SafeArray } from "../../../utils/safeGetters.js"
import { addCallParams } from "./utils.js"

View File

@@ -1,4 +1,4 @@
import { ERC20__factory, SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js"
import { ERC20__factory, SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6/index.js"
import type { AddressLike } from "ethers"
import { type BytesLike, ethers, type BigNumberish } from "ethers"

View File

@@ -1,4 +1,4 @@
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js"
import { SwapExecutor__factory } from "@orionprotocol/contracts/lib/ethers-v6/index.js"
import type { BigNumberish } from "ethers"
import { type CallParams, addCallParams } from "./utils.js"
import type { AddressLike } from "ethers"

View File

@@ -1,6 +1,6 @@
import { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import getBalances from '../../utils/getBalances.js';
import BalanceGuard from '../../BalanceGuard.js';
import type Unit from '../index.js';

View File

@@ -1,4 +1,4 @@
import type { LibValidator } from '@orionprotocol/contracts/lib/ethers-v6-cjs/Exchange.js';
import type { LibValidator } from '@orionprotocol/contracts/lib/ethers-v6/Exchange.js';
import { ethers, ZeroAddress } from 'ethers';
import type { AddressLike, JsonRpcProvider, BigNumberish, BytesLike } from 'ethers';
import cloneDeep from 'lodash.clonedeep';

View File

@@ -1,6 +1,6 @@
import { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import getBalances from '../../utils/getBalances.js';
import BalanceGuard from '../../BalanceGuard.js';
import getAvailableSources from '../../utils/getAvailableFundsSources.js';

View File

@@ -1,6 +1,6 @@
import { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import getBalances from '../../utils/getBalances.js';
import BalanceGuard from '../../BalanceGuard.js';
import getAvailableSources from '../../utils/getAvailableFundsSources.js';

View File

@@ -1,6 +1,6 @@
import { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import getBalances from '../../utils/getBalances.js';
import BalanceGuard from '../../BalanceGuard.js';
import type Unit from '../index.js';

View File

@@ -4,7 +4,7 @@ import {pmmOrderSchema} from "./schemas/order";
import {simpleFetch} from "simple-typed-fetch";
import {ethers, Wallet} from "ethers";
import {BigNumber} from "bignumber.js";
import { ERC20__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { ERC20__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import {orionRFQContractABI} from "./abi/OrionRFQ";
export default class Pmm {

View File

@@ -81,7 +81,7 @@ describe('Orion', () => {
test('Init Orion testing', () => {
const orion = new Orion('testing');
expect(orion.referralSystem).toBeInstanceOf(ReferralSystem);
expect(orion.unitsArray.length).toBe(4); // eth, bsc, polygon, fantom
expect(orion.unitsArray.length).toBe(2); // eth, bsc
const unitBSC = orion.units[SupportedChainId.BSC_TESTNET];
expect(unitBSC?.chainId).toBe(SupportedChainId.BSC_TESTNET);
@@ -89,23 +89,11 @@ describe('Orion', () => {
expect(orion.getSiblingsOf(SupportedChainId.BSC_TESTNET)).toHaveLength(3);
expect(unitBSC?.networkCode).toBe('bsc');
const unitRopsten = orion.units[SupportedChainId.ROPSTEN]
expect(unitRopsten?.chainId).toBe(SupportedChainId.ROPSTEN);
const unitSepolia = orion.units[SupportedChainId.SEPOLIA]
expect(unitSepolia?.chainId).toBe(SupportedChainId.SEPOLIA);
// expect(unitRopsten?.env).toBe('testing');
expect(orion.getSiblingsOf(SupportedChainId.ROPSTEN)).toHaveLength(3);
expect(unitRopsten?.networkCode).toBe('eth');
const unitPolygon = orion.units[SupportedChainId.POLYGON_TESTNET];
expect(unitPolygon?.chainId).toBe(SupportedChainId.POLYGON_TESTNET);
// expect(unitPolygon?.env).toBe('testing');
expect(orion.getSiblingsOf(SupportedChainId.POLYGON_TESTNET)).toHaveLength(3);
expect(unitPolygon?.networkCode).toBe('polygon');
const unitFantom = orion.units[SupportedChainId.FANTOM_TESTNET];
expect(unitFantom?.chainId).toBe(SupportedChainId.FANTOM_TESTNET);
// expect(unitFantom?.env).toBe('testing');
expect(orion.getSiblingsOf(SupportedChainId.FANTOM_TESTNET)).toHaveLength(3);
expect(unitFantom?.networkCode).toBe('ftm');
expect(orion.getSiblingsOf(SupportedChainId.SEPOLIA)).toHaveLength(3);
expect(unitSepolia?.networkCode).toBe('eth');
});
test('Init Orion production', () => {

View File

@@ -51,32 +51,6 @@
"curveRegistry": ""
}
},
"3": {
"chainId": "3",
"explorer": "https://ropsten.etherscan.io/",
"label": "Ropsten",
"shortName": "ETH-Ropsten",
"code": "eth",
"rpc": "https://testing.orion.xyz/eth-ropsten/rpc",
"baseCurrencyName": "ETH",
"contracts": {
"WETH": "",
"curveRegistry": ""
}
},
"5": {
"chainId": "5",
"explorer": "https://goerli.etherscan.io/",
"label": "Goerli",
"shortName": "ETH-Goerli",
"code": "eth",
"rpc": "https://testing.orion.xyz/eth-goerli/rpc",
"baseCurrencyName": "ETH",
"contracts": {
"WETH": "",
"curveRegistry": ""
}
},
"11155111": {
"chainId": "11155111",
"explorer": "https://sepolia.etherscan.io/",
@@ -90,19 +64,6 @@
"curveRegistry": ""
}
},
"421613": {
"chainId": "421613",
"explorer": "https://goerli.arbiscan.io/",
"label": "Arbitrum Goerli",
"shortName": "Arbitrum Goerli",
"code": "arb",
"rpc": "https://goerli-rollup.arbitrum.io/rpc",
"baseCurrencyName": "ETH",
"contracts": {
"WETH": "",
"curveRegistry": ""
}
},
"42161": {
"chainId": "42161",
"explorer": "https://arbiscan.io/",
@@ -116,19 +77,6 @@
"curveRegistry": "0x445FE580eF8d70FF569aB36e80c647af338db351"
}
},
"4002": {
"chainId": "4002",
"explorer": "https://testnet.ftmscan.com/",
"label": "Fantom Testnet",
"shortName": "FTM-Testnet",
"code": "ftm",
"rpc": "https://rpc.testnet.fantom.network/",
"baseCurrencyName": "FTM",
"contracts": {
"WETH": "",
"curveRegistry": ""
}
},
"250": {
"chainId": "250",
"explorer": "https://ftmscan.com/",
@@ -155,19 +103,6 @@
"curveRegistry": "0x094d12e5b541784701FD8d65F11fc0598FBC6332"
}
},
"80001": {
"chainId": "80001",
"label": "Polygon Mumbai",
"shortName": "Polygon Mumbai",
"code": "polygon",
"baseCurrencyName": "MATIC",
"rpc": "https://rpc.ankr.com/polygon_mumbai",
"explorer": "https://mumbai.polygonscan.com/",
"contracts": {
"WETH": "",
"curveRegistry": ""
}
},
"66": {
"chainId": "66",
"explorer": "https://www.oklink.com/okc/",
@@ -181,32 +116,6 @@
"curveRegistry": ""
}
},
"65": {
"chainId": "65",
"explorer": "https://www.oklink.com/okc-test/",
"label": "OKC Testnet",
"shortName": "OKC-Testnet",
"code": "okc",
"rpc": "https://exchaintestrpc.okex.org/",
"baseCurrencyName": "OKT",
"contracts": {
"WETH": "",
"curveRegistry": ""
}
},
"56303": {
"chainId": "56303",
"label": "DRIP Chain",
"shortName": "DRIP Chain",
"code": "drip",
"baseCurrencyName": "DRIP",
"rpc": "https://testnet.1d.rip/",
"explorer": "https://explorer-testnet.1d.rip/",
"contracts": {
"WETH": "",
"curveRegistry": ""
}
},
"2525": {
"chainId": "2525",
"label": "inEVM",

View File

@@ -244,78 +244,6 @@
"http": "/orion-indexer/"
}
}
},
"421613": {
"api": "https://testing.orion.xyz/arbitrum-goerli",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
},
"4002": {
"api": "https://testing.orion.xyz/ftm-testnet",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
},
"80001": {
"api": "https://testing.orion.xyz/polygon-mumbai",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
},
"56303": {
"api": "https://testing.orion.xyz/drip-testnet",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
}
}
},
@@ -544,24 +472,6 @@
"http": "/orion-indexer/"
}
}
},
"3": {
"api": "https://dn-dev.orion.xyz/eth-ropsten",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
}
}
},

View File

@@ -2,13 +2,7 @@ import { SupportedChainId } from '../types.js';
export const developmentChains = [
SupportedChainId.BSC_TESTNET,
SupportedChainId.ROPSTEN,
SupportedChainId.GOERLI,
SupportedChainId.SEPOLIA,
SupportedChainId.ARBITRUM_GOERLI,
SupportedChainId.FANTOM_TESTNET,
SupportedChainId.POLYGON_TESTNET,
SupportedChainId.OKC_TESTNET,
];
export const productionChains = [
SupportedChainId.MAINNET,

View File

@@ -108,26 +108,19 @@ export type Pair = {
export enum SupportedChainId {
MAINNET = '1',
ARBITRUM = '42161',
FANTOM_OPERA = '250',
POLYGON = '137',
OKC = '66',
OPBNB = '204',
INEVM = '2525',
LINEA = '59144',
AVAX = '43114',
BASE = '8453',
ROPSTEN = '3',
GOERLI = '5',
SEPOLIA = '11155111',
POLYGON_TESTNET = '80001',
FANTOM_TESTNET = '4002',
BSC = '56',
OKC = '66',
POLYGON = '137',
OPBNB = '204',
FANTOM_OPERA = '250',
INEVM = '2525',
BASE = '8453',
ARBITRUM = '42161',
AVAX = '43114',
LINEA = '59144',
BSC_TESTNET = '97',
OKC_TESTNET = '65',
DRIP_TESTNET = '56303',
ARBITRUM_GOERLI = '421613',
SEPOLIA = '11155111',
// For testing and debug purpose
// BROKEN = '0',

View File

@@ -1,4 +1,4 @@
import { ERC20__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { ERC20__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import { ethers } from 'ethers';
import invariant from 'tiny-invariant';

View File

@@ -1,4 +1,4 @@
import { ERC20__factory, Exchange__factory, type Exchange } from "@orionprotocol/contracts/lib/ethers-v6-cjs/index.js";
import { ERC20__factory, Exchange__factory, type Exchange } from "@orionprotocol/contracts/lib/ethers-v6/index.js";
import type { BigNumber } from "bignumber.js";
import { ZeroAddress, ethers } from "ethers";
import { INTERNAL_PROTOCOL_PRECISION, NATIVE_CURRENCY_PRECISION } from "../constants/index.js";

View File

@@ -1,4 +1,4 @@
import type { Exchange } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import type { Exchange } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import type { BigNumber } from 'bignumber.js';
import type { ethers } from 'ethers';
import type { Aggregator } from '../services/Aggregator/index.js';

View File

@@ -1,4 +1,4 @@
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6-cjs/index.js';
import { Exchange__factory } from '@orionprotocol/contracts/lib/ethers-v6/index.js';
import { ethers } from 'ethers';
import { z } from 'zod';