Skip to content

Commit

Permalink
Merge branch 'master' into deprecate-legacy-fee-values
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki authored Jan 22, 2025
2 parents c27c814 + 0985627 commit 4972755
Show file tree
Hide file tree
Showing 87 changed files with 6,413 additions and 2,358 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# testing
/coverage
gas-price-comparison.csv

# production
/build
Expand Down
14 changes: 14 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# This is a comment.
# Each line is a file pattern followed by one or more owners.
# Note: CODEOWNERS are automatically requested for review on relevant PRs.
# Order is important; the last matching pattern takes the most
# precedence.

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

# Serverless api
/api/ @mrice32 @nicholaspai @dohaki @james-a-morris @pxrl

19 changes: 11 additions & 8 deletions api-docs-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ paths:
description: >
Calldata passed to the `recipient` if `recipient` is a contract
address. This calldata is passed to the recipient via the
recipient's handleAcrossMessage() public function. The length of
this value is constrained by the API to ~4096 chars minus the length
of the full URL.
recipient's handleAcrossMessage() public function.
_Example:_ 0xABC123
schema:
Expand Down Expand Up @@ -169,13 +166,15 @@ paths:
"quoteBlock": "19237525",
"spokePoolAddress": "0xe35e9842fceaCA96570B734083f4a58e8F7C5f2A",
"expectedFillTimeSec": "4",
"limits": {
"fillDeadline": "1737033609",
"limits":
{
"minDeposit": "7799819",
"maxDeposit": "22287428516241",
"maxDepositInstant": "201958902363",
"maxDepositShortDelay": "2045367713809",
"recommendedDepositInstant": "201958902363"
}
"recommendedDepositInstant": "201958902363",
},
}
"400":
description: Invalid input
Expand Down Expand Up @@ -530,8 +529,12 @@ components:
description: >
The expected time (in seconds) for a fill to be made. Represents 75th percentile of the 7-day rolling average of times (updated daily). Times are dynamic by origin/destination token/chain for a given amount.
example: "4"
fillDeadline:
type: string
description: >
The recommended deadline (UNIX timestamp in seconds) for the relayer to fill the deposit. After this destination chain timestamp, the fill will revert on the destination chain.
limits:
$ref: '#/components/schemas/TransferLimits'
$ref: "#/components/schemas/TransferLimits"
TransferLimits:
type: object
properties:
Expand Down
5 changes: 4 additions & 1 deletion api/_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export function buildCacheKey(
}

export function buildInternalCacheKey(...args: (string | number)[]): string {
return buildCacheKey("QUOTES_API", ...args);
return buildCacheKey(
`${process.env.CACHE_PREFIX ? process.env.CACHE_PREFIX + "-" : ""}QUOTES_API`,
...args
);
}

export async function getCachedValue<T>(
Expand Down
8 changes: 8 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 Expand Up @@ -202,3 +208,5 @@ export const DOMAIN_CALLDATA_DELIMITER = "0x1dc0de";
export const DEFAULT_LITE_CHAIN_USD_MAX_BALANCE = "250000";

export const DEFAULT_LITE_CHAIN_USD_MAX_DEPOSIT = "25000";

export const DEFAULT_FILL_DEADLINE_BUFFER_SECONDS = 2.5 * 60 * 60; // 2.5 hours
14 changes: 9 additions & 5 deletions api/_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,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 Expand Up @@ -267,6 +270,7 @@ export function handleErrorCondition(
at: endpoint,
code: acrossApiError.code,
message: `Status ${acrossApiError.status} - ${acrossApiError.message}`,
cause: acrossApiError.cause,
});

return response.status(acrossApiError.status).json(acrossApiError);
Expand Down
19 changes: 19 additions & 0 deletions api/_fill-deadline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { DEFAULT_FILL_DEADLINE_BUFFER_SECONDS } from "./_constants";
import { getSpokePool } from "./_utils";

function getFillDeadlineBuffer(chainId: number) {
const bufferFromEnv = (
JSON.parse(process.env.FILL_DEADLINE_BUFFER_SECONDS || "{}") as Record<
string,
string
>
)?.[chainId.toString()];
return Number(bufferFromEnv ?? DEFAULT_FILL_DEADLINE_BUFFER_SECONDS);
}

export async function getFillDeadline(chainId: number): Promise<number> {
const fillDeadlineBuffer = getFillDeadlineBuffer(chainId);
const spokePool = getSpokePool(chainId);
const currentTime = await spokePool.callStatic.getCurrentTime();
return Number(currentTime) + fillDeadlineBuffer;
}
9 changes: 9 additions & 0 deletions api/_types/utility.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ export type TokenInfo = {
name: string;
addresses: Record<number, string>;
};

export type DepositRoute = {
originChainId: number;
originToken: string;
destinationChainId: number;
destinationToken: string;
originTokenSymbol: string;
destinationTokenSymbol: string;
};
Loading

0 comments on commit 4972755

Please sign in to comment.