Merge branch 'refs/heads/main' into OP-5247-frontend-optimization

# Conflicts:
#	package.json
This commit is contained in:
Mikhail Gladchenko
2024-05-06 14:42:51 +01:00
12 changed files with 129 additions and 56 deletions

101
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.82",
"version": "0.20.86",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@orionprotocol/sdk",
"version": "0.20.82",
"version": "0.20.86",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
@@ -19,7 +19,7 @@
"bson-objectid": "^2.0.4",
"buffer": "^6.0.3",
"crypto-js": "^4.2.0",
"ethers": "^6.7.1",
"ethers": "^6.12.0",
"express": "^4.18.2",
"isomorphic-ws": "^5.0.0",
"just-clone": "^6.2.0",
@@ -81,9 +81,9 @@
}
},
"node_modules/@adraffy/ens-normalize": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz",
"integrity": "sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg=="
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz",
"integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw=="
},
"node_modules/@ampproject/remapping": {
"version": "2.2.1",
@@ -2364,27 +2364,27 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@noble/hashes": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz",
"integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
]
"node_modules/@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"dependencies": {
"@noble/hashes": "1.3.2"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/secp256k1": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz",
"integrity": "sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
]
"node_modules/@noble/hashes": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
@@ -5531,9 +5531,9 @@
}
},
"node_modules/ethers": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.7.1.tgz",
"integrity": "sha512-qX5kxIFMfg1i+epfgb0xF4WM7IqapIIu50pOJ17aebkxxa4BacW5jFrQRmCJpDEg2ZK2oNtR5QjrQ1WDBF29dA==",
"version": "6.12.1",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.12.1.tgz",
"integrity": "sha512-j6wcVoZf06nqEcBbDWkKg8Fp895SS96dSnTCjiXT+8vt2o02raTn4Lo9ERUuIVU5bAjoPYeA+7ytQFexFmLuVw==",
"funding": [
{
"type": "individual",
@@ -5545,9 +5545,9 @@
}
],
"dependencies": {
"@adraffy/ens-normalize": "1.9.2",
"@noble/hashes": "1.1.2",
"@noble/secp256k1": "1.7.1",
"@adraffy/ens-normalize": "1.10.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"@types/node": "18.15.13",
"aes-js": "4.0.0-beta.5",
"tslib": "2.4.0",
@@ -11951,9 +11951,9 @@
"dev": true
},
"@adraffy/ens-normalize": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz",
"integrity": "sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg=="
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz",
"integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw=="
},
"@ampproject/remapping": {
"version": "2.2.1",
@@ -13449,15 +13449,18 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"@noble/hashes": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz",
"integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA=="
"@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"requires": {
"@noble/hashes": "1.3.2"
}
},
"@noble/secp256k1": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz",
"integrity": "sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw=="
"@noble/hashes": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ=="
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
@@ -15801,13 +15804,13 @@
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="
},
"ethers": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.7.1.tgz",
"integrity": "sha512-qX5kxIFMfg1i+epfgb0xF4WM7IqapIIu50pOJ17aebkxxa4BacW5jFrQRmCJpDEg2ZK2oNtR5QjrQ1WDBF29dA==",
"version": "6.12.1",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.12.1.tgz",
"integrity": "sha512-j6wcVoZf06nqEcBbDWkKg8Fp895SS96dSnTCjiXT+8vt2o02raTn4Lo9ERUuIVU5bAjoPYeA+7ytQFexFmLuVw==",
"requires": {
"@adraffy/ens-normalize": "1.9.2",
"@noble/hashes": "1.1.2",
"@noble/secp256k1": "1.7.1",
"@adraffy/ens-normalize": "1.10.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"@types/node": "18.15.13",
"aes-js": "4.0.0-beta.5",
"tslib": "2.4.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.79-rc12",
"version": "0.20.79-rc13",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",
@@ -94,7 +94,7 @@
"bson-objectid": "^2.0.4",
"buffer": "^6.0.3",
"crypto-js": "^4.2.0",
"ethers": "^6.7.1",
"ethers": "^6.12.0",
"express": "^4.18.2",
"isomorphic-ws": "^5.0.0",
"just-clone": "^6.2.0",

View File

@@ -232,5 +232,18 @@
"WETH": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
"curveRegistry": ""
}
},
"8453": {
"chainId": "8453",
"label": "Base",
"shortName": "BASE",
"code": "base",
"baseCurrencyName": "ETH",
"rpc": "https://mainnet.base.org/",
"explorer": "https://basescan.org/",
"contracts": {
"WETH": "0x4200000000000000000000000000000000000006",
"curveRegistry": ""
}
}
}

View File

@@ -183,6 +183,24 @@
"http": "/orion-indexer/"
}
}
},
"8453": {
"api": "https://trade.orion.xyz/base-mainnet",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
}
}
},
@@ -432,7 +450,7 @@
}
},
"2525": {
"api": "https://trade.orion.xyz/inevm-mainnet",
"api": "https://staging.orion.xyz/inevm-mainnet",
"services": {
"aggregator": {
"http": "/backend",
@@ -450,7 +468,7 @@
}
},
"59144": {
"api": "https://trade.orion.xyz/linea-mainnet",
"api": "https://staging.orion.xyz/linea-mainnet",
"services": {
"aggregator": {
"http": "/backend",
@@ -468,7 +486,25 @@
}
},
"43114": {
"api": "https://trade.orion.xyz/avalanche-c-chain",
"api": "https://staging.orion.xyz/avalanche-c-chain",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
},
"8453": {
"api": "https://staging.orion.xyz/base-mainnet",
"services": {
"aggregator": {
"http": "/backend",

View File

@@ -20,4 +20,5 @@ export const productionChains = [
SupportedChainId.INEVM,
SupportedChainId.LINEA,
SupportedChainId.AVAX,
SupportedChainId.BASE,
];

View File

@@ -1 +1 @@
export default ['ftm', 'bsc', 'eth', 'polygon', 'okc', 'arb', 'drip', 'opbnb', 'inevm', 'linea', 'avax'] as const;
export default ['ftm', 'bsc', 'eth', 'polygon', 'okc', 'arb', 'drip', 'opbnb', 'inevm', 'linea', 'avax', 'base'] as const;

View File

@@ -1 +1 @@
export default ['FTM', 'BSC', 'ETH', 'POLYGON', 'OKC', 'ARB', 'OPBNB', 'INEVM', 'LINEA', 'AVAX'] as const;
export default ['FTM', 'BSC', 'ETH', 'POLYGON', 'OKC', 'ARB', 'OPBNB', 'INEVM', 'LINEA', 'AVAX', 'BASE'] as const;

View File

@@ -72,6 +72,7 @@ class Aggregator {
this.getPoolReserves = this.getPoolReserves.bind(this);
this.getVersion = this.getVersion.bind(this);
this.getPrices = this.getPrices.bind(this);
this.getIsCexLiquidityAvailable = this.getIsCexLiquidityAvailable.bind(this);
}
get basicAuthHeaders() {
@@ -390,6 +391,20 @@ class Aggregator {
return fetchWithValidation(url.toString(), atomicSwapHistorySchema, { headers: this.basicAuthHeaders });
};
getIsCexLiquidityAvailable = (
assetIn: string,
assetOut: string,
) => {
const url = new URL(`${this.apiUrl}/api/v1/pairs/cex/liquidity/${assetIn}/${assetOut}`);
return fetchWithValidation(
url.toString(),
z.boolean(),
{ headers: this.basicAuthHeaders },
errorSchema,
);
};
// private encode_utf8(s: string) {
// return unescape(encodeURIComponent(s));
// }

View File

@@ -49,6 +49,7 @@ const swapInfoBase = z.object({
mi: z.number().optional(), // market amount in, USD
d: z.string().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage
}).optional(),
autoSlippage: z.number().optional(),
});
const swapInfoByAmountIn = swapInfoBase.extend({

View File

@@ -541,6 +541,7 @@ class AggregatorWS {
marketAmountIn: json.usd.mi,
difference: json.usd.d,
},
autoSlippage: json.sl,
};
switch (json.k) { // kind

View File

@@ -48,6 +48,7 @@ const swapInfoSchemaBase = baseMessageSchema.extend({
mi: z.number().optional(), // market amount in, USD
d: z.string().optional(), // difference in available amount in/out (USD) and market amount out/in (USD) in percentage
}).optional(),
sl: z.number().optional(),
});
const swapInfoSchemaByAmountIn = swapInfoSchemaBase.extend({

View File

@@ -92,6 +92,7 @@ export enum SupportedChainId {
INEVM = '2525',
LINEA = '59144',
AVAX = '43114',
BASE = '8453',
POLYGON_TESTNET = '80001',
FANTOM_TESTNET = '4002',
@@ -210,6 +211,7 @@ export type SwapInfoBase = {
marketAmountIn: number | undefined
difference: string | undefined
} | undefined
autoSlippage: number | undefined
}
export type SwapInfoByAmountIn = SwapInfoBase & {