Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CHAIN_NAMESPACE, fromAssetId } from '@shapeshiftoss/caip'
import { CHAIN_NAMESPACE, fromAssetId, monadChainId } from '@shapeshiftoss/caip'
import { evm } from '@shapeshiftoss/chain-adapters'
import {
bn,
Expand Down Expand Up @@ -125,10 +125,32 @@ export const getTradeRate = async (
const getFeeData = async (): Promise<string | undefined> => {
switch (chainNamespace) {
case CHAIN_NAMESPACE.Evm: {
try {
const contractAddress = contractAddressOrUndefined(sellAsset.assetId)
const data = evm.getErc20Data(depositAddress, sellAmount, contractAddress)
const sellAdapter = deps.assertGetEvmChainAdapter(sellAsset.chainId)
const contractAddress = contractAddressOrUndefined(sellAsset.assetId)
const data = evm.getErc20Data(depositAddress, sellAmount, contractAddress)

// For Monad, skip Tenderly and use adapter's getFeeData directly
if (sellAsset.chainId === monadChainId) {
try {
const feeData = await sellAdapter.getFeeData({
to: contractAddress ?? depositAddress,
value: isNativeEvmAsset(sellAsset.assetId) ? sellAmount : '0',
chainSpecific: {
from: sendAddress || depositAddress,
contractAddress,
data: data || '0x',
},
sendMax: false,
})
return feeData.fast.txFee
} catch (error) {
console.error('Failed to estimate fees for Monad Near Intents:', error)
return '0'
}
}

// For other EVM chains, use Tenderly simulation
try {
const simulationResult = await simulateWithStateOverrides(
{
chainId: sellAsset.chainId,
Expand All @@ -150,11 +172,8 @@ export const getTradeRate = async (
}

// Calculate network fee using the simulated gas limit
const sellAdapter = deps.assertGetEvmChainAdapter(sellAsset.chainId)
const { average } = await sellAdapter.getGasFeeData()

const supportsEIP1559 = 'maxFeePerGas' in average

const networkFeeCryptoBaseUnit = evm.calcNetworkFeeCryptoBaseUnit({
...average,
supportsEIP1559,
Expand Down
2 changes: 2 additions & 0 deletions packages/swapper/src/swappers/NearIntentsSwapper/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const nearIntentsSupportedChainIds = [
KnownChainIds.SolanaMainnet,
KnownChainIds.TronMainnet,
KnownChainIds.SuiMainnet,
KnownChainIds.MonadMainnet,
] as const

export type NearIntentsSupportedChainId = (typeof nearIntentsSupportedChainIds)[number]
Expand All @@ -40,4 +41,5 @@ export const chainIdToNearIntentsChain: Record<NearIntentsSupportedChainId, stri
[KnownChainIds.SolanaMainnet]: 'sol',
[KnownChainIds.TronMainnet]: 'tron',
[KnownChainIds.SuiMainnet]: 'sui',
[KnownChainIds.MonadMainnet]: 'monad',
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const getNearIntentsAsset = ({
return `nep141:${nearNetwork}-${contractAddress.toLowerCase()}.omft.near`
}

const NEP245_CHAINS = ['bsc', 'pol', 'avax', 'op', 'tron'] as const
const NEP245_CHAINS = ['bsc', 'pol', 'avax', 'op', 'tron', 'monad'] as const
Comment thread
NeOMakinG marked this conversation as resolved.
const TOKEN_LOOKUP_CHAINS = ['sui'] as const

export const assetToNearIntentsAsset = async (asset: Asset): Promise<string | null> => {
Expand Down