-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: addressed testing issues and formatting
- Loading branch information
msacco8
committed
Feb 6, 2024
1 parent
5c4db22
commit fa22967
Showing
4 changed files
with
240 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Forta-Bots-Challenge-4/liquidatable-positions/src/mock.agent.utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { BigNumber, Contract } from "ethers"; | ||
|
||
export type CollateralAddresses = { | ||
[key: string]: string; | ||
}; | ||
|
||
export type CollateralBalances = { | ||
[key: string]: string; | ||
}; | ||
|
||
export type CollateralQuotes = { | ||
[key: string]: string; | ||
}; | ||
|
||
export type CollateralContracts = { | ||
[key: string]: Contract; | ||
}; | ||
|
||
export type PositionData = { | ||
owner: string; | ||
token: string; | ||
}; | ||
|
||
export type PositionDataResponse = { | ||
newOrUpdatedPosition: boolean; | ||
position: PositionData; | ||
}; | ||
|
||
export type Liquidatable = { | ||
position: PositionData; | ||
isLiquidatable: boolean; | ||
borrowBalance: BigNumber; | ||
collateralBalances: CollateralBalances; | ||
collateralQuotes: CollateralQuotes; | ||
}; | ||
|
||
export type FetcherConfig = { | ||
cometAddress: string; | ||
baseAssetAddress: string; | ||
collateralAddresses: CollateralAddresses; | ||
borrowThreshold: BigNumber; | ||
maxPositions: number; | ||
}; | ||
|
||
export const emptyPositionData: PositionData = { | ||
owner: "", | ||
token: "", | ||
}; | ||
|
||
export const emptyPositionDataResponse: PositionDataResponse = { | ||
newOrUpdatedPosition: false, | ||
position: emptyPositionData, | ||
}; | ||
|
||
export const emptyLiquidationInfo: Liquidatable = { | ||
position: emptyPositionData, | ||
isLiquidatable: false, | ||
borrowBalance: BigNumber.from(0), | ||
collateralBalances: {}, | ||
collateralQuotes: {}, | ||
}; |
80 changes: 80 additions & 0 deletions
80
Forta-Bots-Challenge-4/liquidatable-positions/src/mock.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { createAddress } from "forta-agent-tools"; | ||
import { Interface } from "ethers/lib/utils"; | ||
import { BigNumber } from "ethers"; | ||
import { CollateralAddresses, FetcherConfig } from "./mock.agent.utils"; | ||
|
||
export const mockCallSignatures: string[] = ["withdraw", "withdrawTo", "withdrawFrom", "supply", "supplyTo", "supplyFrom"]; | ||
|
||
const mockBorrowThresholdUSDC: BigNumber = BigNumber.from(50); | ||
const mockBorrowThresholdWETH: BigNumber = BigNumber.from(5); | ||
|
||
export const mockCometAddressUSDC: string = createAddress("0xa1"); | ||
export const mockCometAddressWETH: string = createAddress("0xa2"); | ||
|
||
export const mockBaseUSDC: string = createAddress("0xa3"); | ||
export const mockBaseWETH: string = createAddress("0xa4"); | ||
|
||
export const mockERC20ABI: string[] = ["function balanceOf(address) external view returns (uint256)"]; | ||
export const mockCometABI: string[] = [ | ||
"function isLiquidatable(address) public view returns (bool)", | ||
"function borrowBalanceOf(address) public view returns (uint256)", | ||
"function quoteCollateral(address, uint) public view returns (uint)", | ||
]; | ||
export const mockCometSignatures: string[] = [ | ||
"function withdraw(address, uint) external", | ||
"function withdrawTo(address, address, uint) external", | ||
"function withdrawFrom(address, address, address, uint) external", | ||
"function supply(address, uint) external", | ||
"function supplyTo(address, address, uint) external", | ||
"function supplyFrom(address, address, address, uint) external", | ||
]; | ||
|
||
export const mockERC20IFACE: Interface = new Interface(mockERC20ABI); | ||
export const mockCometIFACE: Interface = new Interface(mockCometABI); | ||
export const mockCometSignaturesIFACE: Interface = new Interface(mockCometSignatures); | ||
|
||
export const mockCollateralUSDC: CollateralAddresses = { | ||
WBTC: createAddress("0xb1"), | ||
WETH: createAddress("0xb2"), | ||
COMP: createAddress("0xb3"), | ||
UNI: createAddress("0xb4"), | ||
LINK: createAddress("0xb5"), | ||
}; | ||
export const mockCollateralWETH: CollateralAddresses = { | ||
wstETH: createAddress("0xc1"), | ||
cbETH: createAddress("0xc2"), | ||
rETH: createAddress("0xc3"), | ||
}; | ||
|
||
export const mockFetcherConfigUSDC: FetcherConfig = { | ||
cometAddress: mockCometAddressUSDC, | ||
baseAssetAddress: mockBaseUSDC, | ||
collateralAddresses: mockCollateralUSDC, | ||
borrowThreshold: mockBorrowThresholdUSDC, | ||
maxPositions: 5, | ||
}; | ||
export const mockFetcherConfigWETH: FetcherConfig = { | ||
cometAddress: mockCometAddressWETH, | ||
baseAssetAddress: mockBaseWETH, | ||
collateralAddresses: mockCollateralWETH, | ||
borrowThreshold: mockBorrowThresholdWETH, | ||
maxPositions: 5, | ||
}; | ||
|
||
export const mockSenders: string[] = [ | ||
createAddress("0xd1"), | ||
createAddress("0xd2"), | ||
createAddress("0xd3"), | ||
createAddress("0xd4"), | ||
createAddress("0xd5"), | ||
createAddress("0xd6"), | ||
]; | ||
|
||
export const mockSendees: string[] = [ | ||
createAddress("0xe1"), | ||
createAddress("0xe2"), | ||
createAddress("0xe3"), | ||
createAddress("0xe4"), | ||
]; | ||
|
||
export const mockManaged: string[] = [createAddress("0xf1"), createAddress("0xf2")]; |