Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add spark triggers #113

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading