Skip to content

Commit

Permalink
Tasks: Group tasks config on a separate entity (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatricioHenderson authored and facuspagnuolo committed Sep 20, 2023
1 parent ed68ef2 commit e68a092
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 138 deletions.
31 changes: 18 additions & 13 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@ type Task @entity {
environment: Environment!
smartVault: SmartVault!
tokensSource: String!
executionType: String!
taskConfig: TaskConfig @derivedFrom(field: "task")
}

type TaskConfig @entity{
id: ID!
task: Task!
nextBalanceConnector: String!
previousBalanceConnector: String!
executionType: String!
gasPriceLimit: BigInt!
priorityFeeLimit: BigInt!
txCostLimitPct: BigInt!
Expand All @@ -91,22 +97,21 @@ type Task @entity {
acceptanceList: AcceptanceList!
defaultVolumeLimit: VolumeLimit
defaultTokenThreshold: TokenThreshold
customVolumeLimit: [CustomVolumeLimit!] @derivedFrom(field: "task")
customTokenThreshold: [CustomTokenThreshold!] @derivedFrom(field: "task")
# Specific tasks config
customVolumeLimit: [CustomVolumeLimit!] @derivedFrom(field: "taskConfig")
customTokenThreshold: [CustomTokenThreshold!] @derivedFrom(field: "taskConfig")
connector: String
defaultDestinationChain: BigInt
defaultMaxSlippage: BigInt
defaultTokenOut: ERC20
recipient: String
customDestinationChain: [CustomDestinationChain!] @derivedFrom(field: "task")
customTokenOut: [CustomTokenOut!] @derivedFrom(field: "task")
customMaxSlippage: [CustomMaxSlippage!] @derivedFrom(field: "task")
customDestinationChain: [CustomDestinationChain!] @derivedFrom(field: "taskConfig")
customTokenOut: [CustomTokenOut!] @derivedFrom(field: "taskConfig")
customMaxSlippage: [CustomMaxSlippage!] @derivedFrom(field: "taskConfig")
}

type AcceptanceList @entity {
id: ID!
task: Task!
taskConfig: TaskConfig!
type: String!
tokens: [String!]!
}
Expand All @@ -120,21 +125,21 @@ type VolumeLimit @entity {

type CustomDestinationChain @entity {
id: ID!
task: Task!
taskConfig: TaskConfig!
token: ERC20!
destinationChain: BigInt!
}

type CustomMaxSlippage @entity {
id: ID!
task: Task!
taskConfig: TaskConfig!
token: ERC20!
maxSlippage: BigInt!
}

type CustomTokenOut @entity {
id: ID!
task: Task!
taskConfig: TaskConfig!
token: ERC20!
tokenOut: ERC20!
}
Expand All @@ -148,14 +153,14 @@ type TokenThreshold @entity {

type CustomTokenThreshold @entity {
id: ID!
task: Task!
taskConfig: TaskConfig!
token: ERC20!
threshold: TokenThreshold!
}

type CustomVolumeLimit @entity {
id: ID!
task: Task!
taskConfig: TaskConfig!
token: ERC20!
volumeLimit: VolumeLimit!
}
Expand Down
14 changes: 2 additions & 12 deletions src/Deployer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BigInt, Bytes, crypto, log } from '@graphprotocol/graph-ts'
import { Address, Bytes, crypto, log } from '@graphprotocol/graph-ts'

import { AuthorizerDeployed, PriceOracleDeployed, SmartVaultDeployed, TaskDeployed } from '../types/Deployer/Deployer'
import { Authorizer, Environment, PriceOracle, SmartVault, Task } from '../types/schema'
Expand All @@ -11,7 +11,7 @@ import {
import { getNetworkName } from './Networks'
import { loadOrCreateImplementation } from './Registry'
import { getAuthorizer, getPriceOracle, getRegistry } from './SmartVault'
import { getExecutionType, getSmartVault, getTokensSource, loadOrCreateAcceptanceList } from './Task'
import { getExecutionType, getSmartVault, getTokensSource } from './Task'

export function handleAuthorizerDeployed(event: AuthorizerDeployed): void {
log.warning('New authorizer deployed {}', [event.params.instance.toHexString()])
Expand Down Expand Up @@ -74,17 +74,7 @@ export function handleTaskDeployed(event: TaskDeployed): void {
task.environment = environment.id
task.smartVault = getSmartVault(event.params.instance).toHexString()
task.tokensSource = getTokensSource(event.params.instance).toHexString()
task.previousBalanceConnector = '0x0000000000000000000000000000000000000000000000000000000000000000'
task.nextBalanceConnector = '0x0000000000000000000000000000000000000000000000000000000000000000'
task.executionType = getExecutionType(event.params.instance).toHexString()
task.gasPriceLimit = BigInt.zero()
task.priorityFeeLimit = BigInt.zero()
task.txCostLimitPct = BigInt.zero()
task.txCostLimit = BigInt.zero()
task.timeLockDelay = BigInt.zero()
task.timeLockExecutionPeriod = BigInt.zero()
task.timeLockExpiration = BigInt.zero()
task.acceptanceList = loadOrCreateAcceptanceList(taskId).id
task.save()

TaskTemplate.create(event.params.instance)
Expand Down
Loading

0 comments on commit e68a092

Please sign in to comment.