# TermAuctionOfferLocker.sol

## TermAuctionOfferLocker

This contract handles and proceesses Term Auction offer submissions

*This contract belongs to the Term Auction group of contracts and is specific to a Term Repo deployment*

### MAX\_OFFER\_PRICE

```solidity
uint256 MAX_OFFER_PRICE
```

### MAX\_OFFER\_COUNT

```solidity
uint256 MAX_OFFER_COUNT
```

### ADMIN\_ROLE

```solidity
bytes32 ADMIN_ROLE
```

### AUCTIONEER\_ROLE

```solidity
bytes32 AUCTIONEER_ROLE
```

### DEVOPS\_ROLE

```solidity
bytes32 DEVOPS_ROLE
```

### INITIALIZER\_ROLE

```solidity
bytes32 INITIALIZER_ROLE
```

### termRepoId

```solidity
bytes32 termRepoId
```

### termAuctionId

```solidity
bytes32 termAuctionId
```

### auctionStartTime

```solidity
uint256 auctionStartTime
```

### revealTime

```solidity
uint256 revealTime
```

### auctionEndTime

```solidity
uint256 auctionEndTime
```

### minimumTenderAmount

```solidity
uint256 minimumTenderAmount
```

### purchaseToken

```solidity
contract IERC20Upgradeable purchaseToken
```

### collateralTokens

```solidity
mapping(contract IERC20Upgradeable => bool) collateralTokens
```

### termRepoServicer

```solidity
contract ITermRepoServicer termRepoServicer
```

### emitter

```solidity
contract ITermEventEmitter emitter
```

### termAuction

```solidity
contract ITermAuction termAuction
```

### offers

```solidity
mapping(bytes32 => struct TermAuctionOffer) offers
```

### offerCount

```solidity
uint256 offerCount
```

### termContractPaired

```solidity
bool termContractPaired
```

### lockingPaused

```solidity
bool lockingPaused
```

### unlockingPaused

```solidity
bool unlockingPaused
```

### onlyWhileAuctionOpen

```solidity
modifier onlyWhileAuctionOpen()
```

### onlyWhileAuctionRevealing

```solidity
modifier onlyWhileAuctionRevealing()
```

### onlyOfferor

```solidity
modifier onlyOfferor(address offeror, address authedUser)
```

### onlyExistingOffer

```solidity
modifier onlyExistingOffer(bytes32 id)
```

### whenLockingNotPaused

```solidity
modifier whenLockingNotPaused()
```

### whenUnlockingNotPaused

```solidity
modifier whenUnlockingNotPaused()
```

### notTermContractPaired

```solidity
modifier notTermContractPaired()
```

### constructor

```solidity
constructor() public
```

### initialize

```solidity
function initialize(string termRepoId_, string auctionId_, uint256 auctionStartTime_, uint256 revealTime_, uint256 auctionEndTime_, uint256 minimumTenderAmount_, contract IERC20Upgradeable purchaseToken_, contract IERC20Upgradeable[] collateralTokens_, address termInitializer_) external
```

### pairTermContracts

```solidity
function pairTermContracts(address termAuction_, contract ITermEventEmitter emitter_, contract ITermRepoServicer termRepoServicer_, address devopsMultisig_, address adminWallet_) external
```

### lockOffersWithReferral

```solidity
function lockOffersWithReferral(struct TermAuctionOfferSubmission[] offerSubmissions, address referralAddress) external returns (bytes32[])
```

#### Parameters

| Name             | Type                                 | Description                                                                                                |
| ---------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
| offerSubmissions | struct TermAuctionOfferSubmission\[] | An array of Term Auction offer submissions to lend an amount of money at rate no lower than the offer rate |
| referralAddress  | address                              | A user address that referred the submitter of this offer                                                   |

#### Return Values

| Name | Type       | Description                                   |
| ---- | ---------- | --------------------------------------------- |
| \[0] | bytes32\[] | A bytes32 array of unique on chain offer ids. |

### lockOffers

```solidity
function lockOffers(struct TermAuctionOfferSubmission[] offerSubmissions) external returns (bytes32[])
```

#### Parameters

| Name             | Type                                 | Description                   |
| ---------------- | ------------------------------------ | ----------------------------- |
| offerSubmissions | struct TermAuctionOfferSubmission\[] | An array of offer submissions |

#### Return Values

| Name | Type       | Description                                   |
| ---- | ---------- | --------------------------------------------- |
| \[0] | bytes32\[] | A bytes32 array of unique on chain offer ids. |

### lockedOffer

```solidity
function lockedOffer(bytes32 id) external view returns (struct TermAuctionOffer)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| id   | bytes32 | An offer Id |

#### Return Values

| Name | Type                    | Description                                         |
| ---- | ----------------------- | --------------------------------------------------- |
| \[0] | struct TermAuctionOffer | A struct containing the details of the locked offer |

### revealOffers

```solidity
function revealOffers(bytes32[] ids, uint256[] prices, uint256[] nonces) external
```

#### Parameters

| Name   | Type       | Description                                           |
| ------ | ---------- | ----------------------------------------------------- |
| ids    | bytes32\[] | An array offer ids to reveal                          |
| prices | uint256\[] | An array of the offer prices to reveal                |
| nonces | uint256\[] | An array of nonce values to generate bid price hashes |

### unlockOffers

```solidity
function unlockOffers(bytes32[] ids) external
```

unlockOffers unlocks multiple offers and returns funds to the offeror

#### Parameters

| Name | Type       | Description           |
| ---- | ---------- | --------------------- |
| ids  | bytes32\[] | An array of offer ids |

### getAllOffers

```solidity
function getAllOffers(bytes32[] revealedOffers, bytes32[] unrevealedOffers) external returns (struct TermAuctionRevealedOffer[], struct TermAuctionOffer[])
```

#### Parameters

| Name             | Type       | Description                          |
| ---------------- | ---------- | ------------------------------------ |
| revealedOffers   | bytes32\[] | An array of the revealed offer ids   |
| unrevealedOffers | bytes32\[] | An array of the unrevealed offer ids |

#### Return Values

| Name | Type                               | Description                                                                            |
| ---- | ---------------------------------- | -------------------------------------------------------------------------------------- |
| \[0] | struct TermAuctionRevealedOffer\[] | An array of TermAuctionRevealedOffer structs containing details of the revealed offers |
| \[1] | struct TermAuctionOffer\[]         | An array of TermAuctionOffer structs containing details of the unrevealed offers       |

### unlockOfferPartial

```solidity
function unlockOfferPartial(bytes32 id, address offeror, uint256 amount) public
```

#### Parameters

| Name    | Type    | Description                             |
| ------- | ------- | --------------------------------------- |
| id      | bytes32 | An offer Id                             |
| offeror | address | Address of the offeror                  |
| amount  | uint256 | The amount of purchase tokens to unlock |

### \_lock

```solidity
function _lock(struct TermAuctionOfferSubmission offerSubmission, address authedUser) internal returns (struct TermAuctionOffer)
```

### \_unlock

```solidity
function _unlock(bytes32 id, address offeror) internal
```

### \_revealOffer

```solidity
function _revealOffer(bytes32 id, uint256 price, uint256 nonce) internal
```

*Will revert if either the price does not match the offer price or is greater than the max offer price*

#### Parameters

| Name  | Type    | Description                                                  |
| ----- | ------- | ------------------------------------------------------------ |
| id    | bytes32 | An offer Id                                                  |
| price | uint256 | The price of the offer to reveal                             |
| nonce | uint256 | The user provided nonce value to generate the bid price hash |

### \_generateOfferId

```solidity
function _generateOfferId(bytes32 id, address user) internal view returns (bytes32)
```

### \_processOfferForAuction

```solidity
function _processOfferForAuction(bytes32 id) internal
```

### \_truncateOfferStruct

```solidity
function _truncateOfferStruct(struct TermAuctionOffer hidden, uint256 price) internal pure returns (struct TermAuctionRevealedOffer revealed)
```

*This does not check the hash of the revealed offer price*

#### Parameters

| Name   | Type                    | Description                                             |
| ------ | ----------------------- | ------------------------------------------------------- |
| hidden | struct TermAuctionOffer | TermAuctionOffer to convert to TermAuctionRevealedOffer |
| price  | uint256                 | The revealed price of the offer                         |

### pauseLocking

```solidity
function pauseLocking() external
```

### unpauseLocking

```solidity
function unpauseLocking() external
```

### pauseUnlocking

```solidity
function pauseUnlocking() external
```

### unpauseUnlocking

```solidity
function unpauseUnlocking() external
```

### \_authorizeUpgrade

```solidity
function _authorizeUpgrade(address impl) internal
```

*required override by the OpenZeppelin UUPS module*

#### Parameters

| Name | Type    | Description                        |
| ---- | ------- | ---------------------------------- |
| impl | address | new impl address for proxy upgrade |
