Carbonmark Solidity Reference Documentation
This page was generated by Foundry Forge from the natspec comments within Carbonmark solidity smart contracts.
It serves as technical reference for developers looking to integrate with Carbonmark contracts directly.
See Carbonmark docs for more information.
Contents
DiamondCutFacet
Inherits: IDiamondCut
Functions
diamondCut
Add/replace/remove any number of functions and optionally execute a function with delegatecall
function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external override;
Parameters
| Name | Type | Description |
|---|---|---|
_diamondCut | FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A function call, including function selector and arguments _calldata is executed with delegatecall on _init |
DiamondLoupeFacet
Inherits: IDiamondLoupe, IERC165
Functions
facets
These functions are expected to be called frequently by tools.
Gets all facets and their selectors.
function facets() external view override returns (Facet[] memory facets_);
Returns
| Name | Type | Description |
|---|---|---|
facets_ | Facet[] | Facet |
facetFunctionSelectors
Gets all the function selectors supported by a specific facet.
function facetFunctionSelectors(address _facet)
external
view
override
returns (bytes4[] memory _facetFunctionSelectors);
Parameters
| Name | Type | Description |
|---|---|---|
_facet | address | The facet address. |
Returns
| Name | Type | Description |
|---|---|---|
_facetFunctionSelectors | bytes4[] | The selectors associated with a facet address. |
facetAddresses
Get all the facet addresses used by a diamond.
function facetAddresses() external view override returns (address[] memory facetAddresses_);
Returns
| Name | Type | Description |
|---|---|---|
facetAddresses_ | address[] | facetAddresses_ |
facetAddress
Gets the facet address that supports the given selector.
If facet is not found return address(0).
function facetAddress(bytes4 _functionSelector) external view override returns (address facetAddress_);
Parameters
| Name | Type | Description |
|---|---|---|
_functionSelector | bytes4 | The function selector. |
Returns
| Name | Type | Description |
|---|---|---|
facetAddress_ | address | The facet address. |
supportsInterface
function supportsInterface(bytes4 _interfaceId) external view override returns (bool);
MarketplaceFacet
Inherits: ReentrancyGuard, IMarketplace
Author: Cujo, Tufnel_Enterprises
Contains the logic for creating and interacting with listings for the marketplace.
Functions
createListing
This function creates a new listing and returns the resulting listing ID
function createListing(
address token,
uint256 amount,
uint256 unitPrice,
uint256 minFillAmount,
uint256 deadline
)
external
override
nonReentrant
returns (bytes32 id);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token being listed |
amount | uint256 | The amount to be listed |
unitPrice | uint256 | The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000 |
minFillAmount | uint256 | The minimum number of tons needed to be purchased to fill this listing |
deadline | uint256 | The block timestamp at which this listing will expire |
Returns
| Name | Type | Description |
|---|---|---|
id | bytes32 | The ID of the listing that was created |
createListing
This function creates a new listing and returns the resulting listing ID
function createListing(
address token,
uint256 tokenId,
uint256 amount,
uint256 unitPrice,
uint256 minFillAmount,
uint256 deadline
)
external
override
nonReentrant
returns (bytes32 id);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token being listed |
tokenId | uint256 | |
amount | uint256 | The amount to be listed |
unitPrice | uint256 | The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000 |
minFillAmount | uint256 | The minimum number of tons needed to be purchased to fill this listing |
deadline | uint256 | The block timestamp at which this listing will expire |
Returns
| Name | Type | Description |
|---|---|---|
id | bytes32 | The ID of the listing that was created |
_createListing
function _createListing(
address token,
uint256 tokenId,
uint256 amount,
uint256 unitPrice,
uint256 minFillAmount,
uint256 deadline,
Storage.TokenType tokenType
)
internal
returns (bytes32 id);
updateListing
This function takes an old listing and replaces it with an updated listing
function updateListing(
bytes32 id,
uint256 newAmount,
uint256 newUnitPrice,
uint256 newMinFillAmount,
uint256 newDeadline
)
external
override
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to update |
newAmount | uint256 | The amount for the new listing |
newUnitPrice | uint256 | The unit price for the new listing |
newMinFillAmount | uint256 | The minFillAmount for the new listing |
newDeadline | uint256 | The deadline for the new listing |
cancelListing
This function cancels an existing listing
function cancelListing(bytes32 id) external override nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to cancel |
fillListing
This function fills an existing listing
function fillListing(
bytes32 id,
address listingAccount,
address listingToken,
uint256 listingUnitPrice,
uint256 amount,
uint256 maxCost
)
external
override
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to update |
listingAccount | address | The account that created the listing you are filling |
listingToken | address | The token you are swapping for |
listingUnitPrice | uint256 | The unit price per token to fill the listing |
amount | uint256 | Amount of the listing to fill |
maxCost | uint256 | Maximum cost in USDC for filling this listing |
_hashListing
function _hashListing(
address account,
uint256 tokenId,
address token,
uint256 increment
)
internal
pure
returns (bytes32 lHash);
_checkListingToken
function _checkListingToken(address token) internal returns (Storage.TokenType);
_getERC20BalanceAndAllowance
function _getERC20BalanceAndAllowance(
address token,
address account,
uint256 potentialListingAmount
)
internal
view
returns (uint256 balance, uint256 allowance);
_getERC1155BalanceAndAllowance
function _getERC1155BalanceAndAllowance(
address token,
address account,
uint256 tokenId,
uint256 potentialListingAmount
)
internal
view
returns (uint256 balance, bool approval);
getListingOwner
function getListingOwner(bytes32 id) external view returns (address);
getUnitPrice
function getUnitPrice(bytes32 id) external view returns (uint256);
getRemainingAmount
function getRemainingAmount(bytes32 id) external view returns (uint256);
getListingDeadline
function getListingDeadline(bytes32 id) external view returns (uint256);
getListingTotalByCredit
function getListingTotalByCredit(address account, address token, uint256 tokenId) external view returns (uint256);
OwnershipFacet
Inherits: IERC173
Functions
transferOwnership
function transferOwnership(address _newOwner) external override;
acceptOwnership
function acceptOwnership() external;
owner
function owner() external view override returns (address owner_);
pendingOwner
function pendingOwner() external view returns (address pendingOwner_);
Contents
- ICR
- IC3ProjectFactory
- ICMARKFactory
- IMarketplace
- IDiamond
- IDiamondCut
- IDiamondLoupe
- IERC165
- IERC173
- IToucanContractRegistry
Contents
ICarbonContractRegistryICR
Functions
getProjectIdFromAddress
function getProjectIdFromAddress(address projectAddress) external view returns (uint256);
IProjectICR
Functions
totalSupply
function totalSupply(uint256 id) external view returns (uint256);
isTokenExists
function isTokenExists(address _address) external returns (bool);
IC3ProjectFactory
Functions
isTokenExists
function isTokenExists(address _address) external returns (bool);
ICMARKFactory
Functions
creditAddressToId
function creditAddressToId(address _address) external view returns (string memory);
issueCredits
function issueCredits(string calldata creditId, uint256 amount, address to) external;
owner
function owner() external view returns (address);
creditIdToAddress
function creditIdToAddress(string calldata creditId) external view returns (address);
IMarketplace
Functions
createListing
This function creates a new listing and returns the resulting listing ID
This functino handles ERC20 tokens
function createListing(
address token,
uint256 amount,
uint256 unitPrice,
uint256 minFillAmount,
uint256 deadline
)
external
returns (bytes32 id);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token being listed |
amount | uint256 | The amount to be listed |
unitPrice | uint256 | The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000 |
minFillAmount | uint256 | The minimum number of tons needed to be purchased to fill this listing |
deadline | uint256 | The block timestamp at which this listing will expire |
Returns
| Name | Type | Description |
|---|---|---|
id | bytes32 | The ID of the listing that was created |
createListing
This function creates a new listing and returns the resulting listing ID
This function handles ERC1155 tokens
function createListing(
address token,
uint256 tokenId,
uint256 amount,
uint256 unitPrice,
uint256 minFillAmount,
uint256 deadline
)
external
returns (bytes32 id);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token being listed |
tokenId | uint256 | The token ID of the ERC1155 being listed |
amount | uint256 | The amount to be listed |
unitPrice | uint256 | The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000 |
minFillAmount | uint256 | The minimum number of tons needed to be purchased to fill this listing |
deadline | uint256 | The block timestamp at which this listing will expire |
Returns
| Name | Type | Description |
|---|---|---|
id | bytes32 | The ID of the listing that was created |
updateListing
This function takes an old listing and replaces it with an updated listing
function updateListing(
bytes32 id,
uint256 newAmount,
uint256 newUnitPrice,
uint256 newMinFillAmount,
uint256 newDeadline
)
external;
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to update |
newAmount | uint256 | The amount for the new listing |
newUnitPrice | uint256 | The unit price for the new listing |
newMinFillAmount | uint256 | The minFillAmount for the new listing |
newDeadline | uint256 | The deadline for the new listing |
cancelListing
This function cancels an existing listing
function cancelListing(bytes32 id) external;
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to cancel |
fillListing
This function fills an existing listing
function fillListing(
bytes32 id,
address listingAccount,
address listingToken,
uint256 listingUnitPrice,
uint256 amount,
uint256 maxCost
)
external;
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to update |
listingAccount | address | The account that created the listing you are filling |
listingToken | address | The token you are swapping for |
listingUnitPrice | uint256 | The unit price per token to fill the listing |
amount | uint256 | Amount of the listing to fill |
maxCost | uint256 | Maximum cost in USDC for filling this listing |
Events
ListingCreated
Emitted each time a new listing is created
event ListingCreated(
bytes32 id,
address account,
address token,
uint256 tokenId,
uint256 price,
uint256 amount,
uint256 minFillAmount,
uint256 deadline
);
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The resulting hashed listing ID |
account | address | The ethereum account that created the listing |
token | address | The ethereum address of the token being listed |
tokenId | uint256 | |
price | uint256 | The unit price in USDC for this listing |
amount | uint256 | The total amount of the token being listed |
minFillAmount | uint256 | The minimum amount needed to purchase to fill this listing |
deadline | uint256 | The block timestamp at which this listing expires |
ListingUpdated
Emitted every time an existing listing is updated
event ListingUpdated(
bytes32 id,
uint256 oldAmount,
uint256 newAmount,
uint256 oldUnitPrice,
uint256 newUnitPrice,
uint256 oldMinFillAmount,
uint256 newMinFillAmount,
uint256 oldDeadline,
uint256 newDeadline
);
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The hashed ID of the listing to update |
oldAmount | uint256 | Remaining amount to fill before the update |
newAmount | uint256 | Remaining amount to fill after the update |
oldUnitPrice | uint256 | Unit price before the update |
newUnitPrice | uint256 | Unit price after the update |
oldMinFillAmount | uint256 | Minimum fill amount before the update |
newMinFillAmount | uint256 | Minimum fill amount after the update |
oldDeadline | uint256 | Expiring deadline before the update |
newDeadline | uint256 | Expiring deadline after the update |
ListingCancelled
Emitted every time a listing is cancelled
event ListingCancelled(bytes32 id);
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The hashed ID of the listing being cancelled |
ListingFilled
Emitted every time a listing is filled
event ListingFilled(bytes32 id, address account, uint256 amount, uint256 totalCost);
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | ID of the listing being filled |
account | address | Ethereum address of account filling the listing |
amount | uint256 | Amount of the listing that was filled |
totalCost | uint256 | Total cost in USDC used to fill the listing |
Structs
CreditListing
Struct containing all of the detail information about a listing
struct CreditListing {
address account;
address token;
uint256 originalAmount;
uint256 remainingAmount;
uint256 unitPrice;
uint256 minFillAmount;
uint256 deadline;
}
Properties
| Name | Type | Description |
|---|---|---|
account | address | Ethereum address of the account who owns the listing |
token | address | Ethereum address of the token being listing |
originalAmount | uint256 | Original amount of the listing |
remainingAmount | uint256 | Remaining amount that can be filled on this listing |
unitPrice | uint256 | The unit price in USDC of the listing |
minFillAmount | uint256 | The minimum amount needed to purchase in order to fill the listing |
deadline | uint256 | The block timestamp at which this listing expires |
IDiamond
Events
DiamondCut
event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
Structs
FacetCut
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
Enums
FacetCutAction
enum FacetCutAction {
Add,
Replace,
Remove
}
IDiamondCut
Inherits: IDiamond
Functions
diamondCut
Add/replace/remove any number of functions and optionally execute a function with delegatecall
function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external;
Parameters
| Name | Type | Description |
|---|---|---|
_diamondCut | FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A function call, including function selector and arguments _calldata is executed with delegatecall on _init |
IDiamondLoupe
Functions
facets
Gets all facet addresses and their four byte function selectors.
function facets() external view returns (Facet[] memory facets_);
Returns
| Name | Type | Description |
|---|---|---|
facets_ | Facet[] | Facet |
facetFunctionSelectors
Gets all the function selectors supported by a specific facet.
function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);
Parameters
| Name | Type | Description |
|---|---|---|
_facet | address | The facet address. |
Returns
| Name | Type | Description |
|---|---|---|
facetFunctionSelectors_ | bytes4[] | facetFunctionSelectors_ |
facetAddresses
Get all the facet addresses used by a diamond.
function facetAddresses() external view returns (address[] memory facetAddresses_);
Returns
| Name | Type | Description |
|---|---|---|
facetAddresses_ | address[] | facetAddresses_ |
facetAddress
Gets the facet that supports the given selector.
If facet is not found return address(0).
function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);
Parameters
| Name | Type | Description |
|---|---|---|
_functionSelector | bytes4 | The function selector. |
Returns
| Name | Type | Description |
|---|---|---|
facetAddress_ | address | The facet address. |
Structs
Facet
These functions are expected to be called frequently by tools.
struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}
IERC165
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 | The interface identifier, as specified in ERC-165 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IERC173
Functions
owner
Get the address of the owner
function owner() external view returns (address owner_);
Returns
| Name | Type | Description |
|---|---|---|
owner_ | address | The address of the owner. |
transferOwnership
Set the address of the new owner of the contract
Set _newOwner to address(0) to renounce any ownership.
function transferOwnership(address _newOwner) external;
Parameters
| Name | Type | Description |
|---|---|---|
_newOwner | address | The address of the new owner of the contract |
Events
OwnershipTransferred
This emits when ownership of a contract changes.
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
IToucanContractRegistry
Functions
isValidERC20
function isValidERC20(address erc20) external returns (bool);
Contents
- Errors
- LibAppStorage
- LibDeploy
- NoSelectorsGivenToAdd
- NotContractOwner
- NoSelectorsProvidedForFacetForCut
- CannotAddSelectorsToZeroAddress
- NoBytecodeAtAddress
- IncorrectFacetCutAction
- CannotAddFunctionToDiamondThatAlreadyExists
- CannotReplaceFunctionsFromFacetWithZeroAddress
- CannotReplaceImmutableFunction
- CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet
- CannotReplaceFunctionThatDoesNotExists
- RemoveFacetAddressMustBeZeroAddress
- CannotRemoveFunctionThatDoesNotExist
- CannotRemoveImmutableFunction
- InitializationFunctionReverted
- NotPendingOwner
- LibDiamond
Errors
Any custom errors that Carbonmark may revert with are listed here.
Errors
CarbonmarkMarketplace_ListingDoesNotExist
error CarbonmarkMarketplace_ListingDoesNotExist();
CarbonmarkMarketplace_ListingAlreadyExists
error CarbonmarkMarketplace_ListingAlreadyExists();
CarbonmarkMarketplace_ListingNotOwner
error CarbonmarkMarketplace_ListingNotOwner();
CarbonmarkMarketplace_ListingExpired
error CarbonmarkMarketplace_ListingExpired();
CarbonmarkMarketplace_ListingTokenNotSupported
error CarbonmarkMarketplace_ListingTokenNotSupported(address token);
CarbonmarkMarketplace_ListingTokenBalanceTooLow
error CarbonmarkMarketplace_ListingTokenBalanceTooLow(address token, uint256 currentBalance, uint256 listingAmount);
CarbonmarkMarketplace_ListingTokenAllowanceTooLow
error CarbonmarkMarketplace_ListingTokenAllowanceTooLow(address token, uint256 currentAllowance, uint256 listingAmount);
CarbonmarkMarketplace_ListingTokenNotApprovedForAll
error CarbonmarkMarketplace_ListingTokenNotApprovedForAll(address token, bool approval);
CarbonmarkMarketplace_ListingPurchaseInExcessOfAvailable
error CarbonmarkMarketplace_ListingPurchaseInExcessOfAvailable();
CarbonmarkMarketplace_ListingFillTotalCostGreaterThanMax
error CarbonmarkMarketplace_ListingFillTotalCostGreaterThanMax();
CarbonmarkMarketplace_ListingPurchaseBelowMinimumFill
error CarbonmarkMarketplace_ListingPurchaseBelowMinimumFill();
CarbonmarkMarketplace_ListingFillDetailsMismatch
error CarbonmarkMarketplace_ListingFillDetailsMismatch();
CarbonmarkMarketplace_ListingAmountLessThanMinFillAmount
error CarbonmarkMarketplace_ListingAmountLessThanMinFillAmount(uint256 amount, uint256 minFillAmount);
CarbonmarkMarketplace_ListingAmountZero
error CarbonmarkMarketplace_ListingAmountZero();
LibAppStorage
Author: Cujo
Functions
diamondStorage
function diamondStorage() internal pure returns (AppStorage storage ds);
LibDeploy
Contains functions for deploying facets and creating facet cuts without relying on external helpers.
Functions
deployMarketplaceFacet
Deploys the MarketplaceFacet contract.
function deployMarketplaceFacet() internal returns (MarketplaceFacet marketplaceF);
Returns
| Name | Type | Description |
|---|---|---|
marketplaceF | MarketplaceFacet | The deployed MarketplaceFacet contract. |
marketplaceFacetCuts
Creates a cut to replace all marketplace function selectors and point them at the given facetAddress
function marketplaceFacetCuts(address facetAddress) internal pure returns (IDiamond.FacetCut[] memory cut);
Parameters
| Name | Type | Description |
|---|---|---|
facetAddress | address | The address of the facet to be added or replaced. |
Returns
| Name | Type | Description |
|---|---|---|
cut | IDiamond.FacetCut[] | An array containing the FacetCut struct. |
getMarketplaceFacetSelectors
Retrieves the function selectors from the MarketplaceFacet.
function getMarketplaceFacetSelectors() internal pure returns (bytes4[] memory selectors);
Returns
| Name | Type | Description |
|---|---|---|
selectors | bytes4[] | An array of function selectors. |
getOwnershipFacetSelectors
function getOwnershipFacetSelectors() internal pure returns (bytes4[] memory selectors);
getDiamondLoupeFacetSelectors
function getDiamondLoupeFacetSelectors() internal pure returns (bytes4[] memory selectors);
getDiamondCutFacetSelectors
function getDiamondCutFacetSelectors() internal pure returns (bytes4[] memory selectors);
encodeDiamondCutData
Encodes the diamond cut data to be used in the transaction.
function encodeDiamondCutData(IDiamond.FacetCut[] memory cut) internal pure returns (bytes memory data);
Parameters
| Name | Type | Description |
|---|---|---|
cut | IDiamond.FacetCut[] | The array of FacetCut structs. |
Returns
| Name | Type | Description |
|---|---|---|
data | bytes | The encoded calldata for the diamond cut. |
NoSelectorsGivenToAdd
error NoSelectorsGivenToAdd();
NotContractOwner
error NotContractOwner(address _user, address _contractOwner);
NoSelectorsProvidedForFacetForCut
error NoSelectorsProvidedForFacetForCut(address _facetAddress);
CannotAddSelectorsToZeroAddress
error CannotAddSelectorsToZeroAddress(bytes4[] _selectors);
NoBytecodeAtAddress
error NoBytecodeAtAddress(address _contractAddress, string _message);
IncorrectFacetCutAction
error IncorrectFacetCutAction(uint8 _action);
CannotAddFunctionToDiamondThatAlreadyExists
error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);
CannotReplaceFunctionsFromFacetWithZeroAddress
error CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);
CannotReplaceImmutableFunction
error CannotReplaceImmutableFunction(bytes4 _selector);
CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet
error CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);
CannotReplaceFunctionThatDoesNotExists
error CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);
RemoveFacetAddressMustBeZeroAddress
error RemoveFacetAddressMustBeZeroAddress(address _facetAddress);
CannotRemoveFunctionThatDoesNotExist
error CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);
CannotRemoveImmutableFunction
error CannotRemoveImmutableFunction(bytes4 _selector);
InitializationFunctionReverted
error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);
NotPendingOwner
error NotPendingOwner(address _user, address _pendingOwner);
LibDiamond
State Variables
DIAMOND_STORAGE_POSITION
bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");
Functions
diamondStorage
function diamondStorage() internal pure returns (DiamondStorage storage ds);
setContractOwner
function setContractOwner(address _newOwner) internal;
transferContractOwner
function transferContractOwner() internal;
contractOwner
function contractOwner() internal view returns (address contractOwner_);
pendingOwner
function pendingOwner() internal view returns (address pendingOwner_);
enforceIsContractOwner
function enforceIsContractOwner() internal view;
enforceIsPendingOwner
function enforceIsPendingOwner() internal view;
startTransferOwnership
function startTransferOwnership(address newOwner) internal;
diamondCut
function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal;
addFunctions
function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;
replaceFunctions
function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;
removeFunctions
function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;
initializeDiamondCut
function initializeDiamondCut(address _init, bytes memory _calldata) internal;
enforceHasContractCode
function enforceHasContractCode(address _contract, string memory _errorMessage) internal view;
Events
OwnershipTransferred
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
OwnershipTransferStarted
event OwnershipTransferStarted(address indexed owner, address indexed pendingOwner);
DiamondCut
event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);
Structs
FacetAddressAndSelectorPosition
struct FacetAddressAndSelectorPosition {
address facetAddress;
uint16 selectorPosition;
}
DiamondStorage
struct DiamondStorage {
mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;
bytes4[] selectors;
mapping(bytes4 => bool) supportedInterfaces;
address contractOwner;
address pendingOwner;
}
Contents
- DiamondInit
- AddressAndCalldataLengthDoNotMatch
- DiamondMultiInit
- InitProjectTotals
- UpdateListingInit
- InitProjectTotals
DiamondInit
Functions
init
function init() external;
AddressAndCalldataLengthDoNotMatch
error AddressAndCalldataLengthDoNotMatch(uint256 _addressesLength, uint256 _calldataLength);
DiamondMultiInit
Functions
multiInit
function multiInit(address[] calldata _addresses, bytes[] calldata _calldata) external;
InitProjectTotals
State Variables
s
AppStorage internal s;
Functions
init
function init() external;
Events
ListingUpdated
event ListingUpdated(
bytes32 id,
uint256 oldAmount,
uint256 newAmount,
uint256 oldUnitPrice,
uint256 newUnitPrice,
uint256 oldMinFillAmount,
uint256 newMinFillAmount,
uint256 oldDeadline,
uint256 newDeadline
);
UpdateListingInit
Functions
init
function init() external;
Events
ListingCancelled
event ListingCancelled(bytes32 id);
InitProjectTotals
State Variables
s
AppStorage internal s;
Functions
init
function init() external;
Events
ListingUpdated
event ListingUpdated(
bytes32 id,
uint256 oldAmount,
uint256 newAmount,
uint256 oldUnitPrice,
uint256 newUnitPrice,
uint256 oldMinFillAmount,
uint256 newMinFillAmount,
uint256 oldDeadline,
uint256 newDeadline
);
Account
Author: Cujo
Stores User-level Carbonmark state.
Structs
State
Stores the account level state for a user of Carbonmark
struct State {
uint256 totalListings;
mapping(address token => mapping(uint256 tokenId => uint256 listingTotal)) listingTotalByCredit;
}
Properties
| Name | Type | Description |
|---|---|---|
totalListings | uint256 | |
listingTotalByCredit | mapping(address token => mapping(uint256 tokenId => uint256 listingTotal)) | The current sum total of all listings for a specified total. ERC20 tokens have a dummy ID of 0. ERC1155 tokens have a real ID. |
Storage
Author: Cujo
Stores System-level Carbonmark state.
Structs
CreditListing
Stores the detailed data for currently valid listings within this struct
struct CreditListing {
address account;
address token;
uint256 tokenId;
uint256 originalAmount;
uint256 remainingAmount;
uint256 unitPrice;
uint256 minFillAmount;
uint256 deadline;
TokenType tokenType;
}
Properties
| Name | Type | Description |
|---|---|---|
account | address | The ethereum account that owns this listing |
token | address | The ethereum address of the token listed |
tokenId | uint256 | |
originalAmount | uint256 | |
remainingAmount | uint256 | The remaining unfilled amount on this listing |
unitPrice | uint256 | The unit price in USDC, expected to be six decimals |
minFillAmount | uint256 | The minimum amount needed to fill any part of this listing |
deadline | uint256 | The last UNIX timestamp for which this listing is valid |
tokenType | TokenType |
Enums
CreditProtocol
Enum providing values to check against when a new token is being listed
enum CreditProtocol {
UNKNOWN,
TOUCAN,
C3,
ICR,
CMARK
}
TokenType
enum TokenType {
UNKNOWN,
ERC20,
ERC1155
}
AppStorage
Author: Cujo
Defines the state object for Carbonmark
struct AppStorage {
uint256 reentrantStatus;
mapping(address => Storage.CreditProtocol) tokenCreditProtocol;
mapping(bytes32 => Storage.CreditListing) creditListings;
mapping(address => Account.State) a;
}
Properties
| Name | Type | Description |
|---|---|---|
reentrantStatus | uint256 | An intra-transaction state variable to protect against reentrance. |
tokenCreditProtocol | mapping(address => Storage.CreditProtocol) | Mapping of a credit token address to the credit protocol that issued it |
creditListings | mapping(bytes32 => Storage.CreditListing) | Mapping of a listing ID to the CreditListing struct that holds the details of this listing |
a | mapping(address => Account.State) | Mapping to the account level state. |
C
Author: Cujo
State Variables
USDC
address constant USDC = 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359;
USDC_BRIDGED
address constant USDC_BRIDGED = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;
TOUCAN_REGISTRY
address constant TOUCAN_REGISTRY = 0x263fA1c180889b3a3f46330F32a4a23287E99FC9;
C3_PROJECT_FACTORY
address constant C3_PROJECT_FACTORY = 0xa4c951B30952f5E2feFC8a92F4d3c7551925A63B;
ICR_CARBON_CONTRACT_REGISTRY
address constant ICR_CARBON_CONTRACT_REGISTRY = 0x9f87988FF45E9b58ae30fA1685088460125a7d8A;
CMARK_FACTORY
address constant CMARK_FACTORY = 0xEeE3abDD638E219261e061c06C0798Fd5C05B5D3;
Functions
usdc
function usdc() internal pure returns (address);
usdc_bridged
function usdc_bridged() internal pure returns (address);
toucanRegistry
function toucanRegistry() internal pure returns (address);
c3ProjectFactory
function c3ProjectFactory() internal pure returns (address);
icrCarbonContractRegistry
function icrCarbonContractRegistry() internal pure returns (address);
cmarkFactory
function cmarkFactory() internal pure returns (address);
FunctionNotFound
error FunctionNotFound(bytes4 _functionSelector);
DiamondArgs
struct DiamondArgs {
address owner;
address init;
bytes initCalldata;
}
Diamond
State Variables
s
AppStorage internal s;
Functions
constructor
constructor(IDiamondCut.FacetCut[] memory _diamondCut, DiamondArgs memory _args) payable;
fallback
fallback() external payable;
receive
receive() external payable;
ReentrancyGuard
Author: Beanstalk Farms
State Variables
_NOT_ENTERED
uint256 private constant _NOT_ENTERED = 1;
_ENTERED
uint256 private constant _ENTERED = 2;
s
AppStorage internal s;
Functions
nonReentrant
modifier nonReentrant();