generated from defi-wonderland/ts-turborepo-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: base strategy class and refactor strategyId mappings
- Loading branch information
Showing
19 changed files
with
635 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Add your external exports here | ||
export { StrategyProcessor, AlloProcessor } from "./internal.js"; | ||
export type { IProcessor } from "./internal.js"; | ||
|
||
export { existsHandler } from "./internal.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 37 additions & 2 deletions
39
packages/processors/src/interfaces/strategyHandler.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,50 @@ | ||
import { Changeset } from "@grants-stack-indexer/repository"; | ||
import { ContractToEventName, ProtocolEvent } from "@grants-stack-indexer/shared"; | ||
import type { Changeset } from "@grants-stack-indexer/repository"; | ||
import type { | ||
Address, | ||
ContractToEventName, | ||
ProtocolEvent, | ||
Token, | ||
} from "@grants-stack-indexer/shared"; | ||
|
||
import type { StrategyTimings } from "../internal.js"; | ||
|
||
/** | ||
* Interface for an event handler. | ||
* @template C - The contract name. | ||
* @template E - The event name. | ||
*/ | ||
export interface IStrategyHandler<E extends ContractToEventName<"Strategy">> { | ||
/** | ||
* The name of the strategy. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* Handles the event. | ||
* @returns A promise that resolves to an array of changesets. | ||
*/ | ||
handle(event: ProtocolEvent<"Strategy", E>): Promise<Changeset[]>; | ||
|
||
/** | ||
* Fetch the strategy timings data from the strategy contract | ||
* @param strategyAddress - The address of the strategy | ||
* @returns The strategy timings | ||
*/ | ||
fetchStrategyTimings(strategyAddress: Address): Promise<StrategyTimings>; | ||
|
||
/** | ||
* Fetch the match amount for a strategy | ||
* @param matchingFundsAvailable - The matching funds available | ||
* @param token - The token | ||
* @param blockTimestamp - The block timestamp | ||
* @returns The match amount and match amount in USD | ||
*/ | ||
fetchMatchAmount( | ||
matchingFundsAvailable: number, | ||
token: Token, | ||
blockTimestamp: number, | ||
): Promise<{ | ||
matchAmount: bigint; | ||
matchAmountInUsd: string; | ||
}>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
// Add your internal exports here | ||
// Types and interfaces | ||
export * from "./types/index.js"; | ||
export * from "./interfaces/index.js"; | ||
|
||
// Exceptions | ||
export * from "./exceptions/index.js"; | ||
|
||
// Allo | ||
export * from "./allo/index.js"; | ||
|
||
// Strategy | ||
export * from "./strategy/common/index.js"; | ||
export * from "./strategy/index.js"; | ||
export * from "./strategy/strategyHandler.factory.js"; | ||
export * from "./strategy/strategy.processor.js"; | ||
export { getHandler, existsHandler } from "./strategy/mapping.js"; |
Oops, something went wrong.