Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add polygon zkevm network #398

Merged
merged 45 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e389f62
[In progress] Send XY trades to Generic faucet
lilchizh May 26, 2023
0bbbbf3
XY Generic contract
lilchizh May 31, 2023
50f3ee3
Update generic providers, refactoring symbiosis to generic
axtezy Jun 6, 2023
d267223
add polygon zkEVM network
Doctor-Cyclone Jun 20, 2023
97db445
add polygon zkEVM cross-chain
Doctor-Cyclone Jun 21, 2023
e0a3e54
minor upd
Doctor-Cyclone Jun 23, 2023
761a8b5
Merge branch 'master' into feature/add-polygon-zkevm-network
Doctor-Cyclone Jun 23, 2023
31f4e53
upd symb config and quickswap v3
Doctor-Cyclone Jun 26, 2023
83ab851
Merge branch 'master' into feature/add-polygon-zkevm-network
Doctor-Cyclone Jun 28, 2023
05c59a7
upd multicall address
Doctor-Cyclone Jun 28, 2023
058403b
Merge branch 'master' into feature/add-polygon-zkevm-network
Doctor-Cyclone Jun 30, 2023
32fb88a
fix algebra quoter controller
Doctor-Cyclone Jun 30, 2023
afaffff
Merge branch 'master' into feature/add-polygon-zkevm-network
Doctor-Cyclone Jun 30, 2023
851edfb
add quoter controller for quickswap v3
Doctor-Cyclone Jul 3, 2023
402c8c7
Add squidrouter
axtezy Jul 4, 2023
e18fb6e
Add squidrouter transaction status traction
axtezy Jul 4, 2023
78c3052
Remove via and rango
axtezy Jul 4, 2023
821cef3
Fix providers list
axtezy Jul 4, 2023
9f1523c
Fix swaps
axtezy Jul 4, 2023
df912da
Merge branch 'master' into rubic-1393
axtezy Jul 11, 2023
6beb634
Update proxy contract call
axtezy Jul 11, 2023
3a811c3
Update version
axtezy Jul 11, 2023
fdd547e
Fix generic extra fee params
axtezy Jul 11, 2023
3fe1144
Fix extra fee field
axtezy Jul 11, 2023
b8b92a3
Fix extra fee field
axtezy Jul 11, 2023
bfc34ff
Add additional networks
axtezy Jul 11, 2023
ba97aef
Merge branch 'rubic-1393' into rubic-1516/squidrouter
axtezy Jul 11, 2023
36b58b7
Update generic contract
axtezy Jul 11, 2023
800abc1
Fix xy and symbiosis proxy
axtezy Jul 12, 2023
37c1174
Remove stargate disability
axtezy Jul 12, 2023
736564b
Add proxy squidrouter
axtezy Jul 12, 2023
8eeb381
Fix squidrouter fee info
axtezy Jul 12, 2023
c316313
Merge branch 'master' into feature/add-polygon-zkevm-network
Doctor-Cyclone Jul 12, 2023
e76c376
fix symb
Doctor-Cyclone Jul 12, 2023
7021261
Fix squid method
axtezy Jul 12, 2023
cb6619f
Fix gateway call
axtezy Jul 13, 2023
43e5739
upd symbiosis provider
Doctor-Cyclone Jul 13, 2023
d696114
add proxy
Doctor-Cyclone Jul 13, 2023
2006942
Merge remote-tracking branch 'origin/rubic-1516/squidrouter' into fea…
Doctor-Cyclone Jul 14, 2023
21598d7
merge squidrouter branch
Doctor-Cyclone Jul 14, 2023
0869039
added wBTC transit token
Doctor-Cyclone Jul 14, 2023
640437e
Fix extra fee
axtezy Jul 18, 2023
3b8eadc
Merge branch 'master' into feature/add-polygon-zkevm-network
Doctor-Cyclone Jul 18, 2023
c63ec09
merge master
Doctor-Cyclone Jul 18, 2023
feb44c0
set prod version
Doctor-Cyclone Jul 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubic-sdk",
"version": "4.7.3",
"version": "4.8.0",
"description": "Simplify dApp creation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -86,7 +86,7 @@
"lodash.clonedeep": "^4.5.0",
"rango-sdk-basic": "^0.0.7",
"rxjs": "7.8.1",
"symbiosis-js-sdk": "^2.9.52",
"symbiosis-js-sdk": "2.10.5",
"tronweb": "^4.3.0",
"web3": "^1.8.1"
},
Expand Down
7 changes: 7 additions & 0 deletions src/common/tokens/constants/native-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export const nativeTokensList: Record<BlockchainName, Token> = {
symbol: 'MATIC',
decimals: 18
}),
[BLOCKCHAIN_NAME.POLYGON_ZKEVM]: new Token({
blockchain: BLOCKCHAIN_NAME.POLYGON_ZKEVM,
address: EvmWeb3Pure.nativeTokenAddress,
name: 'ETH',
symbol: 'ETH',
decimals: 18
}),
[BLOCKCHAIN_NAME.AVALANCHE]: new Token({
blockchain: BLOCKCHAIN_NAME.AVALANCHE,
address: EvmWeb3Pure.nativeTokenAddress,
Expand Down
7 changes: 7 additions & 0 deletions src/common/tokens/constants/wrapped-native-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export const wrappedNativeTokensList: Partial<Record<EvmBlockchainName, Token>>
symbol: 'WMATIC',
decimals: 18
}),
[BLOCKCHAIN_NAME.POLYGON_ZKEVM]: new Token({
blockchain: BLOCKCHAIN_NAME.POLYGON_ZKEVM,
address: '0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9',
name: 'Wrapped Ether',
symbol: 'Weth',
decimals: 18
}),
[BLOCKCHAIN_NAME.AVALANCHE]: new Token({
blockchain: BLOCKCHAIN_NAME.AVALANCHE,
address: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
Expand Down
1 change: 1 addition & 0 deletions src/core/blockchain/models/blockchain-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const EVM_BLOCKCHAIN_NAME = {
ETHEREUM: 'ETH',
BINANCE_SMART_CHAIN: 'BSC',
POLYGON: 'POLYGON',
POLYGON_ZKEVM: 'POLYGON_ZKEVM',
AVALANCHE: 'AVALANCHE',
MOONRIVER: 'MOONRIVER',
FANTOM: 'FANTOM',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const blockchainId: Record<BlockchainName, number> = {
[BLOCKCHAIN_NAME.ETHEREUM]: 1,
[BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]: 56,
[BLOCKCHAIN_NAME.POLYGON]: 137,
[BLOCKCHAIN_NAME.POLYGON_ZKEVM]: 1101,
[BLOCKCHAIN_NAME.AVALANCHE]: 43114,
[BLOCKCHAIN_NAME.MOONRIVER]: 1285,
[BLOCKCHAIN_NAME.FANTOM]: 250,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export const MULTICALL_ADDRESSES: Record<Web3PublicSupportedBlockchain, string>
[BLOCKCHAIN_NAME.VELAS]: '0x0747CFe82D3Bee998f634569FE2B0005dF9d8EDE',
[BLOCKCHAIN_NAME.SYSCOIN]: '0x0c50a45401fA051F5F38e98d0E323f08eFa3bb0b',
[BLOCKCHAIN_NAME.ZK_SYNC]: '0xDBA7ab3Ed22044417380E9358aAabCF85683f3c8',
[BLOCKCHAIN_NAME.PULSECHAIN]: '0x5ba1e12693dc8f9c48aad8770482f4739beed696'
[BLOCKCHAIN_NAME.PULSECHAIN]: '0x5ba1e12693dc8f9c48aad8770482f4739beed696',
[BLOCKCHAIN_NAME.POLYGON_ZKEVM]: '0xca11bde05977b3631167028862be2a173976ca11'
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const proxySupportedBlockchains = [
BLOCKCHAIN_NAME.ETHEREUM,
BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN,
BLOCKCHAIN_NAME.POLYGON,
BLOCKCHAIN_NAME.POLYGON_ZKEVM,
BLOCKCHAIN_NAME.AVALANCHE,
BLOCKCHAIN_NAME.MOONRIVER,
BLOCKCHAIN_NAME.FANTOM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CbridgeCrossChainProvider } from 'src/features/cross-chain/calculation-
import { ChangenowCrossChainProvider } from 'src/features/cross-chain/calculation-manager/providers/changenow-provider/changenow-cross-chain-provider';
import { DebridgeCrossChainProvider } from 'src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider';
import { LifiCrossChainProvider } from 'src/features/cross-chain/calculation-manager/providers/lifi-provider/lifi-cross-chain-provider';
import { SquidrouterCrossChainProvider } from 'src/features/cross-chain/calculation-manager/providers/squidrouter-provider/squidrouter-cross-chain-provider';
import { SymbiosisCrossChainProvider } from 'src/features/cross-chain/calculation-manager/providers/symbiosis-provider/symbiosis-cross-chain-provider';
import { XyCrossChainProvider } from 'src/features/cross-chain/calculation-manager/providers/xy-provider/xy-cross-chain-provider';

Expand All @@ -14,7 +15,8 @@ const proxyProviders = [
StargateCrossChainProvider,
XyCrossChainProvider,
CbridgeCrossChainProvider,
LifiCrossChainProvider
LifiCrossChainProvider,
SquidrouterCrossChainProvider
] as const;

const nonProxyProviders = [
Expand All @@ -24,11 +26,4 @@ const nonProxyProviders = [
ArbitrumRbcBridgeProvider
] as const;

export const CrossChainProviders = [
...proxyProviders,
...nonProxyProviders
// MultichainCrossChainProvider,
// CelerCrossChainProvider,
// RangoCrossChainProvider,
// ViaCrossChainProvider,
] as const;
export const CrossChainProviders = [...proxyProviders, ...nonProxyProviders] as const;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
} from 'src/features/cross-chain/calculation-manager/models/cross-chain-options';
import { CrossChainTradeType } from 'src/features/cross-chain/calculation-manager/models/cross-chain-trade-type';
import { LifiBridgeTypes } from 'src/features/cross-chain/calculation-manager/providers/lifi-provider/models/lifi-bridge-types';
import { RangoBridgeTypes } from 'src/features/cross-chain/calculation-manager/providers/rango-provider/models/rango-bridge-types';
import { MarkRequired } from 'ts-essentials';

export type CrossChainManagerCalculationOptions = Omit<CrossChainOptions, 'providerAddress'> & {
Expand All @@ -14,8 +13,6 @@ export type CrossChainManagerCalculationOptions = Omit<CrossChainOptions, 'provi
readonly disabledProviders?: CrossChainTradeType[];

readonly lifiDisabledBridgeTypes?: LifiBridgeTypes[];

readonly rangoDisabledBridgeTypes?: RangoBridgeTypes[];
};

export type RequiredCrossChainManagerCalculationOptions = MarkRequired<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CrossChainTradeType } from 'src/features/cross-chain/calculation-manager/models/cross-chain-trade-type';
import { LifiBridgeTypes } from 'src/features/cross-chain/calculation-manager/providers/lifi-provider/models/lifi-bridge-types';
import { RangoBridgeTypes } from 'src/features/cross-chain/calculation-manager/providers/rango-provider/models/rango-bridge-types';
import { MarkRequired } from 'ts-essentials';

export interface CrossChainOptions {
Expand Down Expand Up @@ -53,8 +52,6 @@ export interface CrossChainOptions {
*/
timeout?: number;

rangoDisabledBridgeTypes?: RangoBridgeTypes[];

lifiDisabledBridgeTypes?: LifiBridgeTypes[];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ export const CROSS_CHAIN_TRADE_TYPE = {
SYMBIOSIS: 'symbiosis',
LIFI: 'lifi',
DEBRIDGE: 'dln',
VIA: 'via',
RANGO: 'rango',
BRIDGERS: 'bridgers',
MULTICHAIN: 'multichain',
XY: 'xy',
CELER_BRIDGE: 'celer_bridge',
CHANGENOW: 'changenow',
STARGATE: 'stargate',
ARBITRUM: 'arbitrum'
ARBITRUM: 'arbitrum',
SQUIDROUTER: 'squidrouter'
} as const;

export type CrossChainTradeType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ export class CbridgeCrossChainTrade extends EvmCrossChainTrade {
const providerData = await ProxyCrossChainEvmTrade.getGenericProviderData(
to,
data!,
this.fromBlockchain
this.fromBlockchain,
to,
'0'
);

const methodArguments = swapData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,16 @@ export const evmCommonCrossChainAbi: AbiItem[] = [
name: 'router',
type: 'address'
},
{
internalType: 'address',
name: 'approveTo',
type: 'address'
},
{
internalType: 'uint256',
name: 'extraNative',
type: 'uint256'
},
{
internalType: 'bytes',
name: 'callData',
Expand Down Expand Up @@ -967,6 +977,16 @@ export const evmCommonCrossChainAbi: AbiItem[] = [
name: 'router',
type: 'address'
},
{
internalType: 'address',
name: 'approveTo',
type: 'address'
},
{
internalType: 'uint256',
name: 'extraNative',
type: 'uint256'
},
{
internalType: 'bytes',
name: 'callData',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,17 @@ export class ProxyCrossChainEvmTrade {
public static async getGenericProviderData(
providerAddress: string,
providerData: string,
fromBlockchain: EvmBlockchainName
): Promise<[string, string]> {
fromBlockchain: EvmBlockchainName,
gatewayAddress: string,
extraNative: string
): Promise<[string, string, string, string]> {
await ProxyCrossChainEvmTrade.checkCrossChainWhiteList(
fromBlockchain,
providerAddress,
providerData.slice(0, 10)
);

return [providerAddress, providerData];
return [providerAddress, gatewayAddress, extraNative, providerData];
}

public static async checkCrossChainWhiteList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ export class LifiCrossChainProvider extends CrossChainProvider {
throw new RubicSdkError('Incorrect bridges filter param');
}

const defaultDisabled = options.lifiDisabledBridgeTypes || [];
const denyBridges = from.isNative
? options.lifiDisabledBridgeTypes
: Array.from(new Set([...defaultDisabled, LifiBridgeTypes.STARGATE]));

const denyBridges = options.lifiDisabledBridgeTypes || [];
const routeOptions: RouteOptions = {
slippage: options.slippageTolerance,
order: 'RECOMMENDED',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,15 @@ export class LifiCrossChainTrade extends EvmCrossChainTrade {
type: `lifi:${this.bridgeType}`,
fromAddress: this.walletAddress
});
const extraNativeFee = this.from.isNative
? new BigNumber(providerValue).minus(this.from.stringWeiAmount).toFixed()
: new BigNumber(providerValue).toFixed();
const providerData = await ProxyCrossChainEvmTrade.getGenericProviderData(
providerRouter,
data!,
this.fromBlockchain
this.fromBlockchain,
providerRouter,
extraNativeFee
);

const methodArguments = [bridgeData, providerData];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ export class MultichainCrossChainTrade extends EvmCrossChainTrade {
providerData = await ProxyCrossChainEvmTrade.getGenericProviderData(
providerRouter!,
data!,
this.from.blockchain
this.from.blockchain,
providerRouter!,
'0'
);
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading