Skip to content

Commit

Permalink
Add chain Base
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Sep 30, 2024
1 parent 3d83900 commit a30cc3a
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum class Chain(
) {
Ethereum(1, 60, 2_000_000, 15, true),
BinanceSmartChain(56, 60, 10_000_000, 15, false),
Base(8453, 60, 10_000_000, 15, true),
Polygon(137, 60, 10_000_000, 15, true),
Optimism(10, 60, 10_000_000, 15, false),
ArbitrumOne(42161, 60, 10_000_000, 15, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@ sealed class RpcSource {
return Http(listOf(URI("https://rpc.fantom.network")), null)
}

fun baseRpcHttp(): Http {
return Http(listOf(URI("https://mainnet.base.org")), null)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class TransactionSource(val name: String, val type: SourceType) {
)
}

fun basescan(apiKey: String): TransactionSource {
return TransactionSource(
"basescan.org",
SourceType.Etherscan("https://api.basescan.org", "https://basescan.org", apiKey)
)
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import io.horizontalsystems.oneinchkit.contracts.OneInchContractMethodFactories
import io.horizontalsystems.oneinchkit.decorations.OneInchMethodDecorator
import io.horizontalsystems.oneinchkit.decorations.OneInchTransactionDecorator
import java.math.BigInteger
import java.util.*
import java.util.Objects

class OneInchKit(
private val service: OneInchService
Expand Down Expand Up @@ -105,7 +105,9 @@ class OneInchKit(
Chain.ArbitrumOne,
Chain.Gnosis,
Chain.Fantom,
Chain.Avalanche -> Address("0x1111111254eeb25477b68fb85ed929f73a960582")
Chain.Avalanche,
Chain.Base,
-> Address("0x1111111254EEB25477B68fb85Ed929f73A960582")

else -> throw IllegalArgumentException("Invalid Chain: ${chain.id}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TokenFactory {
Chain.Avalanche -> "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"
Chain.EthereumGoerli -> "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"
Chain.ArbitrumOne -> "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
Chain.Base -> "0x4200000000000000000000000000000000000006"
else -> throw UnsupportedChainError.NoWethAddress
}
return Address(wethAddressHex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ import io.horizontalsystems.ethereumkit.models.Address
import io.horizontalsystems.ethereumkit.models.Chain
import io.horizontalsystems.ethereumkit.models.RpcSource
import io.horizontalsystems.ethereumkit.models.TransactionData
import io.horizontalsystems.uniswapkit.contract.*
import io.horizontalsystems.uniswapkit.contract.GetReservesMethod
import io.horizontalsystems.uniswapkit.contract.SwapETHForExactTokensMethod
import io.horizontalsystems.uniswapkit.contract.SwapExactETHForTokensMethod
import io.horizontalsystems.uniswapkit.contract.SwapExactTokensForETHMethod
import io.horizontalsystems.uniswapkit.contract.SwapExactTokensForTokensMethod
import io.horizontalsystems.uniswapkit.contract.SwapTokensForExactETHMethod
import io.horizontalsystems.uniswapkit.contract.SwapTokensForExactTokensMethod
import io.horizontalsystems.uniswapkit.models.*
import io.horizontalsystems.uniswapkit.models.Token.Erc20
import io.horizontalsystems.uniswapkit.models.Token.Ether
import io.reactivex.Single
import java.math.BigInteger
import java.util.*
import java.util.Date
import java.util.logging.Logger

class TradeManager {
Expand Down Expand Up @@ -125,6 +131,7 @@ class TradeManager {
Chain.BinanceSmartChain -> Address("0x10ED43C718714eb63d5aA57B78B54704E256024E")
Chain.Polygon -> Address("0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff")
Chain.Avalanche -> Address("0x60aE616a2155Ee3d9A68541Ba4544862310933d4")
Chain.Base -> Address("0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24")
else -> throw UnsupportedChainError.NoRouterAddress
}

Expand All @@ -134,12 +141,19 @@ class TradeManager {
Chain.BinanceSmartChain -> "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"
Chain.Polygon -> "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32"
Chain.Avalanche -> "0x9Ad6C38BE94206cA50bb0d90783181662f0Cfa10"
Chain.Base -> "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6"
else -> throw UnsupportedChainError.NoFactoryAddress
}

private fun getInitCodeHashString(chain: Chain) =
when (chain) {
Chain.Ethereum, Chain.EthereumGoerli, Chain.Polygon, Chain.Avalanche -> "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f"
Chain.Ethereum,
Chain.EthereumGoerli,
Chain.Polygon,
Chain.Avalanche,
Chain.Base,
-> "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f"

Chain.BinanceSmartChain -> "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5"
else -> throw UnsupportedChainError.NoInitCodeHash
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PoolManager(
Chain.ArbitrumOne,
Chain.EthereumGoerli -> "0x1F98431c8aD98523631AE4a59f267346ea31F984"
Chain.BinanceSmartChain -> "0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7"
Chain.Base -> "0x33128a8fC17869897dcE68Ed026d694621f6FDfD"
else -> throw IllegalStateException("Not supported Uniswap chain ${chain}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class QuoterV2(
Chain.EthereumGoerli -> "0x61fFE014bA17989E743c5F6cB21bF9697530B21e"

Chain.BinanceSmartChain -> "0x78D78E420Da98ad378D7799bE8f4AF69033EB077"
Chain.Base -> "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a"
else -> throw IllegalStateException("Not supported Uniswap chain $chain")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ class SwapRouter(private val dexType: DexType) {
Chain.EthereumGoerli -> Address("0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45")

Chain.BinanceSmartChain -> Address("0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2")
Chain.Base -> Address("0x2626664c2603336E57B271c5C0b26F421741e481")
else -> throw IllegalStateException("Not supported Uniswap chain ${chain}")
}

private fun getPancakeSwapRouterAddress(chain: Chain) = when (chain) {
Chain.BinanceSmartChain,
Chain.Ethereum -> Address("0x13f4EA83D0bd40E75C8222255bc855a974568Dd4")
Chain.Base -> Address("0x678Aa4bF4E210cf2166753e054d5b7c31cc7fa86")

else -> throw IllegalStateException("Not supported PancakeSwap chain ${chain}")
}
Expand Down

0 comments on commit a30cc3a

Please sign in to comment.