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

🛕 Historical revenue share participants #286

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions schema/token.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ type RevenueShare @entity {
"ending block"
endsAt: Int!

"number of holders that could join the split before it ended"
potentialParticipantsNum: Int

"Number of participants (stackers)"
participantsNum: Int!

Expand Down
1 change: 1 addition & 0 deletions src/mappings/token/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
}: EventHandlerContext<'ProjectToken.TokenIssued'>) {
// create token
const totalSupply = initialAllocation.reduce((acc, [_, allocation]) => {

Check warning on line 54 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

'_' is defined but never used
return acc + allocation.amount
}, BigInt(0))

Expand Down Expand Up @@ -288,7 +288,7 @@
buyerAccount.totalAmount += crtMinted
}

const activeAmm = await overlay.getRepository(AmmCurve).getByIdOrFail(token.currentAmmSaleId!)

Check warning on line 291 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion

activeAmm.mintedByAmm += crtMinted
const tx = overlay.getRepository(AmmTransaction).new({
Expand All @@ -314,7 +314,7 @@
}: EventHandlerContext<'ProjectToken.TokensSoldOnAmm'>) {
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
token.totalSupply -= crtBurned
const activeAmm = await overlay.getRepository(AmmCurve).getByIdOrFail(token.currentAmmSaleId!)

Check warning on line 317 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
const ammId = activeAmm.id

const sellerAccount = await getTokenAccountByMemberByTokenOrFail(overlay, memberId, tokenId)
Expand Down Expand Up @@ -353,7 +353,7 @@
}

const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
const sale = await overlay.getRepository(Sale).getByIdOrFail(token.currentSaleId!)

Check warning on line 356 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
sale.tokensSold += amountPurchased

overlay.getRepository(SaleTransaction).new({
Expand Down Expand Up @@ -385,7 +385,7 @@
},
}: EventHandlerContext<'ProjectToken.UpcomingTokenSaleUpdated'>) {
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
const sale = await overlay.getRepository(Sale).getByIdOrFail(token.currentSaleId!)

Check warning on line 388 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion

if (newStart) {
sale.startBlock = newStart
Expand Down Expand Up @@ -417,6 +417,7 @@
claimed: BigInt(0),
startingAt: startBlock,
endsAt,
potentialParticipantsNum: token.accountsNum,
}) as RevenueShare

token.currentRenvenueShareId = id
Expand All @@ -435,13 +436,13 @@
export async function processAmmDeactivatedEvent({
overlay,
event: {
asV2002: [tokenId, , burnedAmount],

Check warning on line 439 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

'burnedAmount' is defined but never used
},
}: EventHandlerContext<'ProjectToken.AmmDeactivated'>) {
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
token.status = TokenStatus.IDLE

const activeAmm = await overlay.getRepository(AmmCurve).getByIdOrFail(token.currentAmmSaleId!)

Check warning on line 445 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
activeAmm.finalized = true

token.currentAmmSaleId = null
Expand Down Expand Up @@ -480,12 +481,12 @@
},
}: EventHandlerContext<'ProjectToken.TokenSaleFinalized'>) {
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
const sale = await overlay.getRepository(Sale).getByIdOrFail(token.currentSaleId!)

Check warning on line 484 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
sale.finalized = true

const sourceAccount = await overlay
.getRepository(TokenAccount)
.getByIdOrFail(sale.fundsSourceAccountId!)

Check warning on line 489 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
sourceAccount.totalAmount += quantityLeft

token.status = TokenStatus.IDLE
Expand All @@ -505,7 +506,7 @@
// TODO: refactor this as should be true all the times, might be a good idea to panic
const revenueShare = await overlay
.getRepository(RevenueShare)
.getByIdOrFail(token.currentRenvenueShareId!)

Check warning on line 509 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
revenueShare.participantsNum -= 1
const qRevenueShareParticipation = (
await overlay
Expand Down
Loading