RepoTokenLinkedList.sol#RepoTokenLinkedList

Git Source

Inherits: Initializable, UUPSUpgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable, RepoTokenLinkedListStorageV1

A marketplace for trading repo tokens

Implements upgradeable patterns and various security features

State Variables

TERM_CONTROLLER

ITermController public immutable TERM_CONTROLLER;

REPO_TOKEN_LINKED_LIST_EVENT_EMITTER

RepoTokenLinkedListEventEmitter public immutable REPO_TOKEN_LINKED_LIST_EVENT_EMITTER;

ADMIN_ROLE

bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

DEVOPS_ROLE

bytes32 public constant DEVOPS_ROLE = keccak256("DEVOPS_ROLE");

RATE_PRECISION

MAX_MARKUP

REDEMPTION_VALUE_PRECISION

THREESIXTY_DAYCOUNT_SECONDS

USDC

WETH

Functions

constructor

Contract constructor

Parameters

Name
Type
Description

termController

address

Address of the term controller contract

repoTokenLinkedListEventEmitter

address

Address of the event emitter contract

initialize

Initializes the contract with admin and devops roles

Sets up roles and initializes the contract using OpenZeppelin's upgradeable pattern

See: https://docs.openzeppelin.com/contracts/4.x/upgradeable

Parameters

Name
Type
Description

discountRateAdapter_

address

The address of the discount rate oracle

adminWallet_

address

The address to be granted the admin role

devopsWallet_

address

The address to be granted the devops role

onlyValidatedRepoToken

Modifier to check if a repo token is valid

setRepoTokenBlacklist

Sets the blacklist status for a repo token

Parameters

Name
Type
Description

repoToken

address

The address of the repo token

blacklisted

bool

The blacklist status to set

setDiscountRateAdapter

Sets a new discount rate adapter

Parameters

Name
Type
Description

newAdapter

address

The address of the new discount rate adapter

setDiscountRateMarkup

Sets a new value for the discount rate markup

Only callable by accounts with the ADMIN_ROLE

Parameters

Name
Type
Description

newMarkup

uint256

The new markup value to set

manageMinimumListing

pause

Pauses the contract

unpause

Unpauses the contract

createListing

Creates a new listing for a repo token

Parameters

Name
Type
Description

repoToken

address

The address of the repo token to list

amount

uint256

The amount of tokens to list

purchase

Allows a user to purchase repo tokens

Parameters

Name
Type
Description

desiredAmount

uint256

The amount of tokens to purchase

repoToken

address

The address of the repo token to purchase

swapExactPurchaseForRepo

Allows a user to purchase repo tokens

Parameters

Name
Type
Description

purchaseTokenAmount

uint256

The amount of purchase tokens to spend in purchase

repoToken

address

The address of the repo token to purchase

_purchase

Internal function to handle the purchase logic

Parameters

Name
Type
Description

repoToken

address

The address of the repo token to purchase

purchaseToken

address

The address of the token used for purchase

desiredAmount

uint256

The amount of tokens to purchase

pricePerToken

uint256

The price per token

_emitAndTransfer

cancelListing

Allows a seller to cancel their listing

Parameters

Name
Type
Description

listingId

uint256

The ID of the listing to cancel

skipRedeem

bool

Whether to skip the redeem process

batchCancelListings

Repotokens can be redeemed by anyone on behalf of any third-party

removeListing

Internal function to remove a listing

Parameters

Name
Type
Description

repoToken

address

The address of the repo token

listingId

uint256

The ID of the listing to remove

getListing

Retrieves the details of a listing

Parameters

Name
Type
Description

listingId

uint256

The ID of the listing to retrieve

Returns

Name
Type
Description

seller

address

The address of the seller

token

address

The address of the token being sold

amount

uint256

The amount of tokens being sold

getTotalListings

Gets the total number of active listings

Parameters

Name
Type
Description

repoToken

address

The address of the repo token

Returns

Name
Type
Description

<none>

uint256

The total number of listings

isRepoTokenValid

Checks if a repo token is valid

Parameters

Name
Type
Description

repoToken

address

The address of the repo token to check

Returns

Name
Type
Description

<none>

bool

bool indicating if the repo token is valid

_authorizeUpgrade

Ensures only authorized addresses can upgrade the contract

Overrides the UUPSUpgradeable _authorizeUpgrade function to include role checks.

required override by the OpenZeppelin UUPS module

Parameters

Name
Type
Description

<none>

address

Last updated