diff --git a/src/abi/SettlementSale.ts b/src/abi/SettlementSale.ts index 42ec36c..7d5fd47 100644 --- a/src/abi/SettlementSale.ts +++ b/src/abi/SettlementSale.ts @@ -4,6 +4,19 @@ export const settlementSaleAbi = [ "inputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "COMMITMENT_REDUCER_ROLE", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "DEFAULT_ADMIN_ROLE", @@ -135,13 +148,6 @@ export const settlementSaleAbi = [ ], "stateMutability": "view" }, - { - "type": "function", - "name": "closeCommitment", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, { "type": "function", "name": "entitiesIn", @@ -187,19 +193,19 @@ export const settlementSaleAbi = [ }, { "type": "function", - "name": "entityStateByID", + "name": "entityStatesByIDs", "inputs": [ { - "name": "entityID", - "type": "bytes16", - "internalType": "bytes16" + "name": "entityIDs", + "type": "bytes16[]", + "internalType": "bytes16[]" } ], "outputs": [ { "name": "", - "type": "tuple", - "internalType": "struct SettlementSale.EntityStateView", + "type": "tuple[]", + "internalType": "struct SettlementSale.EntityStateView[]", "components": [ { "name": "entityID", @@ -211,11 +217,6 @@ export const settlementSaleAbi = [ "type": "uint32", "internalType": "uint32" }, - { - "name": "cancelled", - "type": "bool", - "internalType": "bool" - }, { "name": "refunded", "type": "bool", @@ -258,23 +259,6 @@ export const settlementSaleAbi = [ "type": "bytes16", "internalType": "bytes16" }, - { - "name": "acceptedAmountByToken", - "type": "tuple[]", - "internalType": "struct TokenAmount[]", - "components": [ - { - "name": "token", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, { "name": "committedAmountByToken", "type": "tuple[]", @@ -291,89 +275,9 @@ export const settlementSaleAbi = [ "internalType": "uint256" } ] - } - ] - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "entityStatesByIDs", - "inputs": [ - { - "name": "entityIDs", - "type": "bytes16[]", - "internalType": "bytes16[]" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "internalType": "struct SettlementSale.EntityStateView[]", - "components": [ - { - "name": "entityID", - "type": "bytes16", - "internalType": "bytes16" - }, - { - "name": "bidTimestamp", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "cancelled", - "type": "bool", - "internalType": "bool" - }, - { - "name": "refunded", - "type": "bool", - "internalType": "bool" - }, - { - "name": "currentBid", - "type": "tuple", - "internalType": "struct SettlementSale.Bid", - "components": [ - { - "name": "lockup", - "type": "bool", - "internalType": "bool" }, { - "name": "price", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "name": "walletStates", - "type": "tuple[]", - "internalType": "struct SettlementSale.WalletStateView[]", - "components": [ - { - "name": "addr", - "type": "address", - "internalType": "address" - }, - { - "name": "entityID", - "type": "bytes16", - "internalType": "bytes16" - }, - { - "name": "acceptedAmountByToken", + "name": "cancelledAmountByToken", "type": "tuple[]", "internalType": "struct TokenAmount[]", "components": [ @@ -390,7 +294,7 @@ export const settlementSaleAbi = [ ] }, { - "name": "committedAmountByToken", + "name": "acceptedAmountByToken", "type": "tuple[]", "internalType": "struct TokenAmount[]", "components": [ @@ -444,11 +348,6 @@ export const settlementSaleAbi = [ "type": "uint32", "internalType": "uint32" }, - { - "name": "cancelled", - "type": "bool", - "internalType": "bool" - }, { "name": "refunded", "type": "bool", @@ -492,7 +391,7 @@ export const settlementSaleAbi = [ "internalType": "bytes16" }, { - "name": "acceptedAmountByToken", + "name": "committedAmountByToken", "type": "tuple[]", "internalType": "struct TokenAmount[]", "components": [ @@ -509,7 +408,24 @@ export const settlementSaleAbi = [ ] }, { - "name": "committedAmountByToken", + "name": "cancelledAmountByToken", + "type": "tuple[]", + "internalType": "struct TokenAmount[]", + "components": [ + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "acceptedAmountByToken", "type": "tuple[]", "internalType": "struct TokenAmount[]", "components": [ @@ -545,6 +461,36 @@ export const settlementSaleAbi = [ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "forceReduceCommitment", + "inputs": [ + { + "name": "reductions", + "type": "tuple[]", + "internalType": "struct WalletTokenAmount[]", + "components": [ + { + "name": "wallet", + "type": "address", + "internalType": "address" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, { "type": "function", "name": "getRoleAdmin", @@ -703,6 +649,16 @@ export const settlementSaleAbi = [ "type": "bool", "internalType": "bool" }, + { + "name": "reduceCommitmentEnabled", + "type": "bool", + "internalType": "bool" + }, + { + "name": "skipPreOpen", + "type": "bool", + "internalType": "bool" + }, { "name": "maxWalletsPerEntity", "type": "uint8", @@ -1146,6 +1102,49 @@ export const settlementSaleAbi = [ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "reduceCommitment", + "inputs": [ + { + "name": "reductions", + "type": "tuple[]", + "internalType": "struct WalletTokenAmount[]", + "components": [ + { + "name": "wallet", + "type": "address", + "internalType": "address" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "reduceCommitmentEnabled", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "renounceRole", @@ -1501,6 +1500,19 @@ export const settlementSaleAbi = [ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "setReduceCommitmentEnabled", + "inputs": [ + { + "name": "enabled", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, { "type": "function", "name": "stage", @@ -1571,6 +1583,44 @@ export const settlementSaleAbi = [ ], "stateMutability": "view" }, + { + "type": "function", + "name": "totalCancelledAmount", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalCancelledAmountByToken", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "internalType": "struct TokenAmount[]", + "components": [ + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "totalCommittedAmount", @@ -1685,19 +1735,19 @@ export const settlementSaleAbi = [ }, { "type": "function", - "name": "walletStateByAddress", + "name": "walletStatesByAddresses", "inputs": [ { - "name": "addr", - "type": "address", - "internalType": "address" + "name": "addrs", + "type": "address[]", + "internalType": "address[]" } ], "outputs": [ { "name": "", - "type": "tuple", - "internalType": "struct SettlementSale.WalletStateView", + "type": "tuple[]", + "internalType": "struct SettlementSale.WalletStateView[]", "components": [ { "name": "addr", @@ -1709,23 +1759,6 @@ export const settlementSaleAbi = [ "type": "bytes16", "internalType": "bytes16" }, - { - "name": "acceptedAmountByToken", - "type": "tuple[]", - "internalType": "struct TokenAmount[]", - "components": [ - { - "name": "token", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, { "name": "committedAmountByToken", "type": "tuple[]", @@ -1742,40 +1775,9 @@ export const settlementSaleAbi = [ "internalType": "uint256" } ] - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "walletStatesByAddresses", - "inputs": [ - { - "name": "addrs", - "type": "address[]", - "internalType": "address[]" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "internalType": "struct SettlementSale.WalletStateView[]", - "components": [ - { - "name": "addr", - "type": "address", - "internalType": "address" - }, - { - "name": "entityID", - "type": "bytes16", - "internalType": "bytes16" }, { - "name": "acceptedAmountByToken", + "name": "cancelledAmountByToken", "type": "tuple[]", "internalType": "struct TokenAmount[]", "components": [ @@ -1792,7 +1794,7 @@ export const settlementSaleAbi = [ ] }, { - "name": "committedAmountByToken", + "name": "acceptedAmountByToken", "type": "tuple[]", "internalType": "struct TokenAmount[]", "components": [ @@ -1907,31 +1909,6 @@ export const settlementSaleAbi = [ ], "anonymous": false }, - { - "type": "event", - "name": "BidCancelled", - "inputs": [ - { - "name": "entityID", - "type": "bytes16", - "indexed": true, - "internalType": "bytes16" - }, - { - "name": "wallet", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, { "type": "event", "name": "BidPlaced", @@ -1987,6 +1964,68 @@ export const settlementSaleAbi = [ ], "anonymous": false }, + { + "type": "event", + "name": "CommitmentIncreased", + "inputs": [ + { + "name": "entityID", + "type": "bytes16", + "indexed": true, + "internalType": "bytes16" + }, + { + "name": "wallet", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "token", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CommitmentReduced", + "inputs": [ + { + "name": "entityID", + "type": "bytes16", + "indexed": true, + "internalType": "bytes16" + }, + { + "name": "wallet", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "token", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, { "type": "event", "name": "EntityInitialized", @@ -2114,6 +2153,19 @@ export const settlementSaleAbi = [ ], "anonymous": false }, + { + "type": "event", + "name": "ReduceCommitmentEnabledChanged", + "inputs": [ + { + "name": "enabled", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, { "type": "event", "name": "RefundedEntitySkipped", @@ -2347,11 +2399,6 @@ export const settlementSaleAbi = [ "name": "entityID", "type": "bytes16", "internalType": "bytes16" - }, - { - "name": "acceptedAmount", - "type": "uint256", - "internalType": "uint256" } ] }, @@ -2397,17 +2444,6 @@ export const settlementSaleAbi = [ } ] }, - { - "type": "error", - "name": "BidAlreadyCancelled", - "inputs": [ - { - "name": "entityID", - "type": "bytes16", - "internalType": "bytes16" - } - ] - }, { "type": "error", "name": "BidAmountCannotBeLowered", @@ -2726,6 +2762,47 @@ export const settlementSaleAbi = [ } ] }, + { + "type": "error", + "name": "ReduceCommitmentDisabled", + "inputs": [] + }, + { + "type": "error", + "name": "ReductionExceedsReducibleAmount", + "inputs": [ + { + "name": "entityID", + "type": "bytes16", + "internalType": "bytes16" + }, + { + "name": "wallet", + "type": "address", + "internalType": "address" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "committed", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "allocated", + "type": "uint256", + "internalType": "uint256" + } + ] + }, { "type": "error", "name": "SafeERC20FailedOperation", diff --git a/src/hooks.ts b/src/hooks.ts index eb13802..fa08ad1 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -77,21 +77,21 @@ export const useSaleContract = (saleSpecificEntityID: Hex) => { setTxHash(bidHash); }, - [writeContractAsync, config] + [writeContractAsync, config], ); - const { data: entityState, error: entityStateError } = useReadContract({ + const { data: entityStates, error: entityStateError } = useReadContract({ address: saleContract, abi: settlementSaleAbi, - functionName: "entityStateByID", - args: [saleSpecificEntityID], + functionName: "entityStatesByIDs", + args: [[saleSpecificEntityID]], query: { refetchInterval: 3000, }, }); return { - entityState, + entityState: entityStates?.[0], entityStateError, commitWithPermit, awaitingTxReceipt,