@oasisdex/automation
Advanced tools
Comparing version 1.1.11 to 1.1.12
@@ -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[]>; |
@@ -25,4 +25,5 @@ "use strict"; | ||
'0x2ecc5086ce10194175607d0d082fc27c3416693d': { type: types_1.CommandContractType.BasicSellCommand }, | ||
'0x15c595ce24576924b2302bbcad552e3dadfa4469': { type: types_1.CommandContractType.CMBasicSellCommand }, | ||
'0xcbaaae60eeab8b3df33fa84f704c0c43cec29f73': { type: types_1.CommandContractType.CMBasicBuyCommand }, | ||
'0x02b7391cdd0c8a75ecfc278d387e3dcc3d796340': { | ||
type: types_1.CommandContractType.AutoTakeProfitCommand, | ||
}, | ||
}, | ||
@@ -40,2 +41,3 @@ [types_1.EthereumNetwork.MAINNET]: { | ||
[types_1.CommandContractType.CloseCommand]: ['uint256', 'uint16', 'uint256'], | ||
[types_1.CommandContractType.AutoTakeProfitCommand]: ['uint256', 'uint16', 'uint256', 'uint32'], | ||
[types_1.CommandContractType.BasicBuyCommand]: [ | ||
@@ -61,22 +63,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', | ||
], | ||
}; | ||
@@ -83,0 +65,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.11", | ||
"version": "1.1.12", | ||
"description": "The set of utilities for Oasis automation", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/OasisDEX/common#readme", |
@@ -28,2 +28,5 @@ import { | ||
'0x2ecc5086ce10194175607d0d082fc27c3416693d': { type: CommandContractType.BasicSellCommand }, | ||
'0x02b7391cdd0c8a75ecfc278d387e3dcc3d796340': { | ||
type: CommandContractType.AutoTakeProfitCommand, | ||
}, | ||
}, | ||
@@ -42,2 +45,3 @@ [EthereumNetwork.MAINNET]: { | ||
[CommandContractType.CloseCommand]: ['uint256', 'uint16', 'uint256'], | ||
[CommandContractType.AutoTakeProfitCommand]: ['uint256', 'uint16', 'uint256', 'uint32'], | ||
[CommandContractType.BasicBuyCommand]: [ | ||
@@ -44,0 +48,0 @@ 'uint256', |
@@ -10,2 +10,3 @@ import { ethers } from 'ethers'; | ||
CloseCommand = 'CloseCommand', | ||
AutoTakeProfitCommand = 'AutoTakeProfitCommand', | ||
BasicBuyCommand = 'BasicBuyCommand', | ||
@@ -20,2 +21,4 @@ BasicSellCommand = 'BasicSellCommand', | ||
BasicSell = 4, | ||
AutoTakeProfitToCollateral = 7, | ||
AutoTakeProfitToDai = 8, | ||
} | ||
@@ -22,0 +25,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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
72682
589
1