Skip to content

FilosofiaCodigo/Biblioteca

Repository files navigation

Alchemy Supercharged

workflow Coverage Status

Maximize interoperability for your smart contracts with the integrations library for decentralized protocols.

📜 Contracts

Origin Contract Released Unit Tests Audit
Uniswap V2 Fee Token
Uniswap V2 AutoSwap Token
Balancer V2 Fee Token
Uniswap V3 Fee Token
OpenZeppelin NFT Collection
Azuki NFT Collection
Aave Interface
Sudoswap Interface

🤔 Why Biblioteca?

Our ultimate goal is to simplify access to information and bring people together through web3. That's why we are so passionate about building a library that connects people and protocols. We encourage you to experiment with the library yourself by launching the examples or to study the underliying prococols by exploring the Unit Tests. If you would like to contribute, PRs are welcome!

🛡️ Running Tests & Coverage

npx hardhat test
npx hardhat coverage

🗎 Generate Documentation

npx hardhat docgen

📝 Take note

  • This contracts are based on OpenZeppelin libraries but changed private variables to internal for flexibility
  • All contracts are Ownable
  • All percentage numbers are 2 digit decimals (e.g. 150 percent is 1.5%)

⚠️ Important!

Many libraries are not audited. Use at your own risk! Also, PRs and upstream changes very welcome.

🪙 ERC20 Tokens

Uniswap V2 Fee Token

ERC20 token that takes fees on P2P, buy and sell on Uniswap V2 and transfer them to a Vault.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "biblioteca/contracts/ERC20/UniswapV2FeeToken.sol";

contract MyUniswapV2FeeToken is UniswapV2FeeToken
{
    constructor() UniswapV2FeeToken(
        "My Token", "MTKN",                         // Name and Symbol
        1_000_000_000 ether,                        // 1 billion supply
        100, 200, 50,                               // Fees: 1% buy 2% sell 0.5% P2P
        msg.sender,                                 // Fee Receiver
        0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address: Uniswap V2
        0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) // Base Token Address: USDC
    {
    }
}

See full API documentation.

Uniswap V2 AutoSwap Token

ERC20 token that takes fees on P2P, buy and sell on Uniswap V2, converts them to Base Tokens and transfer them to a Vault.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "biblioteca/contracts/ERC20/UniswapV2AutoSwapToken.sol";

contract MyUniswapV2AutoSwapToken is UniswapV2AutoSwapToken
{
    constructor() UniswapV2AutoSwapToken(
        "My Token", "MTKN",                         // Name and Symbol
        1_000_000_000 ether,                        // 1 billion supply
        100, 200, 50,                               // Fees: 1% buy 2% sell 0.5% P2P
        msg.sender,                                 // AutoSwap Receiver
        0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address: Uniswap V2
        0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, // Base Token Address: USDC
        100)                                        // 1% in tokens before swap percent
    {
    }
}

See full API documentation.

Balancer V2 Fee Token

ERC20 token that takes fees on P2P, buy and sell on Balancer and transfer them to a Vault.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "biblioteca/contracts/ERC20/BalancerV2FeeToken.sol";

contract MyBalancerFeeToken is BalancerV2FeeToken
{
    constructor() BalancerV2FeeToken(
        "My Token", "MTKN",     // Name and Symbol
        1_000_000_000 ether,    // 1 billion supply
        100, 200, 50,           // Fees: 2% buy 1% sell 0.5% P2P
        msg.sender)             // Fee Receiver
    {
    }
}

See full API documentation.

Uniswap V3 Fee Token

ERC20 token that takes fees on P2P, and buy on Uniswap V3 and transfer them to a Vault.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "biblioteca/contracts/ERC20/UniswapV3FeeToken.sol";

contract MyUniswapV3FeeToken is UniswapV3FeeToken
{
    constructor() UniswapV3FeeToken(
        "My Token", "MTKN",                         // Name and Symbol
        1_000_000_000 ether,                        // 1 billion supply
        100, 200,                                   // Fees: 1% buy 2% P2P
        msg.sender,                                 // Vault Address
        0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // Base token: WETH
        1000)                                       // Initial rate: 1 WETH = 1000 tokens
    {
    }
}

See full API documentation.

🖼️ NFT Collections

OpenZeppelin NFT Collection

NFT collection with a mint price and max supply. Uses OpenZeppelin library wich is more adopted and save transfer gas fees compared to Azuki's ERC721a.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "biblioteca/contracts//ERC721/OpenZeppelinNFTCollection.sol";

contract MyOpenZeppelinNFTCollection is OpenZeppelinNFTCollection
{
    constructor() OpenZeppelinNFTCollection(
        "My NFT Collection", "MNFT",    // Name and Symbol
        "https://raw.githubusercontent.com/FilosofiaCodigo/nft-collection-api/master/metadata/",    // Base Metadata URI
        10_000,         // 10,000 max supply
        0.01 ether)     // 0.01 eth mint price
    {
    }
}

Azuki ERC721a NFT Collection

NFT collection with a mint price and max supply. Uses ERC721a library wich is more newer and save batch mint gas fees compared to OpenZeppelin's ERC721 implementation.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "biblioteca/contracts//ERC721/ERC721aCollection.sol";

contract MyERC721aCollection is ERC721aCollection
{
    constructor() ERC721aCollection(
        "My NFT Collection", "MNFT",    // Name and Symbol
        "https://raw.githubusercontent.com/FilosofiaCodigo/nft-collection-api/master/metadata/",    // Base Metadata URI
        10_000,         // 10,000 max supply
        0.01 ether)     // 0.01 eth mint price
    {
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published