Skip to content

Commit

Permalink
feat: set limit for intent
Browse files Browse the repository at this point in the history
  • Loading branch information
john-xina-p88 committed May 15, 2024
1 parent ba8e708 commit 5fbcc39
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions script/ts/configs/TradeOrderHelper/set-limit.ts
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);
});

0 comments on commit 5fbcc39

Please sign in to comment.