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

Ready: monitor the funding account of vortex #277

Open
wants to merge 8 commits into
base: polygon-prototype-staging
Choose a base branch
from

Conversation

Sharqiewicz
Copy link
Contributor

@Sharqiewicz Sharqiewicz commented Nov 13, 2024

🦈 🟢 PR

  • install @slack/web-api
  • add SLACK_WEB_HOOK_TOKEN env variable ⚠️
  • add funds monitoring for: moonbeam (GLMR), pendulum (EUR, USDC.axl, PEN), stellar (XLM)

@Sharqiewicz Sharqiewicz linked an issue Nov 13, 2024 that may be closed by this pull request
Copy link

netlify bot commented Nov 13, 2024

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit 200c184
🔍 Latest deploy log https://app.netlify.com/sites/pendulum-pay/deploys/6735efe9a063f00008e58e7c
😎 Deploy Preview https://deploy-preview-277--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Sharqiewicz Sharqiewicz changed the title wip: monitor the funding account of vortex Ready: monitor the funding account of vortex Nov 14, 2024
@Sharqiewicz Sharqiewicz requested a review from a team November 14, 2024 10:48
@TorstenStueber
Copy link
Member

@Sharqiewicz can you please merge or rebase the latest polygon-prototype-staging?

Copy link

yarn.lock changes

Click to toggle table visibility
Name Status Previous Current
@slack/logger ADDED - 4.0.0
@slack/types ADDED - 2.14.0
@slack/web-api ADDED - 7.7.0
@types/retry ADDED - 0.12.0
axios UPDATED 1.6.8 1.7.7
is-electron ADDED - 2.2.2
p-retry ADDED - 4.6.2
retry UPDATED 0.12.0 0.13.1
undici-types ADDED - 6.19.8

Copy link
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, though I would appreciate if we add some mechanism that limits the number of duplicate messages emitted to one per .. 6 hours maybe? So we avoid spamming the channel. Each type of warning should have its own timer though.


// ensure we have at the very least 10 XLM in the account
if (Number(stellarBalance.balance) < STELLAR_FUNDING_AMOUNT_UNITS) {
slackNotifier.sendMessage({
text: `Current balance of funding account is ${stellarBalance.balance} XLM please charge this account ${FUNDING_PUBLIC_KEY}.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: `Current balance of funding account is ${stellarBalance.balance} XLM please charge this account ${FUNDING_PUBLIC_KEY}.`,
text: `Current balance of funding account is ${stellarBalance.balance} XLM, please charge the account ${FUNDING_PUBLIC_KEY}.`,

Comment on lines +146 to +148
text: `Current balance of funding account is ${divideByPowerOfTen(
nativeBalance,
).toString()} PEN please charge this account ${fundingAccountKeypair.address}.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: `Current balance of funding account is ${divideByPowerOfTen(
nativeBalance,
).toString()} PEN please charge this account ${fundingAccountKeypair.address}.`,
text: `Current balance of funding account is ${divideByPowerOfTen(
nativeBalance,
).toString()} PEN, please charge the account ${fundingAccountKeypair.address}.`,

Comment on lines +131 to +133
text: `Current balance of funding account is ${nativeToDecimal(
remainingMaxSubsidiesAvailable,
).toString()} ${token} please charge this account ${fundingAccountKeypair.address}.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: `Current balance of funding account is ${nativeToDecimal(
remainingMaxSubsidiesAvailable,
).toString()} ${token} please charge this account ${fundingAccountKeypair.address}.`,
text: `Current balance of funding account is ${nativeToDecimal(
remainingMaxSubsidiesAvailable,
).toString()} ${token}, please charge the account ${fundingAccountKeypair.address}.`,


if (balance < minimumBalance) {
slackService.sendMessage({
text: `Current balance of funding account is ${balance} GLMR please charge this account ${moonbeamExecutorAccount.address}.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: `Current balance of funding account is ${balance} GLMR please charge this account ${moonbeamExecutorAccount.address}.`,
text: `Current balance of funding account is ${balance} GLMR, please charge the account ${moonbeamExecutorAccount.address}.`,


if (balance < minimumBalance) {
slackService.sendMessage({
text: `Current balance of funding account is ${balance} GLMR please charge this account ${moonbeamExecutorAccount.address}.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

balance is the raw amount, not the unit amount, correct? In that case can we write

Suggested change
text: `Current balance of funding account is ${balance} GLMR please charge this account ${moonbeamExecutorAccount.address}.`,
text: `Current balance of funding account is ${balance.div(Big(10).pow(18)).toFixed(2,0)} GLMR please charge this account ${moonbeamExecutorAccount.address}.`,


slackNotifier.sendMessage({
text: `Current balance of funding account is ${nativeToDecimal(
remainingMaxSubsidiesAvailable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remainingMaxSubsidiesAvailable is actually not a currency amount but just a number counting how many subsidies are still possible with the remaining funds, assuming that every subsidy requires the maximum amount. Therefore nativeToDecimal does not make sense here.

Or you use tokenBalance instead of remainingMaxSubsidiesAvailable.

if (nativeBalance.gte(minimumBalanceFundingAccount) && isTokensSufficient) {
return { status: true, public: fundingAccountKeypair.address };
}
slackNotifier.sendMessage({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be that we reach this point just because isTokensSufficient is false – in that case we already sent an error message above.

We only need to send this message if nativeBalance.gte(minimumBalanceFundingAccount).

Furthermore, don't forget the second argument apiData.decimals for divideByPowerOfTen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitor the funding account of Vortex
3 participants