diff --git a/src/indexer/abis/allo-v2/v1/DirectAllocationStrategy.ts b/src/indexer/abis/allo-v2/v1/DirectAllocationStrategy.ts new file mode 100644 index 00000000..81dbf190 --- /dev/null +++ b/src/indexer/abis/allo-v2/v1/DirectAllocationStrategy.ts @@ -0,0 +1,600 @@ +export default [ + { + inputs: [ + { + internalType: "address", + name: "_allo", + type: "address", + }, + { + internalType: "string", + name: "_name", + type: "string", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "ALLOCATION_ACTIVE", + type: "error", + }, + { + inputs: [], + name: "ALLOCATION_NOT_ACTIVE", + type: "error", + }, + { + inputs: [], + name: "ALLOCATION_NOT_ENDED", + type: "error", + }, + { + inputs: [], + name: "ALREADY_INITIALIZED", + type: "error", + }, + { + inputs: [], + name: "AMOUNT_MISMATCH", + type: "error", + }, + { + inputs: [], + name: "ANCHOR_ERROR", + type: "error", + }, + { + inputs: [], + name: "ARRAY_MISMATCH", + type: "error", + }, + { + inputs: [], + name: "INVALID", + type: "error", + }, + { + inputs: [], + name: "INVALID_ADDRESS", + type: "error", + }, + { + inputs: [], + name: "INVALID_FEE", + type: "error", + }, + { + inputs: [], + name: "INVALID_METADATA", + type: "error", + }, + { + inputs: [], + name: "INVALID_REGISTRATION", + type: "error", + }, + { + inputs: [], + name: "IS_APPROVED_STRATEGY", + type: "error", + }, + { + inputs: [], + name: "MISMATCH", + type: "error", + }, + { + inputs: [], + name: "NONCE_NOT_AVAILABLE", + type: "error", + }, + { + inputs: [], + name: "NON_ZERO_VALUE", + type: "error", + }, + { + inputs: [], + name: "NOT_APPROVED_STRATEGY", + type: "error", + }, + { + inputs: [], + name: "NOT_ENOUGH_FUNDS", + type: "error", + }, + { + inputs: [], + name: "NOT_IMPLEMENTED", + type: "error", + }, + { + inputs: [], + name: "NOT_INITIALIZED", + type: "error", + }, + { + inputs: [], + name: "NOT_PENDING_OWNER", + type: "error", + }, + { + inputs: [], + name: "POOL_ACTIVE", + type: "error", + }, + { + inputs: [], + name: "POOL_INACTIVE", + type: "error", + }, + { + inputs: [], + name: "RECIPIENT_ALREADY_ACCEPTED", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "recipientId", + type: "address", + }, + ], + name: "RECIPIENT_ERROR", + type: "error", + }, + { + inputs: [], + name: "RECIPIENT_NOT_ACCEPTED", + type: "error", + }, + { + inputs: [], + name: "REGISTRATION_ACTIVE", + type: "error", + }, + { + inputs: [], + name: "REGISTRATION_NOT_ACTIVE", + type: "error", + }, + { + inputs: [], + name: "UNAUTHORIZED", + type: "error", + }, + { + inputs: [], + name: "ZERO_ADDRESS", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "recipientId", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "token", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "Allocated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "profileId", + type: "bytes32", + }, + { + indexed: false, + internalType: "address", + name: "profileOwner", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "token", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "DirectAllocated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "recipientId", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "recipientAddress", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "Distributed", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "poolId", + type: "uint256", + }, + { + indexed: false, + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bool", + name: "active", + type: "bool", + }, + ], + name: "PoolActive", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "recipientId", + type: "address", + }, + { + indexed: false, + internalType: "bytes", + name: "data", + type: "bytes", + }, + { + indexed: false, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "Registered", + type: "event", + }, + { + inputs: [], + name: "NATIVE", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + { + internalType: "address", + name: "_sender", + type: "address", + }, + ], + name: "allocate", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address[]", + name: "_recipientIds", + type: "address[]", + }, + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + { + internalType: "address", + name: "_sender", + type: "address", + }, + ], + name: "distribute", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getAllo", + outputs: [ + { + internalType: "contract IAllo", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address[]", + name: "_recipientIds", + type: "address[]", + }, + { + internalType: "bytes[]", + name: "_data", + type: "bytes[]", + }, + ], + name: "getPayouts", + outputs: [ + { + components: [ + { + internalType: "address", + name: "recipientAddress", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + internalType: "struct IStrategy.PayoutSummary[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPoolAmount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPoolId", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_recipientId", + type: "address", + }, + ], + name: "getRecipientStatus", + outputs: [ + { + internalType: "enum IStrategy.Status", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getStrategyId", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "increasePoolAmount", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_poolId", + type: "uint256", + }, + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "isPoolActive", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_allocator", + type: "address", + }, + ], + name: "isValidAllocator", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + { + internalType: "address", + name: "_sender", + type: "address", + }, + ], + name: "registerRecipient", + outputs: [ + { + internalType: "address", + name: "recipientId", + type: "address", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + { + internalType: "address", + name: "_recipient", + type: "address", + }, + ], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + stateMutability: "payable", + type: "receive", + }, +] as const; diff --git a/src/indexer/abis/index.ts b/src/indexer/abis/index.ts index 1082fb03..87caba85 100644 --- a/src/indexer/abis/index.ts +++ b/src/indexer/abis/index.ts @@ -27,6 +27,7 @@ import AlloV2DirectGrantsSimpleStrategy from "./allo-v2/v1/DirectGrantsSimpleStr import AlloV1ToV2ProfileMigration from "./allo-v2/AlloV1ToV2ProfileMigration.js"; import AlloV2DirectGrantsLiteStrategy from "./allo-v2/v1/DirectGrantsLiteStrategy.js"; import AlloV2EasyRPGFStrategy from "./allo-v2/v1/EasyRPGFStrategy.js"; +import AlloV2DirectAllocationStrategy from "./allo-v2/v1/DirectAllocationStrategy.js"; const abis = { "AlloV1/ProjectRegistry/V1": ProjectRegistryV1, @@ -62,6 +63,7 @@ const abis = { "AlloV2/DirectGrantsSimpleStrategy/V1": AlloV2DirectGrantsSimpleStrategy, "AlloV2/DirectGrantsLiteStrategy/V1": AlloV2DirectGrantsLiteStrategy, "AlloV2/EasyRPGFStrategy/V1": AlloV2EasyRPGFStrategy, + "AlloV2/DirectAllocationStrategy/V1": AlloV2DirectAllocationStrategy, } as const; export default abis; diff --git a/src/indexer/allo/v2/handleEvent.ts b/src/indexer/allo/v2/handleEvent.ts index 071fde64..ceb89577 100644 --- a/src/indexer/allo/v2/handleEvent.ts +++ b/src/indexer/allo/v2/handleEvent.ts @@ -48,6 +48,8 @@ const ALLO_NATIVE_TOKEN = parseAddress( "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" ); +const addressZero = "0x0000000000000000000000000000000000000000"; + enum ApplicationStatus { NONE = 0, PENDING, @@ -307,13 +309,18 @@ export async function handleEvent( address: strategyAddress, }); break; - case "allov2.EasyRPGFStrategy": subscribeToContract({ contract: "AlloV2/EasyRPGFStrategy/V1", address: strategyAddress, }); break; + case "allov2.DirectAllocationStrategy": + subscribeToContract({ + contract: "AlloV2/DirectAllocationStrategy/V1", + address: strategyAddress, + }); + break; } let applicationsStartTime: Date | null = null; @@ -1206,6 +1213,63 @@ export async function handleEvent( } } } + + case "DirectAllocated": { + const strategyAddress = parseAddress(event.address); + const round = await db.getRoundByStrategyAddress( + chainId, + strategyAddress + ); + + const profile = await db.getProjectById(chainId, event.params.profileId); + + if (profile === null || round === null) { + return []; + } + + const donationId = ethers.utils.solidityKeccak256( + ["string"], + [`${event.blockNumber}-${event.logIndex}`] + ); + + const amount = event.params.amount; + const token = parseAddress(event.params.token); + const sender = parseAddress(event.params.sender); + + const conversionToUSD = await convertToUSD( + priceProvider, + chainId, + token, + event.params.amount, + event.blockNumber + ); + + const amountInUsd = conversionToUSD.amount; + + const donation: Donation = { + id: donationId, + chainId, + roundId: round.id, + applicationId: parseAddress(addressZero), + donorAddress: sender, + recipientAddress: parseAddress(event.params.profileOwner), + projectId: event.params.profileId, + transactionHash: event.transactionHash, + blockNumber: event.blockNumber, + tokenAddress: token, + amount: amount, + amountInUsd, + amountInRoundMatchToken: 0n, + timestamp: conversionToUSD.timestamp, + }; + + return [ + { + type: "InsertDonation", + donation, + }, + ]; + } } return []; diff --git a/src/indexer/allo/v2/strategy.ts b/src/indexer/allo/v2/strategy.ts index f59fe3fc..23f0b961 100644 --- a/src/indexer/allo/v2/strategy.ts +++ b/src/indexer/allo/v2/strategy.ts @@ -115,6 +115,14 @@ export function extractStrategyFromId(_id: string): Strategy | null { name: "allov2.EasyRPGFStrategy", groups: ["allov2.EasyRPGFStrategy"], }; + + // DirectAllocationStrategyv1.1 + case "0x4cd0051913234cdd7d165b208851240d334786d6e5afbb4d0eec203515a9c6f3": + return { + id: id, + name: "allov2.DirectAllocationStrategy", + groups: ["allov2.DirectAllocationStrategy"], + }; } return null;