Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions ops_boba/api/watcher-api/serverless-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,20 @@ functions:
cors: true
layers:
- ${file(env-mainnet.yml):LAYERS}
watcher_getLayerZeroTransactions:
handler: watcher_getLayerZeroTransactions.watcher_getLayerZeroTransactions
memorySize: 10240 # optional, in MB, default is 1024
timeout: 60 # optional, in seconds, default is 6
vpc:
securityGroupIds:
- ${file(env-mainnet.yml):SECURITY_GROUPS}
subnetIds:
- ${file(env-mainnet.yml):SUBNET_ID_1}
- ${file(env-mainnet.yml):SUBNET_ID_2}
events:
- http:
path: get.layerzero.transactions
method: post
cors: true
layers:
- ${file(env-mainnet.yml):LAYERS}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pymysql


def watcher_getLayerZeroTransaction(event, context):
def watcher_getLayerZeroTransactions(event, context):
# Parse incoming event
body = json.loads(event["body"])
address = body.get("address")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import { useTheme } from '@emotion/react'
import { WrapperActionsModal } from 'components/modal/Modal.styles'

import BN from 'bignumber.js'
import parse from 'html-react-parser'
import Select from 'components/select/Select'
import { selectAltL1DepositCost } from 'selectors/balanceSelector'
import { fetchAltL1DepositFee } from 'actions/balanceAction'
import { selectAltL1DepositCost, selectL1FeeBalance } from 'selectors/balanceSelector'
import { fetchAltL1DepositFee, fetchL1FeeBalance } from 'actions/balanceAction'

import networkService from 'services/networkService'

Expand Down Expand Up @@ -58,6 +59,7 @@ function InputStepMultiChain({ handleClose, token, isBridge, openTokenPicker })
const signatureStatus = useSelector(selectSignatureStatus_depositTRAD)
const lookupPrice = useSelector(selectLookupPrice)
const depositFees = useSelector(selectAltL1DepositCost)
const feeBalance = useSelector(selectL1FeeBalance) //amount of ETH on L1 to pay gas

const maxValue = logAmount(token.balance, token.decimals)

Expand Down Expand Up @@ -96,6 +98,7 @@ function InputStepMultiChain({ handleClose, token, isBridge, openTokenPicker })
const isMobile = useMediaQuery(theme.breakpoints.down('md'))

useEffect(() => {
dispatch(fetchL1FeeBalance()) //ETH balance for paying gas
dispatch(fetchAltL1DepositFee())
},[dispatch])

Expand Down Expand Up @@ -150,6 +153,16 @@ function InputStepMultiChain({ handleClose, token, isBridge, openTokenPicker })
}),
}

let ETHstring = ''
let warning = false

if (depositFees[altL1Bridge]) {
if(Number(depositFees[altL1Bridge].fee) > Number(feeBalance)) {
warning = true
ETHstring = `WARNING: your L1 ${networkService.L1NativeTokenSymbol} balance of ${Number(feeBalance).toFixed(4)} is not sufficient to cover this transaction.`
}
}

return (
<>
<Box>
Expand Down Expand Up @@ -204,6 +217,12 @@ function InputStepMultiChain({ handleClose, token, isBridge, openTokenPicker })
</Typography>
)}

{warning && (
<Typography variant="body2" sx={{mt: 2, color: 'red'}}>
{parse(ETHstring)}
</Typography>
)}

</Box>
<WrapperActionsModal>
<Button
Expand All @@ -222,7 +241,7 @@ function InputStepMultiChain({ handleClose, token, isBridge, openTokenPicker })
variant="contained"
loading={depositLoading}
tooltip={depositLoading ? "Your transaction is still pending. Please wait for confirmation." : "Click here to bridge your funds to alt L1"}
disabled={!validValue || !altL1Bridge}
disabled={!validValue || !altL1Bridge || warning}
triggerTime={new Date()}
fullWidth={isMobile}
>
Expand Down
13 changes: 9 additions & 4 deletions packages/boba/gateway/src/services/networkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ const L2GasOracle = '0x420000000000000000000000000000000000000F'
let supportedAltL1Chains = []

let allAddresses = {}
let l0AllProtocols = {}
// preload allAddresses
if (APP_CHAIN === 'rinkeby') {
const bobaBridges = layerZeroTestnet.BOBA_Bridges.Testnet;
const l0Protocols = layerZeroTestnet.Layer_Zero_Protocol.Testnet;
l0AllProtocols = layerZeroTestnet.Layer_Zero_Protocol;
allAddresses = {
...addresses_Rinkeby,
L1LPAddress: addresses_Rinkeby.Proxy__L1LiquidityPool,
Expand All @@ -134,14 +136,15 @@ if (APP_CHAIN === 'rinkeby') {
} else if (APP_CHAIN === 'mainnet') {
const bobaBridges = layerZeroMainnet.BOBA_Bridges.Mainnet;
const l0Protocols = layerZeroMainnet.Layer_Zero_Protocol.Mainnet;
l0AllProtocols = layerZeroMainnet.Layer_Zero_Protocol;
allAddresses = {
...addresses_Mainnet,
L1LPAddress: addresses_Mainnet.Proxy__L1LiquidityPool,
L2LPAddress: addresses_Mainnet.Proxy__L2LiquidityPool,
...bobaBridges,
...l0Protocols
}
supportedAltL1Chains = ['Moonbeam']
supportedAltL1Chains = ['Moonbeam','BNB', 'Fantom', 'Avalanche']
}
let allTokens = {}

Expand Down Expand Up @@ -4915,7 +4918,7 @@ class NetworkService {
const pResponse = supportedAltL1Chains.map(async (type) => {
let L0_ETH_ENDPOINT = allAddresses.Layer_Zero_Endpoint;
let ETH_L1_BOBA_ADDRESS = allAddresses.TK_L1BOBA;
let L0_CHAIN_ID = allAddresses.Layer_Zero_ChainId;
let L0_TARGET_CHAIN_ID = l0AllProtocols[type].Layer_Zero_ChainId;
let ALT_L1_BOBA_ADDRESS = allAddresses[`Proxy__EthBridgeTo${type}`];
let PROXY_ETH_L1_BRIDGE_ADDRESS_TO = allAddresses[`${type}_TK_BOBA`];

Expand Down Expand Up @@ -4950,8 +4953,9 @@ class NetworkService {
);

console.log(`🆙 loading 💵 FEE for ${type}`);
console.log("L0_TARGET_CHAIN_ID: ", L0_TARGET_CHAIN_ID)
const estimatedFee = await ETHLayzerZeroEndpoint.estimateFees(
L0_CHAIN_ID,
L0_TARGET_CHAIN_ID,
Proxy__EthBridge.address,
payload,
false,
Expand Down Expand Up @@ -4987,6 +4991,7 @@ class NetworkService {
}
try {
let L0_ETH_ENDPOINT = allAddresses.Layer_Zero_Endpoint;
let L0_TARGET_CHAIN_ID = l0AllProtocols[type].Layer_Zero_ChainId;
let ETH_L1_BOBA_ADDRESS = allAddresses.TK_L1BOBA;
let PROXY_ETH_L1_BRIDGE_ADDRESS_TO = allAddresses[`Proxy__EthBridgeTo${type}`];
let ALT_L1_BOBA_ADDRESS = allAddresses[`${type}_TK_BOBA`];
Expand Down Expand Up @@ -5037,7 +5042,7 @@ class NetworkService {
);

let estimatedFee = await ETHLayzerZeroEndpoint.estimateFees(
allAddresses.Layer_Zero_ChainId,
L0_TARGET_CHAIN_ID,
Proxy__EthBridge.address,
payload,
false,
Expand Down