Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ To estimate a trade:
yarn start estimateChangePosition -n arbitrum_rinkeby --exchangeAddress 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2 --deltaAsset <deltaAsset> --deltaStable <deltaStable>
```

To get position:

```
yarn start getPosition -n arbitrum_rinkeby --exchangeAddress 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2 --trader <trader_address>
```

`--trader` defaults to your selected address, so it shows your position, if
not specified.

To liquidate:

```
Expand Down
39 changes: 39 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,45 @@ const main = async () => {
}
}
)
.command(
["getPosition"],
"Get position from exchange",
async (yargs: Argv) => {
return yargs
.option("trader", {
alias: "t",
describe: "traders account, uses current account if not specified",
type: "string",
});
},
async (argv) => {
let { trader } = argv;

const { accountNumber, networkId, exchangeAddress } =
getStandardParams(argv);

const wallet = loadAccount(networkId, accountNumber);
const exchange = IExchange__factory.connect(exchangeAddress, wallet);

if (trader === undefined) {
trader = wallet.address;
}

try {
const trade = await exchange.getPosition(trader);

console.log({
asset: trade.asset.toString(),
stable: trade.stable.toString(),
adlTrancheId: trade.adlTrancheId.toString(),
adlShareClass: trade.adlShareClass.toString(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adlTrancheId and adlShareClass are rather internal.
Do we want to show them in this UI?
In particular, adlShareClass, I would think, is not very meaningful to the end users.

});
} catch (e) {
console.log("Can not get position");
console.log({ e });
}
}
)
.command(
["liquidationBot"],
"run a bot to liquidate traders",
Expand Down