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

added DelegatorRewardsClaimed, changed rewards logic, changed voting #129

Merged
merged 3 commits into from
Sep 4, 2023
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
106 changes: 47 additions & 59 deletions DaoPools/abis/DaoPool.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,62 +20,14 @@
"name": "isVoteFor",
"type": "bool"
},
{
"components": [
{
"internalType": "uint256",
"name": "personal",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "micropool",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "treasury",
"type": "uint256"
}
],
"indexed": false,
"internalType": "struct IGovPool.Votes",
"name": "votes",
"type": "tuple"
}
],
"name": "VoteChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "proposalId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "rewardToken",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"name": "totalVoted",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "RewardCanceled",
"name": "VoteChanged",
"type": "event"
},
{
Expand Down Expand Up @@ -196,7 +148,13 @@
{
"indexed": false,
"internalType": "address",
"name": "user",
"name": "delegator",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "delegatee",
"type": "address"
},
{
Expand All @@ -212,7 +170,32 @@
"type": "uint256"
}
],
"name": "MicropoolRewardClaimed",
"name": "DelegatorRewardsClaimed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "proposalId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "delegatee",
"type": "address"
}
],
"name": "DelegatorRewardsSet",
"type": "event"
},
{
Expand Down Expand Up @@ -1192,12 +1175,7 @@
},
{
"internalType": "uint256",
"name": "voteForRewardsCoefficient",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "voteAgainstRewardsCoefficient",
"name": "voteRewardsCoefficient",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1240,6 +1218,16 @@
"name": "votesAgainst",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "rawVotesFor",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "rawVotesAgainst",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "nftPowerSnapshotId",
Expand Down Expand Up @@ -1484,7 +1472,7 @@
},
{
"internalType": "uint256",
"name": "powerVoted",
"name": "totalRawVoted",
"type": "uint256"
},
{
Expand Down
81 changes: 76 additions & 5 deletions DaoPools/abis/TokenSale.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
"internalType": "address",
"name": "saleToken",
"type": "address"
},
{
"indexed": false,
"internalType": "enum ITokenSaleProposal.ParticipationType",
"name": "participationType",
"type": "uint8"
}
],
"name": "TierCreated",
Expand Down Expand Up @@ -193,11 +199,6 @@
"internalType": "address",
"name": "_govAddress",
"type": "address"
},
{
"internalType": "contract ISBT721",
"name": "_babt",
"type": "address"
}
],
"name": "__TokenSaleProposal_init",
Expand Down Expand Up @@ -332,6 +333,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "coreProperties",
"outputs": [
{
"internalType": "contract CoreProperties",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -453,6 +467,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "dexeGovAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -496,6 +523,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getInjector",
"outputs": [
{
"internalType": "address",
"name": "injector_",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -1138,6 +1178,37 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "contractsRegistry",
"type": "address"
},
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"name": "setDependencies",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "injector_",
"type": "address"
}
],
"name": "setInjector",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
13 changes: 4 additions & 9 deletions DaoPools/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,12 @@ type VoterInProposal @entity {
id: Bytes! # voter address + proposal entity id
isVoteFor: Boolean!

personalVote: BigInt!
micropoolVote: BigInt!
treasuryVote: BigInt!
totalVote: BigInt!

staticRewardUSD: BigInt!
personalRewardUSD: BigInt!
micropoolRewardUSD: BigInt!
treasuryRewardUSD: BigInt!
votingRewardUSD: BigInt!

micropoolRewardUSD: BigInt!
claimedRewardUSD: BigInt!

pool: DaoPool!
Expand All @@ -276,9 +273,7 @@ type ProposalInteraction @entity(immutable: true) {
timestamp: BigInt!

interactionType: BigInt! # 0 -> vote for, 1 -> vote against, 2 -> cancel
personalVote: BigInt!
micropoolVote: BigInt!
treasuryVote: BigInt!
totalVote: BigInt!

voter: VoterInProposal!
proposal: Proposal!
Expand Down
8 changes: 2 additions & 6 deletions DaoPools/src/entities/ProposalInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export function getProposalInteraction(
voterInProposal: VoterInProposal,
timestamp: BigInt,
interactionType: BigInt,
personalVote: BigInt,
micropoolVote: BigInt,
treasuryVote: BigInt
totalVote: BigInt
): ProposalInteraction {
let counter = getInteractionCount(hash);
let id = hash.concatI32(counter.count.toI32());
Expand All @@ -22,9 +20,7 @@ export function getProposalInteraction(
proposalVote.timestamp = timestamp;

proposalVote.interactionType = interactionType;
proposalVote.personalVote = personalVote;
proposalVote.micropoolVote = micropoolVote;
proposalVote.treasuryVote = treasuryVote;
proposalVote.totalVote = totalVote;

proposalVote.proposal = voterInProposal.proposal;
proposalVote.voter = voterInProposal.id;
Expand Down
5 changes: 3 additions & 2 deletions DaoPools/src/entities/TokenSaleTier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { TokenSaleContract, TokenSaleTier } from "../../generated/schema";
export function getTokenSaleTier(
tokenSale: TokenSaleContract,
tierId: BigInt,
saleToken: Address = Address.zero()
saleToken: Address = Address.zero(),
whitelistType: BigInt = BigInt.zero()
): TokenSaleTier {
let id = tokenSale.id.concatI32(tierId.toI32());
let tier = TokenSaleTier.load(id);
Expand All @@ -17,7 +18,7 @@ export function getTokenSaleTier(
tier.totalBuyersCount = BigInt.zero();
tier.buyers = new Array();

tier.whitelistType = BigInt.zero();
tier.whitelistType = whitelistType;

tier.tokenSale = tokenSale.id;
}
Expand Down
8 changes: 3 additions & 5 deletions DaoPools/src/entities/Voters/VoterInProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ export function getVoterInProposal(proposal: Proposal, voterInPool: VoterInPool)

voterInProposal.isVoteFor = false;

voterInProposal.personalVote = BigInt.zero();
voterInProposal.micropoolVote = BigInt.zero();
voterInProposal.treasuryVote = BigInt.zero();
voterInProposal.totalVote = BigInt.zero();

voterInProposal.staticRewardUSD = BigInt.zero();
voterInProposal.personalRewardUSD = BigInt.zero();
voterInProposal.votingRewardUSD = BigInt.zero();

voterInProposal.micropoolRewardUSD = BigInt.zero();
voterInProposal.treasuryRewardUSD = BigInt.zero();

voterInProposal.claimedRewardUSD = BigInt.zero();

Expand Down
11 changes: 3 additions & 8 deletions DaoPools/src/entities/global/RewardTypeEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import { BigInt } from "@graphprotocol/graph-ts";

export enum RewardType {
CREATE = 0,
VOTE_FOR = 1,
VOTE_AGAINST = 2,
VOTE_FOR_DELEGATED = 3,
VOTE_AGAINST_DELEGATED = 4,
VOTE_FOR_TREASURY = 5,
VOTE_AGAINST_TREASURY = 6,
EXECUTE = 7,
SAVE_OFFCHAIN_RESULTS = 8,
VOTE = 1,
EXECUTE = 2,
SAVE_OFFCHAIN_RESULTS = 3,
}

export function getEnumBigInt(operation: RewardType): BigInt {
Expand Down
Loading