Skip to content

Commit

Permalink
new contract updates
Browse files Browse the repository at this point in the history
  • Loading branch information
brightiron committed Jul 29, 2024
1 parent a025e70 commit 6771378
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 95 deletions.
106 changes: 29 additions & 77 deletions src/abi/CoolerConsolidation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@
{ "name": "gohm_", "type": "address", "internalType": "address" },
{ "name": "sdai_", "type": "address", "internalType": "address" },
{ "name": "dai_", "type": "address", "internalType": "address" },
{ "name": "lender_", "type": "address", "internalType": "address" }
{ "name": "owner_", "type": "address", "internalType": "address" },
{ "name": "lender_", "type": "address", "internalType": "address" },
{ "name": "collector_", "type": "address", "internalType": "address" },
{ "name": "feePercentage_", "type": "uint256", "internalType": "uint256" }
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "approve",
"inputs": [
{ "name": "cooler_", "type": "address", "internalType": "address" },
{ "name": "spender_", "type": "address", "internalType": "address" }
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "collector",
Expand All @@ -31,45 +24,13 @@
"type": "function",
"name": "consolidateWithFlashLoan",
"inputs": [
{ "name": "target_", "type": "address", "internalType": "address" },
{
"name": "clearinghouse_",
"type": "address",
"internalType": "address"
},
{
"name": "batch_",
"type": "tuple[]",
"internalType": "struct CoolerUtils.Batch[]",
"components": [
{ "name": "cooler", "type": "address", "internalType": "address" },
{ "name": "ids", "type": "uint256[]", "internalType": "uint256[]" }
]
},
{
"name": "availableFunds_",
"type": "uint256",
"internalType": "uint256"
},
{ "name": "sdai_", "type": "bool", "internalType": "bool" }
],
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "consolidateWithUserFunds",
"inputs": [
{ "name": "clearinghouse_", "type": "address", "internalType": "address" },
{ "name": "cooler_", "type": "address", "internalType": "address" },
{
"name": "clearinghouse_",
"type": "address",
"internalType": "address"
},
{ "name": "ids_", "type": "uint256[]", "internalType": "uint256[]" },
{ "name": "useFunds_", "type": "uint256", "internalType": "uint256" },
{ "name": "sdai_", "type": "bool", "internalType": "bool" }
],
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"outputs": [],
"stateMutability": "nonpayable"
},
{
Expand All @@ -93,27 +54,11 @@
"outputs": [{ "name": "", "type": "address", "internalType": "contract IERC20" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "isApprovedFor",
"inputs": [
{ "name": "", "type": "address", "internalType": "address" },
{ "name": "", "type": "address", "internalType": "address" }
],
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "lender",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IERC3156FlashLender"
}
],
"outputs": [{ "name": "", "type": "address", "internalType": "contract IERC3156FlashLender" }],
"stateMutability": "view"
},
{
Expand All @@ -129,6 +74,13 @@
"outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "owner",
"inputs": [],
"outputs": [{ "name": "", "type": "address", "internalType": "address" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "requiredApprovals",
Expand All @@ -144,16 +96,6 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "revoke",
"inputs": [
{ "name": "cooler_", "type": "address", "internalType": "address" },
{ "name": "spender_", "type": "address", "internalType": "address" }
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "sdai",
Expand All @@ -162,12 +104,22 @@
"stateMutability": "view"
},
{
"type": "error",
"name": "MissingApproval",
"inputs": [{ "name": "cooler_", "type": "address", "internalType": "address" }]
"type": "function",
"name": "setCollector",
"inputs": [{ "name": "collector_", "type": "address", "internalType": "address" }],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "setFeePercentage",
"inputs": [{ "name": "feePercentage_", "type": "uint256", "internalType": "uint256" }],
"outputs": [],
"stateMutability": "nonpayable"
},
{ "type": "error", "name": "NotCoolerOwner", "inputs": [] },
{ "type": "error", "name": "OnlyCoolerOwner", "inputs": [] },
{ "type": "error", "name": "OnlyLender", "inputs": [] },
{ "type": "error", "name": "OnlyOwner", "inputs": [] },
{ "type": "error", "name": "OnlyThis", "inputs": [] }
]
}
2 changes: 0 additions & 2 deletions src/components/TokenAllowanceGuard/TokenAllowanceGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export const TokenAllowanceGuard: React.FC<{
const approveMutation = useApproveToken(tokenAddressMap);
const { data: allowance } = useContractAllowance(tokenAddressMap, spenderAddressMap);

console.log(allowance, "allowance", tokenAddressMap);

if (!allowance && tokenAddressMap[chain.id as NetworkId] !== ethers.constants.AddressZero)
return (
<Box display="flex" alignItems="center" justifyContent="center" height={isVertical ? "84px" : "40px"}>
Expand Down
2 changes: 1 addition & 1 deletion src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ export const COOLER_CLEARING_HOUSE_V2_ADDRESSES = {
};

export const COOLER_CONSOLIDATION_ADDRESSES = {
[NetworkId.MAINNET]: "0xD706dc3BffbF3883f43b4219F12c35A52e4ad42d",
[NetworkId.MAINNET]: "0xD24fAba2506b5B42Be42a6E6C1BA1Dd6856A412d",
[NetworkId.TESTNET_GOERLI]: "",
};
18 changes: 3 additions & 15 deletions src/views/Lending/Cooler/hooks/useConsolidateCooler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,9 @@ export const useConsolidateCooler = () => {
if (!signer) throw new Error(`Please connect a wallet`);
const contractAddress = COOLER_CONSOLIDATION_CONTRACT.addresses[networks.MAINNET];
const contract = CoolerConsolidation__factory.connect(contractAddress, signer);
const cooler = await contract.consolidateWithFlashLoan(
coolerAddress,
clearingHouseAddress,
[
{
cooler: coolerAddress,
ids: loanIds,
},
],
0,
false,
{
gasLimit: loanIds.length <= 30 ? loanIds.length * 1000000 : 30000000,
},
);
const cooler = await contract.consolidateWithFlashLoan(clearingHouseAddress, coolerAddress, loanIds, 0, false, {
gasLimit: loanIds.length <= 30 ? loanIds.length * 1000000 : 30000000,
});
const receipt = await cooler.wait();
return receipt;
},
Expand Down

0 comments on commit 6771378

Please sign in to comment.