This project has not been audited yet, please use at your own risk. For any questions, please contact [email protected].
This repository includes the DebtEngine contract for the CMTAT token.
The debtEngine allows to define debt
and credit events
for several different contracts.
A debt
is defined with the following attributes
struct DebtBase {
uint256 interestRate;
uint256 parValue;
string guarantor;
string bondHolder;
string maturityDate;
string interestScheduleFormat;
string interestPaymentDate;
string dayCountConvention;
string businessDayConvention;
string publicHolidaysCalendar;
string issuanceDate;
string couponFrequency;
}
A creditEvents
is defined with the following attributes
struct CreditEvents {
bool flagDefault;
bool flagRedeemed;
string rating;
}
While it has been designed for the CMTAT, the debtEngine can be used with others contracts to define debt and credit events.
For that, the only thing to do is to import in your contract the interface IDebtEngine
which declares the two functions debt
and creditEvents
.
This interface can be found in CMTAT/contracts/interfaces/engine/IDebtEngine.sol
interface IDebtEngine is IDebtGlobal {
function debt() external view returns(IDebtGlobal.DebtBase memory);
function creditEvents() external view returns(IDebtGlobal.CreditEvents memory);
}
Contract | Type | Bases | ||
---|---|---|---|---|
└ | Function Name | Visibility | Mutability | Modifiers |
DebtEngine | Implementation | IDebtEngine, AccessControl, DebtEngineInvariantStorage | ||
└ | Public ❗️ | 🛑 | NO❗️ | |
└ | debt | External ❗️ | NO❗️ | |
└ | debt | Public ❗️ | NO❗️ | |
└ | creditEvents | External ❗️ | NO❗️ | |
└ | creditEvents | Public ❗️ | NO❗️ | |
└ | setDebt | External ❗️ | 🛑 | onlyRole |
└ | setCreditEvents | External ❗️ | 🛑 | onlyRole |
└ | setCreditEventsBatch | External ❗️ | 🛑 | onlyRole |
└ | setDebtsBatch | External ❗️ | 🛑 | onlyRole |
└ | hasRole | Public ❗️ | NO❗️ |
Symbol | Meaning |
---|---|
🛑 | Function can modify state |
💵 | Function is payable |
The DebtEngine supports client-side gasless transactions using the Gas Station Network (GSN) pattern, the main open standard for transfering fee payment to another account than that of the transaction issuer. The contract uses the OpenZeppelin contract ERC2771ContextUpgradeable
, which allows a contract to get the original client with _msgSender()
instead of the fee payer given by msg.sender
while allowing upgrades on the main contract (see Deployment via a proxy above).
At deployment, the parameter forwarder
inside the constructor has to be set with the defined address of the forwarder. Please note that the forwarder can not be changed after deployment.
Please see the OpenGSN documentation for more details on what is done to support GSN in the contract.
The toolchain includes the following components, where the versions are the latest ones that we tested:
- Foundry
- Solidity 0.8.26 (via solc-js)
- OpenZeppelin Contracts (submodule) v5.0.2
- Tests
- CMTAT v2.5.0-rc0
- OpenZeppelin Contracts Upgradeable(submodule) v5.0.2
The CMTAT contracts and the OpenZeppelin library are included as a submodule of the present repository.
npx prettier --write --plugin=prettier-plugin-solidity 'src/**/*.sol'
slither . --checklist --filter-paths "openzeppelin-contracts|test|CMTAT|forge-std" > slither-report.md
See ./doc/script
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Foundry consists of:
- Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
- Chisel: Fast, utilitarian, and verbose solidity REPL.
$ forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage
$ forge test --gas-report
$ forge build
$ forge test
$ forge fmt
$ forge snapshot
$ anvil
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
$ cast <subcommand>
$ forge --help
$ anvil --help
$ cast --help
The code is copyright (c) Capital Market and Technology Association, 2018-2024, and is released under Mozilla Public License 2.0.