-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba8e708
commit 5fbcc39
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Command } from "commander"; | ||
import { loadConfig, loadMarketConfig } from "../../utils/config"; | ||
import signers from "../../entities/signers"; | ||
import { OwnerWrapper } from "../../wrappers/OwnerWrapper"; | ||
import { TradeOrderHelper__factory } from "../../../../typechain"; | ||
import { ethers } from "ethers"; | ||
|
||
async function main(chainId: number) { | ||
const inputs = [ | ||
{ marketIndex: 52, positionSizeLimit: 100000, tradeSizeLimit: 100000 }, | ||
{ marketIndex: 53, positionSizeLimit: 200000, tradeSizeLimit: 200000 }, | ||
]; | ||
|
||
const config = loadConfig(chainId); | ||
const marketConfig = loadMarketConfig(chainId); | ||
const deployer = signers.deployer(chainId); | ||
const ownerWrapper = new OwnerWrapper(chainId, deployer); | ||
const limitTradeHelper = TradeOrderHelper__factory.connect(config.helpers.tradeOrder!, deployer); | ||
|
||
console.log(`[configs/TradeOrderHelper] Set Limit By Market Index...`); | ||
console.table( | ||
inputs.map((i) => { | ||
return { | ||
marketIndex: i.marketIndex, | ||
market: marketConfig.markets[i.marketIndex].name, | ||
positionSizeLimit: i.positionSizeLimit, | ||
tradeSizeLimit: i.tradeSizeLimit, | ||
}; | ||
}) | ||
); | ||
await ownerWrapper.authExec( | ||
limitTradeHelper.address, | ||
limitTradeHelper.interface.encodeFunctionData("setLimit", [ | ||
inputs.map((input) => input.marketIndex), | ||
inputs.map((input) => ethers.utils.parseUnits(input.positionSizeLimit.toString(), 30)), | ||
inputs.map((input) => ethers.utils.parseUnits(input.tradeSizeLimit.toString(), 30)), | ||
]) | ||
); | ||
} | ||
|
||
const program = new Command(); | ||
|
||
program.requiredOption("--chain-id <number>", "chain id", parseInt); | ||
|
||
const opts = program.parse(process.argv).opts(); | ||
|
||
main(opts.chainId) | ||
.then(() => { | ||
process.exit(0); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |