refactor(archive): move historical contracts and adapters to archive directory
- Archived multiple non-EVM adapters (Algorand, Hedera, Tron, TON, Cosmos, Solana) and compliance contracts (IndyVerifier) to `archive/solidity/contracts/`. - Updated documentation to reflect the historical status of archived components. - Adjusted `foundry.toml` and `README.md` for clarity on historical dependencies and configurations. - Enhanced Makefile and package.json scripts for improved contract testing and building processes. - Removed obsolete contracts (AlltraCustomBridge, CommodityCCIPBridge, ISO4217WCCIPBridge, VaultBridgeAdapter) from the main directory. - Updated implementation reports to indicate archived status for various components.
This commit is contained in:
@@ -1,150 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
/**
|
||||
* @title CurrencyValidation
|
||||
* @notice Library for validating currency codes and types according to ISO 4217 compliance
|
||||
* @dev Ensures all currency references are either ISO 4217 compliant or explicitly identified as non-ISO
|
||||
*/
|
||||
library CurrencyValidation {
|
||||
/**
|
||||
* @notice Currency type enumeration
|
||||
*/
|
||||
enum CurrencyType {
|
||||
ISO4217_FIAT, // Standard ISO 4217 fiat currency (USD, EUR, etc.)
|
||||
ISO4217_CRYPTO, // ISO 4217 cryptocurrency code (if applicable)
|
||||
NON_ISO_SYNTHETIC, // Non-ISO synthetic unit of account (e.g., GRU)
|
||||
NON_ISO_INTERNAL, // Non-ISO internal accounting unit
|
||||
COMMODITY // Commodity code (XAU, XAG, etc.)
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Validate ISO 4217 currency code format
|
||||
* @dev ISO 4217 codes are exactly 3 uppercase letters
|
||||
* @param code Currency code to validate
|
||||
* @return isValid True if code matches ISO 4217 format
|
||||
*/
|
||||
function isValidISO4217Format(string memory code) internal pure returns (bool isValid) {
|
||||
bytes memory codeBytes = bytes(code);
|
||||
if (codeBytes.length != 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint256 i = 0; i < 3; i++) {
|
||||
uint8 char = uint8(codeBytes[i]);
|
||||
if (char < 65 || char > 90) { // Not A-Z
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Check if currency code is a recognized ISO 4217 code
|
||||
* @dev This is a simplified check - in production, maintain a full registry
|
||||
* @param code Currency code
|
||||
* @return isISO4217 True if code is recognized ISO 4217
|
||||
*/
|
||||
function isISO4217Currency(string memory code) internal pure returns (bool isISO4217) {
|
||||
if (!isValidISO4217Format(code)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Common ISO 4217 codes (extend as needed)
|
||||
bytes32 codeHash = keccak256(bytes(code));
|
||||
|
||||
// Major currencies
|
||||
if (codeHash == keccak256("USD") || // US Dollar
|
||||
codeHash == keccak256("EUR") || // Euro
|
||||
codeHash == keccak256("GBP") || // British Pound
|
||||
codeHash == keccak256("JPY") || // Japanese Yen
|
||||
codeHash == keccak256("CNY") || // Chinese Yuan
|
||||
codeHash == keccak256("CHF") || // Swiss Franc
|
||||
codeHash == keccak256("CAD") || // Canadian Dollar
|
||||
codeHash == keccak256("AUD") || // Australian Dollar
|
||||
codeHash == keccak256("NZD") || // New Zealand Dollar
|
||||
codeHash == keccak256("SGD")) { // Singapore Dollar
|
||||
return true;
|
||||
}
|
||||
|
||||
// In production, maintain a full registry or use oracle/external validation
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Check if code is GRU (Global Reserve Unit)
|
||||
* @dev GRU is a non-ISO 4217 synthetic unit of account
|
||||
* @param code Currency code
|
||||
* @return gru True if code is GRU
|
||||
*/
|
||||
function isGRU(string memory code) internal pure returns (bool gru) {
|
||||
bytes32 codeHash = keccak256(bytes(code));
|
||||
return codeHash == keccak256("GRU") ||
|
||||
codeHash == keccak256("M00") ||
|
||||
codeHash == keccak256("M0") ||
|
||||
codeHash == keccak256("M1");
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Check if code is XAU (Gold)
|
||||
* @dev XAU is the ISO 4217 commodity code for gold
|
||||
* @param code Currency code
|
||||
* @return xau True if code is XAU
|
||||
*/
|
||||
function isXAU(string memory code) internal pure returns (bool xau) {
|
||||
return keccak256(bytes(code)) == keccak256("XAU");
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Get currency type
|
||||
* @param code Currency code
|
||||
* @return currencyType Type of currency
|
||||
*/
|
||||
function getCurrencyType(string memory code) internal pure returns (CurrencyType currencyType) {
|
||||
if (isXAU(code)) {
|
||||
return CurrencyType.COMMODITY;
|
||||
}
|
||||
|
||||
if (isGRU(code)) {
|
||||
return CurrencyType.NON_ISO_SYNTHETIC;
|
||||
}
|
||||
|
||||
if (isISO4217Currency(code)) {
|
||||
return CurrencyType.ISO4217_FIAT;
|
||||
}
|
||||
|
||||
// If format is valid but not recognized, treat as potentially valid ISO 4217
|
||||
if (isValidISO4217Format(code)) {
|
||||
return CurrencyType.ISO4217_FIAT; // Assume valid but not in our list
|
||||
}
|
||||
|
||||
return CurrencyType.NON_ISO_INTERNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Validate that currency is legal tender (ISO 4217 fiat)
|
||||
* @param code Currency code
|
||||
* @return legalTender True if currency is ISO 4217 legal tender
|
||||
*/
|
||||
function isLegalTender(string memory code) internal pure returns (bool legalTender) {
|
||||
CurrencyType currencyType = getCurrencyType(code);
|
||||
return currencyType == CurrencyType.ISO4217_FIAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Require currency to be legal tender or revert
|
||||
* @param code Currency code
|
||||
*/
|
||||
function requireLegalTender(string memory code) internal pure {
|
||||
require(isLegalTender(code), "CurrencyValidation: not legal tender - must be ISO 4217");
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Require currency to NOT be legal tender (for synthetic units)
|
||||
* @param code Currency code
|
||||
*/
|
||||
function requireNonLegalTender(string memory code) internal pure {
|
||||
require(!isLegalTender(code), "CurrencyValidation: must be non-legal tender");
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
/**
|
||||
* @title MonetaryFormulas
|
||||
* @notice Implementation of mandatory monetary formulas
|
||||
* @dev All formulas MUST be applied exactly as specified without modification
|
||||
*
|
||||
* Formulas:
|
||||
* - Money Supply: M = C + D and M = MB × m
|
||||
* - Money Velocity: V = PQ / M
|
||||
* - Money Multiplier: m = 1 / r and m = (1 + c) / (r + c)
|
||||
*/
|
||||
library MonetaryFormulas {
|
||||
/**
|
||||
* @notice Calculate money supply: M = C + D
|
||||
* @dev M = Money Supply, C = Currency, D = Deposits
|
||||
* @param currency Currency component (C)
|
||||
* @param deposits Deposits component (D)
|
||||
* @return moneySupply Money supply (M)
|
||||
*/
|
||||
function calculateMoneySupply(uint256 currency, uint256 deposits) internal pure returns (uint256 moneySupply) {
|
||||
return currency + deposits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Calculate money supply: M = MB × m
|
||||
* @dev M = Money Supply, MB = Monetary Base, m = Money Multiplier
|
||||
* @param monetaryBase Monetary base (MB)
|
||||
* @param moneyMultiplier Money multiplier (m)
|
||||
* @return moneySupply Money supply (M)
|
||||
*/
|
||||
function calculateMoneySupplyFromMultiplier(uint256 monetaryBase, uint256 moneyMultiplier) internal pure returns (uint256 moneySupply) {
|
||||
return (monetaryBase * moneyMultiplier) / 1e18; // Assuming multiplier in 18 decimals
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Calculate money velocity: V = PQ / M
|
||||
* @dev V = Velocity, P = Price Level, Q = Quantity of Goods, M = Money Supply
|
||||
* @param priceLevel Price level (P)
|
||||
* @param quantityOfGoods Quantity of goods (Q)
|
||||
* @param moneySupply Money supply (M)
|
||||
* @return velocity Money velocity (V)
|
||||
*/
|
||||
function calculateMoneyVelocity(uint256 priceLevel, uint256 quantityOfGoods, uint256 moneySupply) internal pure returns (uint256 velocity) {
|
||||
if (moneySupply == 0) {
|
||||
return 0;
|
||||
}
|
||||
return (priceLevel * quantityOfGoods) / moneySupply;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Calculate simple money multiplier: m = 1 / r
|
||||
* @dev m = Money Multiplier, r = Reserve Ratio
|
||||
* @param reserveRatio Reserve ratio (r) in basis points (e.g., 1000 = 10%)
|
||||
* @return moneyMultiplier Money multiplier (m) in 18 decimals
|
||||
*/
|
||||
function calculateSimpleMoneyMultiplier(uint256 reserveRatio) internal pure returns (uint256 moneyMultiplier) {
|
||||
require(reserveRatio > 0, "MonetaryFormulas: reserve ratio must be positive");
|
||||
require(reserveRatio <= 10000, "MonetaryFormulas: reserve ratio cannot exceed 100%");
|
||||
|
||||
// m = 1 / r, where r is in basis points
|
||||
// Convert to 18 decimals: m = (1e18 * 10000) / reserveRatio
|
||||
return (1e18 * 10000) / reserveRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Calculate money multiplier with currency ratio: m = (1 + c) / (r + c)
|
||||
* @dev m = Money Multiplier, r = Reserve Ratio, c = Currency Ratio
|
||||
* @param reserveRatio Reserve ratio (r) in basis points
|
||||
* @param currencyRatio Currency ratio (c) in basis points
|
||||
* @return moneyMultiplier Money multiplier (m) in 18 decimals
|
||||
*/
|
||||
function calculateMoneyMultiplierWithCurrency(uint256 reserveRatio, uint256 currencyRatio) internal pure returns (uint256 moneyMultiplier) {
|
||||
require(reserveRatio > 0, "MonetaryFormulas: reserve ratio must be positive");
|
||||
require(reserveRatio <= 10000, "MonetaryFormulas: reserve ratio cannot exceed 100%");
|
||||
require(currencyRatio <= 10000, "MonetaryFormulas: currency ratio cannot exceed 100%");
|
||||
|
||||
// m = (1 + c) / (r + c), where r and c are in basis points
|
||||
// Convert to 18 decimals: m = (1e18 * (10000 + currencyRatio)) / (reserveRatio + currencyRatio)
|
||||
uint256 numerator = 1e18 * (10000 + currencyRatio);
|
||||
uint256 denominator = reserveRatio + currencyRatio;
|
||||
|
||||
require(denominator > 0, "MonetaryFormulas: invalid denominator");
|
||||
return numerator / denominator;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
/**
|
||||
* @title XAUTriangulation
|
||||
* @notice Library for enforcing XAU triangulation for all currency conversions
|
||||
* @dev MANDATORY: All currency conversions MUST go through XAU (gold)
|
||||
*
|
||||
* Triangulation formula:
|
||||
* CurrencyA → XAU → CurrencyB
|
||||
*
|
||||
* Steps:
|
||||
* 1. Convert CurrencyA to XAU: xauAmount = currencyAAmount / xauRateA
|
||||
* 2. Convert XAU to CurrencyB: currencyBAmount = xauAmount * xauRateB
|
||||
*/
|
||||
library XAUTriangulation {
|
||||
/**
|
||||
* @notice Triangulate from Currency A to Currency B via XAU
|
||||
* @dev All conversions MUST go through XAU - this is mandatory
|
||||
* @param currencyAAmount Amount in Currency A (18 decimals)
|
||||
* @param xauRateA Rate: 1 oz XAU = xauRateA units of Currency A (18 decimals)
|
||||
* @param xauRateB Rate: 1 oz XAU = xauRateB units of Currency B (18 decimals)
|
||||
* @return currencyBAmount Amount in Currency B (18 decimals)
|
||||
*/
|
||||
function triangulate(
|
||||
uint256 currencyAAmount,
|
||||
uint256 xauRateA,
|
||||
uint256 xauRateB
|
||||
) internal pure returns (uint256 currencyBAmount) {
|
||||
require(xauRateA > 0, "XAUTriangulation: invalid XAU rate A");
|
||||
require(xauRateB > 0, "XAUTriangulation: invalid XAU rate B");
|
||||
|
||||
// Step 1: Convert Currency A to XAU
|
||||
// xauAmount = currencyAAmount / xauRateA
|
||||
uint256 xauAmount = (currencyAAmount * 1e18) / xauRateA;
|
||||
|
||||
// Step 2: Convert XAU to Currency B
|
||||
// currencyBAmount = xauAmount * xauRateB / 1e18
|
||||
currencyBAmount = (xauAmount * xauRateB) / 1e18;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Convert amount to XAU
|
||||
* @param amount Amount to convert (18 decimals)
|
||||
* @param xauRate Rate: 1 oz XAU = xauRate units (18 decimals)
|
||||
* @return xauAmount Amount in XAU (18 decimals)
|
||||
*/
|
||||
function toXAU(uint256 amount, uint256 xauRate) internal pure returns (uint256 xauAmount) {
|
||||
require(xauRate > 0, "XAUTriangulation: invalid XAU rate");
|
||||
xauAmount = (amount * 1e18) / xauRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Convert XAU amount to currency
|
||||
* @param xauAmount Amount in XAU (18 decimals)
|
||||
* @param xauRate Rate: 1 oz XAU = xauRate units (18 decimals)
|
||||
* @return currencyAmount Amount in currency (18 decimals)
|
||||
*/
|
||||
function fromXAU(uint256 xauAmount, uint256 xauRate) internal pure returns (uint256 currencyAmount) {
|
||||
require(xauRate > 0, "XAUTriangulation: invalid XAU rate");
|
||||
currencyAmount = (xauAmount * xauRate) / 1e18;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user