Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETA adjustments #672

Merged
merged 2 commits into from
Aug 14, 2024
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
4 changes: 2 additions & 2 deletions connect/src/protocols/cctp/cctpTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Chain, Network } from "@wormhole-foundation/sdk-base";
import { circle, encoding, finality, toChain } from "@wormhole-foundation/sdk-base";
import { circle, encoding, finality, guardians, toChain } from "@wormhole-foundation/sdk-base";
import type {
Attestation,
AttestationId,
Expand Down Expand Up @@ -592,7 +592,7 @@ export namespace CircleTransfer {

// https://developers.circle.com/stablecoins/docs/required-block-confirmations
const eta =
srcChain.chain === "Polygon" ? 2_000 * 200 : finality.estimateFinalityTime(srcChain.chain);
(srcChain.chain === "Polygon" ? 2_000 * 200 : finality.estimateFinalityTime(srcChain.chain)) + guardians.guardianAttestationEta;
if (!transfer.automatic) {
return {
sourceToken: { token: srcToken, amount: transfer.amount },
Expand Down
4 changes: 2 additions & 2 deletions connect/src/protocols/tokenBridge/tokenTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Chain, Network } from "@wormhole-foundation/sdk-base";
import { amount, encoding, finality, toChain as toChainName } from "@wormhole-foundation/sdk-base";
import { amount, encoding, finality, guardians, toChain as toChainName } from "@wormhole-foundation/sdk-base";
import type {
AttestationId,
AutomaticTokenBridge,
Expand Down Expand Up @@ -717,7 +717,7 @@ export namespace TokenTransfer {
const dstDecimals = await dstChain.getDecimals(dstToken.address);
const dstAmountReceivable = amount.scale(srcAmountTruncated, dstDecimals);

const eta = finality.estimateFinalityTime(srcChain.chain);
const eta = finality.estimateFinalityTime(srcChain.chain) + guardians.guardianAttestationEta;
if (!transfer.automatic) {
return {
sourceToken: {
Expand Down
2 changes: 1 addition & 1 deletion core/base/src/constants/finality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const safeThreshold = constMap(safeThresholds);
// Number of blocks before a transaction is considered "final"
const finalityThresholds = [
["Solana", 32],
["Ethereum", 64],
["Ethereum", 96],
["Bsc", 15],
// Checkpointed to L1 after ~512 blocks
["Optimism", 512],
Expand Down
4 changes: 4 additions & 0 deletions core/base/src/constants/guardians.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ export const guardianKeyToName = constMap(guardianKeyAndNameEntries, [1, [0, 2]]

export const devnetGuardianPrivateKey =
"cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0";

// Number of seconds we expect to wait for attestation
// Used for eta calculation in route code
export const guardianAttestationEta = 5;
Loading