Skip to content

Commit

Permalink
update: add liquidate account method for test contract
Browse files Browse the repository at this point in the history
  • Loading branch information
asolovov committed Nov 14, 2023
1 parent 813ece5 commit 18dc1a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/testing-contracts/perps-test/perps-market.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ func (m *TestPerpsMarket) CommitOrder(marketIDS string, sizeS string) {
logger.Log().WithField("layer", "TestPerpsMarket-CommitOrder").Infof("order commited, tx hash: %v", tx.Hash())
}

func (m *TestPerpsMarket) LiquidateAccount(accountIDs string) {
aut := m.getAut("Liquidate")

accountID := m.getBig(accountIDs)

tx, err := m.perpsMarket.Liquidate(aut, accountID)
if err != nil {
logger.Log().WithField("layer", "TestPerpsMarket-LiquidateAccount").Fatalf("liquidate account err: %v", err.Error())
}

logger.Log().WithField("layer", "TestPerpsMarket-LiquidateAccount").Infof("account liquidated, tx hash: %v", tx.Hash())
}

func (m *TestPerpsMarket) Close() {
m.rpcClient.Close()
}
Expand Down
3 changes: 3 additions & 0 deletions utils/testing-contracts/perps-test/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func main() {
// Account ID, Permission and User
perps.GrantPermission(args[2], args[3], args[4])
perps.Close()
case "LiquidateAccount":
perps.LiquidateAccount(args[2])
perps.Close()
default:
perps.Close()
logger.Log().WithField("layer", "TestPerpsMarket-Main").Fatalf("unknown command")
Expand Down

0 comments on commit 18dc1a2

Please sign in to comment.