From ff9a4f10029f3fa764e0f0eef03471d1893d9e82 Mon Sep 17 00:00:00 2001 From: Charles Bergeron Date: Tue, 27 Jun 2023 13:57:59 -0700 Subject: [PATCH] converting from previous isWinner implementation to the new one --- package.json | 4 ++-- .../draw/40/prizes.json | 1 + .../draw/40/status.json | 17 +++++++++++++++++ .../draw/48/prizes.json | 1 + .../draw/48/status.json | 17 +++++++++++++++++ src/commands/compute/drawPrizes.ts | 13 +++++++++---- src/lib/utils/prizeAmounts.ts | 10 +++++----- 7 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/prizes.json create mode 100644 prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/status.json create mode 100644 prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/prizes.json create mode 100644 prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/status.json diff --git a/package.json b/package.json index 6c154d2..33f074a 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@oclif/core": "^2.8.5", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^3.0.1", - "@pooltogether/v5-utils-js": "0.0.1-beta.23", + "@pooltogether/v5-utils-js": "file:.yalc/@pooltogether/v5-utils-js", "ajv": "^8.10.0", "ethers": "^5.7.2", "graphql": "^16.3.0", @@ -76,4 +76,4 @@ "oclif" ], "types": "dist/index.d.ts" -} \ No newline at end of file +} diff --git a/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/prizes.json b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/prizes.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/prizes.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/status.json b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/status.json new file mode 100644 index 0000000..9a792d5 --- /dev/null +++ b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/40/status.json @@ -0,0 +1,17 @@ +{ + "status": "SUCCESS", + "createdAt": 1687470140874, + "updatedAt": 1687470144435, + "runtime": 3561, + "meta": { + "prizeLength": 0, + "amountsTotal": "101705333770489105822", + "tierPrizeAmounts": { + "0": "101146446829269034316", + "1": "493485255234583365", + "2": "65401685985488141", + "3": "0", + "4": "0" + } + } +} \ No newline at end of file diff --git a/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/prizes.json b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/prizes.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/prizes.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/status.json b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/status.json new file mode 100644 index 0000000..0620c98 --- /dev/null +++ b/prizes/11155111/0xc5a77bcb8cd13c5619153d46fb7379c9158a8884/draw/48/status.json @@ -0,0 +1,17 @@ +{ + "status": "SUCCESS", + "createdAt": 1687815803695, + "updatedAt": 1687815808669, + "runtime": 4974, + "meta": { + "prizeLength": 0, + "amountsTotal": "7443639326093697432177", + "tierPrizeAmounts": { + "0": "6012683193669987282922", + "1": "1179675564248702319956", + "2": "199100262487709589381", + "3": "49609209479182543225", + "4": "2571096208115696693" + } + } +} \ No newline at end of file diff --git a/src/commands/compute/drawPrizes.ts b/src/commands/compute/drawPrizes.ts index 40cc378..45f2edd 100644 --- a/src/commands/compute/drawPrizes.ts +++ b/src/commands/compute/drawPrizes.ts @@ -1,4 +1,4 @@ -import { ethers, Contract } from "ethers"; +import { BigNumber, ethers, Contract } from "ethers"; import { Provider } from "@ethersproject/providers"; import { Command, Flags } from "@oclif/core"; import { @@ -108,15 +108,19 @@ export default class DrawPrizes extends Command { // Find out how much each tier won const contracts = await downloadContractsBlob(Number(chainId)); - const tiersRangeArray = prizePoolData.tiers.rangeArray; - const tierPrizeAmounts = await getTierPrizeAmounts(readProvider, contracts, tiersRangeArray); + // const tierPrizeAmounts = await getTierPrizeAmounts(readProvider, contracts, tiersRangeArray); + const tierPrizeAmounts = { + "0": BigNumber.from(2), + "1": BigNumber.from(4), + "2": BigNumber.from(8), + "3": BigNumber.from(16), + }; const filterAutoClaimDisabled = false; const claims: Claim[] = await computeDrawWinners( readProvider, contracts, Number(chainId), - tiersRangeArray, Number(drawId), filterAutoClaimDisabled ); @@ -155,6 +159,7 @@ const getPrizePoolData = async ( const drawId = await prizePool.getLastCompletedDrawId(); const numberOfTiers = await prizePool.numberOfTiers(); + console.log("..."); const rangeArray = Array.from({ length: numberOfTiers + 1 }, (value, index) => index); const tiers: TiersContext = { numberOfTiers, rangeArray }; diff --git a/src/lib/utils/prizeAmounts.ts b/src/lib/utils/prizeAmounts.ts index bfb737d..9c527b3 100644 --- a/src/lib/utils/prizeAmounts.ts +++ b/src/lib/utils/prizeAmounts.ts @@ -1,5 +1,5 @@ import { BigNumber } from '@ethersproject/bignumber' -import { Amounts, Claim } from '@pooltogether/v5-utils-js' +import { TierPrizeAmounts, Claim } from '@pooltogether/v5-utils-js' interface amountsAsString { [key: string]: string; @@ -13,13 +13,13 @@ interface ClaimWithAmount extends Claim { amount: string } -export function sumPrizeAmounts(tierPrizeAmounts: Amounts): string { +export function sumPrizeAmounts(tierPrizeAmounts: TierPrizeAmounts): string { return Object.values(tierPrizeAmounts) .reduce((a, b) => a.add(b), BigNumber.from(0)) .toString() } -export function mapTierPrizeAmountsToString(tierPrizeAmounts: Amounts) { +export function mapTierPrizeAmountsToString(tierPrizeAmounts: TierPrizeAmounts) { const obj: amountsAsString = {}; for (const entry of Object.entries(tierPrizeAmounts)) { @@ -30,7 +30,7 @@ export function mapTierPrizeAmountsToString(tierPrizeAmounts: Amounts) { return obj; }; -export function addTierPrizeAmountsToClaims(claims: Claim[], tierPrizeAmounts: Amounts): ClaimWithAmount[] { +export function addTierPrizeAmountsToClaims(claims: Claim[], tierPrizeAmounts: TierPrizeAmounts): ClaimWithAmount[] { const claimsByTier = groupByTier(claims, tierPrizeAmounts) const claimsWithAmounts:ClaimWithAmount[] = [] @@ -55,7 +55,7 @@ export function addTierPrizeAmountsToClaims(claims: Claim[], tierPrizeAmounts: A return claimsWithAmounts } -const groupByTier = (claims: any, tierPrizeAmounts: Amounts) =>{ +const groupByTier = (claims: any, tierPrizeAmounts: TierPrizeAmounts) =>{ const initialClaims: claimTiers = {}; for (const tier of Object.keys(tierPrizeAmounts)) { initialClaims[tier] = [];