├── .nvmrc ├── abis ├── v3_1_0 │ └── abis │ │ ├── console.json │ │ ├── BalanceDrip.json │ │ ├── FixedPoint.json │ │ ├── Initializable.json │ │ ├── UInt256Array.json │ │ ├── VolumeDrip.json │ │ ├── YieldSource.json │ │ ├── AddressUpgradeable.json │ │ ├── BalanceDripManager.json │ │ ├── ContextUpgradeable.json │ │ ├── ExtendedSafeCast.json │ │ ├── SafeCastUpgradeable.json │ │ ├── SafeMathUpgradeable.json │ │ ├── StringsUpgradeable.json │ │ ├── UniformRandomNumber.json │ │ ├── VolumeDripManager.json │ │ ├── ERC165CheckerUpgradeable.json │ │ ├── EnumerableMapUpgradeable.json │ │ ├── EnumerableSetUpgradeable.json │ │ ├── SafeERC20Upgradeable.json │ │ ├── SortitionSumTreeFactory.json │ │ ├── OpenZeppelinSafeMath_V3_3_0.json │ │ ├── ReentrancyGuardUpgradeable.json │ │ ├── Timestamp.json │ │ ├── RegistryInterface.json │ │ ├── MappedSinglyLinkedList.json │ │ ├── TokenListenerLibrary.json │ │ ├── PeriodicPrizeStrategyDistributorInterface.json │ │ ├── PeriodicPrizeStrategyListenerLibrary.json │ │ ├── TicketInterface.json │ │ ├── ERC165Upgradeable.json │ │ ├── IERC165Upgradeable.json │ │ ├── ReserveInterface.json │ │ ├── PrizePoolBuilder.json │ │ ├── TokenControllerInterface.json │ │ ├── IERC1820ImplementerUpgradeable.json │ │ ├── IERC721ReceiverUpgradeable.json │ │ ├── UInt256ArrayExposed.json │ │ ├── ExtendedSafeCastExposed.json │ │ ├── ProxyFactory.json │ │ ├── PeriodicPrizeStrategyListener.json │ │ ├── PeriodicPrizeStrategyListenerInterface.json │ │ ├── IERC777RecipientUpgradeable.json │ │ ├── ComptrollerStorage.json │ │ ├── OwnableUpgradeable.json │ │ ├── OpenZeppelinProxyFactoryInterface.json │ │ ├── TicketProxyFactory.json │ │ ├── ControlledTokenProxyFactory.json │ │ ├── MultipleWinnersProxyFactory.json │ │ ├── StakePrizePoolProxyFactory.json │ │ ├── yVaultPrizePoolProxyFactory.json │ │ ├── CompoundPrizePoolProxyFactory.json │ │ ├── SingleRandomWinnerProxyFactory.json │ │ ├── MultipleWinnersHarnessProxyFactory.json │ │ ├── yVaultPrizePoolHarnessProxyFactory.json │ │ ├── CompoundPrizePoolHarnessProxyFactory.json │ │ ├── ERC1820ImplementerMock.json │ │ ├── YieldSourceStub.json │ │ ├── TokenListener.json │ │ ├── TokenListenerInterface.json │ │ ├── Constants.json │ │ ├── DoppelgangerWithExec.json │ │ ├── MappedSinglyLinkedListExposed.json │ │ ├── Registry.json │ │ ├── StakePrizePoolBuilder.json │ │ ├── CompoundPrizePoolBuilder.json │ │ ├── VaultPrizePoolBuilder.json │ │ ├── RNGInterface.json │ │ ├── Reserve.json │ │ ├── RNGServiceMock.json │ │ ├── BalanceDripExposed.json │ │ ├── ControlledTokenBuilder.json │ │ ├── PermitAndDepositDai.json │ │ ├── BalanceDripManagerExposed.json │ │ ├── IERC20Upgradeable.json │ │ ├── VolumeDripManagerExposed.json │ │ ├── MultipleWinnersBuilder.json │ │ ├── VolumeDripExposed.json │ │ ├── IERC1820RegistryUpgradeable.json │ │ ├── DaiInterface.json │ │ ├── yVaultInterface.json │ │ ├── ControlledTokenInterface.json │ │ ├── ERC20Upgradeable.json │ │ ├── IERC721Upgradeable.json │ │ └── CTokenInterface.json └── v3_2_0 │ └── abis │ └── CompoundPrizePoolProxyFactory.json ├── Subgraph-V3.code-workspace ├── draftquery.graphql ├── scripts └── package-version.sh ├── testQueries └── testDaiPrizePool.graphql ├── src ├── helpers │ ├── loadOrCreateSablierStream.ts │ ├── common.ts │ ├── loadOrCreatePrizeStrategy.ts │ ├── loadOrCreatePrize.ts │ ├── loadOrCreatePrizeSplit.ts │ ├── loadOrCreatePrizePoolAccount.ts │ ├── loadOrCreatePrizePoolCreditRate.ts │ ├── loadOrCreateStakePrizePool.ts │ ├── loadOrCreateAwardedControlledToken.ts │ ├── loadOrCreateCompoundPrizePool.ts │ ├── loadOrCreateYieldSourcePrizePool.ts │ ├── idTemplates.ts │ ├── loadOrCreateControlledToken.ts │ ├── loadOrCreateSingleRandomWinner.ts │ ├── loadOrCreateExternalAward.ts │ ├── loadOrCreateAccount.ts │ ├── loadOrCreateAwardedExternalErc.ts │ ├── loadOrCreateMultipleWinnersExternalAward.ts │ └── loadOrCreatePrizePool.ts ├── mappingForControlledTokenProxyFactory.ts ├── mappingForTicketProxyFactory.ts ├── mappingForStakePrizePoolProxyFactory.ts ├── mappingForYieldSourcePrizePool.ts ├── mappingForYieldSourcePrizePoolProxyFactory.ts ├── mappingForStakePrizePool.ts ├── mappingForCompoundPrizePoolProxyFactory.ts ├── mappingForCompoundPrizePool.ts ├── mappingForSablierStreamManager.ts ├── mappingForMultipleWinnersProxyFactory.ts ├── mappingForControlledToken.ts └── mappingForPrizePool.ts ├── .gitignore ├── test ├── networks ├── bsc.json ├── celo.json ├── rinkeby.json ├── mainnet.json └── polygon.json ├── LICENSE ├── README.md ├── testquery.gql └── package.json /.nvmrc: -------------------------------------------------------------------------------- 1 | v10.20.1 2 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/console.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/BalanceDrip.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/FixedPoint.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/Initializable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/UInt256Array.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/VolumeDrip.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/YieldSource.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/AddressUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/BalanceDripManager.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ContextUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ExtendedSafeCast.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/SafeCastUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/SafeMathUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/StringsUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/UniformRandomNumber.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/VolumeDripManager.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ERC165CheckerUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/EnumerableMapUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/EnumerableSetUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/SafeERC20Upgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/SortitionSumTreeFactory.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/OpenZeppelinSafeMath_V3_3_0.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ReentrancyGuardUpgradeable.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /Subgraph-V3.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /draftquery.graphql: -------------------------------------------------------------------------------- 1 | { 2 | controlledToken(id:"0x4fb19557fbd8d73ac884efbe291626fd5641c778"){ 3 | id 4 | numberOfHolders 5 | } 6 | } -------------------------------------------------------------------------------- /scripts/package-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo $(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') -------------------------------------------------------------------------------- /testQueries/testDaiPrizePool.graphql: -------------------------------------------------------------------------------- 1 | { 2 | prizePool(id:"0xebfb47a7ad0fd6e57323c8a42b2e5a6a4f68fc1a"){ 3 | id 4 | reserveRegistry 5 | prizes(first: 5){ 6 | id 7 | awardedBlock 8 | lockBlock 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /abis/v3_1_0/abis/Timestamp.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "blockTime", 5 | "outputs": [ 6 | { 7 | "internalType": "uint256", 8 | "name": "", 9 | "type": "uint256" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | } 15 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/RegistryInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "lookup", 5 | "outputs": [ 6 | { 7 | "internalType": "address", 8 | "name": "", 9 | "type": "address" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | } 15 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/MappedSinglyLinkedList.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "SENTINEL", 5 | "outputs": [ 6 | { 7 | "internalType": "address", 8 | "name": "", 9 | "type": "address" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | } 15 | ] -------------------------------------------------------------------------------- /src/helpers/loadOrCreateSablierStream.ts: -------------------------------------------------------------------------------- 1 | import { SablierStream } from "../../generated/schema" 2 | 3 | export function loadOrCreateSablierStream(id : string) : SablierStream{ 4 | let stream = SablierStream.load(id) 5 | if(!stream){ 6 | stream = new SablierStream(id) 7 | } 8 | return stream as SablierStream 9 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .history 3 | build 4 | subgraph.local.yaml 5 | subgraph.kovan.yaml 6 | subgraph.yaml 7 | subgraph.ropsten.yaml 8 | subgraph.rinkeby.yaml 9 | subgraph.mainnet.yaml 10 | subgraph.polygon.yaml 11 | subgraph.bsc.yaml 12 | subgraph.celo.yaml 13 | networks/local.json 14 | generated 15 | generated/schema.ts 16 | build -------------------------------------------------------------------------------- /test: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0x3124db361ba65c12719269459c1acd5233ac5422", 3 | "prizeStrategy": null 4 | }, 5 | { 6 | "id": "0x3836f2044e19dd4449a4f0b20189061ba9338782", 7 | "prizeStrategy": null 8 | }, 9 | { 10 | 11 | rinkeby prizepools that dont have a prizeStrategy on rinkeby-staging. -------------------------------------------------------------------------------- /abis/v3_1_0/abis/TokenListenerLibrary.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "ERC165_INTERFACE_ID_TOKEN_LISTENER", 5 | "outputs": [ 6 | { 7 | "internalType": "bytes4", 8 | "name": "", 9 | "type": "bytes4" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | } 15 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/PeriodicPrizeStrategyDistributorInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "randomNumber", 7 | "type": "uint256" 8 | } 9 | ], 10 | "name": "distribute", 11 | "outputs": [], 12 | "stateMutability": "nonpayable", 13 | "type": "function" 14 | } 15 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/PeriodicPrizeStrategyListenerLibrary.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "ERC165_INTERFACE_ID_PERIODIC_PRIZE_STRATEGY_LISTENER", 5 | "outputs": [ 6 | { 7 | "internalType": "bytes4", 8 | "name": "", 9 | "type": "bytes4" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | } 15 | ] -------------------------------------------------------------------------------- /src/mappingForControlledTokenProxyFactory.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ProxyCreated, 3 | } from '../generated/ControlledTokenProxyFactory/ControlledTokenProxyFactory' 4 | 5 | import { 6 | ControlledToken as ControlledTokenTemplate, 7 | } from '../generated/templates' 8 | 9 | export function handleProxyCreated(event: ProxyCreated): void { 10 | ControlledTokenTemplate.create(event.params.proxy) 11 | } 12 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/TicketInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "randomNumber", 7 | "type": "uint256" 8 | } 9 | ], 10 | "name": "draw", 11 | "outputs": [ 12 | { 13 | "internalType": "address", 14 | "name": "", 15 | "type": "address" 16 | } 17 | ], 18 | "stateMutability": "view", 19 | "type": "function" 20 | } 21 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ERC165Upgradeable.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "bytes4", 6 | "name": "interfaceId", 7 | "type": "bytes4" 8 | } 9 | ], 10 | "name": "supportsInterface", 11 | "outputs": [ 12 | { 13 | "internalType": "bool", 14 | "name": "", 15 | "type": "bool" 16 | } 17 | ], 18 | "stateMutability": "view", 19 | "type": "function" 20 | } 21 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/IERC165Upgradeable.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "bytes4", 6 | "name": "interfaceId", 7 | "type": "bytes4" 8 | } 9 | ], 10 | "name": "supportsInterface", 11 | "outputs": [ 12 | { 13 | "internalType": "bool", 14 | "name": "", 15 | "type": "bool" 16 | } 17 | ], 18 | "stateMutability": "view", 19 | "type": "function" 20 | } 21 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ReserveInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "prizePool", 7 | "type": "address" 8 | } 9 | ], 10 | "name": "reserveRateMantissa", 11 | "outputs": [ 12 | { 13 | "internalType": "uint256", 14 | "name": "", 15 | "type": "uint256" 16 | } 17 | ], 18 | "stateMutability": "view", 19 | "type": "function" 20 | } 21 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/PrizePoolBuilder.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": true, 7 | "internalType": "address", 8 | "name": "creator", 9 | "type": "address" 10 | }, 11 | { 12 | "indexed": true, 13 | "internalType": "address", 14 | "name": "prizePool", 15 | "type": "address" 16 | } 17 | ], 18 | "name": "PrizePoolCreated", 19 | "type": "event" 20 | } 21 | ] -------------------------------------------------------------------------------- /src/mappingForTicketProxyFactory.ts: -------------------------------------------------------------------------------- 1 | import { log } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | ProxyCreated 5 | } from '../generated/TicketProxyFactory/TicketProxyFactory' 6 | 7 | import { 8 | ControlledToken as ControlledTokenTemplate 9 | } from '../generated/templates' 10 | 11 | export function handleProxyCreated(event: ProxyCreated): void { 12 | log.warning("TicketProxyFactory created {}", [event.params.proxy.toHexString()]) 13 | ControlledTokenTemplate.create(event.params.proxy) 14 | } 15 | -------------------------------------------------------------------------------- /src/helpers/common.ts: -------------------------------------------------------------------------------- 1 | import { BigInt } from '@graphprotocol/graph-ts' 2 | 3 | export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" 4 | 5 | export const ZERO = BigInt.fromI32(0) 6 | export const ONE = BigInt.fromI32(1) 7 | 8 | export function generateCompositeId(key1: string , key2: string) : string { 9 | return key1 + "-" + key2 10 | } 11 | 12 | export function generateAwardedControlledTokenCompositeId(key1: string , key2: string, key3: string, key4: string) : string { 13 | return key1 + "-" + key2 + "-" + key3 + "-" + key4 14 | } -------------------------------------------------------------------------------- /src/helpers/loadOrCreatePrizeStrategy.ts: -------------------------------------------------------------------------------- 1 | import { Address } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | PrizeStrategy, 5 | } from '../../generated/schema' 6 | 7 | export function loadOrCreatePrizeStrategy( 8 | prizeStrategy: Address 9 | ): PrizeStrategy { 10 | let _prizeStrategy = PrizeStrategy.load(prizeStrategy.toHex()) 11 | 12 | if (!_prizeStrategy) { 13 | // Create PrizeStrategy Link 14 | _prizeStrategy = new PrizeStrategy(prizeStrategy.toHex()) 15 | _prizeStrategy.save() 16 | } 17 | 18 | return _prizeStrategy as PrizeStrategy 19 | } 20 | -------------------------------------------------------------------------------- /src/mappingForStakePrizePoolProxyFactory.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ProxyCreated, 3 | } from '../generated/StakePrizePoolProxyFactory/StakePrizePoolProxyFactory' 4 | 5 | import { 6 | PrizePool as PrizePoolTemplate, 7 | StakePrizePool as StakePrizeTemplate, 8 | } from '../generated/templates' 9 | 10 | export function handleStakePrizePoolCreated(event: ProxyCreated): void { 11 | // Start listening for events from the dynamically generated contract 12 | PrizePoolTemplate.create(event.params.proxy) 13 | StakePrizeTemplate.create(event.params.proxy) 14 | } 15 | -------------------------------------------------------------------------------- /src/mappingForYieldSourcePrizePool.ts: -------------------------------------------------------------------------------- 1 | import { 2 | YieldSourcePrizePoolInitialized, 3 | } from '../generated/templates/YieldSourcePrizePool/YieldSourcePrizePool' 4 | 5 | import { loadOrCreateYieldSourcePrizePool } from './helpers/loadOrCreateYieldSourcePrizePool' 6 | 7 | export function handleYieldSourcePrizePoolInitialized(event: YieldSourcePrizePoolInitialized): void { 8 | const _yieldSourcePrizePool = loadOrCreateYieldSourcePrizePool(event.address) 9 | _yieldSourcePrizePool.yieldSource = event.params.yieldSource 10 | _yieldSourcePrizePool.save() 11 | } 12 | -------------------------------------------------------------------------------- /src/mappingForYieldSourcePrizePoolProxyFactory.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ProxyCreated, 3 | } from "../generated/YieldSourcePrizePoolProxyFactory/YieldSourcePrizePoolProxyFactory" 4 | 5 | import { 6 | 7 | PrizePool as PrizePoolTemplate, 8 | YieldSourcePrizePool as YieldSourcePrizePoolTemplate, 9 | } from '../generated/templates' 10 | 11 | export function handleProxyCreated(event: ProxyCreated): void { 12 | // Start listening for events from the dynamically generated contract 13 | PrizePoolTemplate.create(event.params.proxy) 14 | YieldSourcePrizePoolTemplate.create(event.params.proxy) 15 | } 16 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/TokenControllerInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "from", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "to", 12 | "type": "address" 13 | }, 14 | { 15 | "internalType": "uint256", 16 | "name": "amount", 17 | "type": "uint256" 18 | } 19 | ], 20 | "name": "beforeTokenTransfer", 21 | "outputs": [], 22 | "stateMutability": "nonpayable", 23 | "type": "function" 24 | } 25 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/IERC1820ImplementerUpgradeable.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "bytes32", 6 | "name": "interfaceHash", 7 | "type": "bytes32" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "account", 12 | "type": "address" 13 | } 14 | ], 15 | "name": "canImplementInterfaceForAddress", 16 | "outputs": [ 17 | { 18 | "internalType": "bytes32", 19 | "name": "", 20 | "type": "bytes32" 21 | } 22 | ], 23 | "stateMutability": "view", 24 | "type": "function" 25 | } 26 | ] -------------------------------------------------------------------------------- /src/mappingForStakePrizePool.ts: -------------------------------------------------------------------------------- 1 | 2 | import { log } from '@graphprotocol/graph-ts' 3 | import { 4 | StakePrizePoolInitialized, 5 | } from '../generated/templates/StakePrizePool/StakePrizePool' 6 | 7 | import { loadOrCreateStakePrizePool } from './helpers/loadOrCreateStakePrizePool' 8 | 9 | export function handleStakePrizePoolInitialized(event: StakePrizePoolInitialized): void { 10 | log.warning("initializing stake pool for {} ", [event.address.toHex()]) 11 | const _stakePrizePool = loadOrCreateStakePrizePool(event.address) 12 | _stakePrizePool.stakeToken = event.params.stakeToken 13 | _stakePrizePool.save() 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/helpers/loadOrCreatePrize.ts: -------------------------------------------------------------------------------- 1 | import { Prize } from '../../generated/schema' 2 | import { ZERO } from './common' 3 | 4 | import { prizeId } from './idTemplates' 5 | 6 | export function loadOrCreatePrize(prizePoolAddress: string, currentPrizeId: string): Prize { 7 | const id = prizeId( 8 | prizePoolAddress, 9 | currentPrizeId 10 | ) 11 | let prize = Prize.load(id) 12 | 13 | if (!prize) { 14 | prize = new Prize(id) 15 | prize.prizePool = prizePoolAddress 16 | prize.numberOfSubWinners = ZERO 17 | prize.numberOfExternalAwardedErc20Winners = ZERO 18 | prize.save() 19 | } 20 | return prize as Prize 21 | } 22 | -------------------------------------------------------------------------------- /src/mappingForCompoundPrizePoolProxyFactory.ts: -------------------------------------------------------------------------------- 1 | 2 | import { 3 | ProxyCreated, 4 | } from '../generated/CompoundPrizePoolProxyFactory/CompoundPrizePoolProxyFactory' 5 | 6 | import { 7 | PrizePool as PrizePoolTemplate, 8 | CompoundPrizePool as CompoundPrizePoolTemplate, 9 | } from '../generated/templates' 10 | 11 | export function handleProxyCreated(event: ProxyCreated): void { 12 | // Start listening for events from the dynamically generated contract 13 | // PrizePoolV3Template.create(event.params.proxy) 14 | PrizePoolTemplate.create(event.params.proxy) 15 | CompoundPrizePoolTemplate.create(event.params.proxy) 16 | } -------------------------------------------------------------------------------- /src/helpers/loadOrCreatePrizeSplit.ts: -------------------------------------------------------------------------------- 1 | import { Address } from '@graphprotocol/graph-ts' 2 | import { PrizeSplit } from '../../generated/schema' 3 | import { ZERO, ZERO_ADDRESS } from './common' 4 | 5 | export function loadOrCreatePrizeSplit(prizeStrategy: string, index: string): PrizeSplit { 6 | const id = prizeStrategy + "-" + "-" + index.toString() 7 | let prizeSplit = PrizeSplit.load(id) 8 | 9 | if (!prizeSplit) { 10 | prizeSplit = new PrizeSplit(id) 11 | prizeSplit.target = Address.fromString(ZERO_ADDRESS) 12 | prizeSplit.tokenType = ZERO 13 | prizeSplit.percentage = ZERO 14 | prizeSplit.save() 15 | } 16 | return prizeSplit as PrizeSplit 17 | } 18 | -------------------------------------------------------------------------------- /src/mappingForCompoundPrizePool.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CompoundPrizePoolInitialized, 3 | } from '../generated/templates/CompoundPrizePool/CompoundPrizePool' // but any should do since its the same event for all 4 | 5 | import { loadOrCreateCompoundPrizePool } from './helpers/loadOrCreateCompoundPrizePool' 6 | 7 | // the initialised event is the same for all compound prize pools so just one handler required 8 | // called form the data source template 9 | 10 | export function handleCompoundPrizePoolInitialized(event: CompoundPrizePoolInitialized): void { 11 | const _compoundPrizePool = loadOrCreateCompoundPrizePool(event.address) 12 | _compoundPrizePool.cToken = event.params.cToken 13 | _compoundPrizePool.save() 14 | } 15 | -------------------------------------------------------------------------------- /src/mappingForSablierStreamManager.ts: -------------------------------------------------------------------------------- 1 | import { store } from "@graphprotocol/graph-ts" 2 | import { SablierStreamCreated, SablierStreamCancelled } from "../generated/SablierManager/SablierManager" 3 | import { loadOrCreateSablierStream } from "./helpers/loadOrCreateSablierStream" 4 | 5 | export function handleSablierStreamCreated(event: SablierStreamCreated): void { 6 | const stream = loadOrCreateSablierStream(event.params.streamId.toHexString()) 7 | stream.prizePool = event.params.prizePool.toHexString() 8 | stream.save() 9 | } 10 | 11 | export function handleSablierStreamCancelled(event: SablierStreamCancelled): void { 12 | const stream = loadOrCreateSablierStream(event.params.streamId.toHexString()) 13 | store.remove("SablierStream", stream.id) 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/helpers/loadOrCreatePrizePoolAccount.ts: -------------------------------------------------------------------------------- 1 | import { log, Address } from '@graphprotocol/graph-ts' 2 | import {PrizePoolAccount} from "../../generated/schema" 3 | import {generateCompositeId, ZERO} from "./common" 4 | 5 | export function loadOrCreatePrizePoolAccount( 6 | prizePool: Address, 7 | account: string 8 | ): PrizePoolAccount { 9 | let prizePoolAccount = PrizePoolAccount.load(generateCompositeId(prizePool.toHex(),account)) 10 | if(!prizePoolAccount){ // create 11 | prizePoolAccount = new PrizePoolAccount(generateCompositeId(prizePool.toHex(),account)) 12 | prizePoolAccount.prizePool = prizePool.toHex() 13 | prizePoolAccount.account = account 14 | 15 | prizePoolAccount.save() 16 | } 17 | return prizePoolAccount as PrizePoolAccount 18 | } 19 | 20 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/IERC721ReceiverUpgradeable.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "operator", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "from", 12 | "type": "address" 13 | }, 14 | { 15 | "internalType": "uint256", 16 | "name": "tokenId", 17 | "type": "uint256" 18 | }, 19 | { 20 | "internalType": "bytes", 21 | "name": "data", 22 | "type": "bytes" 23 | } 24 | ], 25 | "name": "onERC721Received", 26 | "outputs": [ 27 | { 28 | "internalType": "bytes4", 29 | "name": "", 30 | "type": "bytes4" 31 | } 32 | ], 33 | "stateMutability": "nonpayable", 34 | "type": "function" 35 | } 36 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/UInt256ArrayExposed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256[]", 6 | "name": "_array", 7 | "type": "uint256[]" 8 | } 9 | ], 10 | "stateMutability": "nonpayable", 11 | "type": "constructor" 12 | }, 13 | { 14 | "inputs": [ 15 | { 16 | "internalType": "uint256", 17 | "name": "index", 18 | "type": "uint256" 19 | } 20 | ], 21 | "name": "remove", 22 | "outputs": [], 23 | "stateMutability": "nonpayable", 24 | "type": "function" 25 | }, 26 | { 27 | "inputs": [], 28 | "name": "toArray", 29 | "outputs": [ 30 | { 31 | "internalType": "uint256[]", 32 | "name": "", 33 | "type": "uint256[]" 34 | } 35 | ], 36 | "stateMutability": "view", 37 | "type": "function" 38 | } 39 | ] -------------------------------------------------------------------------------- /src/helpers/loadOrCreatePrizePoolCreditRate.ts: -------------------------------------------------------------------------------- 1 | import { Address } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | CreditRate, 5 | } from '../../generated/schema' 6 | 7 | import { 8 | creditRateId, 9 | } from './idTemplates' 10 | 11 | import { ZERO } from './common' 12 | 13 | 14 | export function loadOrCreatePrizePoolCreditRate( 15 | prizePool: Address, 16 | controlledToken: Address, 17 | ): CreditRate { 18 | const _creditRateId = creditRateId(prizePool.toHex(), controlledToken.toHex()) 19 | let _creditRate = CreditRate.load(_creditRateId) 20 | if (!_creditRate) { 21 | _creditRate = new CreditRate(_creditRateId) 22 | 23 | _creditRate.prizePool = prizePool.toHex() 24 | _creditRate.creditLimitMantissa = ZERO 25 | _creditRate.creditRateMantissa = ZERO 26 | 27 | _creditRate.save() 28 | } 29 | return _creditRate as CreditRate 30 | } 31 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ExtendedSafeCastExposed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "value", 7 | "type": "uint256" 8 | } 9 | ], 10 | "name": "toUint112", 11 | "outputs": [ 12 | { 13 | "internalType": "uint112", 14 | "name": "", 15 | "type": "uint112" 16 | } 17 | ], 18 | "stateMutability": "pure", 19 | "type": "function" 20 | }, 21 | { 22 | "inputs": [ 23 | { 24 | "internalType": "uint256", 25 | "name": "value", 26 | "type": "uint256" 27 | } 28 | ], 29 | "name": "toUint96", 30 | "outputs": [ 31 | { 32 | "internalType": "uint96", 33 | "name": "", 34 | "type": "uint96" 35 | } 36 | ], 37 | "stateMutability": "pure", 38 | "type": "function" 39 | } 40 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "address", 8 | "name": "proxy", 9 | "type": "address" 10 | } 11 | ], 12 | "name": "ProxyCreated", 13 | "type": "event" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "address", 19 | "name": "_logic", 20 | "type": "address" 21 | }, 22 | { 23 | "internalType": "bytes", 24 | "name": "_data", 25 | "type": "bytes" 26 | } 27 | ], 28 | "name": "deployMinimal", 29 | "outputs": [ 30 | { 31 | "internalType": "address", 32 | "name": "proxy", 33 | "type": "address" 34 | } 35 | ], 36 | "stateMutability": "nonpayable", 37 | "type": "function" 38 | } 39 | ] -------------------------------------------------------------------------------- /networks/bsc.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "bsc", 3 | "compoundPrizePoolProxyFactory": { 4 | "address": "0xaFcEa072BcBad91029A2bA0b37bAC8269dd4f5E6", 5 | "startBlock": "9218895" 6 | }, 7 | "controlledTokenProxyFactory": { 8 | "address": "0x317625b28Acb3C0540DB00b179D84D9b804277f7", 9 | "startBlock": "9218902" 10 | }, 11 | "multipleWinnersProxyFactory": { 12 | "address": "0x53A2E4F8BFe581bC28e0d1d30808ffB163E53A46", 13 | "startBlock": "9218912" 14 | }, 15 | "ticketProxyFactory": { 16 | "address": "0x72Edd573E230C7d68274Bf718A4C6aD82b5d5f90", 17 | "startBlock": "9218905" 18 | }, 19 | "stakePrizePoolProxyFactory": { 20 | "address": "0x5effa0823e486A5ED1D49d88A1374Fc337e1f9F4", 21 | "startBlock": "9218909" 22 | }, 23 | "yieldSourcePrizePoolProxyFactory": { 24 | "address": "0xdc488E6e8c55a11d20032997cd1fF7c4951401df", 25 | "startBlock": "9218898" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /networks/celo.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "celo", 3 | "compoundPrizePoolProxyFactory": { 4 | "address": "0x03e75AeEB92adD6f3b168412671360eB94f0dBf7", 5 | "startBlock": "8453649" 6 | }, 7 | "controlledTokenProxyFactory": { 8 | "address": "0xa6358441F68eD4707E1c4366a0D2E2233bB4841D", 9 | "startBlock": "8453653" 10 | }, 11 | "multipleWinnersProxyFactory": { 12 | "address": "0x6dc7cA9e2c19Da475B39cce7437994c1725d85C9", 13 | "startBlock": "8453656" 14 | }, 15 | "ticketProxyFactory": { 16 | "address": "0xCB876f60399897db24058b2d58D0B9f713175eeF", 17 | "startBlock": "8453654" 18 | }, 19 | "stakePrizePoolProxyFactory": { 20 | "address": "0xef3d36A282e74b5bcba8a45262687DDb31495Cd2", 21 | "startBlock": "8453655" 22 | }, 23 | "yieldSourcePrizePoolProxyFactory": { 24 | "address": "0xc79B5D46f010c88f738A00B3bed7757d04dd2a37", 25 | "startBlock": "8453651" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /networks/rinkeby.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "rinkeby", 3 | "compoundPrizePoolProxyFactory": { 4 | "address": "0x766b62E17AE78d095D3505d779741B1b5647d773", 5 | "startBlock": "8948891" 6 | }, 7 | "controlledTokenProxyFactory": { 8 | "address": "0xD477FF7Db0C75C859eA866F4986e73B6057e7590", 9 | "startBlock": "8948893" 10 | }, 11 | "multipleWinnersProxyFactory": { 12 | "address": "0x0C52e524B139d38Eb6fd50395700fc1f7b59C14E", 13 | "startBlock": "8948896" 14 | }, 15 | "ticketProxyFactory": { 16 | "address": "0x5ef5FA5A04665165753239CEdF87cb3ee0D3ab86", 17 | "startBlock": "8948894" 18 | }, 19 | "stakePrizePoolProxyFactory": { 20 | "address": "0x2318b6B9C517cb42D2efaF61195966f8Dc073758", 21 | "startBlock": "8948895" 22 | }, 23 | "yieldSourcePrizePoolProxyFactory": { 24 | "address": "0xD6073119B123859A0e390865A5630E0bB4E2670C", 25 | "startBlock": "8948892" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/PeriodicPrizeStrategyListener.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "randomNumber", 7 | "type": "uint256" 8 | }, 9 | { 10 | "internalType": "uint256", 11 | "name": "prizePeriodStartedAt", 12 | "type": "uint256" 13 | } 14 | ], 15 | "name": "afterPrizePoolAwarded", 16 | "outputs": [], 17 | "stateMutability": "nonpayable", 18 | "type": "function" 19 | }, 20 | { 21 | "inputs": [ 22 | { 23 | "internalType": "bytes4", 24 | "name": "interfaceId", 25 | "type": "bytes4" 26 | } 27 | ], 28 | "name": "supportsInterface", 29 | "outputs": [ 30 | { 31 | "internalType": "bool", 32 | "name": "", 33 | "type": "bool" 34 | } 35 | ], 36 | "stateMutability": "view", 37 | "type": "function" 38 | } 39 | ] -------------------------------------------------------------------------------- /networks/mainnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "mainnet", 3 | "compoundPrizePoolProxyFactory": { 4 | "address": "0xFb92015f58B239296c9F13003b75D3B7CFB1111e", 5 | "startBlock": "12841066" 6 | }, 7 | "controlledTokenProxyFactory": { 8 | "address": "0x97CBd3708CC001a8F7D1c4bC89936207F1FC70C7", 9 | "startBlock": "12841069" 10 | }, 11 | "multipleWinnersProxyFactory": { 12 | "address": "0xb789B73ebeA500e797C068C4a3D7B1b490B58475", 13 | "startBlock": "12841075" 14 | }, 15 | "ticketProxyFactory": { 16 | "address": "0x67581cC48320d7Ab4EbA57e26D05d665a0Ff31DB", 17 | "startBlock": "12841070" 18 | }, 19 | "stakePrizePoolProxyFactory": { 20 | "address": "0x166F6240a5560a34352b054468Deb85042c85142", 21 | "startBlock": "12841072" 22 | }, 23 | "yieldSourcePrizePoolProxyFactory": { 24 | "address": "0x0835c8C4Ab282B5dBF06d59E1489eF17F1c40D96", 25 | "startBlock": "12841067" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /networks/polygon.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "matic", 3 | "compoundPrizePoolProxyFactory": { 4 | "address": "0x20b0bBDe753A85860dAe49130C33452bffBec8A0", 5 | "startBlock": "16940709" 6 | }, 7 | "controlledTokenProxyFactory": { 8 | "address": "0xAa4e28Ead244B439eB670986DdF3F084522Dc4f9", 9 | "startBlock": "16940717" 10 | }, 11 | "multipleWinnersProxyFactory": { 12 | "address": "0xF3317f7D9F6479eb8D2633c30C555Aa09Bd07cc7", 13 | "startBlock": "16940730" 14 | }, 15 | "ticketProxyFactory": { 16 | "address": "0xd08a60b0A41a1282efCCEEf13CE187F848549170", 17 | "startBlock": "16940721" 18 | }, 19 | "stakePrizePoolProxyFactory": { 20 | "address": "0x97762742Aea8CC2C54c368AACB9E1bf8aAD8F17b", 21 | "startBlock": "16940726" 22 | }, 23 | "yieldSourcePrizePoolProxyFactory": { 24 | "address": "0x447838A9A11F7190C9F7E65C43bE685CD8109962", 25 | "startBlock": "16940713" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/PeriodicPrizeStrategyListenerInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "randomNumber", 7 | "type": "uint256" 8 | }, 9 | { 10 | "internalType": "uint256", 11 | "name": "prizePeriodStartedAt", 12 | "type": "uint256" 13 | } 14 | ], 15 | "name": "afterPrizePoolAwarded", 16 | "outputs": [], 17 | "stateMutability": "nonpayable", 18 | "type": "function" 19 | }, 20 | { 21 | "inputs": [ 22 | { 23 | "internalType": "bytes4", 24 | "name": "interfaceId", 25 | "type": "bytes4" 26 | } 27 | ], 28 | "name": "supportsInterface", 29 | "outputs": [ 30 | { 31 | "internalType": "bool", 32 | "name": "", 33 | "type": "bool" 34 | } 35 | ], 36 | "stateMutability": "view", 37 | "type": "function" 38 | } 39 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/IERC777RecipientUpgradeable.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "operator", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "from", 12 | "type": "address" 13 | }, 14 | { 15 | "internalType": "address", 16 | "name": "to", 17 | "type": "address" 18 | }, 19 | { 20 | "internalType": "uint256", 21 | "name": "amount", 22 | "type": "uint256" 23 | }, 24 | { 25 | "internalType": "bytes", 26 | "name": "userData", 27 | "type": "bytes" 28 | }, 29 | { 30 | "internalType": "bytes", 31 | "name": "operatorData", 32 | "type": "bytes" 33 | } 34 | ], 35 | "name": "tokensReceived", 36 | "outputs": [], 37 | "stateMutability": "nonpayable", 38 | "type": "function" 39 | } 40 | ] -------------------------------------------------------------------------------- /src/helpers/loadOrCreateStakePrizePool.ts: -------------------------------------------------------------------------------- 1 | import { log, Address } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | StakePrizePool, 5 | } from '../../generated/schema' 6 | import { ONE, ZERO } from './common' 7 | 8 | import { loadOrCreatePrizePool } from './loadOrCreatePrizePool' 9 | 10 | 11 | export function loadOrCreateStakePrizePool( 12 | prizePool: Address 13 | ): StakePrizePool { 14 | let _stakePrizePool = StakePrizePool.load(prizePool.toHex()) 15 | if (!_stakePrizePool) { 16 | log.warning("debug7623 creating stakeprizepool {} ",[prizePool.toHexString()]) 17 | _stakePrizePool = new StakePrizePool(prizePool.toHex()) 18 | 19 | const _prizePool = loadOrCreatePrizePool(prizePool) 20 | _prizePool.prizePoolType = 'Stake' 21 | 22 | _prizePool.stakePrizePool = _stakePrizePool.id 23 | _prizePool.currentPrizeId = ONE 24 | _prizePool.save() 25 | _stakePrizePool.save() 26 | 27 | } 28 | 29 | return _stakePrizePool as StakePrizePool 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 PoolTogether LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /src/helpers/loadOrCreateAwardedControlledToken.ts: -------------------------------------------------------------------------------- 1 | import { Address } from '@graphprotocol/graph-ts' 2 | import { AwardedControlledToken } from '../../generated/schema' 3 | import { generateAwardedControlledTokenCompositeId, ZERO } from './common' 4 | 5 | 6 | export function loadOrCreateAwardedControlledToken(prizePoolAddress: string, winner: Address, currentPrizePoolId: string, winnerIndex: string): AwardedControlledToken { 7 | let awardedControlledToken = AwardedControlledToken.load(generateAwardedControlledTokenCompositeId(prizePoolAddress, winner.toHexString(),currentPrizePoolId, winnerIndex)) 8 | if(!awardedControlledToken){ // create new 9 | awardedControlledToken = new AwardedControlledToken(generateAwardedControlledTokenCompositeId(prizePoolAddress, winner.toHexString(),currentPrizePoolId, winnerIndex)) 10 | awardedControlledToken.winner = winner 11 | // temp values 12 | awardedControlledToken.amount = ZERO 13 | awardedControlledToken.token = null 14 | } 15 | 16 | return awardedControlledToken as AwardedControlledToken 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/helpers/loadOrCreateCompoundPrizePool.ts: -------------------------------------------------------------------------------- 1 | import { log, Address } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | CompoundPrizePool, 5 | } from '../../generated/schema' 6 | 7 | import { 8 | CompoundPrizePool as CompoundPrizePoolContract, 9 | } from '../../generated/templates/CompoundPrizePool/CompoundPrizePool' 10 | 11 | import { loadOrCreatePrizePool } from './loadOrCreatePrizePool' 12 | 13 | 14 | export function loadOrCreateCompoundPrizePool( 15 | prizePool: Address 16 | ): CompoundPrizePool { 17 | let _compoundPrizePool = CompoundPrizePool.load(prizePool.toHex()) 18 | if (!_compoundPrizePool) { 19 | _compoundPrizePool = new CompoundPrizePool(prizePool.toHex()) 20 | 21 | const _prizePool = loadOrCreatePrizePool(prizePool) 22 | _prizePool.prizePoolType = 'Compound' 23 | _prizePool.compoundPrizePool = _compoundPrizePool.id 24 | _prizePool.save() 25 | 26 | const _boundCompoundPrizePool = CompoundPrizePoolContract.bind(prizePool) 27 | _compoundPrizePool.cToken = _boundCompoundPrizePool.cToken() 28 | _compoundPrizePool.save() 29 | 30 | } 31 | 32 | return _compoundPrizePool as CompoundPrizePool 33 | } 34 | -------------------------------------------------------------------------------- /src/helpers/loadOrCreateYieldSourcePrizePool.ts: -------------------------------------------------------------------------------- 1 | import { log, Address } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | YieldSourcePrizePool, 5 | } from '../../generated/schema' 6 | 7 | import { 8 | YieldSourcePrizePool as YieldSourcePrizePoolContract 9 | } from '../../generated/templates/YieldSourcePrizePool/YieldSourcePrizePool' 10 | 11 | import { loadOrCreatePrizePool } from './loadOrCreatePrizePool' 12 | 13 | 14 | export function loadOrCreateYieldSourcePrizePool( 15 | prizePool: Address 16 | ): YieldSourcePrizePool { 17 | let _yieldSourcePrizePool = YieldSourcePrizePool.load(prizePool.toHex()) 18 | if (!_yieldSourcePrizePool) { 19 | _yieldSourcePrizePool = new YieldSourcePrizePool(prizePool.toHex()) 20 | 21 | const _prizePool = loadOrCreatePrizePool(prizePool) 22 | _prizePool.prizePoolType = 'YieldSource' 23 | _prizePool.yieldSourcePrizePool = _yieldSourcePrizePool.id 24 | _prizePool.save() 25 | 26 | 27 | const _boundYieldSourcePrizePool = YieldSourcePrizePoolContract.bind(prizePool) 28 | _yieldSourcePrizePool.yieldSource = _boundYieldSourcePrizePool.yieldSource() 29 | _yieldSourcePrizePool.save() 30 | 31 | } 32 | 33 | return _yieldSourcePrizePool as YieldSourcePrizePool 34 | } 35 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ComptrollerStorage.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": true, 7 | "internalType": "address", 8 | "name": "previousOwner", 9 | "type": "address" 10 | }, 11 | { 12 | "indexed": true, 13 | "internalType": "address", 14 | "name": "newOwner", 15 | "type": "address" 16 | } 17 | ], 18 | "name": "OwnershipTransferred", 19 | "type": "event" 20 | }, 21 | { 22 | "inputs": [], 23 | "name": "owner", 24 | "outputs": [ 25 | { 26 | "internalType": "address", 27 | "name": "", 28 | "type": "address" 29 | } 30 | ], 31 | "stateMutability": "view", 32 | "type": "function" 33 | }, 34 | { 35 | "inputs": [], 36 | "name": "renounceOwnership", 37 | "outputs": [], 38 | "stateMutability": "nonpayable", 39 | "type": "function" 40 | }, 41 | { 42 | "inputs": [ 43 | { 44 | "internalType": "address", 45 | "name": "newOwner", 46 | "type": "address" 47 | } 48 | ], 49 | "name": "transferOwnership", 50 | "outputs": [], 51 | "stateMutability": "nonpayable", 52 | "type": "function" 53 | } 54 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/OwnableUpgradeable.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": true, 7 | "internalType": "address", 8 | "name": "previousOwner", 9 | "type": "address" 10 | }, 11 | { 12 | "indexed": true, 13 | "internalType": "address", 14 | "name": "newOwner", 15 | "type": "address" 16 | } 17 | ], 18 | "name": "OwnershipTransferred", 19 | "type": "event" 20 | }, 21 | { 22 | "inputs": [], 23 | "name": "owner", 24 | "outputs": [ 25 | { 26 | "internalType": "address", 27 | "name": "", 28 | "type": "address" 29 | } 30 | ], 31 | "stateMutability": "view", 32 | "type": "function" 33 | }, 34 | { 35 | "inputs": [], 36 | "name": "renounceOwnership", 37 | "outputs": [], 38 | "stateMutability": "nonpayable", 39 | "type": "function" 40 | }, 41 | { 42 | "inputs": [ 43 | { 44 | "internalType": "address", 45 | "name": "newOwner", 46 | "type": "address" 47 | } 48 | ], 49 | "name": "transferOwnership", 50 | "outputs": [], 51 | "stateMutability": "nonpayable", 52 | "type": "function" 53 | } 54 | ] -------------------------------------------------------------------------------- /src/mappingForMultipleWinnersProxyFactory.ts: -------------------------------------------------------------------------------- 1 | import { BigInt, log } from '@graphprotocol/graph-ts' 2 | 3 | import { ProxyCreated } from "../generated/MultipleWinnersProxyFactory/MultipleWinnersProxyFactory" 4 | 5 | import { loadOrCreatePrizeStrategy } from './helpers/loadOrCreatePrizeStrategy' 6 | 7 | import { 8 | MultipleWinnersPrizeStrategy 9 | } from '../generated/schema' 10 | 11 | import { MultipleWinners } from "../generated/templates" 12 | 13 | export function handleMultipleWinnersCreated(event: ProxyCreated) : void{ 14 | const address = event.params.proxy.toHexString() 15 | 16 | 17 | log.info("debug771 creating a MWPrizeStrategy for {}", [address]) 18 | 19 | const multipleWinners = new MultipleWinnersPrizeStrategy(address) 20 | 21 | // set fields to blank/generic for now - Initialized event called straight after 22 | multipleWinners.prizePeriodSeconds = new BigInt(0) 23 | multipleWinners.prizePeriodStartedAt = new BigInt(0) 24 | multipleWinners.prizePeriodEndAt = new BigInt(0) 25 | 26 | multipleWinners.save() 27 | 28 | let prizeStrategy = loadOrCreatePrizeStrategy(event.params.proxy) 29 | prizeStrategy.multipleWinners = multipleWinners.id 30 | prizeStrategy.save() 31 | 32 | 33 | // creating multiple templates 34 | MultipleWinners.create(event.params.proxy) 35 | 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/OpenZeppelinProxyFactoryInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "_salt", 7 | "type": "uint256" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "_logic", 12 | "type": "address" 13 | }, 14 | { 15 | "internalType": "address", 16 | "name": "_admin", 17 | "type": "address" 18 | }, 19 | { 20 | "internalType": "bytes", 21 | "name": "_data", 22 | "type": "bytes" 23 | } 24 | ], 25 | "name": "deploy", 26 | "outputs": [ 27 | { 28 | "internalType": "address", 29 | "name": "", 30 | "type": "address" 31 | } 32 | ], 33 | "stateMutability": "nonpayable", 34 | "type": "function" 35 | }, 36 | { 37 | "inputs": [ 38 | { 39 | "internalType": "uint256", 40 | "name": "_salt", 41 | "type": "uint256" 42 | }, 43 | { 44 | "internalType": "address", 45 | "name": "_sender", 46 | "type": "address" 47 | } 48 | ], 49 | "name": "getDeploymentAddress", 50 | "outputs": [ 51 | { 52 | "internalType": "address", 53 | "name": "", 54 | "type": "address" 55 | } 56 | ], 57 | "stateMutability": "view", 58 | "type": "function" 59 | } 60 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/TicketProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract Ticket", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract Ticket", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ControlledTokenProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract ControlledToken", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract ControlledToken", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/MultipleWinnersProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract MultipleWinners", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract MultipleWinners", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/StakePrizePoolProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract StakePrizePool", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract StakePrizePool", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/yVaultPrizePoolProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract yVaultPrizePool", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract yVaultPrizePool", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/CompoundPrizePoolProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract CompoundPrizePool", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract CompoundPrizePool", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/SingleRandomWinnerProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract SingleRandomWinner", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract SingleRandomWinner", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_2_0/abis/CompoundPrizePoolProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract CompoundPrizePool", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract CompoundPrizePool", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] 71 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/MultipleWinnersHarnessProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract MultipleWinnersHarness", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract MultipleWinnersHarness", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/yVaultPrizePoolHarnessProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract yVaultPrizePoolHarness", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract yVaultPrizePoolHarness", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/CompoundPrizePoolHarnessProxyFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": false, 12 | "internalType": "address", 13 | "name": "proxy", 14 | "type": "address" 15 | } 16 | ], 17 | "name": "ProxyCreated", 18 | "type": "event" 19 | }, 20 | { 21 | "inputs": [], 22 | "name": "create", 23 | "outputs": [ 24 | { 25 | "internalType": "contract CompoundPrizePoolHarness", 26 | "name": "", 27 | "type": "address" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "inputs": [ 35 | { 36 | "internalType": "address", 37 | "name": "_logic", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "bytes", 42 | "name": "_data", 43 | "type": "bytes" 44 | } 45 | ], 46 | "name": "deployMinimal", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "proxy", 51 | "type": "address" 52 | } 53 | ], 54 | "stateMutability": "nonpayable", 55 | "type": "function" 56 | }, 57 | { 58 | "inputs": [], 59 | "name": "instance", 60 | "outputs": [ 61 | { 62 | "internalType": "contract CompoundPrizePoolHarness", 63 | "name": "", 64 | "type": "address" 65 | } 66 | ], 67 | "stateMutability": "view", 68 | "type": "function" 69 | } 70 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/ERC1820ImplementerMock.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "inputs": [ 9 | { 10 | "internalType": "bytes32", 11 | "name": "", 12 | "type": "bytes32" 13 | }, 14 | { 15 | "internalType": "address", 16 | "name": "", 17 | "type": "address" 18 | } 19 | ], 20 | "name": "canImplementInterfaceForAddress", 21 | "outputs": [ 22 | { 23 | "internalType": "bytes32", 24 | "name": "", 25 | "type": "bytes32" 26 | } 27 | ], 28 | "stateMutability": "view", 29 | "type": "function" 30 | }, 31 | { 32 | "inputs": [ 33 | { 34 | "internalType": "address", 35 | "name": "operator", 36 | "type": "address" 37 | }, 38 | { 39 | "internalType": "address", 40 | "name": "from", 41 | "type": "address" 42 | }, 43 | { 44 | "internalType": "address", 45 | "name": "to", 46 | "type": "address" 47 | }, 48 | { 49 | "internalType": "uint256", 50 | "name": "amount", 51 | "type": "uint256" 52 | }, 53 | { 54 | "internalType": "bytes", 55 | "name": "userData", 56 | "type": "bytes" 57 | }, 58 | { 59 | "internalType": "bytes", 60 | "name": "operatorData", 61 | "type": "bytes" 62 | } 63 | ], 64 | "name": "tokensReceived", 65 | "outputs": [], 66 | "stateMutability": "nonpayable", 67 | "type": "function" 68 | } 69 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/YieldSourceStub.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "balance", 5 | "outputs": [ 6 | { 7 | "internalType": "uint256", 8 | "name": "", 9 | "type": "uint256" 10 | } 11 | ], 12 | "stateMutability": "nonpayable", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "address", 19 | "name": "_externalToken", 20 | "type": "address" 21 | } 22 | ], 23 | "name": "canAwardExternal", 24 | "outputs": [ 25 | { 26 | "internalType": "bool", 27 | "name": "", 28 | "type": "bool" 29 | } 30 | ], 31 | "stateMutability": "view", 32 | "type": "function" 33 | }, 34 | { 35 | "inputs": [ 36 | { 37 | "internalType": "uint256", 38 | "name": "redeemAmount", 39 | "type": "uint256" 40 | } 41 | ], 42 | "name": "redeem", 43 | "outputs": [ 44 | { 45 | "internalType": "uint256", 46 | "name": "", 47 | "type": "uint256" 48 | } 49 | ], 50 | "stateMutability": "nonpayable", 51 | "type": "function" 52 | }, 53 | { 54 | "inputs": [ 55 | { 56 | "internalType": "uint256", 57 | "name": "mintAmount", 58 | "type": "uint256" 59 | } 60 | ], 61 | "name": "supply", 62 | "outputs": [], 63 | "stateMutability": "nonpayable", 64 | "type": "function" 65 | }, 66 | { 67 | "inputs": [], 68 | "name": "token", 69 | "outputs": [ 70 | { 71 | "internalType": "contract IERC20Upgradeable", 72 | "name": "", 73 | "type": "address" 74 | } 75 | ], 76 | "stateMutability": "view", 77 | "type": "function" 78 | } 79 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/TokenListener.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "to", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "uint256", 11 | "name": "amount", 12 | "type": "uint256" 13 | }, 14 | { 15 | "internalType": "address", 16 | "name": "controlledToken", 17 | "type": "address" 18 | }, 19 | { 20 | "internalType": "address", 21 | "name": "referrer", 22 | "type": "address" 23 | } 24 | ], 25 | "name": "beforeTokenMint", 26 | "outputs": [], 27 | "stateMutability": "nonpayable", 28 | "type": "function" 29 | }, 30 | { 31 | "inputs": [ 32 | { 33 | "internalType": "address", 34 | "name": "from", 35 | "type": "address" 36 | }, 37 | { 38 | "internalType": "address", 39 | "name": "to", 40 | "type": "address" 41 | }, 42 | { 43 | "internalType": "uint256", 44 | "name": "amount", 45 | "type": "uint256" 46 | }, 47 | { 48 | "internalType": "address", 49 | "name": "controlledToken", 50 | "type": "address" 51 | } 52 | ], 53 | "name": "beforeTokenTransfer", 54 | "outputs": [], 55 | "stateMutability": "nonpayable", 56 | "type": "function" 57 | }, 58 | { 59 | "inputs": [ 60 | { 61 | "internalType": "bytes4", 62 | "name": "interfaceId", 63 | "type": "bytes4" 64 | } 65 | ], 66 | "name": "supportsInterface", 67 | "outputs": [ 68 | { 69 | "internalType": "bool", 70 | "name": "", 71 | "type": "bool" 72 | } 73 | ], 74 | "stateMutability": "view", 75 | "type": "function" 76 | } 77 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/TokenListenerInterface.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "to", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "uint256", 11 | "name": "amount", 12 | "type": "uint256" 13 | }, 14 | { 15 | "internalType": "address", 16 | "name": "controlledToken", 17 | "type": "address" 18 | }, 19 | { 20 | "internalType": "address", 21 | "name": "referrer", 22 | "type": "address" 23 | } 24 | ], 25 | "name": "beforeTokenMint", 26 | "outputs": [], 27 | "stateMutability": "nonpayable", 28 | "type": "function" 29 | }, 30 | { 31 | "inputs": [ 32 | { 33 | "internalType": "address", 34 | "name": "from", 35 | "type": "address" 36 | }, 37 | { 38 | "internalType": "address", 39 | "name": "to", 40 | "type": "address" 41 | }, 42 | { 43 | "internalType": "uint256", 44 | "name": "amount", 45 | "type": "uint256" 46 | }, 47 | { 48 | "internalType": "address", 49 | "name": "controlledToken", 50 | "type": "address" 51 | } 52 | ], 53 | "name": "beforeTokenTransfer", 54 | "outputs": [], 55 | "stateMutability": "nonpayable", 56 | "type": "function" 57 | }, 58 | { 59 | "inputs": [ 60 | { 61 | "internalType": "bytes4", 62 | "name": "interfaceId", 63 | "type": "bytes4" 64 | } 65 | ], 66 | "name": "supportsInterface", 67 | "outputs": [ 68 | { 69 | "internalType": "bool", 70 | "name": "", 71 | "type": "bool" 72 | } 73 | ], 74 | "stateMutability": "view", 75 | "type": "function" 76 | } 77 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/Constants.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "ACCEPT_MAGIC", 5 | "outputs": [ 6 | { 7 | "internalType": "bytes32", 8 | "name": "", 9 | "type": "bytes32" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [], 17 | "name": "ERC165_INTERFACE_ID_ERC165", 18 | "outputs": [ 19 | { 20 | "internalType": "bytes4", 21 | "name": "", 22 | "type": "bytes4" 23 | } 24 | ], 25 | "stateMutability": "view", 26 | "type": "function" 27 | }, 28 | { 29 | "inputs": [], 30 | "name": "ERC165_INTERFACE_ID_ERC721", 31 | "outputs": [ 32 | { 33 | "internalType": "bytes4", 34 | "name": "", 35 | "type": "bytes4" 36 | } 37 | ], 38 | "stateMutability": "view", 39 | "type": "function" 40 | }, 41 | { 42 | "inputs": [], 43 | "name": "REGISTRY", 44 | "outputs": [ 45 | { 46 | "internalType": "contract IERC1820RegistryUpgradeable", 47 | "name": "", 48 | "type": "IERC1820RegistryUpgradeable" 49 | } 50 | ], 51 | "stateMutability": "view", 52 | "type": "function" 53 | }, 54 | { 55 | "inputs": [], 56 | "name": "TOKENS_RECIPIENT_INTERFACE_HASH", 57 | "outputs": [ 58 | { 59 | "internalType": "bytes32", 60 | "name": "", 61 | "type": "bytes32" 62 | } 63 | ], 64 | "stateMutability": "view", 65 | "type": "function" 66 | }, 67 | { 68 | "inputs": [], 69 | "name": "TOKENS_SENDER_INTERFACE_HASH", 70 | "outputs": [ 71 | { 72 | "internalType": "bytes32", 73 | "name": "", 74 | "type": "bytes32" 75 | } 76 | ], 77 | "stateMutability": "view", 78 | "type": "function" 79 | } 80 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/DoppelgangerWithExec.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "payable", 4 | "type": "fallback" 5 | }, 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "target", 11 | "type": "address" 12 | }, 13 | { 14 | "internalType": "bytes", 15 | "name": "data", 16 | "type": "bytes" 17 | } 18 | ], 19 | "name": "__waffle__call", 20 | "outputs": [ 21 | { 22 | "internalType": "bytes", 23 | "name": "", 24 | "type": "bytes" 25 | } 26 | ], 27 | "stateMutability": "nonpayable", 28 | "type": "function" 29 | }, 30 | { 31 | "inputs": [ 32 | { 33 | "internalType": "bytes", 34 | "name": "data", 35 | "type": "bytes" 36 | }, 37 | { 38 | "internalType": "bytes", 39 | "name": "value", 40 | "type": "bytes" 41 | } 42 | ], 43 | "name": "__waffle__mockReturns", 44 | "outputs": [], 45 | "stateMutability": "nonpayable", 46 | "type": "function" 47 | }, 48 | { 49 | "inputs": [ 50 | { 51 | "internalType": "bytes", 52 | "name": "data", 53 | "type": "bytes" 54 | } 55 | ], 56 | "name": "__waffle__mockReverts", 57 | "outputs": [], 58 | "stateMutability": "nonpayable", 59 | "type": "function" 60 | }, 61 | { 62 | "inputs": [ 63 | { 64 | "internalType": "address", 65 | "name": "target", 66 | "type": "address" 67 | }, 68 | { 69 | "internalType": "bytes", 70 | "name": "data", 71 | "type": "bytes" 72 | } 73 | ], 74 | "name": "__waffle__staticcall", 75 | "outputs": [ 76 | { 77 | "internalType": "bytes", 78 | "name": "", 79 | "type": "bytes" 80 | } 81 | ], 82 | "stateMutability": "view", 83 | "type": "function" 84 | } 85 | ] -------------------------------------------------------------------------------- /src/helpers/idTemplates.ts: -------------------------------------------------------------------------------- 1 | export function prizeId(prizePool: string, currentPrizeId: string): string { 2 | return prizePool + '-' + currentPrizeId 3 | } 4 | 5 | export function creditRateId(prizePoolAddress: string, tokenAddress: string): string { 6 | return prizePoolAddress + '-' + tokenAddress 7 | } 8 | 9 | export function externalAwardId(prizeStrategyAddress: string, tokenAddress: string): string { 10 | return prizeStrategyAddress + '-' + tokenAddress 11 | } 12 | 13 | export function awardedExternalErc20TokenId(prizeId: string, tokenAddress: string, winnerAddress: string, winnerIndex: string): string { 14 | return prizeId + '-' + tokenAddress + '-' + winnerAddress + '-' + winnerIndex 15 | } 16 | 17 | export function awardedExternalErc721NftId(prizeId: string, tokenAddress: string): string { 18 | return prizeId + '-' + tokenAddress 19 | } 20 | 21 | export function dripTokenId( 22 | comptrollerAddress: string, 23 | sourceAddress: string, 24 | measureTokenAddress: string, 25 | dripTokenAddress: string, 26 | isReferral: string = '0' 27 | ): string { 28 | return comptrollerAddress + '-' + sourceAddress + '-' + measureTokenAddress + '-' + dripTokenAddress + '-' + isReferral 29 | } 30 | 31 | export function dripTokenPlayerId( 32 | comptrollerAddress: string, 33 | dripTokenAddress: string, 34 | playerAddress: string 35 | ): string { 36 | return comptrollerAddress + '-' + dripTokenAddress + '-' + playerAddress 37 | } 38 | 39 | export function balanceDripPlayerId( 40 | balanceDripId: string, 41 | playerAddress: string, 42 | ): string { 43 | return balanceDripId + '-' + playerAddress 44 | } 45 | 46 | export function volumeDripPlayerId( 47 | volumeDripId: string, 48 | playerAddress: string, 49 | ): string { 50 | return volumeDripId + '-' + playerAddress 51 | } 52 | 53 | export function volumeDripPeriodId( 54 | volumeDripId: string, 55 | periodIndex: string, 56 | ): string { 57 | return volumeDripId + '-' + periodIndex 58 | } 59 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/MappedSinglyLinkedListExposed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "newAddress", 7 | "type": "address" 8 | } 9 | ], 10 | "name": "addAddress", 11 | "outputs": [], 12 | "stateMutability": "nonpayable", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "address[]", 19 | "name": "addresses", 20 | "type": "address[]" 21 | } 22 | ], 23 | "name": "addAddresses", 24 | "outputs": [], 25 | "stateMutability": "nonpayable", 26 | "type": "function" 27 | }, 28 | { 29 | "inputs": [], 30 | "name": "addressArray", 31 | "outputs": [ 32 | { 33 | "internalType": "address[]", 34 | "name": "", 35 | "type": "address[]" 36 | } 37 | ], 38 | "stateMutability": "view", 39 | "type": "function" 40 | }, 41 | { 42 | "inputs": [], 43 | "name": "clearAll", 44 | "outputs": [], 45 | "stateMutability": "nonpayable", 46 | "type": "function" 47 | }, 48 | { 49 | "inputs": [ 50 | { 51 | "internalType": "address", 52 | "name": "addr", 53 | "type": "address" 54 | } 55 | ], 56 | "name": "contains", 57 | "outputs": [ 58 | { 59 | "internalType": "bool", 60 | "name": "", 61 | "type": "bool" 62 | } 63 | ], 64 | "stateMutability": "view", 65 | "type": "function" 66 | }, 67 | { 68 | "inputs": [], 69 | "name": "initialize", 70 | "outputs": [], 71 | "stateMutability": "nonpayable", 72 | "type": "function" 73 | }, 74 | { 75 | "inputs": [ 76 | { 77 | "internalType": "address", 78 | "name": "prevAddress", 79 | "type": "address" 80 | }, 81 | { 82 | "internalType": "address", 83 | "name": "addr", 84 | "type": "address" 85 | } 86 | ], 87 | "name": "removeAddress", 88 | "outputs": [], 89 | "stateMutability": "nonpayable", 90 | "type": "function" 91 | } 92 | ] -------------------------------------------------------------------------------- /src/helpers/loadOrCreateControlledToken.ts: -------------------------------------------------------------------------------- 1 | import { Address, BigInt, log } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | ControlledToken, 5 | } from '../../generated/schema' 6 | 7 | import { 8 | ControlledToken as ControlledTokenContract 9 | } from '../../generated/templates/ControlledToken/ControlledToken' 10 | 11 | import { ZERO } from './common' 12 | 13 | 14 | export function loadOrCreateControlledToken( 15 | tokenAddress: Address 16 | ): ControlledToken { 17 | let controlledToken = ControlledToken.load(tokenAddress.toHexString()) 18 | if (!controlledToken) { 19 | log.warning("debug001 creating controleld token for {} ",[tokenAddress.toHex()]) 20 | 21 | controlledToken = new ControlledToken(tokenAddress.toHex()) 22 | const boundToken = ControlledTokenContract.bind(tokenAddress) 23 | 24 | const tryControllerCall = boundToken.try_controller() 25 | if(tryControllerCall.reverted){ 26 | log.warning("try_controller() reverted ",[]) 27 | } 28 | else{ 29 | controlledToken.controller = tryControllerCall.value.toHexString() 30 | } 31 | 32 | let controlledTokenName = boundToken.try_name() 33 | if(controlledTokenName.reverted){ 34 | log.info('ControlledToken ERC20 try_name() call reverted', []) 35 | } 36 | else{ 37 | controlledToken.name = controlledTokenName.value 38 | } 39 | 40 | 41 | let controlledTokenSymbol = boundToken.try_symbol() 42 | if(controlledTokenSymbol.reverted){ 43 | log.info('ControlledToken ERC20 try_symbol() call reverted', []) 44 | } 45 | else{ 46 | controlledToken.symbol = controlledTokenSymbol.value 47 | } 48 | 49 | let tryDecimalsCallResult = boundToken.try_decimals() 50 | if(tryDecimalsCallResult.reverted) { 51 | log.info('ControlledToken ERC20 try_decimals() call reverted', []) 52 | } 53 | else{ 54 | controlledToken.decimals = BigInt.fromI32(tryDecimalsCallResult.value) 55 | } 56 | controlledToken.numberOfHolders = ZERO 57 | controlledToken.totalSupply = ZERO 58 | 59 | controlledToken.save() 60 | } 61 | 62 | return controlledToken as ControlledToken 63 | } 64 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/Registry.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { 11 | "indexed": true, 12 | "internalType": "address", 13 | "name": "previousOwner", 14 | "type": "address" 15 | }, 16 | { 17 | "indexed": true, 18 | "internalType": "address", 19 | "name": "newOwner", 20 | "type": "address" 21 | } 22 | ], 23 | "name": "OwnershipTransferred", 24 | "type": "event" 25 | }, 26 | { 27 | "anonymous": false, 28 | "inputs": [ 29 | { 30 | "indexed": true, 31 | "internalType": "address", 32 | "name": "pointer", 33 | "type": "address" 34 | } 35 | ], 36 | "name": "Registered", 37 | "type": "event" 38 | }, 39 | { 40 | "inputs": [], 41 | "name": "lookup", 42 | "outputs": [ 43 | { 44 | "internalType": "address", 45 | "name": "", 46 | "type": "address" 47 | } 48 | ], 49 | "stateMutability": "view", 50 | "type": "function" 51 | }, 52 | { 53 | "inputs": [], 54 | "name": "owner", 55 | "outputs": [ 56 | { 57 | "internalType": "address", 58 | "name": "", 59 | "type": "address" 60 | } 61 | ], 62 | "stateMutability": "view", 63 | "type": "function" 64 | }, 65 | { 66 | "inputs": [ 67 | { 68 | "internalType": "address", 69 | "name": "_pointer", 70 | "type": "address" 71 | } 72 | ], 73 | "name": "register", 74 | "outputs": [], 75 | "stateMutability": "nonpayable", 76 | "type": "function" 77 | }, 78 | { 79 | "inputs": [], 80 | "name": "renounceOwnership", 81 | "outputs": [], 82 | "stateMutability": "nonpayable", 83 | "type": "function" 84 | }, 85 | { 86 | "inputs": [ 87 | { 88 | "internalType": "address", 89 | "name": "newOwner", 90 | "type": "address" 91 | } 92 | ], 93 | "name": "transferOwnership", 94 | "outputs": [], 95 | "stateMutability": "nonpayable", 96 | "type": "function" 97 | } 98 | ] -------------------------------------------------------------------------------- /src/helpers/loadOrCreateSingleRandomWinner.ts: -------------------------------------------------------------------------------- 1 | import { Address, log } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | SingleRandomWinnerPrizeStrategy, 5 | } from '../../generated/schema' 6 | 7 | import { loadOrCreatePrizeStrategy } from './loadOrCreatePrizeStrategy' 8 | 9 | import { 10 | SingleRandomWinner as SingleRandomWinnerContract, 11 | } from '../../generated/templates/SingleRandomWinner/SingleRandomWinner' 12 | 13 | import { ZERO_ADDRESS } from './common' 14 | import { loadOrCreateControlledToken } from './loadOrCreateControlledToken' 15 | 16 | export function loadOrCreateSingleRandomWinner( 17 | singleRandomWinner: Address, 18 | ): SingleRandomWinnerPrizeStrategy { 19 | const _singleRandomWinnerAddress = singleRandomWinner.toHex() 20 | let _singleRandomWinner = SingleRandomWinnerPrizeStrategy.load(_singleRandomWinnerAddress) 21 | if (!_singleRandomWinner) { 22 | 23 | // Create SingleRandomWinnerPrizeStrategy 24 | _singleRandomWinner = new SingleRandomWinnerPrizeStrategy(_singleRandomWinnerAddress) 25 | const _boundSingleRandomWinner = SingleRandomWinnerContract.bind(singleRandomWinner) 26 | 27 | _singleRandomWinner.owner = _boundSingleRandomWinner.owner() 28 | _singleRandomWinner.prizePool = _boundSingleRandomWinner.prizePool().toHex() // _prizePool.id 29 | _singleRandomWinner.rng = _boundSingleRandomWinner.rng() 30 | _singleRandomWinner.tokenListener = ZERO_ADDRESS 31 | _singleRandomWinner.ticket = ZERO_ADDRESS 32 | _singleRandomWinner.sponsorship = ZERO_ADDRESS 33 | 34 | _singleRandomWinner.prizePeriodSeconds = _boundSingleRandomWinner.prizePeriodSeconds() 35 | _singleRandomWinner.prizePeriodStartedAt = _boundSingleRandomWinner.prizePeriodStartedAt() 36 | _singleRandomWinner.prizePeriodEndAt = _singleRandomWinner.prizePeriodStartedAt.plus(_singleRandomWinner.prizePeriodSeconds) 37 | 38 | const ticket = loadOrCreateControlledToken( 39 | _boundSingleRandomWinner.ticket() 40 | ) 41 | _singleRandomWinner.ticket = ticket.id 42 | 43 | const sponsorship = loadOrCreateControlledToken( 44 | _boundSingleRandomWinner.sponsorship() 45 | ) 46 | _singleRandomWinner.sponsorship = sponsorship.id 47 | _singleRandomWinner.save() 48 | 49 | let prizeStrategy = loadOrCreatePrizeStrategy(singleRandomWinner) 50 | prizeStrategy.singleRandomWinner = _singleRandomWinner.id 51 | prizeStrategy.save() 52 | } 53 | 54 | return _singleRandomWinner as SingleRandomWinnerPrizeStrategy 55 | } 56 | -------------------------------------------------------------------------------- /src/helpers/loadOrCreateExternalAward.ts: -------------------------------------------------------------------------------- 1 | import { Address, BigInt, log } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | ERC20 as ERC20Contract, 5 | } from '../../generated/templates/PrizePool/ERC20' 6 | 7 | import { 8 | SingleRandomWinnerExternalErc20Award, 9 | SingleRandomWinnerExternalErc721Award, 10 | } from '../../generated/schema' 11 | 12 | import { externalAwardId } from './idTemplates' 13 | 14 | 15 | export function loadOrCreateExternalErc20Award(prizeStrategyAddress: string, tokenAddress: Address): SingleRandomWinnerExternalErc20Award { 16 | const awardId = externalAwardId(prizeStrategyAddress, tokenAddress.toHex()) 17 | 18 | let award = SingleRandomWinnerExternalErc20Award.load(awardId) 19 | if (!award) { 20 | log.warning("creating an externalErc20 entity ",[]) 21 | award = new SingleRandomWinnerExternalErc20Award(awardId) 22 | award.prizeStrategy = prizeStrategyAddress 23 | award.address = tokenAddress 24 | 25 | const boundToken = ERC20Contract.bind(tokenAddress) 26 | 27 | let tryNameCallResult = boundToken.try_name() 28 | if (tryNameCallResult.reverted) { 29 | log.info('ERC20 try_name() call reverted', []) 30 | } else { 31 | award.name = tryNameCallResult.value 32 | } 33 | 34 | let trySymbolCallResult = boundToken.try_symbol() 35 | if (trySymbolCallResult.reverted) { 36 | log.info('ERC20 try_symbol call reverted', []) 37 | } else { 38 | award.symbol = trySymbolCallResult.value 39 | } 40 | 41 | let tryDecimalsCallResult = boundToken.try_decimals() 42 | if (tryDecimalsCallResult.reverted) { 43 | log.info('ERC20 try_decimals() call reverted', []) 44 | } else { 45 | award.decimals = BigInt.fromI32(tryDecimalsCallResult.value) 46 | } 47 | 48 | award.save() 49 | } 50 | else{ 51 | log.warning("external erc20 already existed ",[]) 52 | } 53 | 54 | return award as SingleRandomWinnerExternalErc20Award 55 | } 56 | 57 | export function loadOrCreateExternalErc721Award(prizeStrategyAddress: string, tokenAddress: Address): SingleRandomWinnerExternalErc721Award { 58 | const awardId = externalAwardId(prizeStrategyAddress, tokenAddress.toHex()) 59 | 60 | let award = SingleRandomWinnerExternalErc721Award.load(awardId) 61 | if (!award) { 62 | award = new SingleRandomWinnerExternalErc721Award(awardId) 63 | award.prizeStrategy = prizeStrategyAddress 64 | award.address = tokenAddress 65 | award.save() 66 | } 67 | 68 | return award as SingleRandomWinnerExternalErc721Award 69 | } 70 | -------------------------------------------------------------------------------- /abis/v3_1_0/abis/StakePrizePoolBuilder.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "contract RegistryInterface", 6 | "name": "_reserveRegistry", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "contract StakePrizePoolProxyFactory", 11 | "name": "_stakePrizePoolProxyFactory", 12 | "type": "address" 13 | } 14 | ], 15 | "stateMutability": "nonpayable", 16 | "type": "constructor" 17 | }, 18 | { 19 | "anonymous": false, 20 | "inputs": [ 21 | { 22 | "indexed": true, 23 | "internalType": "address", 24 | "name": "creator", 25 | "type": "address" 26 | }, 27 | { 28 | "indexed": true, 29 | "internalType": "address", 30 | "name": "prizePool", 31 | "type": "address" 32 | } 33 | ], 34 | "name": "PrizePoolCreated", 35 | "type": "event" 36 | }, 37 | { 38 | "inputs": [ 39 | { 40 | "components": [ 41 | { 42 | "internalType": "contract IERC20Upgradeable", 43 | "name": "token", 44 | "type": "address" 45 | }, 46 | { 47 | "internalType": "uint256", 48 | "name": "maxExitFeeMantissa", 49 | "type": "uint256" 50 | }, 51 | { 52 | "internalType": "uint256", 53 | "name": "maxTimelockDuration", 54 | "type": "uint256" 55 | } 56 | ], 57 | "internalType": "struct StakePrizePoolBuilder.StakePrizePoolConfig", 58 | "name": "config", 59 | "type": "tuple" 60 | } 61 | ], 62 | "name": "createStakePrizePool", 63 | "outputs": [ 64 | { 65 | "internalType": "contract StakePrizePool", 66 | "name": "", 67 | "type": "address" 68 | } 69 | ], 70 | "stateMutability": "nonpayable", 71 | "type": "function" 72 | }, 73 | { 74 | "inputs": [], 75 | "name": "reserveRegistry", 76 | "outputs": [ 77 | { 78 | "internalType": "contract RegistryInterface", 79 | "name": "", 80 | "type": "address" 81 | } 82 | ], 83 | "stateMutability": "view", 84 | "type": "function" 85 | }, 86 | { 87 | "inputs": [], 88 | "name": "stakePrizePoolProxyFactory", 89 | "outputs": [ 90 | { 91 | "internalType": "contract StakePrizePoolProxyFactory", 92 | "name": "", 93 | "type": "address" 94 | } 95 | ], 96 | "stateMutability": "view", 97 | "type": "function" 98 | } 99 | ] -------------------------------------------------------------------------------- /abis/v3_1_0/abis/CompoundPrizePoolBuilder.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "contract RegistryInterface", 6 | "name": "_reserveRegistry", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "contract CompoundPrizePoolProxyFactory", 11 | "name": "_compoundPrizePoolProxyFactory", 12 | "type": "address" 13 | } 14 | ], 15 | "stateMutability": "nonpayable", 16 | "type": "constructor" 17 | }, 18 | { 19 | "anonymous": false, 20 | "inputs": [ 21 | { 22 | "indexed": true, 23 | "internalType": "address", 24 | "name": "creator", 25 | "type": "address" 26 | }, 27 | { 28 | "indexed": true, 29 | "internalType": "address", 30 | "name": "prizePool", 31 | "type": "address" 32 | } 33 | ], 34 | "name": "PrizePoolCreated", 35 | "type": "event" 36 | }, 37 | { 38 | "inputs": [], 39 | "name": "compoundPrizePoolProxyFactory", 40 | "outputs": [ 41 | { 42 | "internalType": "contract CompoundPrizePoolProxyFactory", 43 | "name": "", 44 | "type": "address" 45 | } 46 | ], 47 | "stateMutability": "view", 48 | "type": "function" 49 | }, 50 | { 51 | "inputs": [ 52 | { 53 | "components": [ 54 | { 55 | "internalType": "contract CTokenInterface", 56 | "name": "cToken", 57 | "type": "address" 58 | }, 59 | { 60 | "internalType": "uint256", 61 | "name": "maxExitFeeMantissa", 62 | "type": "uint256" 63 | }, 64 | { 65 | "internalType": "uint256", 66 | "name": "maxTimelockDuration", 67 | "type": "uint256" 68 | } 69 | ], 70 | "internalType": "struct CompoundPrizePoolBuilder.CompoundPrizePoolConfig", 71 | "name": "config", 72 | "type": "tuple" 73 | } 74 | ], 75 | "name": "createCompoundPrizePool", 76 | "outputs": [ 77 | { 78 | "internalType": "contract CompoundPrizePool", 79 | "name": "", 80 | "type": "address" 81 | } 82 | ], 83 | "stateMutability": "nonpayable", 84 | "type": "function" 85 | }, 86 | { 87 | "inputs": [], 88 | "name": "reserveRegistry", 89 | "outputs": [ 90 | { 91 | "internalType": "contract RegistryInterface", 92 | "name": "", 93 | "type": "address" 94 | } 95 | ], 96 | "stateMutability": "view", 97 | "type": "function" 98 | } 99 | ] -------------------------------------------------------------------------------- /src/helpers/loadOrCreateAccount.ts: -------------------------------------------------------------------------------- 1 | import { Address, BigInt, log } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | DripTokenPlayer, 5 | BalanceDripPlayer, 6 | VolumeDripPlayer, 7 | } from '../../generated/schema' 8 | 9 | import { 10 | dripTokenPlayerId, 11 | balanceDripPlayerId, 12 | volumeDripPlayerId, 13 | } from './idTemplates' 14 | 15 | import {Account} from "../../generated/schema" 16 | 17 | export function loadOrCreateAccount( 18 | address: Address 19 | ): Account { 20 | let account = Account.load(address.toHex()) 21 | 22 | if (!account) { 23 | account = new Account(address.toHex()) 24 | account.save() 25 | } 26 | 27 | return account as Account 28 | } 29 | 30 | export function loadOrCreateDripTokenPlayer( 31 | comptroller: Address, 32 | dripToken: Address, 33 | player: Address 34 | ): DripTokenPlayer { 35 | const _playerId = dripTokenPlayerId(comptroller.toHex(), dripToken.toHex(), player.toHex()) 36 | let _player = DripTokenPlayer.load(_playerId) 37 | 38 | if (!_player) { 39 | _player = new DripTokenPlayer(_playerId) 40 | 41 | log.warning('DripTokenPlayer {}', [player.toHex()]) 42 | _player.dripToken = dripToken 43 | _player.comptroller = comptroller.toHex() 44 | _player.address = player 45 | _player.balance = BigInt.fromI32(0) 46 | _player.save() 47 | } 48 | 49 | return _player as DripTokenPlayer 50 | } 51 | 52 | 53 | export function loadOrCreateBalanceDripPlayer( 54 | balanceDripId: string, 55 | player: Address, 56 | ): BalanceDripPlayer { 57 | const _playerId = balanceDripPlayerId(balanceDripId, player.toHex()) 58 | let _player = BalanceDripPlayer.load(_playerId) 59 | 60 | if (!_player) { 61 | _player = new BalanceDripPlayer(_playerId) 62 | 63 | // log.warning('BalanceDripPlayer {}', [player.toHex()]) 64 | _player.balanceDrip = balanceDripId 65 | _player.address = player 66 | _player.save() 67 | } 68 | 69 | return _player as BalanceDripPlayer 70 | } 71 | 72 | 73 | export function loadOrCreateVolumeDripPlayer( 74 | volumeDripId: string, 75 | player: Address, 76 | ): VolumeDripPlayer { 77 | const _playerId = volumeDripPlayerId(volumeDripId, player.toHex()) 78 | let _player = VolumeDripPlayer.load(_playerId) 79 | 80 | if (!_player) { 81 | _player = new VolumeDripPlayer(_playerId) 82 | 83 | // log.warning('VolumeDripPlayer {}', [player.toHex()]) 84 | _player.volumeDrip = volumeDripId 85 | _player.address = player 86 | _player.periodIndex = BigInt.fromI32(0) 87 | _player.balance = BigInt.fromI32(0) 88 | _player.save() 89 | } 90 | 91 | return _player as VolumeDripPlayer 92 | } 93 | -------------------------------------------------------------------------------- /src/helpers/loadOrCreateAwardedExternalErc.ts: -------------------------------------------------------------------------------- 1 | import { Address, BigInt, log } from '@graphprotocol/graph-ts' 2 | 3 | import { 4 | ERC20 as ERC20Contract, 5 | } from '../../generated/templates/PrizePool/ERC20' 6 | 7 | import { 8 | Prize, 9 | AwardedExternalErc20Token, 10 | AwardedExternalErc721Nft, 11 | PrizeStrategy, 12 | } from '../../generated/schema' 13 | 14 | import { awardedExternalErc20TokenId, awardedExternalErc721NftId } from './idTemplates' 15 | import { loadOrCreateExternalErc721Award } from './loadOrCreateExternalAward' 16 | 17 | export function loadOrCreateAwardedExternalErc20Token(prize: Prize, tokenAddress: Address, winnerAddress: Address, winnerIndex: string): AwardedExternalErc20Token { 18 | const awardId = awardedExternalErc20TokenId(prize.id, tokenAddress.toHex(), winnerAddress.toHex(), winnerIndex) 19 | 20 | let award = AwardedExternalErc20Token.load(awardId) 21 | if (!award) { 22 | award = new AwardedExternalErc20Token(awardId) 23 | award.prize = prize.id 24 | award.address = tokenAddress 25 | 26 | const boundToken = ERC20Contract.bind(tokenAddress) 27 | 28 | 29 | let tryNameCallResult = boundToken.try_name() 30 | if (tryNameCallResult.reverted) { 31 | log.info('ERC20 try_name() call reverted', []) 32 | } else { 33 | award.name = tryNameCallResult.value 34 | } 35 | 36 | let trySymbolCallResult = boundToken.try_symbol() 37 | if (trySymbolCallResult.reverted) { 38 | log.info('ERC20 try_symbol call reverted', []) 39 | } else { 40 | award.symbol = trySymbolCallResult.value 41 | } 42 | 43 | let tryDecimalsCallResult = boundToken.try_decimals() 44 | if (tryDecimalsCallResult.reverted) { 45 | log.info('ERC20 try_decimals() call reverted', []) 46 | } else { 47 | award.decimals = BigInt.fromI32(tryDecimalsCallResult.value) 48 | } 49 | 50 | award.save() 51 | } 52 | 53 | return award as AwardedExternalErc20Token 54 | } 55 | 56 | export function loadOrCreateAwardedExternalErc721Nft(prize: Prize, prizeStrategy: PrizeStrategy, tokenAddress: Address): AwardedExternalErc721Nft { 57 | const awardId = awardedExternalErc721NftId(prize.id, tokenAddress.toHex()) 58 | 59 | let award = AwardedExternalErc721Nft.load(awardId) 60 | if (!award) { 61 | award = new AwardedExternalErc721Nft(awardId) 62 | 63 | let externalErc721Award = loadOrCreateExternalErc721Award( 64 | prizeStrategy.id.toString(), 65 | tokenAddress 66 | ) 67 | 68 | award.address = externalErc721Award.address 69 | award.prize = prize.id 70 | award.tokenIds = externalErc721Award.tokenIds 71 | 72 | award.save() 73 | } 74 | 75 | return award as AwardedExternalErc721Nft 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |