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

Update/modify token sale #148

Merged
merged 5 commits into from
Mar 18, 2024
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
264 changes: 264 additions & 0 deletions DaoPools/abis/TokenSale.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,43 @@
"name": "TierCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "tierId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "saleToken",
"type": "address"
},
{
"components": [
{
"internalType": "enum ITokenSaleProposal.ParticipationType",
"name": "participationType",
"type": "uint8"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"indexed": false,
"internalType": "struct ITokenSaleProposal.ParticipationDetails[]",
"name": "participationDetails",
"type": "tuple[]"
}
],
"name": "TierModified",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -355,6 +392,36 @@
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tierId",
"type": "uint256"
},
{
"components": [
{
"internalType": "enum ITokenSaleProposal.ParticipationType",
"name": "participationType",
"type": "uint8"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"internalType": "struct ITokenSaleProposal.ParticipationDetails[]",
"name": "newSettings",
"type": "tuple[]"
}
],
"name": "changeParticipationDetails",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -571,6 +638,72 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tierId",
"type": "uint256"
}
],
"name": "getParticipationDetails",
"outputs": [
{
"components": [
{
"internalType": "bool",
"name": "isWhitelisted",
"type": "bool"
},
{
"internalType": "bool",
"name": "isBABTed",
"type": "bool"
},
{
"internalType": "uint256",
"name": "requiredDaoVotes",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "requiredTokenAddresses",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "requiredTokenAmounts",
"type": "uint256[]"
},
{
"internalType": "address[]",
"name": "requiredNftAddresses",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "requiredNftAmounts",
"type": "uint256[]"
},
{
"internalType": "bytes32",
"name": "merkleRoot",
"type": "bytes32"
},
{
"internalType": "string",
"name": "merkleUri",
"type": "string"
}
],
"internalType": "struct ITokenSaleProposal.ParticipationInfoView",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -809,6 +942,11 @@
"internalType": "string",
"name": "merkleUri",
"type": "string"
},
{
"internalType": "uint256",
"name": "lastModified",
"type": "uint256"
}
],
"internalType": "struct ITokenSaleProposal.TierAdditionalInfo",
Expand Down Expand Up @@ -1102,6 +1240,132 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tierId",
"type": "uint256"
},
{
"components": [
{
"components": [
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "description",
"type": "string"
}
],
"internalType": "struct ITokenSaleProposal.TierMetadata",
"name": "metadata",
"type": "tuple"
},
{
"internalType": "uint256",
"name": "totalTokenProvided",
"type": "uint256"
},
{
"internalType": "uint64",
"name": "saleStartTime",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "saleEndTime",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "claimLockDuration",
"type": "uint64"
},
{
"internalType": "address",
"name": "saleTokenAddress",
"type": "address"
},
{
"internalType": "address[]",
"name": "purchaseTokenAddresses",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "exchangeRates",
"type": "uint256[]"
},
{
"internalType": "uint256",
"name": "minAllocationPerUser",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxAllocationPerUser",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint256",
"name": "vestingPercentage",
"type": "uint256"
},
{
"internalType": "uint64",
"name": "vestingDuration",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "cliffPeriod",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "unlockStep",
"type": "uint64"
}
],
"internalType": "struct ITokenSaleProposal.VestingSettings",
"name": "vestingSettings",
"type": "tuple"
},
{
"components": [
{
"internalType": "enum ITokenSaleProposal.ParticipationType",
"name": "participationType",
"type": "uint8"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"internalType": "struct ITokenSaleProposal.ParticipationDetails[]",
"name": "participationDetails",
"type": "tuple[]"
}
],
"internalType": "struct ITokenSaleProposal.TierInitParams",
"name": "newSettings",
"type": "tuple"
}
],
"name": "modifyTier",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
2 changes: 1 addition & 1 deletion DaoPools/src/helpers/PriceFeedInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getUSDValue(token: Bytes, amount: BigInt): BigInt {
if (token.equals(Bytes.empty())) {
return BigInt.zero();
}

let pfPrototype = PriceFeed.bind(Address.fromString(PRICE_FEED_ADDRESS));

let resp = pfPrototype.try_getNormalizedPriceOutUSD(Address.fromBytes(token), amount);
Expand Down
20 changes: 19 additions & 1 deletion DaoPools/src/mappings/TokenSale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address, BigInt, Bytes } from "@graphprotocol/graph-ts";
import { pushUnique } from "@solarity/graph-lib";
import { Bought, TierCreated, Whitelisted } from "../../generated/templates/TokenSale/TokenSaleProposal";
import { Bought, TierCreated, TierModified, Whitelisted } from "../../generated/templates/TokenSale/TokenSaleProposal";
import { getDaoPool } from "../entities/DaoPool";
import { getTokenSale } from "../entities/TokenSale";
import { getTokenSaleTier } from "../entities/TokenSaleTier";
Expand All @@ -25,6 +25,24 @@ export function onTierCreated(event: TierCreated): void {
tokenSale.save();
}

export function onTierModified(event: TierModified): void {
let tokenSale = getTokenSale(event.address);
let tier = getTokenSaleTier(tokenSale, event.params.tierId, event.params.saleToken);

let participationDetails = event.params.participationDetails;

tier.whitelistTypes = new Array();
tier.data = new Array();

for (let i = 0; i < participationDetails.length; i++) {
tier.whitelistTypes = push(tier.whitelistTypes, BigInt.fromI32(participationDetails[i].participationType));
tier.data = push(tier.data, participationDetails[i].data);
}

tier.save();
tokenSale.save();
}

export function onBought(event: Bought): void {
let tokenSale = getTokenSale(event.address);
let tier = getTokenSaleTier(tokenSale, event.params.tierId);
Expand Down
2 changes: 2 additions & 0 deletions DaoPools/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ templates:
eventHandlers:
- event: TierCreated(uint256,address,(uint8,bytes)[])
handler: onTierCreated
- event: TierModified(uint256,address,(uint8,bytes)[])
handler: onTierModified
- event: Bought(uint256,address,uint256,uint256,address)
handler: onBought
- event: Whitelisted(uint256,address)
Expand Down
Loading
Loading