Skip to content

Commit

Permalink
Add Izumi provider (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
axtezy authored Aug 31, 2023
2 parents bcbeae7 + ef9d34f commit 88f2358
Show file tree
Hide file tree
Showing 20 changed files with 717 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubic-sdk",
"version": "4.20.0",
"version": "4.21.0",
"description": "Simplify dApp creation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -88,6 +88,7 @@
"ethers": "^5.6.8",
"graphql-request": "^6.1.0",
"grpc-web": "^1.4.2",
"iziswap-sdk": "^1.4.0",
"lodash.clonedeep": "^4.5.0",
"rango-sdk-basic": "^0.0.7",
"rxjs": "7.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import { GasPrice } from './models/gas-price';
export class EvmWeb3Public extends Web3Public {
protected readonly tokenContractAbi = ERC20_TOKEN_ABI;

public get web3Provider(): Web3 {
return this.web3;
}

constructor(
private readonly web3: Web3,
blockchainName: EvmBlockchainName,
Expand Down Expand Up @@ -427,9 +431,13 @@ export class EvmWeb3Public extends Web3Public {
let maxPriorityFeePerGas = null;

if (block && block.baseFeePerGas) {
lastBaseFeePerGas = this.getBaseFee(block);
maxPriorityFeePerGas = await this.getMaxPriorityFeePerGas();
maxFeePerGas = block.baseFeePerGas * 2 + maxPriorityFeePerGas;
try {
lastBaseFeePerGas = this.getBaseFee(block);
maxPriorityFeePerGas = await this.getMaxPriorityFeePerGas();
maxFeePerGas = block.baseFeePerGas * 2 + maxPriorityFeePerGas;
} catch (err) {
console.debug(err);
}
}

return {
Expand Down
3 changes: 2 additions & 1 deletion src/features/common/constants/proxy-supported-blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const proxySupportedBlockchains = [
BLOCKCHAIN_NAME.PULSECHAIN,
BLOCKCHAIN_NAME.AURORA,
BLOCKCHAIN_NAME.LINEA,
BLOCKCHAIN_NAME.BASE
BLOCKCHAIN_NAME.BASE,
BLOCKCHAIN_NAME.MANTLE
// BLOCKCHAIN_NAME.OKE_X_CHAIN,
// BLOCKCHAIN_NAME.GNOSIS,
// BLOCKCHAIN_NAME.FUSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export const rubicProxyContractAddress: Record<
router = '0xa63c029612ddaD00A269383Ab016D1e7c14E851D';
gateway = '0x8E70e517057e7380587Ea6990dAe81cB1Ba405ce';
}
if (blockchain === BLOCKCHAIN_NAME.LINEA || blockchain === BLOCKCHAIN_NAME.BASE) {
if (
blockchain === BLOCKCHAIN_NAME.LINEA ||
blockchain === BLOCKCHAIN_NAME.BASE ||
blockchain === BLOCKCHAIN_NAME.MANTLE
) {
router = '0xAf14797CcF963B1e3d028a9d51853acE16aedBA1';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { IzumiBaseProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/base/izumi-base/izumi-base-provider';
import { IzumiBscProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/bsc/izumi-bsc/izumi-bsc-provider';
import { IzumiLineaProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/linea/izumi-linea/izumi-linea-provider';
import { IzumiMantleProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/mantle/izumi-mantle/izumi-mantle-provider';
import { IzumiZksyncProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/zksync/izumi-zksync/izumi-zksync-provider';

export const izumiTradeProviders = [
IzumiBscProvider,
IzumiZksyncProvider,
IzumiMantleProvider,
IzumiBaseProvider,
IzumiLineaProvider
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Mutable } from 'src/common/utils/types';
import { BLOCKCHAIN_NAME } from 'src/core/blockchain/models/blockchain-name';
import { AlgebraTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/algebra-trade-providers';
import { BridgersTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/bridgers-trade-providers';
import { izumiTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/izumi-trade-providers';
import { OneinchTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/oneinch-trade-providers';
import { pancakeRouterProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/pancake-router-providers';
import { UniswapV2TradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/uniswap-v2-trade-providers';
Expand All @@ -18,6 +19,7 @@ export const typedTradeProviders: OnChainTypedTradeProviders = [
...BridgersTradeProviders,
// ...CurveTradeProviders, Removed because hack
...pancakeRouterProviders,
...izumiTradeProviders,
SyncSwapProvider,
VooiProvider
].reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { OpenOceanProvider } from 'src/features/on-chain/calculation-manager/pro
* Contains methods to calculate on-chain trades.
*/
export class OnChainManager {
public static readonly defaultCalculationTimeout = 10_000;
public static readonly defaultCalculationTimeout = 20_000;

/**
* List of all on-chain trade providers, combined by blockchains.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export const ON_CHAIN_TRADE_TYPE = {
TRADER: 'TRADER',
TRISOLARIS: 'TRISOLARIS',

IZUMI: 'IZUMI',

UBE_SWAP: 'UBE_SWAP',
UNISWAP_V2: 'UNISWAP_V2',
UNI_SWAP_V3: 'UNI_SWAP_V3',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { wrappedNativeTokensList } from 'src/common/tokens';
import { BLOCKCHAIN_NAME } from 'src/core/blockchain/models/blockchain-name';
import { IzumiProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/common/izumi-abstract/izumi-provider';

export class IzumiBaseProvider extends IzumiProvider {
public readonly blockchain = BLOCKCHAIN_NAME.BASE;

protected readonly dexAddress = '0x02F55D53DcE23B4AA962CC68b0f685f26143Bdb2';

protected readonly config = {
maxTransitTokens: 2,
quoterAddress: '0x3EF68D3f7664b2805D4E88381b64868a56f88bC4',
liquidityManagerAddress: '0x110dE362cc436D7f54210f96b8C7652C2617887D',
routingTokenAddresses: [
'0x0a3bb08b3a15a19b4de82f8acfc862606fb69a2d', // iUSD
wrappedNativeTokensList[BLOCKCHAIN_NAME.BASE]!.address, // WBNB
'0x60d01ec2d5e98ac51c8b4cf84dfcce98d527c747' // IZI
],
multicallAddress: '0x7a524c7e82874226F0b51aade60A1BE4D430Cf0F',
supportedFees: [10000, 3000, 500]
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { wrappedNativeTokensList } from 'src/common/tokens';
import { BLOCKCHAIN_NAME } from 'src/core/blockchain/models/blockchain-name';
import { IzumiProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/common/izumi-abstract/izumi-provider';

export class IzumiBscProvider extends IzumiProvider {
public readonly blockchain = BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN;

protected readonly dexAddress = '0xedf2021f41AbCfE2dEA4427E1B61f4d0AA5aA4b8';

protected readonly config = {
maxTransitTokens: 2,
quoterAddress: '0xDCe9a4ACC59E69ECcC0cdA2E82fe601fdB726542',
liquidityManagerAddress: '0xBF55ef05412f1528DbD96ED9E7181f87d8C9F453',
routingTokenAddresses: [
'0x55d398326f99059ff775485246999027b3197955', // USDT
wrappedNativeTokensList[BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]!.address, // WBNB
'0xe9e7cea3dedca5984780bafc599bd69add087d56' // BUSD
],
multicallAddress: '0xA1189a420662105bef5Be444B8b1E0a7D8279672',
supportedFees: [2000, 400]
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { AbiItem } from 'web3-utils';

export const izumiQuoterContractAbi: AbiItem[] = [
{
inputs: [
{ internalType: 'uint128', name: 'amount', type: 'uint128' },
{ internalType: 'bytes', name: 'path', type: 'bytes' }
],
name: 'swapAmount',
outputs: [
{ internalType: 'uint256', name: 'acquire', type: 'uint256' },
{ internalType: 'int24[]', name: 'pointAfterList', type: 'int24[]' }
],
stateMutability: 'nonpayable',
type: 'function'
}
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
import { AbiItem } from 'web3-utils';

export const izumiSwapContractAbi: AbiItem[] = [
{
inputs: [{ internalType: 'bytes[]', name: 'data', type: 'bytes[]' }],
name: 'multicall',
outputs: [{ internalType: 'bytes[]', name: 'results', type: 'bytes[]' }],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{ internalType: 'address', name: 'tokenX', type: 'address' },
{ internalType: 'address', name: 'tokenY', type: 'address' },
{ internalType: 'uint24', name: 'fee', type: 'uint24' }
],
name: 'pool',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function'
},
{ inputs: [], name: 'refundETH', outputs: [], stateMutability: 'payable', type: 'function' },
{
inputs: [
{
components: [
{ internalType: 'bytes', name: 'path', type: 'bytes' },
{ internalType: 'address', name: 'recipient', type: 'address' },
{ internalType: 'uint128', name: 'amount', type: 'uint128' },
{ internalType: 'uint256', name: 'minAcquired', type: 'uint256' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' }
],
internalType: 'struct Swap.SwapAmountParams',
name: 'params',
type: 'tuple'
}
],
name: 'swapAmount',
outputs: [
{ internalType: 'uint256', name: 'cost', type: 'uint256' },
{ internalType: 'uint256', name: 'acquire', type: 'uint256' }
],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{
components: [
{ internalType: 'bytes', name: 'path', type: 'bytes' },
{ internalType: 'address', name: 'recipient', type: 'address' },
{ internalType: 'uint128', name: 'desire', type: 'uint128' },
{ internalType: 'uint256', name: 'maxPayed', type: 'uint256' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' }
],
internalType: 'struct Swap.SwapDesireParams',
name: 'params',
type: 'tuple'
}
],
name: 'swapDesire',
outputs: [
{ internalType: 'uint256', name: 'cost', type: 'uint256' },
{ internalType: 'uint256', name: 'acquire', type: 'uint256' }
],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'tokenX', type: 'address' },
{ internalType: 'address', name: 'tokenY', type: 'address' },
{ internalType: 'uint24', name: 'fee', type: 'uint24' },
{ internalType: 'int24', name: 'boundaryPt', type: 'int24' },
{ internalType: 'address', name: 'recipient', type: 'address' },
{ internalType: 'uint128', name: 'amount', type: 'uint128' },
{ internalType: 'uint256', name: 'maxPayed', type: 'uint256' },
{ internalType: 'uint256', name: 'minAcquired', type: 'uint256' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' }
],
internalType: 'struct Swap.SwapParams',
name: 'swapParams',
type: 'tuple'
}
],
name: 'swapX2Y',
outputs: [],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{ internalType: 'uint256', name: 'x', type: 'uint256' },
{ internalType: 'uint256', name: 'y', type: 'uint256' },
{ internalType: 'bytes', name: 'data', type: 'bytes' }
],
name: 'swapX2YCallback',
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'tokenX', type: 'address' },
{ internalType: 'address', name: 'tokenY', type: 'address' },
{ internalType: 'uint24', name: 'fee', type: 'uint24' },
{ internalType: 'int24', name: 'boundaryPt', type: 'int24' },
{ internalType: 'address', name: 'recipient', type: 'address' },
{ internalType: 'uint128', name: 'amount', type: 'uint128' },
{ internalType: 'uint256', name: 'maxPayed', type: 'uint256' },
{ internalType: 'uint256', name: 'minAcquired', type: 'uint256' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' }
],
internalType: 'struct Swap.SwapParams',
name: 'swapParams',
type: 'tuple'
}
],
name: 'swapX2YDesireY',
outputs: [],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'tokenX', type: 'address' },
{ internalType: 'address', name: 'tokenY', type: 'address' },
{ internalType: 'uint24', name: 'fee', type: 'uint24' },
{ internalType: 'int24', name: 'boundaryPt', type: 'int24' },
{ internalType: 'address', name: 'recipient', type: 'address' },
{ internalType: 'uint128', name: 'amount', type: 'uint128' },
{ internalType: 'uint256', name: 'maxPayed', type: 'uint256' },
{ internalType: 'uint256', name: 'minAcquired', type: 'uint256' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' }
],
internalType: 'struct Swap.SwapParams',
name: 'swapParams',
type: 'tuple'
}
],
name: 'swapY2X',
outputs: [],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{ internalType: 'uint256', name: 'x', type: 'uint256' },
{ internalType: 'uint256', name: 'y', type: 'uint256' },
{ internalType: 'bytes', name: 'data', type: 'bytes' }
],
name: 'swapY2XCallback',
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'tokenX', type: 'address' },
{ internalType: 'address', name: 'tokenY', type: 'address' },
{ internalType: 'uint24', name: 'fee', type: 'uint24' },
{ internalType: 'int24', name: 'boundaryPt', type: 'int24' },
{ internalType: 'address', name: 'recipient', type: 'address' },
{ internalType: 'uint128', name: 'amount', type: 'uint128' },
{ internalType: 'uint256', name: 'maxPayed', type: 'uint256' },
{ internalType: 'uint256', name: 'minAcquired', type: 'uint256' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' }
],
internalType: 'struct Swap.SwapParams',
name: 'swapParams',
type: 'tuple'
}
],
name: 'swapY2XDesireX',
outputs: [],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{ internalType: 'address', name: 'token', type: 'address' },
{ internalType: 'uint256', name: 'minAmount', type: 'uint256' },
{ internalType: 'address', name: 'recipient', type: 'address' }
],
name: 'sweepToken',
outputs: [],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{ internalType: 'uint256', name: 'minAmount', type: 'uint256' },
{ internalType: 'address', name: 'recipient', type: 'address' }
],
name: 'unwrapWETH9',
outputs: [],
stateMutability: 'payable',
type: 'function'
},
{ stateMutability: 'payable', type: 'receive' }
];
Loading

0 comments on commit 88f2358

Please sign in to comment.