Skip to content

Commit

Permalink
feat: Add close-and-remain operation definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
zerotucks committed Feb 19, 2024
1 parent 8599d03 commit 83f3c97
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/deploy-configurations/constants/operation-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const OPERATION_NAMES = {
},
v3: {
OPEN_POSITION: 'OpenAAVEV3Position',
CLOSE_POSITION: 'CloseAAVEV3Position_4',
CLOSE_AND_EXIT: 'CloseAAVEV3Position_4',
CLOSE_AND_REMAIN: 'CloseAndRemainAAVEV3Position_4',
ADJUST_RISK_UP: 'AdjustRiskUpAAVEV3Position_5',
ADJUST_RISK_DOWN: 'AdjustRiskDownAAVEV3Position_6',
DEPOSIT_BORROW: 'AAVEV3DepositBorrow',
Expand All @@ -27,7 +28,8 @@ export const OPERATION_NAMES = {
},
spark: {
OPEN_POSITION: 'SparkOpenPosition',
CLOSE_POSITION: 'SparkClosePosition',
CLOSE_AND_EXIT: 'SparkClosePosition',
CLOSE_AND_REMAIN: 'CloseAndRemainSparkPosition',
ADJUST_RISK_UP: 'SparkAdjustRiskUp',
ADJUST_RISK_DOWN: 'SparkAdjustRiskDown',
DEPOSIT_BORROW: 'SparkDepositBorrow',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { loadContractNames, OPERATION_NAMES } from '@deploy-configurations/const
import { Network } from '@deploy-configurations/types/network'
import { getActionHash } from '@deploy-configurations/utils/action-hash'

export function getAaveCloseV3OperationDefinition(network: Network) {
export function getAaveV3CloseAndExitOperationDefinition(network: Network) {
const SERVICE_REGISTRY_NAMES = loadContractNames(network)

return {
name: OPERATION_NAMES.aave.v3.CLOSE_POSITION,
name: OPERATION_NAMES.aave.v3.CLOSE_AND_EXIT,
actions: [
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.TAKE_A_FLASHLOAN_BALANCER),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { loadContractNames, OPERATION_NAMES } from '@deploy-configurations/constants'
import { Network } from '@deploy-configurations/types/network'
import { getActionHash } from '@deploy-configurations/utils/action-hash'

export function getAaveV3CloseAndRemainOperationDefinition(network: Network) {
const SERVICE_REGISTRY_NAMES = loadContractNames(network)

return {
name: OPERATION_NAMES.aave.v3.CLOSE_AND_REMAIN,
actions: [
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.TAKE_A_FLASHLOAN_BALANCER),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.SET_APPROVAL),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.aave.v3.DEPOSIT),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.aave.v3.WITHDRAW),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.SWAP_ACTION),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.SET_APPROVAL),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.aave.v3.PAYBACK),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.aave.v3.WITHDRAW_AUTO),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.aave.v3.WITHDRAW),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.RETURN_FUNDS),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.RETURN_FUNDS),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.aave.v3.SET_EMODE),
optional: false,
},
],
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { loadContractNames, OPERATION_NAMES } from '@deploy-configurations/const
import { Network } from '@deploy-configurations/types/network'
import { getActionHash } from '@deploy-configurations/utils/action-hash'

export function getSparkCloseOperationDefinition(network: Network) {
export function getSparkCloseAndExitOperationDefinition(network: Network) {
const SERVICE_REGISTRY_NAMES = loadContractNames(network)

return {
name: OPERATION_NAMES.spark.CLOSE_POSITION,
name: OPERATION_NAMES.spark.CLOSE_AND_EXIT,
actions: [
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.TAKE_A_FLASHLOAN),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { loadContractNames, OPERATION_NAMES } from '@deploy-configurations/constants'
import { Network } from '@deploy-configurations/types/network'
import { getActionHash } from '@deploy-configurations/utils/action-hash'

export function getSparkCloseAndRemainOperationDefinition(network: Network) {
const SERVICE_REGISTRY_NAMES = loadContractNames(network)

return {
name: OPERATION_NAMES.spark.CLOSE_AND_REMAIN,
actions: [
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.TAKE_A_FLASHLOAN),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.SET_APPROVAL),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.spark.PAYBACK),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.spark.SET_EMODE),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.spark.WITHDRAW),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.SWAP_ACTION),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.SEND_TOKEN),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.UNWRAP_ETH),
optional: true,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.RETURN_FUNDS),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.RETURN_FUNDS),
optional: false,
},
],
log: false,
}
}

0 comments on commit 83f3c97

Please sign in to comment.