-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclosePosition.js
More file actions
35 lines (27 loc) · 1.17 KB
/
closePosition.js
File metadata and controls
35 lines (27 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { Guardian__factory, Perpetual__factory } = require("@firefly-exchange/library/dist/src/contracts/exchange");
const { ethers,toBigNumberStr } = require("@firefly-exchange/library");
const environment = require("./environments.json");
require('dotenv').config();
env = environment[process.env.env]
market = process.env.market;
console.log("Env:", process.env.env);
console.log("Market:", market);
const providerURL = env["URL"];
const owner = env["DEPLOYER"]
const perpetualContractAddress = env[market]["Perpetual"]
const provider = new ethers.providers.JsonRpcProvider(providerURL);
async function main(ownerPvtKey){
console.log("Close Positions On:", ownerPvtKey);
const owner = ownerPvtKey;
const ownerWallet = new ethers.Wallet(owner, provider);
contract = Perpetual__factory.connect(perpetualContractAddress, ownerWallet);
const address = await ownerWallet.getAddress();
await ( await contract.closePosition(ownerWallet.address )).wait();
}
if(require.main === module){
if(process.argv.length != 3){
console.error(`provide ownerPvtKey e.g. yarn closePosition <ownerPvtKey>`);
process.exit(1);
};
main(process.argv[2]);
}