// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {ERC20} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/ERC20.sol";
import {ERC20Permit} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/extensions/ERC20Permit.sol";
import {ReentrancyGuard} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/utils/ReentrancyGuard.sol";
import {Ownable} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/access/Ownable.sol";
import {Pausable} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/utils/Pausable.sol";
import {IERC20} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title kUSD
* @notice 1:1 USD stablecoin backed by USDT/USDC on BNB Chain.
* Deposit 1 USDT or USDC β receive 1 kUSD.
* Burn 1 kUSD β redeem 1 USDT or USDC.
* 1M kUSD preminted to deployer for LP bootstrapping.
*/
contract kUSD is ERC20, ERC20Permit, Ownable, ReentrancyGuard, Pausable {
using SafeERC20 for IERC20;
IERC20 public immutable usdt;
IERC20 public immutable usdc;
event Deposit(address indexed user, address indexed stable, uint256 amount);
event Redeem(address indexed user, address indexed stable, uint256 amount);
error InvalidStable();
error ZeroAmount();
error InsufficientReserves();
constructor(address initialOwner)
ERC20("kUSD", "kUSD")
ERC20Permit("kUSD")
Ownable(initialOwner)
{
usdt = IERC20(0x55d398326f99059fF775485246999027B3197955);
usdc = IERC20(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d);
// 1M premint to deployer for LP bootstrap
_mint(initialOwner, 1_000_000 * 1e18);
}
/// @notice Deposit USDT or USDC to mint kUSD 1:1
function deposit(address stable, uint256 amount) external nonReentrant whenNotPaused {
if (stable != address(usdt) && stable != address(usdc)) revert InvalidStable();
if (amount == 0) revert ZeroAmount();
IERC20(stable).safeTransferFrom(msg.sender, address(this), amount);
_mint(msg.sender, amount);
emit Deposit(msg.sender, stable, amount);
}
/// @notice Burn kUSD to redeem USDT or USDC 1:1
function redeem(address stable, uint256 amount) external nonReentrant whenNotPaused {
if (stable != address(usdt) && stable != address(usdc)) revert InvalidStable();
if (amount == 0) revert ZeroAmount();
if (IERC20(stable).balanceOf(address(this)) < amount) revert InsufficientReserves();
_burn(msg.sender, amount);
IERC20(stable).safeTransfer(msg.sender, amount);
emit Redeem(msg.sender, stable, amount);
}
/// @notice Total USDT + USDC held as reserves
function totalReserves() external view returns (uint256) {
return usdt.balanceOf(address(this)) + usdc.balanceOf(address(this));
}
function pause() external onlyOwner { _pause(); }
function unpause() external onlyOwner { _unpause(); }
}
pragma solidity ^0.8.24;
import {ERC20} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/ERC20.sol";
import {ERC20Permit} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/extensions/ERC20Permit.sol";
import {ReentrancyGuard} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/utils/ReentrancyGuard.sol";
import {Ownable} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/access/Ownable.sol";
import {Pausable} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/utils/Pausable.sol";
import {IERC20} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title kUSD
* @notice 1:1 USD stablecoin backed by USDT/USDC on BNB Chain.
* Deposit 1 USDT or USDC β receive 1 kUSD.
* Burn 1 kUSD β redeem 1 USDT or USDC.
* 1M kUSD preminted to deployer for LP bootstrapping.
*/
contract kUSD is ERC20, ERC20Permit, Ownable, ReentrancyGuard, Pausable {
using SafeERC20 for IERC20;
IERC20 public immutable usdt;
IERC20 public immutable usdc;
event Deposit(address indexed user, address indexed stable, uint256 amount);
event Redeem(address indexed user, address indexed stable, uint256 amount);
error InvalidStable();
error ZeroAmount();
error InsufficientReserves();
constructor(address initialOwner)
ERC20("kUSD", "kUSD")
ERC20Permit("kUSD")
Ownable(initialOwner)
{
usdt = IERC20(0x55d398326f99059fF775485246999027B3197955);
usdc = IERC20(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d);
// 1M premint to deployer for LP bootstrap
_mint(initialOwner, 1_000_000 * 1e18);
}
/// @notice Deposit USDT or USDC to mint kUSD 1:1
function deposit(address stable, uint256 amount) external nonReentrant whenNotPaused {
if (stable != address(usdt) && stable != address(usdc)) revert InvalidStable();
if (amount == 0) revert ZeroAmount();
IERC20(stable).safeTransferFrom(msg.sender, address(this), amount);
_mint(msg.sender, amount);
emit Deposit(msg.sender, stable, amount);
}
/// @notice Burn kUSD to redeem USDT or USDC 1:1
function redeem(address stable, uint256 amount) external nonReentrant whenNotPaused {
if (stable != address(usdt) && stable != address(usdc)) revert InvalidStable();
if (amount == 0) revert ZeroAmount();
if (IERC20(stable).balanceOf(address(this)) < amount) revert InsufficientReserves();
_burn(msg.sender, amount);
IERC20(stable).safeTransfer(msg.sender, amount);
emit Redeem(msg.sender, stable, amount);
}
/// @notice Total USDT + USDC held as reserves
function totalReserves() external view returns (uint256) {
return usdt.balanceOf(address(this)) + usdc.balanceOf(address(this));
}
function pause() external onlyOwner { _pause(); }
function unpause() external onlyOwner { _unpause(); }
}
β€4π3
Stablecoin Contract
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {ERC20} from "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/v5.1.0/contracts/token/ERC20/ERC20.sol"; import {ERC20Permit} from "https://raw.githubusercontent.com/Openβ¦
Please open Telegram to view this post
VIEW IN TELEGRAM
Forwarded from Kader | Crypto News
https://youtu.be/bxUphTpF-Oo
Please open Telegram to view this post
VIEW IN TELEGRAM
YouTube
How To Create A Stablecoin On Solana [Full No Code Tutorial]
In this video i show you how to deploy an SPL token on Solana and then add LP correctly to maintain the $1 peg. You will maintain the $1 range and earn fees with it. Start small test over a few days don't be too aggressive with it until you get a feel forβ¦