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

Git Source

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

NameTypeDescription
_diamondCutFacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init

DiamondLoupeFacet

Git Source

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

NameTypeDescription
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

NameTypeDescription
_facetaddressThe facet address.

Returns

NameTypeDescription
_facetFunctionSelectorsbytes4[]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

NameTypeDescription
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

NameTypeDescription
_functionSelectorbytes4The function selector.

Returns

NameTypeDescription
facetAddress_addressThe facet address.

supportsInterface

function supportsInterface(bytes4 _interfaceId) external view override returns (bool);

MarketplaceFacet

Git Source

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

NameTypeDescription
tokenaddressThe token being listed
amountuint256The amount to be listed
unitPriceuint256The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000
minFillAmountuint256The minimum number of tons needed to be purchased to fill this listing
deadlineuint256The block timestamp at which this listing will expire

Returns

NameTypeDescription
idbytes32The 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

NameTypeDescription
tokenaddressThe token being listed
tokenIduint256
amountuint256The amount to be listed
unitPriceuint256The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000
minFillAmountuint256The minimum number of tons needed to be purchased to fill this listing
deadlineuint256The block timestamp at which this listing will expire

Returns

NameTypeDescription
idbytes32The 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

NameTypeDescription
idbytes32The listing ID to update
newAmountuint256The amount for the new listing
newUnitPriceuint256The unit price for the new listing
newMinFillAmountuint256The minFillAmount for the new listing
newDeadlineuint256The deadline for the new listing

cancelListing

This function cancels an existing listing

function cancelListing(bytes32 id) external override nonReentrant;

Parameters

NameTypeDescription
idbytes32The 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

NameTypeDescription
idbytes32The listing ID to update
listingAccountaddressThe account that created the listing you are filling
listingTokenaddressThe token you are swapping for
listingUnitPriceuint256The unit price per token to fill the listing
amountuint256Amount of the listing to fill
maxCostuint256Maximum 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

Git Source

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

Contents

ICarbonContractRegistryICR

Git Source

Functions

getProjectIdFromAddress

function getProjectIdFromAddress(address projectAddress) external view returns (uint256);

IProjectICR

Git Source

Functions

totalSupply

function totalSupply(uint256 id) external view returns (uint256);

isTokenExists

function isTokenExists(address _address) external returns (bool);

IC3ProjectFactory

Git Source

Functions

isTokenExists

function isTokenExists(address _address) external returns (bool);

ICMARKFactory

Git Source

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

Git Source

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

NameTypeDescription
tokenaddressThe token being listed
amountuint256The amount to be listed
unitPriceuint256The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000
minFillAmountuint256The minimum number of tons needed to be purchased to fill this listing
deadlineuint256The block timestamp at which this listing will expire

Returns

NameTypeDescription
idbytes32The 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

NameTypeDescription
tokenaddressThe token being listed
tokenIduint256The token ID of the ERC1155 being listed
amountuint256The amount to be listed
unitPriceuint256The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000
minFillAmountuint256The minimum number of tons needed to be purchased to fill this listing
deadlineuint256The block timestamp at which this listing will expire

Returns

NameTypeDescription
idbytes32The 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

NameTypeDescription
idbytes32The listing ID to update
newAmountuint256The amount for the new listing
newUnitPriceuint256The unit price for the new listing
newMinFillAmountuint256The minFillAmount for the new listing
newDeadlineuint256The deadline for the new listing

cancelListing

This function cancels an existing listing

function cancelListing(bytes32 id) external;

Parameters

NameTypeDescription
idbytes32The 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

NameTypeDescription
idbytes32The listing ID to update
listingAccountaddressThe account that created the listing you are filling
listingTokenaddressThe token you are swapping for
listingUnitPriceuint256The unit price per token to fill the listing
amountuint256Amount of the listing to fill
maxCostuint256Maximum 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

NameTypeDescription
idbytes32The resulting hashed listing ID
accountaddressThe ethereum account that created the listing
tokenaddressThe ethereum address of the token being listed
tokenIduint256
priceuint256The unit price in USDC for this listing
amountuint256The total amount of the token being listed
minFillAmountuint256The minimum amount needed to purchase to fill this listing
deadlineuint256The 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

NameTypeDescription
idbytes32The hashed ID of the listing to update
oldAmountuint256Remaining amount to fill before the update
newAmountuint256Remaining amount to fill after the update
oldUnitPriceuint256Unit price before the update
newUnitPriceuint256Unit price after the update
oldMinFillAmountuint256Minimum fill amount before the update
newMinFillAmountuint256Minimum fill amount after the update
oldDeadlineuint256Expiring deadline before the update
newDeadlineuint256Expiring deadline after the update

ListingCancelled

Emitted every time a listing is cancelled

event ListingCancelled(bytes32 id);

Parameters

NameTypeDescription
idbytes32The 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

NameTypeDescription
idbytes32ID of the listing being filled
accountaddressEthereum address of account filling the listing
amountuint256Amount of the listing that was filled
totalCostuint256Total 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

NameTypeDescription
accountaddressEthereum address of the account who owns the listing
tokenaddressEthereum address of the token being listing
originalAmountuint256Original amount of the listing
remainingAmountuint256Remaining amount that can be filled on this listing
unitPriceuint256The unit price in USDC of the listing
minFillAmountuint256The minimum amount needed to purchase in order to fill the listing
deadlineuint256The block timestamp at which this listing expires

IDiamond

Git Source

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

Git Source

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

NameTypeDescription
_diamondCutFacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init

IDiamondLoupe

Git Source

Functions

facets

Gets all facet addresses and their four byte function selectors.

function facets() external view returns (Facet[] memory facets_);

Returns

NameTypeDescription
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

NameTypeDescription
_facetaddressThe facet address.

Returns

NameTypeDescription
facetFunctionSelectors_bytes4[]facetFunctionSelectors_

facetAddresses

Get all the facet addresses used by a diamond.

function facetAddresses() external view returns (address[] memory facetAddresses_);

Returns

NameTypeDescription
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

NameTypeDescription
_functionSelectorbytes4The function selector.

Returns

NameTypeDescription
facetAddress_addressThe facet address.

Structs

Facet

These functions are expected to be called frequently by tools.

struct Facet {
    address facetAddress;
    bytes4[] functionSelectors;
}

IERC165

Git Source

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

NameTypeDescription
interfaceIdbytes4The interface identifier, as specified in ERC-165

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

IERC173

Git Source

Functions

owner

Get the address of the owner

function owner() external view returns (address owner_);

Returns

NameTypeDescription
owner_addressThe 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

NameTypeDescription
_newOwneraddressThe 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

Git Source

Functions

isValidERC20

function isValidERC20(address erc20) external returns (bool);

Contents

Errors

Git Source

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

Git Source

Author: Cujo

Functions

diamondStorage

function diamondStorage() internal pure returns (AppStorage storage ds);

LibDeploy

Git Source

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

NameTypeDescription
marketplaceFMarketplaceFacetThe 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

NameTypeDescription
facetAddressaddressThe address of the facet to be added or replaced.

Returns

NameTypeDescription
cutIDiamond.FacetCut[]An array containing the FacetCut struct.

getMarketplaceFacetSelectors

Retrieves the function selectors from the MarketplaceFacet.

function getMarketplaceFacetSelectors() internal pure returns (bytes4[] memory selectors);

Returns

NameTypeDescription
selectorsbytes4[]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

NameTypeDescription
cutIDiamond.FacetCut[]The array of FacetCut structs.

Returns

NameTypeDescription
databytesThe encoded calldata for the diamond cut.

NoSelectorsGivenToAdd

Git Source

error NoSelectorsGivenToAdd();

NotContractOwner

Git Source

error NotContractOwner(address _user, address _contractOwner);

NoSelectorsProvidedForFacetForCut

Git Source

error NoSelectorsProvidedForFacetForCut(address _facetAddress);

CannotAddSelectorsToZeroAddress

Git Source

error CannotAddSelectorsToZeroAddress(bytes4[] _selectors);

NoBytecodeAtAddress

Git Source

error NoBytecodeAtAddress(address _contractAddress, string _message);

IncorrectFacetCutAction

Git Source

error IncorrectFacetCutAction(uint8 _action);

CannotAddFunctionToDiamondThatAlreadyExists

Git Source

error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);

CannotReplaceFunctionsFromFacetWithZeroAddress

Git Source

error CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);

CannotReplaceImmutableFunction

Git Source

error CannotReplaceImmutableFunction(bytes4 _selector);

CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet

Git Source

error CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);

CannotReplaceFunctionThatDoesNotExists

Git Source

error CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);

RemoveFacetAddressMustBeZeroAddress

Git Source

error RemoveFacetAddressMustBeZeroAddress(address _facetAddress);

CannotRemoveFunctionThatDoesNotExist

Git Source

error CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);

CannotRemoveImmutableFunction

Git Source

error CannotRemoveImmutableFunction(bytes4 _selector);

InitializationFunctionReverted

Git Source

error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);

NotPendingOwner

Git Source

error NotPendingOwner(address _user, address _pendingOwner);

LibDiamond

Git Source

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

Git Source

Functions

init

function init() external;

AddressAndCalldataLengthDoNotMatch

Git Source

error AddressAndCalldataLengthDoNotMatch(uint256 _addressesLength, uint256 _calldataLength);

DiamondMultiInit

Git Source

Functions

multiInit

function multiInit(address[] calldata _addresses, bytes[] calldata _calldata) external;

InitProjectTotals

Git Source

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

Git Source

Functions

init

function init() external;

Events

ListingCancelled

event ListingCancelled(bytes32 id);

InitProjectTotals

Git Source

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

Git Source

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

NameTypeDescription
totalListingsuint256
listingTotalByCreditmapping(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

Git Source

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

NameTypeDescription
accountaddressThe ethereum account that owns this listing
tokenaddressThe ethereum address of the token listed
tokenIduint256
originalAmountuint256
remainingAmountuint256The remaining unfilled amount on this listing
unitPriceuint256The unit price in USDC, expected to be six decimals
minFillAmountuint256The minimum amount needed to fill any part of this listing
deadlineuint256The last UNIX timestamp for which this listing is valid
tokenTypeTokenType

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

Git Source

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

NameTypeDescription
reentrantStatusuint256An intra-transaction state variable to protect against reentrance.
tokenCreditProtocolmapping(address => Storage.CreditProtocol)Mapping of a credit token address to the credit protocol that issued it
creditListingsmapping(bytes32 => Storage.CreditListing)Mapping of a listing ID to the CreditListing struct that holds the details of this listing
amapping(address => Account.State)Mapping to the account level state.

C

Git Source

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

Git Source

error FunctionNotFound(bytes4 _functionSelector);

DiamondArgs

Git Source

struct DiamondArgs {
    address owner;
    address init;
    bytes initCalldata;
}

Diamond

Git Source

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

Git Source

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();