Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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.12 to 1.1.13

LICENSE

8

lib/src/abi-coding.js

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

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

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

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

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

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

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

function encodeTriggerDataByType(type, values) {
const paramTypes = (0, mapping_1.getDefinitionForCommandType)(type);
const paramTypes = 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, TriggerGroupType } from './types';
export { CommandContractType, TriggerType } from './types';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TriggerGroupType = exports.TriggerType = exports.CommandContractType = exports.getCommandAddresses = exports.encodeTriggerDataByType = exports.encodeTriggerData = exports.decodeTriggerDataByType = exports.decodeTriggerData = void 0;
exports.TriggerType = exports.CommandContractType = exports.getCommandAddresses = exports.encodeTriggerDataByType = exports.encodeTriggerData = exports.decodeTriggerDataByType = exports.decodeTriggerData = void 0;
var abi_coding_1 = require("./abi-coding");

@@ -14,3 +14,2 @@ 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,5 +5,6 @@ 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"];
};

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

@@ -25,5 +25,4 @@ "use strict";

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

@@ -41,3 +40,2 @@ [types_1.EthereumNetwork.MAINNET]: {

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

@@ -63,2 +61,22 @@ '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',
],
};

@@ -65,0 +83,0 @@ function getCommandAddresses(network) {

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

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

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

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

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

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

@@ -12,5 +12,6 @@ (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 = {}));

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

TriggerType[TriggerType["BasicSell"] = 4] = "BasicSell";
TriggerType[TriggerType["AutoTakeProfitToCollateral"] = 7] = "AutoTakeProfitToCollateral";
TriggerType[TriggerType["AutoTakeProfitToDai"] = 8] = "AutoTakeProfitToDai";
TriggerType[TriggerType["CMBasicBuy"] = 5] = "CMBasicBuy";
TriggerType[TriggerType["CMBasicSell"] = 6] = "CMBasicSell";
})(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 = (0, mapping_1.getDefinitionForCommandType)(type);
const paramTypes = 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 = (0, abi_coding_1.encodeTriggerData)(commandAddress, network, validValues);
(0, chai_1.expect)(result).to.eq(data);
const result = abi_coding_1.encodeTriggerData(commandAddress, network, validValues);
chai_1.expect(result).to.eq(data);
});
it('can encode trigger data by command type', () => {
const result = (0, abi_coding_1.encodeTriggerDataByType)(type, validValues);
(0, chai_1.expect)(result).to.eq(data);
const result = abi_coding_1.encodeTriggerDataByType(type, validValues);
chai_1.expect(result).to.eq(data);
});
it('can encode if supplied command address is not lowercase', () => {
const result = (0, abi_coding_1.encodeTriggerData)(commandAddress, network, validValues);
(0, chai_1.expect)(result).to.eq(data);
const result = abi_coding_1.encodeTriggerData(commandAddress, network, validValues);
chai_1.expect(result).to.eq(data);
});
it('throws if invalid network provided', () => {
const invalidNetworkId = 100;
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerData)(commandAddress, invalidNetworkId, validValues)).to.throw(`Command addresses for network ${invalidNetworkId} not found`);
chai_1.expect(() => 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;
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerData)(invalidAddress, network, validValues)).to.throw(`Command address ${invalidAddress} for network ${network} not found.`);
chai_1.expect(() => 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';
(0, chai_1.expect)(() => (0, abi_coding_1.encodeTriggerDataByType)(invalidType, validValues)).to.throw(`Unknown command type ${invalidType}`);
chai_1.expect(() => abi_coding_1.encodeTriggerDataByType(invalidType, validValues)).to.throw(`Unknown command type ${invalidType}`);
});
it('throws if invalid values are provided', () => {
const invalidValues = ['1x2', 1, 101];
(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();
chai_1.expect(() => abi_coding_1.encodeTriggerData(commandAddress, network, invalidValues)).to.throw();
chai_1.expect(() => abi_coding_1.encodeTriggerDataByType(type, invalidValues)).to.throw();
});

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

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

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

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

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

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

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

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

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

},
"gitHead": "4c0fe3919c127018d3785ce6cc323621cd565d4f"
"gitHead": "bdc28f1f242386be350a15416387a1433338b7d9"
}

@@ -20,2 +20,3 @@ import {

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

@@ -29,2 +30,3 @@ type: CommandContractType.BasicSellCommand,

'0x2ecc5086ce10194175607d0d082fc27c3416693d': { type: CommandContractType.BasicSellCommand },
'0x940a17668197f71DcAefD77Bf8c43c001c77f5AC': { type: CommandContractType.BasicSellCommand },
'0x02b7391cdd0c8a75ecfc278d387e3dcc3d796340': {

@@ -38,5 +40,7 @@ type: CommandContractType.AutoTakeProfitCommand,

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

@@ -43,0 +47,0 @@ };

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