-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathliquidate-vault.js
37 lines (33 loc) · 1.22 KB
/
liquidate-vault.js
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
36
37
require('dotenv').config();
const CONTRACT_ADDRESS = process.env.CONTRACT_ADDRESS;
const CONTRACT_NAME = 'arkadiko-liquidator-v2-1';
const FUNCTION_NAME = 'notify-risky-vault';
const tx = require('@stacks/transactions');
const utils = require('./utils');
const network = utils.resolveNetwork();
const BN = require('bn.js');
const vaultId = process.argv.slice(2)[0];
console.log('Trying to liquidate vault with ID', vaultId);
const txOptions = {
contractAddress: CONTRACT_ADDRESS,
contractName: CONTRACT_NAME,
functionName: FUNCTION_NAME,
functionArgs: [
tx.contractPrincipalCV(CONTRACT_ADDRESS, 'arkadiko-freddie-v1-1'),
tx.contractPrincipalCV(CONTRACT_ADDRESS, 'arkadiko-auction-engine-v3-1'),
tx.uintCV(vaultId),
tx.contractPrincipalCV(CONTRACT_ADDRESS, 'arkadiko-collateral-types-v1-1'),
tx.contractPrincipalCV(CONTRACT_ADDRESS, 'arkadiko-oracle-v1-1')
],
fee: new BN(10000, 10),
nonce: new BN(581, 10),
senderKey: process.env.STACKS_PRIVATE_KEY,
postConditionMode: 1,
network
};
async function transact() {
const transaction = await tx.makeContractCall(txOptions);
const result = tx.broadcastTransaction(transaction, network);
await utils.processing(result, transaction.txid(), 0);
};
transact();