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

Update estimated time for processing of small deposits to 2 hours #900

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
29 changes: 24 additions & 5 deletions dapp/src/utils/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,31 @@ export function getEstimatedDuration(
amount: bigint,
type: ActivityType,
): string {
// Withdrawal duration is related to the tBTC redemption process, which takes
// approximately 5 - 7 hours. We use the average value of 6 hours.
if (isWithdrawType(type)) return "6 hours"

if (amount < MIN_LIMIT_VALUE_DURATION) return "1 hour"

if (amount >= MIN_LIMIT_VALUE_DURATION && amount < MAX_LIMIT_VALUE_DURATION)
return "2 hours"

// Deposit duration is related to the tBTC minting process, which varies based
// on the amount of BTC deposited.
// Each threshold requires a different number of Bitcoin transaction confirmations:
// <0.1 BTC: 1 Bitcoin block confirmation (~10 minutes),
// >=0.1 BTC and <1 BTC: 3 Bitcoin block confirmations (~30 minutes),
// >=1 BTC: 6 Bitcoin block confirmations (~60 minutes).
// The duration of the transaction minting process depends on the Bitcoin network
// congestion, and the fee paid by the user.
//
// After the required number of Bitcoin block confirmations, the tBTC optimistic
// minting process starts. The optimistic minting process takes approximately
// 1 hour to complete.
// After optimistic minting is completed, the Acre bots will finalize the deposit
// in no more than 10 minutes.
//
// We round the estimated duration up to the nearest hour.
//
// For <0.1 BTC estimated duration is around 1 hour 20 minutes.
if (amount < MIN_LIMIT_VALUE_DURATION) return "2 hours"
// For <1 BTC estimated duration is around 1 hours 40 minutes.
if (amount < MAX_LIMIT_VALUE_DURATION) return "2 hours"
// For >=1 BTC estimated duration is around 2 hours 10 minutes.
return "3 hours"
}
52 changes: 52 additions & 0 deletions dapp/src/utils/tests/activities.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { describe, expect, it } from "vitest"
import { getEstimatedDuration } from "../activities"

describe("Utils functions for activities", () => {
describe("getEstimatedDuration", () => {
describe("withdraw", () => {
describe.each([
// 0.01 BTC
{ value: 0.01, expectedResult: "6 hours" },
// 0.1 BTC
{ value: 0.1, expectedResult: "6 hours" },
// 1 BTC
{ value: 1, expectedResult: "6 hours" },
// 10 BTC
{ value: 10, expectedResult: "6 hours" },
])("when it is $value BTC", ({ value, expectedResult }) => {
it(`should return ${expectedResult}`, () => {
expect(getEstimatedDuration(BigInt(value * 1e8), "withdraw")).toEqual(
expectedResult,
)
})
})
})

describe("deposit", () => {
describe.each([
// 0.0001 BTC
{ value: 0.0001, expectedResult: "2 hours" },
// 0.001 BTC
{ value: 0.001, expectedResult: "2 hours" },
// 0.01 BTC
{ value: 0.01, expectedResult: "2 hours" },
// 0.09 BTC
{ value: 0.09, expectedResult: "2 hours" },
// 0.1 BTC
{ value: 0.1, expectedResult: "2 hours" },
// 0.9 BTC
{ value: 0.9, expectedResult: "2 hours" },
// 1 BTC
{ value: 1, expectedResult: "3 hours" },
// 10 BTC
{ value: 10, expectedResult: "3 hours" },
])("when it is $value BTC", ({ value, expectedResult }) => {
it(`should return ${expectedResult}`, () => {
expect(getEstimatedDuration(BigInt(value * 1e8), "deposit")).toEqual(
expectedResult,
)
})
})
})
})
})
Loading