Skip to content

Commit

Permalink
feat: add spark triggers (#113)
Browse files Browse the repository at this point in the history
* feat: add spark triggers

* chore: add spark command addresses

* chore: add missing aave sl

* chore: add spark bb bs addresses

* chore: format
  • Loading branch information
halaprix authored Feb 26, 2024
1 parent 55186b3 commit 7a77408
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/automation/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@oasisdex/automation",
"packageManager": "yarn@1.22.21",
"version": "1.6.0-alpha.16",
"version": "1.6.3",
"description": "The set of utilities for Oasis automation",
"homepage": "https://github.com/OasisDEX/common#readme",
"main": "lib/src/index.js",
Expand Down
108 changes: 108 additions & 0 deletions packages/automation/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,58 @@ export const commandTypeJsonMapping: Record<CommandContractType, string[]> = {
'trailingDistance',
'closeToCollateral',
],
[CommandContractType.DmaSparkTrailingStopLossCommandV2]: [
'positionAddress',
'triggerType',
'maxCoverage',
'debtToken',
'collateralToken',
'operationName',
'collateralOracle',
'collateralAddedRoundId',
'debtOracle',
'debtAddedRoundId',
'trailingDistance',
'closeToCollateral',
],
[CommandContractType.DmaSparkBasicSellCommandV2]: [
'positionAddress',
'triggerType',
'maxCoverage',
'debtToken',
'collateralToken',
'operationName',
'executionLtv',
'targetLtv',
'minSellPrice',
'deviation',
'maxBaseFeeInGwei',
],
[CommandContractType.DmaSparkBasicBuyCommandV2]: [
'positionAddress',
'triggerType',
'maxCoverage',
'debtToken',
'collateralToken',
'operationName',
'executionLtv',
'targetLtv',
'maxBuyPrice',
'deviation',
'maxBaseFeeInGwei',
],
};
export const commandOffchainDataTypeJsonMapping: Partial<Record<CommandContractType, string[]>> = {
[CommandContractType.DmaAaveTrailingStopLossCommandV2]: [
'collateralMaxPriceRoundId',
'debtClosestPriceRoundId',
'debtNextPriceRoundId',
],
[CommandContractType.DmaSparkTrailingStopLossCommandV2]: [
'collateralMaxPriceRoundId',
'debtClosestPriceRoundId',
'debtNextPriceRoundId',
],
};
export const commandAddressMapping: Record<
number,
Expand Down Expand Up @@ -250,6 +295,24 @@ export const commandAddressMapping: Record<
'0xea0c35bd1c2fae4d540ce30d9738bc55147f2a9c': {
type: CommandContractType.DmaAaveStopLossCommandV2,
},
'0x34B4632482Dc19f5b7E7ddd69F2b90a08E3754f0': {
type: CommandContractType.DmaAaveStopLossCommandV2,
},
'0x3b7701897fd930fEa5A67E60019742b0cdAdfecD': {
type: CommandContractType.DmaAaveTrailingStopLossCommandV2,
},
'0x2d43E84567019D721F095CfD632291c3eE868D8F': {
type: CommandContractType.DmaSparkTrailingStopLossCommandV2,
},
'0xAc728f8248F8CaD0E0f10A2a4e648981EdA095A4': {
type: CommandContractType.DmaSparkStopLossCommandV2,
},
'0x73022668d1E176f8aB56F0A988F358Dc9C8FFD15': {
type: CommandContractType.DmaSparkBasicBuyCommandV2,
},
'0xA870Edf71E88847Cf8f292555C9Da6dE26Ba3470': {
type: CommandContractType.DmaSparkBasicSellCommandV2,
},
},
[EthereumNetwork.BASE]: {
'0xb7CB13e4cD2D64e739b5746563978Ab7ee36B064': {
Expand Down Expand Up @@ -416,6 +479,46 @@ export const defaultCommandTypeMapping: Record<CommandContractType, ParamDefinit
'uint256', // trailingDistance
'bool', // closeToCollateral
],
[CommandContractType.DmaSparkTrailingStopLossCommandV2]: [
'address', //positionAddress
'uint16', // triggerType
'uint256', // maxCoverage
'address', // debtToken
'address', // collateralToken
'bytes32', // operationName
'address', // collateralOracle
'uint80', // collateralAddedRoundId
'address', // debtOracle
'uint80', // debtAddedRoundId
'uint256', // trailingDistance
'bool', // closeToCollateral
],
[CommandContractType.DmaSparkBasicBuyCommandV2]: [
'address', //positionAddress
'uint16', // triggerType
'uint256', // maxCoverage
'address', // debtToken
'address', // collateralToken
'bytes32', // operationName
'uint256', // execCollRatio
'uint256', // targetCollRatio
'uint256', // maxBuyPrice
'uint64', // deviation
'uint32', // maxBaseFeeInGwei
],
[CommandContractType.DmaSparkBasicSellCommandV2]: [
'address', //positionAddress
'uint16', // triggerType
'uint256', // maxCoverage
'address', // debtToken
'address', // collateralToken
'bytes32', // operationName
'uint256', // execCollRatio
'uint256', // targetCollRatio
'uint256', // minSellPrice
'uint64', // deviation
'uint32', // maxBaseFeeInGwei
],
} as const;

export const defaultCommandOffchainDataTypeMapping: Partial<Record<
Expand All @@ -427,6 +530,11 @@ export const defaultCommandOffchainDataTypeMapping: Partial<Record<
'uint80', // debtClosestPriceRoundId
'uint80', // debtNextPriceRoundId
],
[CommandContractType.DmaSparkTrailingStopLossCommandV2]: [
'uint80', // collateralMaxPriceRoundId
'uint80', // debtClosestPriceRoundId
'uint80', // debtNextPriceRoundId
],
} as const;

export function getCommandAddresses(network: number): Record<CommandContractType, string[]> {
Expand Down
9 changes: 9 additions & 0 deletions packages/automation/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export enum CommandContractType {
DmaSparkStopLossCommandV2 = 'DmaSparkStopLossCommandV2',
DmaAaveStopLossCommandV2 = 'DmaAaveV3StopLossCommandV2',
DmaAaveTrailingStopLossCommandV2 = 'DmaAaveV3TrailingStopLossCommandV2',
DmaSparkTrailingStopLossCommandV2 = 'DmaSparkTrailingStopLossCommandV2',
DmaSparkBasicBuyCommandV2 = 'DmaSparkBasicBuyCommandV2',
DmaSparkBasicSellCommandV2 = 'DmaSparkBasicSellCommandV2',
}

export enum TriggerType {
Expand Down Expand Up @@ -54,7 +57,10 @@ export enum TriggerType {
DmaAaveStopLossToDebtV2 = 128,
DmaSparkStopLossToCollateralV2 = 129,
DmaSparkStopLossToDebtV2 = 130,
DmaSparkBasicBuyV2 = 131,
DmaSparkBasicSellV2 = 132,
DmaAaveTrailingStopLossV2 = 10006,
DmaSparkTrailingStopLossV2 = 10007,
}

export const triggerTypeToCommandContractTypeMap: Record<TriggerType, CommandContractType> = {
Expand Down Expand Up @@ -84,6 +90,9 @@ export const triggerTypeToCommandContractTypeMap: Record<TriggerType, CommandCon
[TriggerType.DmaSparkStopLossToCollateralV2]: CommandContractType.DmaSparkStopLossCommandV2,
[TriggerType.DmaSparkStopLossToDebtV2]: CommandContractType.DmaSparkStopLossCommandV2,
[TriggerType.DmaAaveTrailingStopLossV2]: CommandContractType.DmaAaveTrailingStopLossCommandV2,
[TriggerType.DmaSparkTrailingStopLossV2]: CommandContractType.DmaSparkTrailingStopLossCommandV2,
[TriggerType.DmaSparkBasicBuyV2]: CommandContractType.DmaSparkBasicBuyCommandV2,
[TriggerType.DmaSparkBasicSellV2]: CommandContractType.DmaSparkBasicSellCommandV2,
};

export enum TriggerGroupType {
Expand Down

0 comments on commit 7a77408

Please sign in to comment.