-
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: Maker support for get-triggers (#496)
## Description This pull request adds support for Maker automation triggers. It's a part of adding omni kit support to Maker in oasis borrow. ## Changes - mapped all maker triggers - added two types of mapping helpers: - - simple trigger for triggers which are just mapped from the subgraph data - - advanced trigger for triggers that need more data (async) - extracted `mapResponse` function, because the main file became too large - query string params are changed: - -`dpm` is deprecated in favor of `account` (with backwards compatibility) - - this is because `account` field in subgraph works both for ds proxy and dpm - extracted `logger` to make sure it's one instance - added `trigger group id` which is used for `auto buy` + `auto sell` to combine into `constant multiple` ## Testing ``` /api/triggers?chainid=1&account=[ds proxy address] ``` ## Next steps - Add support to create triggers. Please review and provide any feedback or suggestions for improvement. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Enhanced GraphQL query for triggers, now includes additional fields and improved filtering by account. - Introduced new trigger types and constants for Maker protocol, expanding capabilities for automated trading strategies. - Added a new field `triggerGroupId` to the GraphQL schema for better categorization of triggers. - Implemented functions for advanced trigger management and filtering, including support for Maker vault information. - **Bug Fixes** - Updated parameter handling to maintain backward compatibility with existing clients. - **Refactor** - Streamlined code structure by modularizing trigger processing logic, improving maintainability and readability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
0a8399c
commit e934a60
Showing
15 changed files
with
1,255 additions
and
527 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { z } from 'zod' | ||
|
||
import { | ||
addressSchema, | ||
chainIdSchema, | ||
optionalPoolIdSchema, | ||
urlOptionalSchema, | ||
} from '@summerfi/serverless-shared/validators' | ||
|
||
export const paramsSchema = z.object({ | ||
account: addressSchema, | ||
poolId: optionalPoolIdSchema, | ||
chainId: chainIdSchema, | ||
rpc: urlOptionalSchema, | ||
protocol: z.string().optional(), | ||
getDetails: z | ||
.boolean() | ||
.or(z.string().transform((s) => s === 'true')) | ||
.optional() | ||
.default(false), | ||
}) |
5 changes: 5 additions & 0 deletions
5
summerfi-api/get-triggers-function/src/helpers/filter-trigger.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { TriggersQuery } from '@summerfi/automation-subgraph' | ||
|
||
export const filterTrigger = | ||
(triggerType: bigint) => (trigger: TriggersQuery['triggers'][number]) => | ||
BigInt(trigger.triggerType) === triggerType |
Oops, something went wrong.