-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAllV5.ts
77 lines (68 loc) · 2.08 KB
/
AllV5.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { Address } from 'viem';
import { Auction, LoanV5 } from '@/blockchain';
import { Wallet } from '@/contracts';
import { getContracts } from '@/deploys';
import { auctionLoanLiquidatorABI as auctionLoanLiquidatorABIV5 } from '@/generated/blockchain/v5';
import { AllV6 } from './AllV6';
import { BaseContract } from './BaseContract';
export class AllV5 extends BaseContract<typeof auctionLoanLiquidatorABIV5> {
constructor({ walletClient }: { walletClient: Wallet }) {
const {
AuctionLoanLiquidator: { v5 },
} = getContracts(walletClient.chain);
super({
walletClient,
address: v5,
abi: auctionLoanLiquidatorABIV5,
});
}
async placeBid({
collectionContractAddress,
tokenId,
bid,
auction,
}: {
collectionContractAddress: Address;
tokenId: bigint;
bid: bigint;
auction: Auction;
}) {
const txHash = await this.safeContractWrite.placeBid([
collectionContractAddress,
tokenId,
auction,
bid,
]);
return {
txHash,
waitTxInBlock: async () => {
const receipt = await this.bcClient.waitForTransactionReceipt({
hash: txHash,
});
const events = this.parseEventLogs('BidPlaced', receipt.logs);
if (events.length === 0) throw new Error('Bid not placed');
return { ...events[0].args, ...receipt };
},
};
}
getRemainingLockupSeconds() {
return 0;
}
async settleAuctionWithBuyout(): ReturnType<AllV6['settleAuctionWithBuyout']> {
throw new Error('Not implemented for V2');
}
async settleAuction({ auction, loan }: { auction: Auction; loan: LoanV5 }) {
const txHash = await this.safeContractWrite.settleAuction([auction, loan]);
return {
txHash,
waitTxInBlock: async () => {
const receipt = await this.bcClient.waitForTransactionReceipt({
hash: txHash,
});
const events = this.parseEventLogs('AuctionSettled', receipt.logs);
if (events.length === 0) throw new Error('Auction not settled');
return { ...events[0].args, ...receipt };
},
};
}
}