Skip to content

Commit

Permalink
Merge branch 'swap-endpoint' into add-stablecoins-for-a2a-bridging
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki committed Jan 15, 2025
2 parents b33f45b + e3acd1c commit a21fed6
Show file tree
Hide file tree
Showing 22 changed files with 558 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# These owners will be the default owners for everything in
# the repo unless a later match takes precedence.
* @mrice32 @nicholaspai @dohaki @james-a-morris
* @mrice32 @nicholaspai @dohaki @james-a-morris @gsteenkamp89

# Serverless api
/api/ @mrice32 @nicholaspai @dohaki @james-a-morris @pxrl
Expand Down
6 changes: 6 additions & 0 deletions api/_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ const defaultRelayerFeeCapitalCostConfig: {
cutoff: ethers.utils.parseUnits("10000").toString(),
decimals: 18,
},
GRASS: {
lowerBound: ethers.utils.parseUnits("0.0001").toString(),
upperBound: ethers.utils.parseUnits("0.0005").toString(),
cutoff: ethers.utils.parseUnits("10000").toString(),
decimals: 18,
},
};

defaultRelayerFeeCapitalCostConfig["USDC.e"] = {
Expand Down
13 changes: 8 additions & 5 deletions api/_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,14 @@ export function handleErrorCondition(
const { type, path } = error;
// Sanitize the error message that will be sent to client
const message = `Invalid parameter at path '${path}'. Expected type '${type}'`;
acrossApiError = new InputError({
message,
code: AcrossErrorCode.INVALID_PARAM,
param: path.join("."),
});
acrossApiError = new InputError(
{
message,
code: AcrossErrorCode.INVALID_PARAM,
param: path.join("."),
},
{ cause: error }
);
}
// Handle axios errors
else if (error instanceof AxiosError) {
Expand Down
29 changes: 8 additions & 21 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ type RpcProviderName = keyof typeof rpcProvidersJson.providers.urls;

const {
REACT_APP_HUBPOOL_CHAINID,
REACT_APP_PUBLIC_INFURA_ID,
REACT_APP_COINGECKO_PRO_API_KEY,
BASE_FEE_MARKUP,
PRIORITY_FEE_MARKUP,
Expand Down Expand Up @@ -175,9 +174,9 @@ export const getLogger = (): LoggingUtility => {
const defaultLogLevel = VERCEL_ENV === "production" ? "ERROR" : "DEBUG";

let logLevel =
LOG_LEVEL && !Object.keys(LogLevels).includes(LOG_LEVEL)
? defaultLogLevel
: (LOG_LEVEL as keyof typeof LogLevels);
LOG_LEVEL && Object.keys(LogLevels).includes(LOG_LEVEL)
? (LOG_LEVEL as keyof typeof LogLevels)
: defaultLogLevel;

logger = {
debug: (...args) => {
Expand Down Expand Up @@ -558,19 +557,6 @@ export const getHubPool = (provider: providers.Provider) => {
return HubPool__factory.connect(ENABLED_ROUTES.hubPoolAddress, provider);
};

/**
* Resolves an Infura provider given the name of the ETH network
* @param nameOrChainId The name of an ethereum network
* @returns A valid Ethers RPC provider
*/
export const infuraProvider = (nameOrChainId: providers.Networkish) => {
const url = new ethers.providers.InfuraProvider(
nameOrChainId,
REACT_APP_PUBLIC_INFURA_ID
).connection.url;
return new ethers.providers.StaticJsonRpcProvider(url);
};

/**
* Resolves a fixed Static RPC provider if an override url has been specified.
* @returns A provider or undefined if an override was not specified.
Expand Down Expand Up @@ -1100,7 +1086,7 @@ export const getProvider = (
} else if (override) {
providerCache[cacheKey] = override;
} else {
providerCache[cacheKey] = infuraProvider(_chainId);
throw new Error(`No provider URL set for chain: ${chainId}`);
}
}
return providerCache[cacheKey];
Expand All @@ -1119,9 +1105,10 @@ function getProviderFromConfigJson(
const urls = getRpcUrlsFromConfigJson(chainId);

if (urls.length === 0) {
console.warn(
`No provider URL found for chainId ${chainId} in rpc-providers.json`
);
getLogger().warn({
at: "getProviderFromConfigJson",
message: `No provider URL found for chainId ${chainId} in rpc-providers.json`,
});
return undefined;
}

Expand Down
7 changes: 4 additions & 3 deletions api/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VercelResponse } from "@vercel/node";
import { BigNumber, ethers } from "ethers";
import { CHAIN_IDs, DEFAULT_SIMULATED_RECIPIENT_ADDRESS } from "./_constants";
import { TokenInfo, TypedVercelRequest } from "./_types";
import { object, assert, Infer, optional, string } from "superstruct";
import { assert, Infer, optional, string, type } from "superstruct";

import {
ENABLED_ROUTES,
Expand Down Expand Up @@ -38,7 +38,7 @@ import {
} from "./_utils";
import { MissingParamError } from "./_errors";

const LimitsQueryParamsSchema = object({
const LimitsQueryParamsSchema = type({
token: optional(validAddress()),
inputToken: optional(validAddress()),
outputToken: optional(validAddress()),
Expand Down Expand Up @@ -174,7 +174,8 @@ const handler = async (
] = await Promise.all([
getCachedTokenPrice(
l1Token.address,
sdk.utils.getNativeTokenSymbol(destinationChainId).toLowerCase()
sdk.constants.CUSTOM_GAS_TOKENS[destinationChainId]?.toLowerCase() ??
sdk.utils.getNativeTokenSymbol(destinationChainId).toLowerCase()
),
getCachedTokenPrice(l1Token.address, "usd"),
getCachedLatestBlock(HUB_POOL_CHAIN_ID),
Expand Down
1 change: 1 addition & 0 deletions scripts/chain-configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { default as BASE_SEPOLIA } from "./base-sepolia";
export { default as BLAST } from "./blast";
export { default as BLAST_SEPOLIA } from "./blast-sepolia";
export { default as INK } from "./ink";
export { default as LENS_SEPOLIA } from "./lens-sepolia";
export { default as LINEA } from "./linea";
export { default as LISK } from "./lisk";
export { default as LISK_SEPOLIA } from "./lisk-sepolia";
Expand Down
13 changes: 13 additions & 0 deletions scripts/chain-configs/lens-sepolia/assets/grayscale-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions scripts/chain-configs/lens-sepolia/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions scripts/chain-configs/lens-sepolia/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { CHAIN_IDs, PUBLIC_NETWORKS } from "@across-protocol/constants";
import { utils as sdkUtils } from "@across-protocol/sdk";
import { ChainConfig } from "../types";

const { getDeployedAddress, getDeployedBlockNumber } = sdkUtils;

const chainId = CHAIN_IDs.LENS_SEPOLIA;
const chainInfoBase = PUBLIC_NETWORKS[chainId];

export default {
...chainInfoBase,
logoPath: "./assets/logo.svg",
grayscaleLogoPath: "./assets/grayscale-logo.svg",
spokePool: {
address: getDeployedAddress("SpokePool", chainId),
blockNumber: getDeployedBlockNumber("SpokePool", chainId),
},
chainId,
publicRpcUrl: "https://rpc.testnet.lens.dev",
blockTimeSeconds: 1,
tokens: ["GRASS", "WETH", "WGRASS"],
enableCCTP: false,
} as ChainConfig;
2 changes: 1 addition & 1 deletion scripts/chain-configs/sepolia/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
},
chainId,
publicRpcUrl: "https://gateway.tenderly.co/public/sepolia",
tokens: ["WETH", "ETH", "USDC"],
tokens: ["WETH", "ETH", "USDC", "GRASS"],
enableCCTP: false,
swapTokens: [],
} as ChainConfig;
13 changes: 13 additions & 0 deletions scripts/generate-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const enabledSepoliaChainConfigs = [
chainConfigs.POLYGON_AMOY,
chainConfigs.BLAST_SEPOLIA,
chainConfigs.LISK_SEPOLIA,
chainConfigs.LENS_SEPOLIA,
];

const enabledRoutes = {
Expand Down Expand Up @@ -322,6 +323,18 @@ function transformChainConfigs(
];
}

if (
tokenSymbol === "WGRASS" &&
toChainConfig.tokens.includes("GRASS")
) {
return [
{
inputTokenSymbol: "WGRASS",
outputTokenSymbol: "GRASS",
},
];
}

// Handle WETH Polygon & other non-eth chains
if (
tokenSymbol === "WETH" &&
Expand Down
14 changes: 14 additions & 0 deletions src/assets/chain-logos/lens-sepolia-grayscale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/assets/chain-logos/lens-sepolia.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/constants/chains/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ import inkGrayscaleLogo from "assets/chain-logos/ink-grayscale.svg";
import { ReactComponent as inkLogoSvg } from "assets/chain-logos/ink.svg";
import { ReactComponent as inkGrayscaleLogoSvg } from "assets/chain-logos/ink-grayscale.svg";

import lensSepoliaLogo from "assets/chain-logos/lens-sepolia.svg";
import lensSepoliaGrayscaleLogo from "assets/chain-logos/lens-sepolia-grayscale.svg";
import { ReactComponent as lensSepoliaLogoSvg } from "assets/chain-logos/lens-sepolia.svg";
import { ReactComponent as lensSepoliaGrayscaleLogoSvg } from "assets/chain-logos/lens-sepolia-grayscale.svg";

import lineaLogo from "assets/chain-logos/linea.svg";
import lineaGrayscaleLogo from "assets/chain-logos/linea-grayscale.svg";
import { ReactComponent as lineaLogoSvg } from "assets/chain-logos/linea.svg";
Expand Down Expand Up @@ -259,6 +264,23 @@ export const ink = {
pollingInterval: 1000,
};

export const lensSepolia = {
name: "Lens Sepolia",
fullName: "Lens sepolia",
chainId: 37111,
logoURI: lensSepoliaLogo,
grayscaleLogoURI: lensSepoliaGrayscaleLogo,
logoSvg: lensSepoliaLogoSvg,
grayscaleLogoSvg: lensSepoliaGrayscaleLogoSvg,
rpcUrl: "https://rpc.testnet.lens.dev",
explorerUrl: "https://block-explorer.testnet.lens.dev",
constructExplorerLink: (txHash: string) =>
`${lensSepolia.explorerUrl}/tx/${txHash}`,
nativeCurrencySymbol: "GRASS",
customRpcUrl: process.env.REACT_APP_CHAIN_37111_PROVIDER_URL,
pollingInterval: 1000,
};

export const linea = {
name: "Linea",
fullName: "Linea",
Expand Down Expand Up @@ -554,6 +576,7 @@ export const chainConfigs = [
blast,
blastSepolia,
ink,
lensSepolia,
linea,
lisk,
liskSepolia,
Expand Down
1 change: 1 addition & 0 deletions src/constants/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const orderedEnabledChainIds = [
CHAIN_IDs.POLYGON_AMOY,
CHAIN_IDs.BLAST_SEPOLIA,
CHAIN_IDs.LISK_SEPOLIA,
CHAIN_IDs.LENS_SEPOLIA,
];

export const chainInfoList: ChainInfoList = orderedEnabledChainIds.map(
Expand Down
4 changes: 4 additions & 0 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import snxLogo from "assets/token-logos/snx.svg";
import pooltogetherLogo from "assets/token-logos/pool.svg";
import lskLogo from "assets/token-logos/lsk.svg";
import usdbLogo from "assets/token-logos/usdb.svg";
// TODO: Replace with actual GRASS logo once known
import grassLogo from "assets/icons/question-circle.svg";

import { BRIDGED_USDC_SYMBOLS } from "../utils/sdk";

Expand Down Expand Up @@ -83,4 +85,6 @@ export const orderedTokenLogos = {
OP: optimismLogo,
ARB: arbitrumLogo,
LSK: lskLogo,
GRASS: grassLogo,
WGRASS: grassLogo,
};
Loading

0 comments on commit a21fed6

Please sign in to comment.