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

Fix fadeOutAmong bug when sending CELO #167

Merged
merged 3 commits into from
Mar 29, 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
11 changes: 7 additions & 4 deletions apps/firebase/src/celo-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,26 @@ export class CeloAdapter {
) {
const nextAmount = new BigNumber(amount)

// TODO(Arthur):
// Replace `HUNDRED_IN_WEI` with Web3.utils.toWei('20')
// Use a sliding scale instead of if-else statements
if (useGivenAmount) {
return nextAmount
} else if (
recipientBalance.isGreaterThan(
HUNDRED_IN_WIE.multipliedBy(75).dividedBy(100),
HUNDRED_IN_WEI.multipliedBy(20).dividedBy(100),
)
) {
return new BigNumber(0)
} else if (
recipientBalance.isGreaterThan(
HUNDRED_IN_WIE.multipliedBy(50).dividedBy(100),
HUNDRED_IN_WEI.multipliedBy(10).dividedBy(100),
)
) {
return nextAmount.dividedBy(4)
} else if (
recipientBalance.isGreaterThan(
HUNDRED_IN_WIE.multipliedBy(25).dividedBy(100),
HUNDRED_IN_WEI.multipliedBy(5).dividedBy(100),
)
) {
return nextAmount.dividedBy(2)
Expand All @@ -310,4 +313,4 @@ export class CeloAdapter {
}
}

const HUNDRED_IN_WIE = new BigNumber('100000000000000000000')
const HUNDRED_IN_WEI = new BigNumber('100000000000000000000')
2 changes: 1 addition & 1 deletion apps/firebase/src/database-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ async function sendGold(
await snap.ref.update({ goldTxHash: 'skipped' })
return 'skipped'
}
const goldTxHash = await sendCelo(celo, address, amount)
const goldTxHash = await sendCelo(celo, address, actualAmount.toFixed())
console.info(`req(${snap.key}): CELO Transaction Sent. txhash:${goldTxHash}`)
await snap.ref.update({ goldTxHash })
return goldTxHash
Expand Down