Removed unnecessary balance requirement

This commit is contained in:
Aleksandr Kraiz
2022-04-22 18:40:14 +04:00
parent a56c4f0e11
commit 0a17972783
3 changed files with 23 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.2.3",
"version": "0.2.4",
"description": "Orion Protocol SDK",
"main": "lib/index.js",
"types": "lib/index.d.ts",

View File

@@ -19,7 +19,7 @@ export type SwapMarketParams = {
orionUnit: OrionUnit,
options?: {
logger?: (message: string) => void,
// route?: 'pool' | 'aggregator',
route?: 'pool' | 'aggregator',
autoApprove?: boolean,
}
}
@@ -47,6 +47,7 @@ export default async function swapMarket({
orionUnit,
options,
}: SwapMarketParams): Promise<Swap> {
if (options?.route) options?.logger?.('Warning! You specified route in options. Please use only if you know what you are doing.');
if (amount === '') throw new Error('Amount can not be empty');
if (assetIn === '') throw new Error('AssetIn can not be empty');
if (assetOut === '') throw new Error('AssetOut can not be empty');
@@ -134,7 +135,11 @@ export default async function swapMarket({
const percent = new BigNumber(slippagePercent).div(100);
if (swapInfo.isThroughPoolOptimal) {
const isThroughPoolOptimal = options?.route
? options?.route === 'pool'
: swapInfo.isThroughPoolOptimal;
if (isThroughPoolOptimal) {
options?.logger?.('Swap through pool');
const pathAddresses = swapInfo.path.map((name) => {
const assetAddress = assetToAddress?.[name];
@@ -206,17 +211,17 @@ export default async function swapMarket({
sources: getAvailableSources('network_fee', ethers.constants.AddressZero, 'orion_pool'),
});
if (value.gt(0)) {
balanceGuard.registerRequirement({
reason: 'Transaction value (extra amount)',
asset: {
name: nativeCryptocurrency,
address: ethers.constants.AddressZero,
},
amount: value.toString(),
sources: getAvailableSources('amount', ethers.constants.AddressZero, 'orion_pool'),
});
}
// if (value.gt(0)) {
// balanceGuard.registerRequirement({
// reason: 'Transaction value (extra amount)',
// asset: {
// name: nativeCryptocurrency,
// address: ethers.constants.AddressZero,
// },
// amount: value.toString(),
// sources: getAvailableSources('amount', ethers.constants.AddressZero, 'orion_pool'),
// });
// }
await balanceGuard.check(options?.autoApprove);

View File

@@ -1,3 +1,7 @@
import BigNumber from 'bignumber.js';
BigNumber.config({ EXPONENTIAL_AT: 1e9 });
export * as config from './config';
// export * from './entities';
export { default as OrionUnit } from './OrionUnit';