Socket
Socket
Sign inDemoInstall

@oasisdex/automation

Package Overview
Dependencies
Maintainers
10
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oasisdex/automation - npm Package Compare versions

Comparing version 1.1.15 to 1.1.16

8

lib/src/abi-coding.js

@@ -7,3 +7,3 @@ "use strict";

function decodeTriggerData(commandAddress, network, data) {
const paramTypes = mapping_1.getDefinitionForCommandAddress(commandAddress, network);
const paramTypes = (0, mapping_1.getDefinitionForCommandAddress)(commandAddress, network);
return ethers_1.utils.defaultAbiCoder.decode(paramTypes, data);

@@ -13,3 +13,3 @@ }

function decodeTriggerDataByType(type, data) {
const paramTypes = mapping_1.getDefinitionForCommandType(type);
const paramTypes = (0, mapping_1.getDefinitionForCommandType)(type);
return ethers_1.utils.defaultAbiCoder.decode(paramTypes, data);

@@ -19,3 +19,3 @@ }

function encodeTriggerData(commandAddress, network, values) {
const paramTypes = mapping_1.getDefinitionForCommandAddress(commandAddress, network);
const paramTypes = (0, mapping_1.getDefinitionForCommandAddress)(commandAddress, network);
return ethers_1.utils.defaultAbiCoder.encode(paramTypes, values);

@@ -25,3 +25,3 @@ }

function encodeTriggerDataByType(type, values) {
const paramTypes = mapping_1.getDefinitionForCommandType(type);
const paramTypes = (0, mapping_1.getDefinitionForCommandType)(type);
return ethers_1.utils.defaultAbiCoder.encode(paramTypes, values);

@@ -28,0 +28,0 @@ }

export { decodeTriggerData, decodeTriggerDataByType, encodeTriggerData, encodeTriggerDataByType, } from './abi-coding';
export { getCommandAddresses } from './mapping';
export { CommandContractType, TriggerType } from './types';
export { CommandContractType, TriggerType, TriggerGroupType } from './types';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TriggerType = exports.CommandContractType = exports.getCommandAddresses = exports.encodeTriggerDataByType = exports.encodeTriggerData = exports.decodeTriggerDataByType = exports.decodeTriggerData = void 0;
exports.TriggerGroupType = exports.TriggerType = exports.CommandContractType = exports.getCommandAddresses = exports.encodeTriggerDataByType = exports.encodeTriggerData = exports.decodeTriggerDataByType = exports.decodeTriggerData = void 0;
var abi_coding_1 = require("./abi-coding");

@@ -14,2 +14,3 @@ Object.defineProperty(exports, "decodeTriggerData", { enumerable: true, get: function () { return abi_coding_1.decodeTriggerData; } });

Object.defineProperty(exports, "TriggerType", { enumerable: true, get: function () { return types_1.TriggerType; } });
Object.defineProperty(exports, "TriggerGroupType", { enumerable: true, get: function () { return types_1.TriggerGroupType; } });
//# sourceMappingURL=index.js.map

@@ -5,6 +5,5 @@ import { CommandContractInfo, CommandContractType, ParamDefinition } from './types';

readonly CloseCommand: readonly ["uint256", "uint16", "uint256"];
readonly AutoTakeProfitCommand: readonly ["uint256", "uint16", "uint256", "uint32"];
readonly BasicBuyCommand: readonly ["uint256", "uint16", "uint256", "uint256", "uint256", "bool", "uint64", "uint32"];
readonly BasicSellCommand: readonly ["uint256", "uint16", "uint256", "uint256", "uint256", "bool", "uint64", "uint32"];
readonly CMBasicSellCommand: readonly ["uint256", "uint16", "uint256", "uint256", "uint256", "bool", "uint64", "uint32"];
readonly CMBasicBuyCommand: readonly ["uint256", "uint16", "uint256", "uint256", "uint256", "bool", "uint64", "uint32"];
};

@@ -11,0 +10,0 @@ export declare function getCommandAddresses(network: number): Record<CommandContractType, string[]>;

@@ -17,2 +17,3 @@ "use strict";

'0x2003dc19056ba986b7d10ab4704897d685dd62d9': { type: types_1.CommandContractType.BasicBuyCommand },
'0xf19ae4c34e0e0db13d074876a12339e86dc12f06': { type: types_1.CommandContractType.BasicBuyCommand },
'0xd4f94e013c7f47b989ea79c6527e065c027794c7': {

@@ -26,4 +27,6 @@ type: types_1.CommandContractType.BasicSellCommand,

'0x2ecc5086ce10194175607d0d082fc27c3416693d': { type: types_1.CommandContractType.BasicSellCommand },
'0x15c595ce24576924b2302bbcad552e3dadfa4469': { type: types_1.CommandContractType.CMBasicSellCommand },
'0xcbaaae60eeab8b3df33fa84f704c0c43cec29f73': { type: types_1.CommandContractType.CMBasicBuyCommand },
'0x940a17668197f71dcaefd77bf8c43c001c77f5ac': { type: types_1.CommandContractType.BasicSellCommand },
'0x02b7391cdd0c8a75ecfc278d387e3dcc3d796340': {
type: types_1.CommandContractType.AutoTakeProfitCommand,
},
},

@@ -34,5 +37,7 @@ [types_1.EthereumNetwork.MAINNET]: {

'0xd36729c7cac24e47dc32ffd7d433f965caaeb912': { type: types_1.CommandContractType.BasicBuyCommand },
'0x31285A87fB70a62b5AaA43199e53221c197E1e3f': { type: types_1.CommandContractType.BasicBuyCommand },
'0xa6bd41b821972e83d30598c5683efbbe6ad70fb8': { type: types_1.CommandContractType.BasicSellCommand },
'0xf9469da48f9d2ea87e195e3dd522226e876a1185': { type: types_1.CommandContractType.BasicSellCommand },
'0x5588d89a3c68e5a87cafe6b79ef8caa667a702f1': { type: types_1.CommandContractType.BasicSellCommand },
'0x7c0d6d8d6eae8bcb106afdb3a21df5c254c6c0b2': { type: types_1.CommandContractType.BasicSellCommand },
},

@@ -42,2 +47,3 @@ };

[types_1.CommandContractType.CloseCommand]: ['uint256', 'uint16', 'uint256'],
[types_1.CommandContractType.AutoTakeProfitCommand]: ['uint256', 'uint16', 'uint256', 'uint32'],
[types_1.CommandContractType.BasicBuyCommand]: [

@@ -63,22 +69,2 @@ 'uint256',

],
[types_1.CommandContractType.CMBasicSellCommand]: [
'uint256',
'uint16',
'uint256',
'uint256',
'uint256',
'bool',
'uint64',
'uint32',
],
[types_1.CommandContractType.CMBasicBuyCommand]: [
'uint256',
'uint16',
'uint256',
'uint256',
'uint256',
'bool',
'uint64',
'uint32',
],
};

@@ -85,0 +71,0 @@ function getCommandAddresses(network) {

@@ -8,6 +8,5 @@ import { ethers } from 'ethers';

CloseCommand = "CloseCommand",
AutoTakeProfitCommand = "AutoTakeProfitCommand",
BasicBuyCommand = "BasicBuyCommand",
BasicSellCommand = "BasicSellCommand",
CMBasicBuyCommand = "CMBasicBuyCommand",
CMBasicSellCommand = "CMBasicSellCommand"
BasicSellCommand = "BasicSellCommand"
}

@@ -19,5 +18,8 @@ export declare enum TriggerType {

BasicSell = 4,
CMBasicBuy = 5,
CMBasicSell = 6
AutoTakeProfitToCollateral = 7,
AutoTakeProfitToDai = 8
}
export declare enum TriggerGroupType {
ConstantMultiple = 1
}
export declare type ParamDefinition = ReadonlyArray<string | ethers.utils.ParamType>;

@@ -24,0 +26,0 @@ export declare type CommandTypeMapping = Record<CommandContractType, ParamDefinition>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TriggerType = exports.CommandContractType = exports.EthereumNetwork = void 0;
exports.TriggerGroupType = exports.TriggerType = exports.CommandContractType = exports.EthereumNetwork = void 0;
var EthereumNetwork;

@@ -12,6 +12,5 @@ (function (EthereumNetwork) {

CommandContractType["CloseCommand"] = "CloseCommand";
CommandContractType["AutoTakeProfitCommand"] = "AutoTakeProfitCommand";
CommandContractType["BasicBuyCommand"] = "BasicBuyCommand";
CommandContractType["BasicSellCommand"] = "BasicSellCommand";
CommandContractType["CMBasicBuyCommand"] = "CMBasicBuyCommand";
CommandContractType["CMBasicSellCommand"] = "CMBasicSellCommand";
})(CommandContractType = exports.CommandContractType || (exports.CommandContractType = {}));

@@ -24,5 +23,9 @@ var TriggerType;

TriggerType[TriggerType["BasicSell"] = 4] = "BasicSell";
TriggerType[TriggerType["CMBasicBuy"] = 5] = "CMBasicBuy";
TriggerType[TriggerType["CMBasicSell"] = 6] = "CMBasicSell";
TriggerType[TriggerType["AutoTakeProfitToCollateral"] = 7] = "AutoTakeProfitToCollateral";
TriggerType[TriggerType["AutoTakeProfitToDai"] = 8] = "AutoTakeProfitToDai";
})(TriggerType = exports.TriggerType || (exports.TriggerType = {}));
var TriggerGroupType;
(function (TriggerGroupType) {
TriggerGroupType[TriggerGroupType["ConstantMultiple"] = 1] = "ConstantMultiple";
})(TriggerGroupType = exports.TriggerGroupType || (exports.TriggerGroupType = {}));
//# sourceMappingURL=types.js.map

@@ -12,3 +12,3 @@ "use strict";

const [commandAddress] = Object.keys(mapping_1.commandAddressMapping[network]);
const paramTypes = mapping_1.getDefinitionForCommandType(type);
const paramTypes = (0, mapping_1.getDefinitionForCommandType)(type);
const validValues = [12, 1, 101];

@@ -18,29 +18,29 @@ const data = ethers_1.utils.defaultAbiCoder.encode(paramTypes, validValues);

it('can encode trigger data by command address', () => {
const result = abi_coding_1.encodeTriggerData(commandAddress, network, validValues);
chai_1.expect(result).to.eq(data);
const result = (0, abi_coding_1.encodeTriggerData)(commandAddress, network, validValues);
(0, chai_1.expect)(result).to.eq(data);
});
it('can encode trigger data by command type', () => {
const result = abi_coding_1.encodeTriggerDataByType(type, validValues);
chai_1.expect(result).to.eq(data);
const result = (0, abi_coding_1.encodeTriggerDataByType)(type, validValues);
(0, chai_1.expect)(result).to.eq(data);
});
it('can encode if supplied command address is not lowercase', () => {
const result = abi_coding_1.encodeTriggerData(commandAddress, network, validValues);
chai_1.expect(result).to.eq(data);
const result = (0, abi_coding_1.encodeTriggerData)(commandAddress, network, validValues);
(0, chai_1.expect)(result).to.eq(data);
});
it('throws if invalid network provided', () => {
const invalidNetworkId = 100;
chai_1.expect(() => abi_coding_1.encodeTriggerData(commandAddress, invalidNetworkId, validValues)).to.throw(`Command addresses for network ${invalidNetworkId} not found`);
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerData)(commandAddress, invalidNetworkId, validValues)).to.throw(`Command addresses for network ${invalidNetworkId} not found`);
});
it('throws if invalid command address provided', () => {
const invalidAddress = ethers_1.constants.AddressZero;
chai_1.expect(() => abi_coding_1.encodeTriggerData(invalidAddress, network, validValues)).to.throw(`Command address ${invalidAddress} for network ${network} not found.`);
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerData)(invalidAddress, network, validValues)).to.throw(`Command address ${invalidAddress} for network ${network} not found.`);
});
it('throws if invalid type provided', () => {
const invalidType = 'InvalidCommand';
chai_1.expect(() => abi_coding_1.encodeTriggerDataByType(invalidType, validValues)).to.throw(`Unknown command type ${invalidType}`);
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerDataByType)(invalidType, validValues)).to.throw(`Unknown command type ${invalidType}`);
});
it('throws if invalid values are provided', () => {
const invalidValues = ['1x2', 1, 101];
chai_1.expect(() => abi_coding_1.encodeTriggerData(commandAddress, network, invalidValues)).to.throw();
chai_1.expect(() => abi_coding_1.encodeTriggerDataByType(type, invalidValues)).to.throw();
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerData)(commandAddress, network, invalidValues)).to.throw();
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerDataByType)(type, invalidValues)).to.throw();
});

@@ -50,11 +50,11 @@ });

it('can decode trigger data by command address', () => {
const result = abi_coding_1.decodeTriggerData(commandAddress, network, data);
const result = (0, abi_coding_1.decodeTriggerData)(commandAddress, network, data);
result.forEach((value, idx) => {
chai_1.expect(ethers_1.BigNumber.from(value).toNumber()).to.eq(validValues[idx]);
(0, chai_1.expect)(ethers_1.BigNumber.from(value).toNumber()).to.eq(validValues[idx]);
});
});
it('can decode trigger data by command address', () => {
const result = abi_coding_1.decodeTriggerDataByType(type, data);
const result = (0, abi_coding_1.decodeTriggerDataByType)(type, data);
result.forEach((value, idx) => {
chai_1.expect(ethers_1.BigNumber.from(value).toNumber()).to.eq(validValues[idx]);
(0, chai_1.expect)(ethers_1.BigNumber.from(value).toNumber()).to.eq(validValues[idx]);
});

@@ -64,16 +64,16 @@ });

const invalidNetworkId = 100;
chai_1.expect(() => abi_coding_1.decodeTriggerData(commandAddress, invalidNetworkId, data)).to.throw(`Command addresses for network ${invalidNetworkId} not found`);
(0, chai_1.expect)(() => (0, abi_coding_1.decodeTriggerData)(commandAddress, invalidNetworkId, data)).to.throw(`Command addresses for network ${invalidNetworkId} not found`);
});
it('throws if invalid command address provided', () => {
const invalidAddress = ethers_1.constants.AddressZero;
chai_1.expect(() => abi_coding_1.decodeTriggerData(invalidAddress, network, data)).to.throw(`Command address ${invalidAddress} for network ${network} not found.`);
(0, chai_1.expect)(() => (0, abi_coding_1.decodeTriggerData)(invalidAddress, network, data)).to.throw(`Command address ${invalidAddress} for network ${network} not found.`);
});
it('throws if invalid type provided', () => {
const invalidType = 'InvalidCommand';
chai_1.expect(() => abi_coding_1.decodeTriggerDataByType(invalidType, data)).to.throw(`Unknown command type ${invalidType}`);
(0, chai_1.expect)(() => (0, abi_coding_1.decodeTriggerDataByType)(invalidType, data)).to.throw(`Unknown command type ${invalidType}`);
});
it('throws if invalid data provided', () => {
const invalidData = '0xdead';
chai_1.expect(() => abi_coding_1.decodeTriggerData(commandAddress, network, invalidData)).to.throw();
chai_1.expect(() => abi_coding_1.decodeTriggerDataByType(type, invalidData)).to.throw();
(0, chai_1.expect)(() => (0, abi_coding_1.decodeTriggerData)(commandAddress, network, invalidData)).to.throw();
(0, chai_1.expect)(() => (0, abi_coding_1.decodeTriggerDataByType)(type, invalidData)).to.throw();
});

@@ -84,6 +84,6 @@ });

const targetValues = [3567, 2, 160];
const encoded = abi_coding_1.encodeTriggerData(commandAddress, network, targetValues);
const decoded = abi_coding_1.decodeTriggerData(commandAddress, network, encoded);
const encoded = (0, abi_coding_1.encodeTriggerData)(commandAddress, network, targetValues);
const decoded = (0, abi_coding_1.decodeTriggerData)(commandAddress, network, encoded);
decoded.forEach((value, idx) => {
chai_1.expect(ethers_1.BigNumber.from(value).toNumber()).to.eq(targetValues[idx]);
(0, chai_1.expect)(ethers_1.BigNumber.from(value).toNumber()).to.eq(targetValues[idx]);
});

@@ -90,0 +90,0 @@ });

{
"name": "@oasisdex/automation",
"version": "1.1.15",
"version": "1.1.16",
"description": "The set of utilities for Oasis automation",

@@ -27,3 +27,3 @@ "homepage": "https://github.com/OasisDEX/common#readme",

},
"gitHead": "33c43416a2d581c370090a0d9ecae78bf30393e9"
"gitHead": "f2db9851cf1dab4e761a5a11066ad331ead35fa3"
}

@@ -8,3 +8,3 @@ import {

// The addresses must be in lowercase!
// The addresses must be in lowercase
export const commandAddressMapping: Record<number, Record<string, CommandContractInfo>> = {

@@ -11,0 +11,0 @@ [EthereumNetwork.GOERLI]: {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc