Code Monkey home page Code Monkey logo

xocolatl-contracts's Introduction

What is Xocolatl Protocol ? $XOC


Xocolatl (Xoc) (pronounced "choc" as in “chocolate”) is a decentralized stablecoin system that is minted by collateralizing with other cryptocurrencies (or assets) and which price is soft pegged to the Mexican peso (MXN).

Read more in the white paper here


Technical Subjects



Run tests


In a directory, clone the repository locally:

git clone https://github.com/La-DAO/xocolatl-contracts/

Install all dependencies:

yarn install

In a seperate terminal start a local node by running:

npx hardhat node

Then run tests with:

npx hardhat --network localhost test


xocolatl-contracts's People

Contributors

0xdcota avatar 0xnook avatar iafhurtado avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xocolatl-contracts's Issues

AssetsAccountant redundant parameter - RFP

The admin role has the ability to register a ‘house’. The method accepts two arguments. The ‘house’ and the ‘asset’ address. The ‘asset’ address is the ‘reserved’ and the ‘backed’ addresses from the corresponding house. Each house holds its asset address. This address is the same as the second parameter ‘asset’.

function registerHouse(address houseAddress, address asset)  
external   
onlyRole(DEFAULT_ADMIN_ROLE)   
{   
...   
}  

Recommendation
The contract could remove the second parameter ‘asset’ and take the address value from the ‘houseAddress’ parameter.

AssetsAccountant add validation - TCP

The LIQUIDATOR role has the authority to transfer tokens. The ‘safeTransferFrom’ method is solely called by the ‘HouseOfCoin’ addresses. As an extra validation step, the contract could check if the sender is registered in the ‘_isARegisteredHouse’ property.

function safeTransferFrom(  
address from,  
address to,  
uint256 id,  
uint256 amount,  
bytes calldata data  
) public override onlyRole(LIQUIDATOR_ROLE) {  
_safeTransferFrom(from, to, id, amount, data);  
}

Desplegar Nuevo Xoc System en Polygon

After completing the audit recommendations from Cyberscope, Xoc system contracts were refactored and improved.
This issue is to deploy the new contracts and make they live on polygon mainnet.

Reestructurar los deploy scripts

Los scripts en el repositorio actualmente no preservan en algun archivo los "addresses" de los contratos deplegados.

Si se corre multiples veces se vuelven a desplegar los contratos, sin revisar si los contratos ya estan desplegados o no en esta "chain".

Seguir modelo de Fuji para estructurar los scripts.

HouseOfCoin - L07 - Missing Events Arithmetic

contracts/HouseOfCoin.sol#L132

Description
Detected missing events for critical arithmetic parameters. There are functions that have no event emitted, so it is difficult to track off-chain changes.

backedAssetDecimals = IERC20Extension(backedAsset).decimals()

Desplegar el sistema XOC en Gnosis

Propuesta:
Debido a que recientemente se hizo disponible el price feed en Chainlink de MXN/USD en la siguiente 'address': https://gnosisscan.io/address/0xe9cea51a7b1b9b32e057ff62762a2066da933cd2, es posible desplegar el sistema XOC en gnosis chain.
Algunos de los miembros con los que se hablo despues del lanzamiento en Polygon indicaron interés en apoyar la liquidez en ese blockchain si el sistema se desplegaba ahi.
La Gnosis chain tambien permite hacer transacciones a muy bajo costo, inclusive mas barato que Polygon.

Observaciones;
El sistema de oraculo de UMA no estará disponible como back-up en Gnosis chain ya que los contratos de implementacion por parte del equipo de UMA nunca fueron integrados. Los contratos que han deplegado se pueden encontrar aqui: https://github.com/UMAprotocol/protocol/blob/master/packages/core/networks/100.json, sin embargo, el "Finder" no regresa valor alguno cuando se llama el metodo getImplementationAddress.

HouseOfReserve - L07 - Make reserveId Unique and emit event

Where:

reserveTokenID = uint256(
keccak256(abi.encodePacked(reserveAsset, backedAsset, "collateral"))
);
backedTokenID = uint256(
keccak256(
abi.encodePacked(reserveAsset, backedAsset, "backedAsset")
)

Description:
After the first audit, it was identified that for a reserve collateral type on a chain, there can only be one type of reverveId in AssetsAccountant.sol. However, there could be multiple HouseOfReserves for the same reserve collateral asset. This is intended behaviour.

In addition, Cyberscope identified that there is missing events for critical arithmetic parameters. There are functions that
have no event emitted, so it is difficult to track off-chain changes.

Recommendation
Add a parameter to how the reserveTokenId is generated to make it unique.

reserveTokenID =
uint256(keccak256(bytes)(abi.encodePacked(reserveAsset,backedAsset,collateral)))

And emit an event when reserveTokenId and BackedTokenId are set.

HouseOfCoin- L04 - Solidity Naming Conventions

contracts/HouseOfCoin.sol#L559,561,563,522,562,327,132,560,118

Description
Solidity defines a naming convention that should be followed. Rule exceptions:
● Allow constant variable name/symbol/decimals to be lowercase.
● Allow _ at the beginning of the mixed_case match for private variables and unused parameters.

_globalBase
_liquidationThreshold
_collateralPenalty
_reserveAsset
_liquidationPricePenaltyDiscount
_backedTokenID
_assetsAccountant
_backedAsset
_marginCallThreshold
...

HouseOfCoin- MC - Missing Check

The contract is processing variables that have not been properly sanitized and checked that they form the proper shape. These variables may produce vulnerability issues. The contract doesn’t sanitize the address on the initializer.

function initialize(address _backedAsset, address _assetsAccountant)
    public
    initializer
{
    backedAsset = _backedAsset;
    backedAssetDecimals = IERC20Extension(backedAsset).decimals();
    assetsAccountant = _assetsAccountant;

HouseOfReserve - MC - Missing check

Where:

function initialize(

Description:
The contract is processing variables that have not been properly sanitized and checked that they form the proper shape. These variables may produce vulnerability issues. The contract doesn’t sanitize the address on the initializer.

Recommendation
The contract should properly check the variables according to the required specifications. The addresses _reserveAsset, _backedAsset, _assetsAccountant and _WETH should not be zero.

Desplegar Xoc en Binance Smart Chain

BSC is one of the networks with the highest adoption in Mexico and curiously it is the first network that many people use for the first time.

$jMXN is already in BSC where there are also DEXes ve(3,3) deployed.

By launching $XOC in BSC it is possible to generate yield and attract more users, increasing the XOC minted in BSC.

This support of the multi-chain function proposed by LaDAO and will create an opportunity to put XOC to a higher impact use. Thus becoming a multipurpose stable.


BSC es de las redes con mayor adopción en México y curiosamente es la primera red que muchas personas utilizan por primera vez.

$jMXN ya se encuentra en BSC donde también hay DEXes ve(3,3) desplegados.

De lanzar $XOC en BSC es posible generar yield y atraer a más usuarios, incrementando el XOC acuñado en BSC.

Esto apoyado de la función multi-cadena propuesta por La DAO y creará una oportunidad de darle un uso a XOC de mayor impacto. Convirtiendo así una estable multipropósito.


Refer to Dework task

Cambiar licensia a GPL

Este repo tiene licensia MIT, eso significa, has lo que quieras con el codigo.

Sugiero cambiarlo a GPL, que implica, has lo que quieras con el codigo, pero libera el codigo de tus modificaciones con la misma licensia open source.

El razonamiento es que ahora alguien nos puede forkear, avanzar el protocolo y no compartirlo, con GPL alguien forkeandonos estaria contribuyendo a open source, y si sus modificaciones fueran utiles las podriamos integrar nosotros.

HouseOfCoin mint coin mocking

An attacker has the ability to mock the mintCoin parameters in order to mint unlimited amount of backed tokens. The caller can create a custom contract that behave similarly to a “houseOfReserve” contract.

Recommendation
The contract should accept parameters only from approved addresses that cannot be manipulated.

Crear box factory del sistema XOC

El sistema box permite desplegar un contrato, del cual se puede deplegar un sistema completo.
Asi se mantiene un control rigido para que las direcciones de los contratos sean las mismas en todos los blockchain donde se haga despliegue.

HouseOfReserve - L04 - solidity naming conventions

Where:
Throughout code

Description:
Solidity defines a naming convention that should be followed. Rule exceptions:
● Allow constant variable name/symbol/decimals to be lowercase.
● Allow _ at the beginning of the mixed_case match for private variables and unused parameters.

HouseOfReserve.sol contract has functions that take variables with _ as prefix, and this does not follow solidity naming conventions,

Recommendation:
Follow the Solidity naming convention.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.