Skip to content

Commit

Permalink
feat(amount-shares): re-calculate amount from shares with BigInt
Browse files Browse the repository at this point in the history
  • Loading branch information
49659410+tx0c committed May 14, 2024
1 parent 7e4ea7b commit 50e77c1
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 364 deletions.
6 changes: 2 additions & 4 deletions bin/qf-calculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {
calculateQFScore,
checkDropEventsAndNotifs,
// checkDropEventsAndNotifs,
} from '../lib/qf-calculate.js'

async function main() {
Expand All @@ -16,9 +16,7 @@ async function main() {
args.shift()
break
}
if (mode === 'checkDropEventsAndNotifs') {
return checkDropEventsAndNotifs()
}
// if (mode === 'checkDropEventsAndNotifs') { return checkDropEventsAndNotifs() }

const amountTotal = BigInt(+(args?.[0] || 10_000))

Expand Down
14 changes: 12 additions & 2 deletions handlers/qf-calculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { formatUnits } from 'viem'
import * as d3 from 'd3-array'
import {
calculateQFScore,
sendQfNotifications, // sendQfNotificationNEmails,
MattersBillboardS3Bucket,
isProd,
s3FilePathPrefix,
} from '../lib/qf-calculate.js'
import {
sendQfNotifications, // sendQfNotificationNEmails,
} from '../lib/qf-notify.js'
import { s3GetFile } from '../lib/utils/aws.js'
import { SLACK_MESSAGE_STATE, Slack } from '../lib/utils/slack.js'

Expand Down Expand Up @@ -92,7 +94,12 @@ export const handler = async (
}
} else if (method === 'POST' && path === '/send-notifications' && accept) {
// get distrib.json and send notifications;
let { key = 'latest', roundEnd, amountTotal = '' } = queryStringParameters
let {
key = 'latest',
roundEnd,
amountTotal = '',
sharesTotal = 10_000,
} = queryStringParameters
// let key = (queryStringParameters?.key || 'latest') as string
// get latest round path to distrib.json
try {
Expand All @@ -114,6 +121,7 @@ export const handler = async (
}
if (!amountTotal && latestRound?.amountTotal) {
amountTotal = latestRound?.amountTotal
sharesTotal = latestRound?.sharesTotal
}
}
}
Expand Down Expand Up @@ -144,6 +152,8 @@ export const handler = async (
const distribs = JSON.parse(await res1.Body.transformToString())
const sent = await sendQfNotifications(
distribs,
amountTotal,
sharesTotal,
roundEnd,
queryStringParameters?.doNotify === 'true'
)
Expand Down
Loading

0 comments on commit 50e77c1

Please sign in to comment.