Skip to content

Commit

Permalink
add bahamut network (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
IDIDOS authored Jul 5, 2024
2 parents 1ca1276 + 564597a commit e1cc385
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubic-sdk",
"version": "5.29.2",
"version": "5.30.0",
"description": "Simplify dApp creation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
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 @@ -474,5 +474,12 @@ export const nativeTokensList: Record<BlockchainName, Token> = {
name: 'CORE',
symbol: 'CORE',
decimals: 18
}),
[BLOCKCHAIN_NAME.BAHAMUT]: new Token({
blockchain: BLOCKCHAIN_NAME.BAHAMUT,
address: EvmWeb3Pure.nativeTokenAddress,
name: 'FTN',
symbol: 'FTN',
decimals: 18
})
};
1 change: 1 addition & 0 deletions src/common/tokens/constants/wrapped-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const wrappedAddress: Partial<Record<EvmBlockchainName, string>> = {
[BLOCKCHAIN_NAME.TAIKO]: '0xa51894664a773981c6c112c43ce576f315d5b1b6',
[BLOCKCHAIN_NAME.SEI]: '0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7',
[BLOCKCHAIN_NAME.CORE]: '0x191e94fa59739e188dce837f7f6978d84727ad01',
[BLOCKCHAIN_NAME.BAHAMUT]: '0x4084ab20f8ffca76c19aaf854fb5fe9de6217fbb',
// Testnet
[BLOCKCHAIN_NAME.GOERLI]: '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6',
[BLOCKCHAIN_NAME.SCROLL_SEPOLIA]: '0x5300000000000000000000000000000000000004',
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 @@ -457,5 +457,12 @@ export const wrappedNativeTokensList: Partial<Record<EvmBlockchainName, Token>>
name: 'Wrapped CORE',
symbol: 'WCORE',
decimals: 18
}),
[BLOCKCHAIN_NAME.BAHAMUT]: new Token({
blockchain: BLOCKCHAIN_NAME.BAHAMUT,
address: '0x4084ab20f8ffca76c19aaf854fb5fe9de6217fbb',
name: 'Wrapped FTN',
symbol: 'WFTN',
decimals: 18
})
};
3 changes: 2 additions & 1 deletion src/core/blockchain/models/backend-blockchains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const BLOCKCHAINS_MAPPING = {
[BLOCKCHAIN_NAME.XLAYER]: 'xlayer',
[BLOCKCHAIN_NAME.TAIKO]: 'taiko',
[BLOCKCHAIN_NAME.SEI]: 'sei',
[BLOCKCHAIN_NAME.CORE]: 'core'
[BLOCKCHAIN_NAME.CORE]: 'core',
[BLOCKCHAIN_NAME.BAHAMUT]: 'bahamut'
} as const;

export const TO_BACKEND_BLOCKCHAINS: Record<BlockchainName, BackendBlockchain> = {
Expand Down
3 changes: 2 additions & 1 deletion src/core/blockchain/models/blockchain-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const EVM_BLOCKCHAIN_NAME = {
XLAYER: 'XLAYER',
TAIKO: 'TAIKO',
SEI: 'SEI',
CORE: 'CORE'
CORE: 'CORE',
BAHAMUT: 'BAHAMUT'
} as const;

export const BLOCKCHAIN_NAME = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const blockchainId: Record<BlockchainName, number> = {
[BLOCKCHAIN_NAME.TAIKO]: 167000,
[BLOCKCHAIN_NAME.SEI]: 1329,
[BLOCKCHAIN_NAME.CORE]: 1116,
[BLOCKCHAIN_NAME.BAHAMUT]: 5165,
// Tesnents
[BLOCKCHAIN_NAME.GOERLI]: 5,
[BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN_TESTNET]: 87,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ export const MULTICALL_ADDRESSES: Record<Web3PublicSupportedBlockchain, string>
[BLOCKCHAIN_NAME.XLAYER]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[BLOCKCHAIN_NAME.TAIKO]: '0x74F689bb9f86BD24d370BE2a2B9C74446ce08843',
[BLOCKCHAIN_NAME.SEI]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[BLOCKCHAIN_NAME.CORE]: '0xcA11bde05977b3631167028862bE2a173976CA11'
[BLOCKCHAIN_NAME.CORE]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[BLOCKCHAIN_NAME.BAHAMUT]: '0xa385B1436fD2A6a1c6865E22c522A1aA40CaDCC6'
};
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 @@ -33,7 +33,8 @@ export const proxySupportedBlockchains = [
BLOCKCHAIN_NAME.XLAYER,
BLOCKCHAIN_NAME.TAIKO,
BLOCKCHAIN_NAME.SEI,
BLOCKCHAIN_NAME.CORE
BLOCKCHAIN_NAME.CORE,
BLOCKCHAIN_NAME.BAHAMUT
// 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 @@ -18,7 +18,8 @@ const ALTERNATIVE_ROUTER1_NETWORKS = [
BLOCKCHAIN_NAME.XLAYER,
BLOCKCHAIN_NAME.TAIKO,
BLOCKCHAIN_NAME.SEI,
BLOCKCHAIN_NAME.CORE
BLOCKCHAIN_NAME.CORE,
BLOCKCHAIN_NAME.BAHAMUT
] as const;

function isAlternativeRouter1Network(blockchain: BlockchainName): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const symbiosisCrossChainSupportedBlockchains = [
BLOCKCHAIN_NAME.SEI,
BLOCKCHAIN_NAME.TAIKO,
BLOCKCHAIN_NAME.CORE,
BLOCKCHAIN_NAME.BAHAMUT,
// Testnets
BLOCKCHAIN_NAME.GOERLI,
BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN_TESTNET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Injector } from 'src/core/injector/injector';
import { ContractParams } from 'src/features/common/models/contract-params';
import { SwapTransactionOptions } from 'src/features/common/models/swap-transaction-options';
import { SymbiosisApiService } from 'src/features/common/providers/symbiosis/services/symbiosis-api-service';
import { checkUnsupportedReceiverAddress } from 'src/features/common/utils/check-unsupported-receiver-address';
import { CROSS_CHAIN_TRADE_TYPE } from 'src/features/cross-chain/calculation-manager/models/cross-chain-trade-type';
import { rubicProxyContractAddress } from 'src/features/cross-chain/calculation-manager/providers/common/constants/rubic-proxy-contract-address';
import { evmCommonCrossChainAbi } from 'src/features/cross-chain/calculation-manager/providers/common/emv-cross-chain-trade/constants/evm-common-cross-chain-abi';
Expand Down Expand Up @@ -325,6 +326,9 @@ export class SymbiosisCrossChainTrade extends EvmCrossChainTrade {
receiverAddress?: string
): Promise<{ config: EvmEncodeConfig; amount: string }> {
const walletAddress = this.walletAddress;
if (this.from.blockchain === 'BAHAMUT' || this.to.blockchain === 'BAHAMUT') {
await checkUnsupportedReceiverAddress(receiverAddress, this.walletAddress);
}
const params: SymbiosisSwappingParams = {
...this.swappingParams,
from: walletAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class CrossChainStatusManager {
const client = lzPackage.createClient('mainnet');
const scanResponse = await client.getMessagesBySrcTxHash(data.srcTxHash);
const targetTrade = scanResponse.messages.find(
item => item.srcTxHash.toLocaleLowerCase() === data.srcTxHash.toLocaleLowerCase()
item => item.srcTxHash?.toLocaleLowerCase() === data.srcTxHash.toLocaleLowerCase()
);
const txStatusData: TxStatusData = {
status: TX_STATUS.PENDING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { WagyuSwapProvider } from 'src/features/on-chain/calculation-manager/pro
import { EddyFinanceProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/zetachain/eddy-finance/eddy-finance-provider';
import { MuteSwapProvider } from 'src/features/on-chain/calculation-manager/providers/dexes/zksync/mute-swap/mute-swap-provider';

import { UniswapV2BahamutProvider } from '../../providers/dexes/bahamut/uniswap-v2-bahamut/uniswap-v2-bahamut-provider';
import { SushiSwapZetachainProvider } from '../../providers/dexes/zetachain/sushi-swap-zetachain/sushi-swap-zetachain-provider';

export const UniswapV2TradeProviders = [
Expand Down Expand Up @@ -154,5 +155,7 @@ export const UniswapV2TradeProviders = [
// Mode
EddyFinanceModeProvider,
// Sei
DragonSwapProvider
DragonSwapProvider,
//Bahamut
UniswapV2BahamutProvider
] as const;
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const ON_CHAIN_TRADE_TYPE = {
UBE_SWAP: 'UBE_SWAP',
UNISWAP_V2: 'UNISWAP_V2',
UNI_SWAP_V3: 'UNI_SWAP_V3',
UNISWAP_BAHAMUT: 'UNISWAP_BAHAMUT',

VERSE: 'VERSE',
VIPER_SWAP: 'VIPER_SWAP',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { wrappedNativeTokensList } from 'src/common/tokens/constants/wrapped-native-tokens';
import { BLOCKCHAIN_NAME } from 'src/core/blockchain/models/blockchain-name';

import { UniswapV2ProviderConfiguration } from '../common/uniswap-v2-abstract/models/uniswap-v2-provider-configuration';

export const defaultBahamutRoutingProvidersAddresses = [
wrappedNativeTokensList[BLOCKCHAIN_NAME.BAHAMUT]!.address, //WFTN
'0xDeF886C55a79830C47108eeb9c37e78a49684e41', //USDT
'0x4237e0a5b55233d5b6d6d1d9bf421723954130d8', //USDC
'0xE5b3562A0fa9eC3e718C96FfE349e1280D2Be591' //WETH
];

const defaultBahamutWethAddress = wrappedNativeTokensList[BLOCKCHAIN_NAME.BAHAMUT]!.address;

export const defaultBahamutProviderConfiguration: UniswapV2ProviderConfiguration = {
maxTransitTokens: 1,
routingProvidersAddresses: defaultBahamutRoutingProvidersAddresses,
wethAddress: defaultBahamutWethAddress
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defaultBahamutProviderConfiguration } from '../default-constants';

export const UNISWAP_V2_BAHAMUT_CONTRACT_ADDRESS = '0xF660558a4757Fb5953d269FF32E228Ae3d5f6c68';

export const UNISWAP_V2_BAHAMUT_PROVIDER_CONFIGURATION = defaultBahamutProviderConfiguration;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { BLOCKCHAIN_NAME } from 'src/core/blockchain/models/blockchain-name';

import { evmProviderDefaultOptions } from '../../common/on-chain-provider/evm-on-chain-provider/constants/evm-provider-default-options';
import { UniswapV2CalculationOptions } from '../../common/uniswap-v2-abstract/models/uniswap-v2-calculation-options';
import { UniswapV2AbstractProvider } from '../../common/uniswap-v2-abstract/uniswap-v2-abstract-provider';
import { UNISWAP_V2_BAHAMUT_PROVIDER_CONFIGURATION } from './constants';
import { UniswapV2BahamutTrade } from './uniswap-v2-bahamut-trade';

export class UniswapV2BahamutProvider extends UniswapV2AbstractProvider<UniswapV2BahamutTrade> {
public readonly blockchain = BLOCKCHAIN_NAME.BAHAMUT;

protected readonly defaultOptions: UniswapV2CalculationOptions = {
...evmProviderDefaultOptions,
deadlineMinutes: 60,
disableMultihops: false
};

public readonly UniswapV2TradeClass = UniswapV2BahamutTrade;

public readonly providerSettings = UNISWAP_V2_BAHAMUT_PROVIDER_CONFIGURATION;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { EvmEncodeConfig } from 'src/core/blockchain/web3-pure/typed-web3-pure/evm-web3-pure/models/evm-encode-config';
import { EncodeTransactionOptions } from 'src/features/common/models/encode-transaction-options';
import { checkUnsupportedReceiverAddress } from 'src/features/common/utils/check-unsupported-receiver-address';

import { ON_CHAIN_TRADE_TYPE, OnChainTradeType } from '../../../common/models/on-chain-trade-type';
import { UniswapV2AbstractTrade } from '../../common/uniswap-v2-abstract/uniswap-v2-abstract-trade';
import { UNISWAP_V2_BAHAMUT_CONTRACT_ADDRESS } from './constants';

export class UniswapV2BahamutTrade extends UniswapV2AbstractTrade {
public static get type(): OnChainTradeType {
return ON_CHAIN_TRADE_TYPE.UNISWAP_BAHAMUT;
}

public readonly dexContractAddress = UNISWAP_V2_BAHAMUT_CONTRACT_ADDRESS;

public async encode(options: EncodeTransactionOptions): Promise<EvmEncodeConfig> {
await checkUnsupportedReceiverAddress(options.receiverAddress, this.walletAddress);
await this.checkFromAddress(options.fromAddress, true);
await this.checkReceiverAddress(options.receiverAddress);

if (this.useProxy) {
return this.encodeProxy(options);
}
return this.encodeDirect(options);
}
}

0 comments on commit e1cc385

Please sign in to comment.