From 03b78f52e2466b52fa66f24ba850896ce100dfea Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:05:20 +0300 Subject: [PATCH 1/8] relative fee for BTCPMM, create3 --- contracts/Factory/ProxyFactory.sol | 21 +++++++++++++++ contracts/LBTC/LBTC.sol | 29 +++----------------- contracts/libs/FeeUtils.sol | 26 ++++++++++++++++++ contracts/pmm/BTCB/BTCB.sol | 43 ++++++++++++++++++++++++------ 4 files changed, 86 insertions(+), 33 deletions(-) create mode 100644 contracts/Factory/ProxyFactory.sol create mode 100644 contracts/libs/FeeUtils.sol diff --git a/contracts/Factory/ProxyFactory.sol b/contracts/Factory/ProxyFactory.sol new file mode 100644 index 0000000..0a7e224 --- /dev/null +++ b/contracts/Factory/ProxyFactory.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import {CREATE3} from "solmate/src/utils/CREATE3.sol"; +import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; + +contract ProxyFactory { + function createTransparentProxy(address implementation, address admin, bytes memory data, bytes32 salt) public returns (address) { + bytes memory bytecode = abi.encodePacked( + type(TransparentUpgradeableProxy).creationCode, + abi.encode(implementation, admin, data) + ); + + address proxy = CREATE3.deploy(salt, bytecode, 0); + return proxy; + } + + function getDeployed(bytes32 salt) public view returns (address) { + return CREATE3.getDeployed(salt); + } +} diff --git a/contracts/LBTC/LBTC.sol b/contracts/LBTC/LBTC.sol index 5fd1fab..c93b926 100644 --- a/contracts/LBTC/LBTC.sol +++ b/contracts/LBTC/LBTC.sol @@ -9,9 +9,8 @@ import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import { BitcoinUtils, OutputType } from "../libs/BitcoinUtils.sol"; -import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { IBascule } from "../bascule/interfaces/IBascule.sol"; - +import { FeeUtils } from "../libs/FeeUtils.sol"; import "./ILBTC.sol"; import "../libs/OutputCodec.sol"; import "../libs/BridgeDepositCodec.sol"; @@ -65,7 +64,6 @@ contract LBTC is ILBTC, ERC20PausableUpgradeable, Ownable2StepUpgradeable, Reent // keccak256(abi.encode(uint256(keccak256("lombardfinance.storage.LBTC")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant LBTC_STORAGE_LOCATION = 0xa9a2395ec4edf6682d754acb293b04902817fdb5829dd13adb0367ab3a26c700; - uint16 public constant MAX_COMMISSION = 10000; // 100.00% function _getLBTCStorage() private pure returns (LBTCStorage storage $) { assembly { @@ -313,13 +311,7 @@ contract LBTC is ILBTC, ERC20PausableUpgradeable, Ownable2StepUpgradeable, Reent function _deposit(bytes32 toChain, bytes32 toContract, bytes32 toAddress, uint64 amount) internal { // relative fee - uint16 relativeComs = getDepositRelativeCommission(toChain); - if (amount < relativeComs) { - revert AmountTooSmallToPayRelativeFee(); - } - - uint256 fee = _calcRelativeFee(amount, relativeComs); - + uint256 fee = FeeUtils.getRelativeFee(amount, getDepositRelativeCommission(toChain)); // absolute fee fee += getDepositAbsoluteCommission(toChain); @@ -335,15 +327,6 @@ contract LBTC is ILBTC, ERC20PausableUpgradeable, Ownable2StepUpgradeable, Reent emit DepositToBridge(fromAddress, toAddress, toContract, toChain, uint64(amountWithoutFee)); } - function _calcRelativeFee(uint64 amount, uint16 commission) internal pure returns (uint256 fee) { - return Math.mulDiv( - amount, - commission, - MAX_COMMISSION, - Math.Rounding.Ceil - ); - } - function withdrawFromBridge( bytes calldata data, bytes calldata proofSignature @@ -416,9 +399,7 @@ contract LBTC is ILBTC, ERC20PausableUpgradeable, Ownable2StepUpgradeable, Reent revert KnownDestination(); } // do not allow 100% commission or higher values - if (relCommission >= MAX_COMMISSION) { - revert BadCommission(); - } + FeeUtils.validateCommission(relCommission); LBTCStorage storage $ = _getLBTCStorage(); $.destinations[toChain] = toContract; @@ -491,9 +472,7 @@ contract LBTC is ILBTC, ERC20PausableUpgradeable, Ownable2StepUpgradeable, Reent onlyOwner { // do not allow 100% commission - if (newValue >= MAX_COMMISSION) { - revert BadCommission(); - } + FeeUtils.validateCommission(newValue); LBTCStorage storage $ = _getLBTCStorage(); $.depositRelativeCommission[chain] = newValue; emit DepositRelativeCommissionChanged(newValue, chain); diff --git a/contracts/libs/FeeUtils.sol b/contracts/libs/FeeUtils.sol new file mode 100644 index 0000000..66e9dc4 --- /dev/null +++ b/contracts/libs/FeeUtils.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; + +library FeeUtils { + uint256 constant MAX_COMMISSION = 10000; // 100% + + error AmountTooSmallToPayRelativeFee(); + error BadCommission(); + + function calcRelativeFee(uint256 amount, uint16 relativeComs) internal pure returns (uint256) { + return Math.mulDiv(amount, relativeComs, MAX_COMMISSION, Math.Rounding.Ceil); + } + + function getRelativeFee(uint256 amount, uint16 relativeComs) internal pure returns (uint256) { + if(amount < relativeComs) + revert AmountTooSmallToPayRelativeFee(); + return calcRelativeFee(amount, relativeComs); + } + + function validateCommission(uint16 commission) internal pure { + if (commission >= MAX_COMMISSION) + revert BadCommission(); + } +} diff --git a/contracts/pmm/BTCB/BTCB.sol b/contracts/pmm/BTCB/BTCB.sol index f635d5a..86bf843 100644 --- a/contracts/pmm/BTCB/BTCB.sol +++ b/contracts/pmm/BTCB/BTCB.sol @@ -6,8 +6,11 @@ import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/acce import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import {FeeUtils} from "../../../contracts/libs/FeeUtils.sol"; + interface ILBTC { function mint(address to, uint256 amount) external; + function transfer(address to, uint256 amount) external; function decimals() external view returns (uint256); } @@ -21,10 +24,10 @@ contract BTCBPMM is PausableUpgradeable, AccessControlUpgradeable { uint256 stakeLimit; uint256 totalStake; address withdrawAddress; + uint16 relativeFee; } bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); - bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE"); // keccak256(abi.encode(uint256(keccak256("lombardfinance.storage.BTCBPMM")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PMM_STORAGE_LOCATION = 0x75814abe757fd1afd999e293d51fa6528839552b73d81c6cc151470e3106f500; @@ -34,15 +37,16 @@ contract BTCBPMM is PausableUpgradeable, AccessControlUpgradeable { error ZeroAmount(); event StakeLimitSet(uint256 newStakeLimit); event WithdrawalAddressSet(address newWithdrawAddress); - + event RelativeFeeChanged(uint16 oldRelativeFee, uint16 newRelativeFee); /// @dev https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } - function __BTCBPMM_init(address _lbtc, address _btcb, address admin, uint256 _stakeLimit, address withdrawAddress) internal onlyInitializing { + function __BTCBPMM_init(address _lbtc, address _btcb, address admin, uint256 _stakeLimit, address withdrawAddress, uint16 _relativeFee) internal onlyInitializing { _grantRole(DEFAULT_ADMIN_ROLE, admin); + FeeUtils.validateCommission(_relativeFee); PMMStorage storage $ = _getPMMStorage(); $.stakeLimit = _stakeLimit; @@ -50,12 +54,13 @@ contract BTCBPMM is PausableUpgradeable, AccessControlUpgradeable { $.lbtc = ILBTC(_lbtc); $.btcb = IERC20Metadata(_btcb); + $.relativeFee = _relativeFee; } - function initialize(address _lbtc, address _btcb, address admin,uint256 _stakeLimit, address withdrawAddress) external initializer { + function initialize(address _lbtc, address _btcb, address admin,uint256 _stakeLimit, address withdrawAddress, uint16 _relativeFee) external initializer { __Pausable_init(); __AccessControl_init(); - __BTCBPMM_init(_lbtc, _btcb, admin, _stakeLimit, withdrawAddress); + __BTCBPMM_init(_lbtc, _btcb, admin, _stakeLimit, withdrawAddress, _relativeFee); } function swapBTCBToLBTC(uint256 amount) external whenNotPaused { @@ -67,11 +72,16 @@ contract BTCBPMM is PausableUpgradeable, AccessControlUpgradeable { uint256 decimalsDifference = 10 ** (btcb.decimals() - lbtc.decimals()); uint256 amountLBTC = (amount / decimalsDifference); if(amountLBTC == 0) revert ZeroAmount(); + if ($.totalStake + amountLBTC > $.stakeLimit) revert StakeLimitExceeded(); + // relative fee + uint256 fee = FeeUtils.getRelativeFee(amountLBTC, $.relativeFee); + $.totalStake += amountLBTC; btcb.safeTransferFrom(_msgSender(), address(this), amountLBTC * decimalsDifference); - lbtc.mint(_msgSender(), amountLBTC); + lbtc.mint(_msgSender(), amountLBTC - fee); + lbtc.mint(address(this), fee); } function withdrawBTCB(uint256 amount) external whenNotPaused onlyRole(DEFAULT_ADMIN_ROLE) { @@ -79,16 +89,29 @@ contract BTCBPMM is PausableUpgradeable, AccessControlUpgradeable { $.btcb.transfer($.withdrawAddress, amount); } - function setWithdrawalAddress(address newWithdrawAddress) external onlyRole(TIMELOCK_ROLE) { + function withdrawLBTC(uint256 amount) external whenNotPaused onlyRole(DEFAULT_ADMIN_ROLE) { + PMMStorage storage $ = _getPMMStorage(); + $.lbtc.transfer($.withdrawAddress, amount); + } + + function setWithdrawalAddress(address newWithdrawAddress) external onlyRole(DEFAULT_ADMIN_ROLE) { _getPMMStorage().withdrawAddress = newWithdrawAddress; emit WithdrawalAddressSet(newWithdrawAddress); } - function setStakeLimit(uint256 newStakeLimit) external onlyRole(TIMELOCK_ROLE) { + function setStakeLimit(uint256 newStakeLimit) external onlyRole(DEFAULT_ADMIN_ROLE) { _getPMMStorage().stakeLimit = newStakeLimit; emit StakeLimitSet(newStakeLimit); } + function setRelativeFee(uint16 newRelativeFee) external onlyRole(DEFAULT_ADMIN_ROLE) { + FeeUtils.validateCommission(newRelativeFee); + PMMStorage storage $ = _getPMMStorage(); + uint16 oldRelativeFee = $.relativeFee; + $.relativeFee = newRelativeFee; + emit RelativeFeeChanged(oldRelativeFee, newRelativeFee); + } + function pause() external onlyRole(PAUSER_ROLE) { _pause(); } @@ -101,6 +124,10 @@ contract BTCBPMM is PausableUpgradeable, AccessControlUpgradeable { return _getPMMStorage().stakeLimit; } + function relativeFee() external view returns (uint16) { + return _getPMMStorage().relativeFee; + } + function remainingStake() external view returns (uint256) { PMMStorage storage $ = _getPMMStorage(); if ($.totalStake > $.stakeLimit) return 0; From 5cadda9e6e79a0b1f3ad0a7688abd45b5691f3ca Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:06:20 +0300 Subject: [PATCH 2/8] add solmate lib --- package.json | 3 +- yarn.lock | 181 ++++++++++++++++++++++----------------------------- 2 files changed, 79 insertions(+), 105 deletions(-) diff --git a/package.json b/package.json index e2dd453..130e531 100644 --- a/package.json +++ b/package.json @@ -23,10 +23,11 @@ "chai": "^4.2.0", "dotenv": "^16.4.5", "ethers": "^6.4.0", - "hardhat": "^2.22.2", + "hardhat": "^2.22.12", "hardhat-gas-reporter": "^1.0.8", "secp256k1": "^5.0.0", "solidity-coverage": "^0.8.0", + "solmate": "https://github.com/transmissions11/solmate", "ts-node": ">=8.0.0", "typechain": "^8.3.0", "typescript": ">=4.5.0", diff --git a/yarn.lock b/yarn.lock index 50f591a..61050be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -524,53 +524,53 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@nomicfoundation/edr-darwin-arm64@0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr-darwin-arm64/-/edr-darwin-arm64-0.4.0.tgz" - integrity sha512-7+rraFk9tCqvfemv9Ita5vTlSBAeO/S5aDKOgGRgYt0JEKZlrX161nDW6UfzMPxWl9GOLEDUzCEaYuNmXseUlg== +"@nomicfoundation/edr-darwin-arm64@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-arm64/-/edr-darwin-arm64-0.6.3.tgz#7f94f80f25bbf8f15421aca0626b1e243c5b6fba" + integrity sha512-hqtI7tYDqKG5PDmZ//Z65EH5cgH8VL/SAAu50rpHP7WAVfJWkOCcYbecywwF6nhHdonJbRTDGAeG1/+VOy6zew== -"@nomicfoundation/edr-darwin-x64@0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr-darwin-x64/-/edr-darwin-x64-0.4.0.tgz" - integrity sha512-+Hrc0mP9L6vhICJSfyGo/2taOToy1AIzVZawO3lU8Lf7oDQXfhQ4UkZnkWAs9SVu1eUwHUGGGE0qB8644piYgg== +"@nomicfoundation/edr-darwin-x64@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-x64/-/edr-darwin-x64-0.6.3.tgz#57cbbe09c70480e7eb79273ba5a497327d72347b" + integrity sha512-4fGi79/lyOlRUORhCYsYb3sWqRHuHT7qqzyZfZuNOn8llaxmT1k36xNmvpyg37R8SzjnhT/DzoukSJrs23Ip9Q== -"@nomicfoundation/edr-linux-arm64-gnu@0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr-linux-arm64-gnu/-/edr-linux-arm64-gnu-0.4.0.tgz" - integrity sha512-4HUDMchNClQrVRfVTqBeSX92hM/3khCgpZkXP52qrnJPqgbdCxosOehlQYZ65wu0b/kaaZSyvACgvCLSQ5oSzQ== +"@nomicfoundation/edr-linux-arm64-gnu@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-gnu/-/edr-linux-arm64-gnu-0.6.3.tgz#122f5ec8b00297e9ed0111405c8779a3c3ba26f3" + integrity sha512-yFFTvGFMhfAvQ1Z2itUh1jpoUA+mVROyVELcaxjIq8fyg602lQmbS+NXkhQ+oaeDgJ+06mSENrHBg4fcfRf9cw== -"@nomicfoundation/edr-linux-arm64-musl@0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr-linux-arm64-musl/-/edr-linux-arm64-musl-0.4.0.tgz" - integrity sha512-D4J935ZRL8xfnP3zIFlCI9jXInJ0loDUkCTLeCEbOf2uuDumWDghKNQlF1itUS+EHaR1pFVBbuwqq8hVK0dASg== +"@nomicfoundation/edr-linux-arm64-musl@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-musl/-/edr-linux-arm64-musl-0.6.3.tgz#2b0371371540373b10521ead4ffa70a2d9e6ac8e" + integrity sha512-pOKmd0Fa3a6BHg5qbjbl/jMRELVi9oazbfiuU7Bvgn/dpTK+ID3jwT0SXiuC2zxjmPByWgXL6G9XRf5BPAM2rQ== -"@nomicfoundation/edr-linux-x64-gnu@0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr-linux-x64-gnu/-/edr-linux-x64-gnu-0.4.0.tgz" - integrity sha512-6x7HPy+uN5Cb9N77e2XMmT6+QSJ+7mRbHnhkGJ8jm4cZvWuj2Io7npOaeHQ3YHK+TiQpTnlbkjoOIpEwpY3XZA== +"@nomicfoundation/edr-linux-x64-gnu@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-gnu/-/edr-linux-x64-gnu-0.6.3.tgz#63849575eddbcd7a5da581d401fba6f5f9347644" + integrity sha512-3AUferhkLIXtLV63w5GjpHttzdxZ36i656XMy+pkBZbbiqnzIVeKWg6DJv1A94fQY16gB4gqj9CLq4CWvbNN6w== -"@nomicfoundation/edr-linux-x64-musl@0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr-linux-x64-musl/-/edr-linux-x64-musl-0.4.0.tgz" - integrity sha512-3HFIJSXgyubOiaN4MWGXx2xhTnhwlJk0PiSYNf9+L/fjBtcRkb2nM910ZJHTvqCb6OT98cUnaKuAYdXIW2amgw== +"@nomicfoundation/edr-linux-x64-musl@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-musl/-/edr-linux-x64-musl-0.6.3.tgz#3b5e6462f47b40cde81bafc6da003c58b2eb9839" + integrity sha512-fr6bD872WIBXe9YnTDi0CzYepMcYRgSnkVqn0yK4wRnIvKrloWhxXNVY45GVIl51aNZguBnvoA4WEt6HIazs3A== -"@nomicfoundation/edr-win32-x64-msvc@0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr-win32-x64-msvc/-/edr-win32-x64-msvc-0.4.0.tgz" - integrity sha512-CP4GsllEfXEz+lidcGYxKe5rDJ60TM5/blB5z/04ELVvw6/CK9eLcYeku7HV0jvV7VE6dADYKSdQyUkvd0El+A== +"@nomicfoundation/edr-win32-x64-msvc@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-win32-x64-msvc/-/edr-win32-x64-msvc-0.6.3.tgz#45be7ba94b950e78e862cb3af0c320e070e0e452" + integrity sha512-sn34MvN1ajw2Oq1+Drpxej78Z0HfIzI4p4WlolupAV9dOZKzp2JAIQeLVfZpjIFbF3zuyxLPP4dUBrQoFPEqhA== -"@nomicfoundation/edr@^0.4.0": - version "0.4.0" - resolved "https://registry.npmjs.org/@nomicfoundation/edr/-/edr-0.4.0.tgz" - integrity sha512-T96DMSogO8TCdbKKctvxfsDljbhFOUKWc9fHJhSeUh71EEho2qR4951LKQF7t7UWEzguVYh/idQr5L/E3QeaMw== +"@nomicfoundation/edr@^0.6.1": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr/-/edr-0.6.3.tgz#47f1b217ce5eb09aef419d76a8488bb77cd88b94" + integrity sha512-hThe5ORR75WFYTXKL0K2AyLDxkTMrG+VQ1yL9BhQYsuh3OIH+3yNDxMz2LjfvrpOrMmJ4kk5NKdFewpqDojjXQ== dependencies: - "@nomicfoundation/edr-darwin-arm64" "0.4.0" - "@nomicfoundation/edr-darwin-x64" "0.4.0" - "@nomicfoundation/edr-linux-arm64-gnu" "0.4.0" - "@nomicfoundation/edr-linux-arm64-musl" "0.4.0" - "@nomicfoundation/edr-linux-x64-gnu" "0.4.0" - "@nomicfoundation/edr-linux-x64-musl" "0.4.0" - "@nomicfoundation/edr-win32-x64-msvc" "0.4.0" + "@nomicfoundation/edr-darwin-arm64" "0.6.3" + "@nomicfoundation/edr-darwin-x64" "0.6.3" + "@nomicfoundation/edr-linux-arm64-gnu" "0.6.3" + "@nomicfoundation/edr-linux-arm64-musl" "0.6.3" + "@nomicfoundation/edr-linux-x64-gnu" "0.6.3" + "@nomicfoundation/edr-linux-x64-musl" "0.6.3" + "@nomicfoundation/edr-win32-x64-msvc" "0.6.3" "@nomicfoundation/ethereumjs-common@4.0.4": version "4.0.4" @@ -1777,20 +1777,12 @@ chokidar@3.5.3: optionalDependencies: fsevents "~2.3.2" -chokidar@^3.4.0: - version "3.6.0" - resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz" - integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== +chokidar@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.1.tgz#4a6dff66798fb0f72a94f616abbd7e1a19f31d41" + integrity sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA== dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" + readdirp "^4.0.1" chownr@^1.1.4: version "1.1.4" @@ -1923,10 +1915,10 @@ command-line-usage@^6.1.0: table-layout "^1.0.2" typical "^5.2.0" -commander@3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz" - integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== +commander@^8.1.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" + integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== compare-versions@^6.0.0: version "6.1.0" @@ -2889,17 +2881,6 @@ fresh@0.5.2: resolved "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz" integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== -fs-extra@^0.30.0: - version "0.30.0" - resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz" - integrity sha512-UvSPKyhMn6LEd/WpUaV9C9t3zATuqoqfWc3QdPhPLb58prN9tqYPlPWi8Krxi44loBoUzlobqZ3+8tGpxxSzwA== - dependencies: - graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" - path-is-absolute "^1.0.0" - rimraf "^2.2.8" - fs-extra@^10.0.0: version "10.1.0" resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz" @@ -3191,7 +3172,7 @@ got@^11.8.5: p-cancelable "^2.0.0" responselike "^2.0.0" -graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.4: +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4: version "4.2.11" resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -3230,14 +3211,14 @@ hardhat-gas-reporter@^1.0.8: eth-gas-reporter "^0.2.25" sha1 "^1.1.1" -hardhat@^2.22.2: - version "2.22.5" - resolved "https://registry.npmjs.org/hardhat/-/hardhat-2.22.5.tgz" - integrity sha512-9Zq+HonbXCSy6/a13GY1cgHglQRfh4qkzmj1tpPlhxJDwNVnhxlReV6K7hCWFKlOrV13EQwsdcD0rjcaQKWRZw== +hardhat@^2.22.12: + version "2.22.12" + resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.22.12.tgz#a6d0be011fc009c50c454da367ad28c29f58d446" + integrity sha512-yok65M+LsOeTBHQsjg//QreGCyrsaNmeLVzhTFqlOvZ4ZE5y69N0wRxH1b2BC9dGK8S8OPUJMNiL9X0RAvbm8w== dependencies: "@ethersproject/abi" "^5.1.2" "@metamask/eth-sig-util" "^4.0.0" - "@nomicfoundation/edr" "^0.4.0" + "@nomicfoundation/edr" "^0.6.1" "@nomicfoundation/ethereumjs-common" "4.0.4" "@nomicfoundation/ethereumjs-tx" "5.0.4" "@nomicfoundation/ethereumjs-util" "9.0.4" @@ -3250,7 +3231,7 @@ hardhat@^2.22.2: ansi-escapes "^4.3.0" boxen "^5.1.2" chalk "^2.4.2" - chokidar "^3.4.0" + chokidar "^4.0.0" ci-info "^2.0.0" debug "^4.1.1" enquirer "^2.3.0" @@ -3263,6 +3244,7 @@ hardhat@^2.22.2: glob "7.2.0" immutable "^4.0.0-rc.12" io-ts "1.10.4" + json-stream-stringify "^3.1.4" keccak "^3.0.2" lodash "^4.17.11" mnemonist "^0.38.0" @@ -3271,7 +3253,7 @@ hardhat@^2.22.2: raw-body "^2.4.1" resolve "1.17.0" semver "^6.3.0" - solc "0.7.3" + solc "0.8.26" source-map-support "^0.5.13" stacktrace-parser "^0.1.10" tsort "0.0.1" @@ -3774,18 +3756,16 @@ json-schema@0.4.0: resolved "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz" integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== +json-stream-stringify@^3.1.4: + version "3.1.5" + resolved "https://registry.yarnpkg.com/json-stream-stringify/-/json-stream-stringify-3.1.5.tgz#7184383b397a83ac5da33b62371217522e6ac2f6" + integrity sha512-wurRuTiw27mck9MWaUIGAunfwqhPDxnXQVN/+Rzi+IEQUUALU10AZs1nWkSdtjH7PAVuAUcqQjH11S/JHOWeaA== + json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== -jsonfile@^2.1.0: - version "2.4.0" - resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz" - integrity sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw== - optionalDependencies: - graceful-fs "^4.1.6" - jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz" @@ -3838,13 +3818,6 @@ kind-of@^6.0.2: resolved "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== -klaw@^1.0.0: - version "1.3.1" - resolved "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz" - integrity sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw== - optionalDependencies: - graceful-fs "^4.1.9" - kleur@^3.0.3: version "3.0.3" resolved "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz" @@ -4643,6 +4616,11 @@ readable-stream@^2.2.2: string_decoder "~1.1.1" util-deprecate "~1.0.1" +readdirp@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-4.0.2.tgz#388fccb8b75665da3abffe2d8f8ed59fe74c230a" + integrity sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA== + readdirp@~3.6.0: version "3.6.0" resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz" @@ -4724,7 +4702,7 @@ require-directory@^2.1.1: resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== -require-from-string@^2.0.0, require-from-string@^2.0.2: +require-from-string@^2.0.2: version "2.0.2" resolved "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz" integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== @@ -4773,13 +4751,6 @@ reusify@^1.0.4: resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@^2.2.8: - version "2.7.1" - resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.2" resolved "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz" @@ -5048,18 +5019,16 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" -solc@0.7.3: - version "0.7.3" - resolved "https://registry.npmjs.org/solc/-/solc-0.7.3.tgz" - integrity sha512-GAsWNAjGzIDg7VxzP6mPjdurby3IkGCjQcM8GFYZT6RyaoUZKmMU6Y7YwG+tFGhv7dwZ8rmR4iwFDrrD99JwqA== +solc@0.8.26: + version "0.8.26" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.26.tgz#afc78078953f6ab3e727c338a2fefcd80dd5b01a" + integrity sha512-yiPQNVf5rBFHwN6SIf3TUUvVAFKcQqmSUFeq+fb6pNRCo0ZCgpYOZDi3BVoezCPIAcKrVYd/qXlBLUP9wVrZ9g== dependencies: command-exists "^1.2.8" - commander "3.0.2" + commander "^8.1.0" follow-redirects "^1.12.1" - fs-extra "^0.30.0" js-sha3 "0.8.0" memorystream "^0.3.1" - require-from-string "^2.0.0" semver "^5.5.0" tmp "0.0.33" @@ -5095,6 +5064,10 @@ solidity-coverage@^0.8.0: shelljs "^0.8.3" web3-utils "^1.3.6" +"solmate@https://github.com/transmissions11/solmate": + version "6.2.0" + resolved "https://github.com/transmissions11/solmate#97bdb2003b70382996a79a406813f76417b1cf90" + source-map-support@^0.5.13: version "0.5.21" resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" From 2bdbb59dd6a92d82cea78105eaa9d416dcf5af6b Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:06:55 +0300 Subject: [PATCH 3/8] update tests --- test/BTCBPMM.ts | 87 +++++++++++++++++++++++++++++--------------- test/LBTC.ts | 12 +++--- test/ProxyFactory.ts | 48 ++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 test/ProxyFactory.ts diff --git a/test/BTCBPMM.ts b/test/BTCBPMM.ts index 4e4d45a..5d1ed9c 100644 --- a/test/BTCBPMM.ts +++ b/test/BTCBPMM.ts @@ -38,7 +38,8 @@ describe("BTCBPMM", function () { await btcb.getAddress(), await deployer.getAddress(), ethers.parseUnits("30", 8), - await withdrawalAddress.getAddress() + await withdrawalAddress.getAddress(), + 1000 // 10% ]); // use btcb decimals of 8 @@ -54,16 +55,16 @@ describe("BTCBPMM", function () { describe("Access Control", function () { - it("should revert if withdrawal address is not set by the timelock", async function () { + it("should revert if withdrawal address is not set by the admin", async function () { await expect(pmm.connect(signer1).setWithdrawalAddress(await signer1.getAddress())) .to.be.revertedWithCustomError(pmm, "AccessControlUnauthorizedAccount") - .withArgs(signer1.address, await pmm.TIMELOCK_ROLE()); + .withArgs(signer1.address, await pmm.DEFAULT_ADMIN_ROLE()); }); - it("should revert if stake limit is set by non-timelock", async function () { - await expect(pmm.setStakeLimit(100)) + it("should revert if stake limit is set by non-admin", async function () { + await expect(pmm.connect(signer1).setStakeLimit(100)) .to.be.revertedWithCustomError(pmm, "AccessControlUnauthorizedAccount") - .withArgs(deployer.address, await pmm.TIMELOCK_ROLE()); + .withArgs(signer1.address, await pmm.DEFAULT_ADMIN_ROLE()); }); it("should revert if pause is triggered by non-pauser", async function () { @@ -84,6 +85,12 @@ describe("BTCBPMM", function () { .withArgs(signer1.address, await pmm.DEFAULT_ADMIN_ROLE()); }); + it("should revert if withdrawLBTC is triggered by non-admin", async function () { + await expect(pmm.connect(signer1).withdrawLBTC(100)) + .to.be.revertedWithCustomError(pmm, "AccessControlUnauthorizedAccount") + .withArgs(signer1.address, await pmm.DEFAULT_ADMIN_ROLE()); + }); + it("should revert if contract is not paused", async function () { await expect(pmm.unpause()) .to.be.revertedWithCustomError(pmm, "ExpectedPause"); @@ -110,32 +117,44 @@ describe("BTCBPMM", function () { }); }); - describe("With Timelock", function () { - beforeEach(async function () { - await pmm.grantRole(await pmm.TIMELOCK_ROLE(), await timeLock.getAddress()); - }); + it("should set the withdrawal address", async function () { + await expect(pmm.setWithdrawalAddress(withdrawalAddress.address)) + .to.emit(pmm, "WithdrawalAddressSet") + .withArgs(withdrawalAddress.address); + expect(await pmm.withdrawalAddress()).to.equal(withdrawalAddress.address); + }); - it("should set the withdrawal address", async function () { - await expect(pmm.connect(timeLock).setWithdrawalAddress(withdrawalAddress.address)) - .to.emit(pmm, "WithdrawalAddressSet") - .withArgs(withdrawalAddress.address); - expect(await pmm.withdrawalAddress()).to.equal(withdrawalAddress.address); - }); + it("should set the stake limit", async function () { + await expect(pmm.setStakeLimit(100)) + .to.emit(pmm, "StakeLimitSet") + .withArgs(100); + expect(await pmm.stakeLimit()).to.equal(100); + expect(await pmm.remainingStake()).to.equal(100); + }); - it("should set the stake limit", async function () { - await expect(pmm.connect(timeLock).setStakeLimit(100)) - .to.emit(pmm, "StakeLimitSet") - .withArgs(100); - expect(await pmm.stakeLimit()).to.equal(100); - expect(await pmm.remainingStake()).to.equal(100); - }); + it("should set the relative fee", async function () { + await expect(pmm.setRelativeFee(100)) + .to.emit(pmm, "RelativeFeeChanged") + .withArgs(1000, 100); + expect(await pmm.relativeFee()).to.equal(100); + }); + + it("should fail to set the relative fee if not admin", async function () { + await expect(pmm.connect(signer1).setRelativeFee(100)) + .to.be.revertedWithCustomError(pmm, "AccessControlUnauthorizedAccount") + .withArgs(signer1.address, await pmm.DEFAULT_ADMIN_ROLE()); + }); + + it("should fail to set the relative fee if over max commission", async function () { + const iface = {interface: ethers.Interface.from(["error BadCommission()"])}; + await expect(pmm.setRelativeFee(10001)) + .to.be.revertedWithCustomError(iface, "BadCommission"); }); }); describe("Operations", function () { beforeEach(async function () { await pmm.grantRole(await pmm.PAUSER_ROLE(), await pauser.getAddress()); - await pmm.grantRole(await pmm.TIMELOCK_ROLE(), await timeLock.getAddress()); // some btcb for signers await btcb.mint(await signer1.getAddress(), ethers.parseUnits("100", 18)); @@ -143,8 +162,8 @@ describe("BTCBPMM", function () { }); it("should fail to swap if PMM is not whitelisted as minter", async function () { - await btcb.connect(signer1).approve(await pmm.getAddress(), ethers.parseUnits("10", 10)); - await expect(pmm.connect(signer1).swapBTCBToLBTC(ethers.parseUnits("10", 10))) + await btcb.connect(signer1).approve(await pmm.getAddress(), ethers.parseUnits("1000", 10)); + await expect(pmm.connect(signer1).swapBTCBToLBTC(ethers.parseUnits("1000", 10))) .to.be.revertedWithCustomError(lbtc, "UnauthorizedAccount") .withArgs(await pmm.getAddress()); }); @@ -166,9 +185,12 @@ describe("BTCBPMM", function () { .to.emit(btcb, "Transfer") .withArgs(signer1.address, await pmm.getAddress(), ethers.parseUnits("11", 18)) .to.emit(lbtc, "Transfer") - .withArgs(ethers.ZeroAddress, signer1.address, ethers.parseUnits("11", 8)); + .withArgs(ethers.ZeroAddress, signer1.address, ethers.parseUnits("9.9", 8)) + .to.emit(lbtc, "Transfer") + .withArgs(ethers.ZeroAddress, await pmm.getAddress(), ethers.parseUnits("1.1", 8)); expect(await pmm.remainingStake()).to.equal(ethers.parseUnits("19", 8)); - expect(await lbtc.balanceOf(signer1.address)).to.equal(ethers.parseUnits("11", 8)); + expect(await lbtc.balanceOf(signer1.address)).to.equal(ethers.parseUnits("9.9", 8)); + expect(await lbtc.balanceOf(await pmm.getAddress())).to.equal(ethers.parseUnits("1.1", 8)); expect(await btcb.balanceOf(signer1.address)).to.equal(ethers.parseUnits("89", 18)); expect(await btcb.balanceOf(await pmm.getAddress())).to.equal(ethers.parseUnits("11", 18)); }); @@ -184,7 +206,7 @@ describe("BTCBPMM", function () { await pmm.connect(signer1).swapBTCBToLBTC(ethers.parseUnits("30", 18)); expect(await pmm.remainingStake()).to.equal(0); - await pmm.connect(timeLock).setStakeLimit(ethers.parseUnits("40", 8)); + await pmm.setStakeLimit(ethers.parseUnits("40", 8)); expect(await pmm.remainingStake()).to.equal(ethers.parseUnits("10", 8)); await btcb.connect(signer2).approve(await pmm.getAddress(), ethers.parseUnits("10", 18)); await pmm.connect(signer2).swapBTCBToLBTC(ethers.parseUnits("10", 18)); @@ -199,13 +221,18 @@ describe("BTCBPMM", function () { .to.emit(btcb, "Transfer") .withArgs(await pmm.getAddress(), await withdrawalAddress.getAddress(), 1); expect(await btcb.balanceOf(await withdrawalAddress.getAddress())).to.equal(1); + + await expect(pmm.withdrawLBTC(1)) + .to.emit(lbtc, "Transfer") + .withArgs(await pmm.getAddress(), await withdrawalAddress.getAddress(), 1); + expect(await lbtc.balanceOf(await withdrawalAddress.getAddress())).to.equal(1); }); it("should have zero remaining stake if total stake is greater than limit", async function () { await btcb.connect(signer1).approve(await pmm.getAddress(), ethers.parseUnits("30", 18)); await pmm.connect(signer1).swapBTCBToLBTC(ethers.parseUnits("30", 18)); - await pmm.connect(timeLock).setStakeLimit(ethers.parseUnits("20", 8)); + await pmm.setStakeLimit(ethers.parseUnits("20", 8)); expect(await pmm.remainingStake()).to.equal(0); }); diff --git a/test/LBTC.ts b/test/LBTC.ts index c267ee2..3542303 100644 --- a/test/LBTC.ts +++ b/test/LBTC.ts @@ -726,7 +726,7 @@ describe("LBTC", function () { await lbtc["mint(address,uint256)"]( signer1.address, - await lbtc.MAX_COMMISSION() + 10000n ); await lbtc.addDestination( CHAIN_ID, @@ -743,11 +743,11 @@ describe("LBTC", function () { }); it("full flow", async () => { - let amount = await lbtc.MAX_COMMISSION(); + let amount = 10000n; let fee = (amount * (await lbtc.getDepositRelativeCommission(CHAIN_ID))) / - (await lbtc.MAX_COMMISSION()); + 10000n; let amountWithoutFee = amount - fee; @@ -814,7 +814,7 @@ describe("LBTC", function () { fee = (amount * (await lbtc2.getDepositRelativeCommission(CHAIN_ID))) / - (await lbtc.MAX_COMMISSION()); + 10000n; fee = (fee === 0n ? 1n : fee) + absoluteFee; amountWithoutFee = amount - fee; @@ -881,11 +881,11 @@ describe("LBTC", function () { .withArgs(ethers.ZeroAddress, await bascule.getAddress()); // Use the 2nd half of the full flow test to test the Bascule integration - let amount = await lbtc.MAX_COMMISSION(); + let amount = 10000n; let fee = (amount * (await lbtc.getDepositRelativeCommission(CHAIN_ID))) / - (await lbtc.MAX_COMMISSION()); + 10000n; let amountWithoutFee = amount - fee; diff --git a/test/ProxyFactory.ts b/test/ProxyFactory.ts new file mode 100644 index 0000000..4caf4c3 --- /dev/null +++ b/test/ProxyFactory.ts @@ -0,0 +1,48 @@ +import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"; +import { ProxyFactory, LBTC, WBTCMock } from "../typechain-types"; +import { ethers } from "hardhat"; +import { expect } from "chai"; +import { takeSnapshot } from "@nomicfoundation/hardhat-network-helpers"; +describe("ProxyFactory", () => { + let proxyFactory: ProxyFactory; + let lbtcImplementation: LBTC; + let wbtcMockImplementation: WBTCMock; + let deployer: HardhatEthersSigner; + + before(async () => { + [deployer] = await ethers.getSigners(); + + let factory = await ethers.getContractFactory("ProxyFactory"); + let contract = await factory.deploy() as ProxyFactory; + await contract.waitForDeployment(); + proxyFactory = factory.attach(await contract.getAddress()) as ProxyFactory; + + const lbtcFactory = await ethers.getContractFactory("LBTC"); + lbtcImplementation = await lbtcFactory.deploy() as LBTC; + await lbtcImplementation.waitForDeployment(); + + const wbtcMockFactory = await ethers.getContractFactory("WBTCMock"); + wbtcMockImplementation = await wbtcMockFactory.deploy() as WBTCMock; + await wbtcMockImplementation.waitForDeployment(); + }); + + it("should create a proxy", async () => { + const salt = ethers.keccak256("0x1234"); + let data = lbtcImplementation.interface.encodeFunctionData("initialize", [deployer.address, 0]); + + const proxyAddress = await proxyFactory.getDeployed(salt); + + const snapshot = await takeSnapshot(); // snapshot before deployment + await proxyFactory.createTransparentProxy(await lbtcImplementation.getAddress(), deployer.address, data, salt); + + const lbtc = await ethers.getContractAt("LBTC", proxyAddress); + expect(await lbtc.name()).to.equal("Lombard Staked Bitcoin"); + + await snapshot.restore(); + // let's deploy a different contract should be in the same address + data = wbtcMockImplementation.interface.encodeFunctionData("initialize", []); + await proxyFactory.createTransparentProxy(await wbtcMockImplementation.getAddress(), deployer.address, data, salt); + const wbtcMock = await ethers.getContractAt("WBTCMock", proxyAddress); + expect(await wbtcMock.name()).to.equal("Wrapped BTC Mock"); + }); +}); From 07f768f34abbc30c241e4e39b3e38ed8865b585d Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:33:06 +0300 Subject: [PATCH 4/8] update deployment scripts --- addresses-mainnet.json | 6 ++-- contracts/LBTC/LBTC.sol | 4 +-- scripts/deploy-create3-factory.ts | 33 +++++++++++++++++++ scripts/deploy-lbtc.ts | 28 ---------------- scripts/helpers/constants.ts | 2 ++ scripts/helpers/index.ts | 19 +++++++++-- scripts/index.ts | 3 +- scripts/lbtc.ts | 53 +++++++++++++++++++++++++++++++ 8 files changed, 113 insertions(+), 35 deletions(-) create mode 100644 scripts/deploy-create3-factory.ts delete mode 100644 scripts/deploy-lbtc.ts create mode 100644 scripts/helpers/constants.ts create mode 100644 scripts/lbtc.ts diff --git a/addresses-mainnet.json b/addresses-mainnet.json index 86a3e87..24dab66 100644 --- a/addresses-mainnet.json +++ b/addresses-mainnet.json @@ -11,7 +11,8 @@ "LBTC": "0xED7bfd5C1790576105Af4649817f6d35A75CD818", "Owner": "0x62F10cE5b727edf787ea45776bD050308A611508", "Consortium": "0xF573F54b8f788BcA3846Cc961A8A5B3B32538550", - "TimeLock": "" + "TimeLock": "", + "ProxyFactory": "0xF3518F0582fA818Fb1a5F07dDE4C8707558C250a" }, "bscTestnet": { "ThresholdKey": "0xBF1eC504e525E1BdC2f0a9D3066F727b2fA6Fed9", @@ -20,7 +21,8 @@ "Consortium": "0x0c5fF93c30c201756C8066c73Cab697DC90DE6F7", "TimeLock": "", "BTCBMock": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", - "BTCPMM": "0x71162dCC16b321F9F2e321695e70d5774739f45C" + "BTCPMM": "0x71162dCC16b321F9F2e321695e70d5774739f45C", + "ProxyFactory": "0xF3518F0582fA818Fb1a5F07dDE4C8707558C250a" }, "scroll_testnet": { "ThresholdKey": "0x1820b9218cb2D9a3790EDe3b5F20851BEc8971B0", diff --git a/contracts/LBTC/LBTC.sol b/contracts/LBTC/LBTC.sol index c93b926..8ba2755 100644 --- a/contracts/LBTC/LBTC.sol +++ b/contracts/LBTC/LBTC.sol @@ -83,11 +83,11 @@ contract LBTC is ILBTC, ERC20PausableUpgradeable, Ownable2StepUpgradeable, Reent _changeBurnCommission(burnCommission_); } - function initialize(address consortium_, uint64 burnCommission_) external initializer { + function initialize(address consortium_, uint64 burnCommission_, address owner) external initializer { __ERC20_init("LBTC", "LBTC"); __ERC20Pausable_init(); - __Ownable_init(_msgSender()); + __Ownable_init(owner); __Ownable2Step_init(); __ReentrancyGuard_init(); diff --git a/scripts/deploy-create3-factory.ts b/scripts/deploy-create3-factory.ts new file mode 100644 index 0000000..f3e06f3 --- /dev/null +++ b/scripts/deploy-create3-factory.ts @@ -0,0 +1,33 @@ +import { task } from "hardhat/config"; +import { verify } from "./helpers"; +import * as readline from "node:readline"; + +task("deploy-proxy-factory", "Deploys the ProxyFactory contract") + .setAction(async (_, hre) => { + const { ethers, run } = hre; + + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }) + + const signer = (await ethers.getSigners())[0]; + const nonce = await signer.getNonce(); + + if (nonce > 0) { + console.error(`Signer address (${await signer.getAddress()}) nonce ${nonce} > 0`); + rl.question("Do you want to proceed? [Y/n]: ", (ans) => { + if (!ans.includes("Y")) { + console.log("Terminating deploy..."); + process.exit(); + } + rl.close() + }) + } + + const factory = await ethers.deployContract("ProxyFactory"); + const res = await factory.waitForDeployment(); + console.log("ProxyFactory address", await res.getAddress()) + + await verify(run, await factory.getAddress()); + }); diff --git a/scripts/deploy-lbtc.ts b/scripts/deploy-lbtc.ts deleted file mode 100644 index aff9d66..0000000 --- a/scripts/deploy-lbtc.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { task } from "hardhat/config"; -import { verify } from "./helpers"; - -/* - * After deployment: - * 1. Set treasury address - * 2. Set minters (e.g. BTCBPMM) - * 3. Set pauser - */ - - -task("deploy-lbtc", "Deploys the LBTC contract") - .addParam("consortium", "The address of LombardConsortium") - .addParam("burnCommission", "Burn commission (wei)") - .setAction(async (taskArgs, hre) => { - const { consortium, burnCommission } = taskArgs; - const { ethers, upgrades, run } = hre; - - const res = await upgrades.deployProxy( - await ethers.getContractFactory("LBTC"), - [consortium, burnCommission] - ); - await res.waitForDeployment(); - console.log(`Deployment address is ${await res.getAddress()}`); - - console.log(await res.getAddress()); - await verify(run, await res.getAddress()); - }); diff --git a/scripts/helpers/constants.ts b/scripts/helpers/constants.ts new file mode 100644 index 0000000..77828ed --- /dev/null +++ b/scripts/helpers/constants.ts @@ -0,0 +1,2 @@ + +export const DEFAULT_PROXY_FACTORY = "0xF3518F0582fA818Fb1a5F07dDE4C8707558C250a" \ No newline at end of file diff --git a/scripts/helpers/index.ts b/scripts/helpers/index.ts index 53ac31e..7ff4318 100644 --- a/scripts/helpers/index.ts +++ b/scripts/helpers/index.ts @@ -1,5 +1,7 @@ import {BigNumberish, ContractTransaction} from "ethers"; import {BytesLike} from "ethers/lib.commonjs/utils/data"; +import {Proxy} from "../../typechain-types"; +import {DEFAULT_PROXY_FACTORY} from "./constants"; type TAddressesWithNetwork = { [k: string]: TAddresses; @@ -26,14 +28,15 @@ export function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } -export async function verify(run: any, address: string) { +export async function verify(run: any, address: string, options: any = {}) { console.log(`Going to verify...`); await sleep(12_000); try { - await run("verify", { + await run("verify:verify", { address, + ...options, }); } catch (e) { console.error(`Verification failed: ${e}`); @@ -66,4 +69,16 @@ export async function schedule(ethers: any,{timelockAddr, transaction, predecess ); await res.wait(); console.log(res.hash); +} + +export async function getProxyFactoryAt(ethers: any, address: string = DEFAULT_PROXY_FACTORY){ + return ethers.getContractAt("ProxyFactory", address); +} + + +/* + * @return keccak256(finance.lombard.v1.{ledger-network}.{contractName}) + */ +export function getProxySalt(ethers: any, ledgerNetwork: string, contractName: string) { + return ethers.id(`finance.lombard.v1.${ledgerNetwork}.${contractName}`); } \ No newline at end of file diff --git a/scripts/index.ts b/scripts/index.ts index 09261a2..0d297ad 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -1,4 +1,5 @@ import "./deploy-btcbpmm"; import "./deploy-btcb-mock"; import "./deploy-consortium"; -import "./deploy-lbtc"; \ No newline at end of file +import "./lbtc"; +import "./deploy-create3-factory"; \ No newline at end of file diff --git a/scripts/lbtc.ts b/scripts/lbtc.ts new file mode 100644 index 0000000..21c815a --- /dev/null +++ b/scripts/lbtc.ts @@ -0,0 +1,53 @@ +import { task } from "hardhat/config"; +import {getProxyFactoryAt, getProxySalt, verify} from "./helpers"; +import {DEFAULT_PROXY_FACTORY} from "./helpers/constants"; + +/* + * After deployment: + * 1. Set treasury address + * 2. Set minters (e.g. BTCBPMM) + * 3. Set pauser + */ + + +task("deploy-lbtc", "Deploys the LBTC contract") + .addParam("ledgerNetwork", "The network name of ledger", "mainnet") + .addParam("consortium", "The address of LombardConsortium") + .addParam("burnCommission", "The burn commission") + .addParam("admin", "The owner of the proxy") + .addParam("proxyFactoryAddr", "The ProxyFactory address", DEFAULT_PROXY_FACTORY) + .setAction(async (taskArgs, hre, network) => { + const { ledgerNetwork, consortium, burnCommission, testEnv, admin, proxyFactoryAddr } = taskArgs; + const { ethers, run, upgrades } = hre; + + const factory = await getProxyFactoryAt(ethers, proxyFactoryAddr); + const saltHash = getProxySalt(ethers, ledgerNetwork, "LBTC"); + + const lbtcImpl = await ethers.deployContract("LBTC"); + await lbtcImpl.waitForDeployment(); + + const data = lbtcImpl.interface.encodeFunctionData("initialize", [consortium, burnCommission, admin]); + + const tx = await factory.createTransparentProxy(await lbtcImpl.getAddress(), admin, data, saltHash); + await tx.wait(); + + const proxy = await factory.getDeployed(saltHash); + console.log("Proxy address:", proxy); + + const proxyAdmin = await upgrades.erc1967.getAdminAddress(proxy); + console.log("Proxy admin:", proxyAdmin); + + await verify(run, await factory.getAddress()); + await verify(run, await lbtcImpl.getAddress()); + await verify(run, proxyAdmin, { + contract: "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", + constructorArguments: [admin], + }); + await verify(run, proxy, { + contract: "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy", + constructorArguments: [await lbtcImpl.getAddress(), admin, data], + }); + + // reinitialize + await (await ethers.getContractAt("LBTC", proxy)).reinitialize(); + }); \ No newline at end of file From 9da10ad7617662f79b916ef494cb705d9f8f3bff Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:56:26 +0300 Subject: [PATCH 5/8] update consortium amd btcbpmm deployment scripts --- addresses-mainnet.json | 2 +- scripts/btcbpmm.ts | 77 ++++++++++++++++++++++++++++++++++++ scripts/consortium.ts | 42 ++++++++++++++++++++ scripts/deploy-btcbpmm.ts | 54 ------------------------- scripts/deploy-consortium.ts | 25 ------------ scripts/index.ts | 4 +- 6 files changed, 122 insertions(+), 82 deletions(-) create mode 100644 scripts/btcbpmm.ts create mode 100644 scripts/consortium.ts delete mode 100644 scripts/deploy-btcbpmm.ts delete mode 100644 scripts/deploy-consortium.ts diff --git a/addresses-mainnet.json b/addresses-mainnet.json index 24dab66..333eb06 100644 --- a/addresses-mainnet.json +++ b/addresses-mainnet.json @@ -20,7 +20,7 @@ "Owner": "0x62F10cE5b727edf787ea45776bD050308A611508", "Consortium": "0x0c5fF93c30c201756C8066c73Cab697DC90DE6F7", "TimeLock": "", - "BTCBMock": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", + "BTCB": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", "BTCPMM": "0x71162dCC16b321F9F2e321695e70d5774739f45C", "ProxyFactory": "0xF3518F0582fA818Fb1a5F07dDE4C8707558C250a" }, diff --git a/scripts/btcbpmm.ts b/scripts/btcbpmm.ts new file mode 100644 index 0000000..7b85b2d --- /dev/null +++ b/scripts/btcbpmm.ts @@ -0,0 +1,77 @@ +import { task, vars } from "hardhat/config"; +import {verify, getAddresses, getProxyFactoryAt, getProxySalt} from "./helpers"; +import {DEFAULT_PROXY_FACTORY} from "./helpers/constants"; + +/* + * After deployment: + * 1. Grant pauser role + * 2. Grant timelock role + */ + +task("deploy-btcbpmm", "Deploys the LombardConsortium contract via create3") + .addParam("ledgerNetwork", "The network name of ledger", "mainnet") + .addParam("admin", "The address of the owner") + .addParam("proxyFactoryAddr", "The ProxyFactory address", DEFAULT_PROXY_FACTORY) + .addParam("lbtc", "The address of the LBTC contract") + .addParam("btcb", "The address of the BTCB contract") + .addParam("stakeLimit", "The stake limit", (30n*(10n**8n)).toString()) // default is 30 LBTC + .addParam("withdrawAddress", "The address to withdraw to") + .addParam("relativeFee", "The relative fee of the pmm", (10n).toString()) + .setAction(async (taskArgs, hre) => { + + const { ledgerNetwork, lbtc, btcb, admin, stakeLimit, withdrawAddress, proxyFactoryAddr, relativeFee } = taskArgs; + const { ethers, run, upgrades } = hre; + + const factory = await getProxyFactoryAt(ethers, proxyFactoryAddr); + const saltHash = getProxySalt(ethers, ledgerNetwork, "BTCBPMM"); + + const btcpmmImpl = await ethers.deployContract("BTCBPMM"); + await btcpmmImpl.waitForDeployment(); + + const data = btcpmmImpl.interface.encodeFunctionData("initialize", [lbtc, btcb, admin, stakeLimit, withdrawAddress, relativeFee]); + + const tx = await factory.createTransparentProxy(await btcpmmImpl.getAddress(), admin, data, saltHash); + await tx.wait(); + + const proxy = await factory.getDeployed(saltHash); + console.log("Proxy address:", proxy); + + const proxyAdmin = await upgrades.erc1967.getAdminAddress(proxy); + console.log("Proxy admin:", proxyAdmin); + + await verify(run, await factory.getAddress()); + await verify(run, await btcpmmImpl.getAddress()); + await verify(run, proxyAdmin, { + contract: "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", + constructorArguments: [admin], + }); + await verify(run, proxy, { + contract: "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy", + constructorArguments: [await btcpmmImpl.getAddress(), admin, data], + }); + }); + +task("deploy-btcbpmm-vars", "Deploys the BTCBPMM contract with environment variables") + .addOptionalParam("lbtc", "The address of the LBTC contract") + .addOptionalParam("btcb", "The address of the BTCB contract") + .addOptionalParam("admin", "The address of the admin") + .addOptionalParam("stakeLimit", "The stake limit") + .addOptionalParam("withdrawAddress", "The address to withdraw to") + .setAction(async (taskArgs, hre) => { + const { run, network } = hre; + const { lbtc, btcb, admin, stakeLimit, withdrawAddress } = taskArgs; + const addresses = getAddresses(network.name); + + const _lbtc = vars.get("LBTC_ADDRESS", lbtc || addresses.LBTC); + const _btcb = vars.get("BTCB_ADDRESS", btcb || addresses.BTCB); + const _admin = vars.get("ADMIN_ADDRESS", admin || addresses.Owner); + const _stakeLimit = vars.get("STAKE_LIMIT", stakeLimit); + const _withdrawAddress = vars.get("WITHDRAW_ADDRESS", withdrawAddress); + await run("deploy-btcbpmm", { + lbtc: _lbtc, + btcb: _btcb, + admin: _admin, + stakeLimit: _stakeLimit, + withdrawAddress: _withdrawAddress + }); + }); diff --git a/scripts/consortium.ts b/scripts/consortium.ts new file mode 100644 index 0000000..21afe65 --- /dev/null +++ b/scripts/consortium.ts @@ -0,0 +1,42 @@ +import {getProxyFactoryAt, getProxySalt, verify} from "./helpers"; +import { task } from "hardhat/config"; +import {DEFAULT_PROXY_FACTORY} from "./helpers/constants"; + +task("deploy-consortium", "Deploys the LombardConsortium contract via create3") + .addParam("ledgerNetwork", "The network name of ledger", "mainnet") + .addParam("admin", "The address of the owner") + .addParam("thresholdKey", "The address of LombardConsortium") + .addParam("proxyFactoryAddr", "The ProxyFactory address", DEFAULT_PROXY_FACTORY) + .setAction(async (taskArgs, hre) => { + + const { ledgerNetwork, thresholdKey, admin, proxyFactoryAddr } = taskArgs; + const { ethers, run, upgrades } = hre; + + const factory = await getProxyFactoryAt(ethers, proxyFactoryAddr); + const saltHash = getProxySalt(ethers, ledgerNetwork, "LombardConsortium"); + + const consortiumImpl = await ethers.deployContract("LombardConsortium"); + await consortiumImpl.waitForDeployment(); + + const data = consortiumImpl.interface.encodeFunctionData("initialize", [thresholdKey, admin]); + + const tx = await factory.createTransparentProxy(await consortiumImpl.getAddress(), admin, data, saltHash); + await tx.wait(); + + const proxy = await factory.getDeployed(saltHash); + console.log("Proxy address:", proxy); + + const proxyAdmin = await upgrades.erc1967.getAdminAddress(proxy); + console.log("Proxy admin:", proxyAdmin); + + await verify(run, await factory.getAddress()); + await verify(run, await consortiumImpl.getAddress()); + await verify(run, proxyAdmin, { + contract: "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", + constructorArguments: [admin], + }); + await verify(run, proxy, { + contract: "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy", + constructorArguments: [await consortiumImpl.getAddress(), admin, data], + }); + }); diff --git a/scripts/deploy-btcbpmm.ts b/scripts/deploy-btcbpmm.ts deleted file mode 100644 index a47e822..0000000 --- a/scripts/deploy-btcbpmm.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { task, vars } from "hardhat/config"; -import { verify, getAddresses } from "./helpers"; - -/* - * After deployment: - * 1. Grant pauser role - * 2. Grant timelock role - */ - -task("deploy-btcbpmm", "Deploys the BTCBPMM contract") - .addParam("lbtc", "The address of the LBTC contract") - .addParam("btcb", "The address of the BTCB contract") - .addParam("admin", "The address of the admin") - .addParam("stakeLimit", "The stake limit") - .addParam("withdrawAddress", "The address to withdraw to") - .setAction(async (taskArgs, hre) => { - const { lbtc, btcb, admin, stakeLimit, withdrawAddress } = taskArgs; - const { ethers, upgrades, run } = hre; - - const deployment = await upgrades.deployProxy( - await ethers.getContractFactory("BTCBPMM"), - [lbtc, btcb, admin, stakeLimit, withdrawAddress] - ); - await deployment.waitForDeployment(); - - console.log(`Deployment address is ${await deployment.getAddress()}`); - - await verify(run, await deployment.getAddress()); - }); - -task("deploy-btcbpmm-vars", "Deploys the BTCBPMM contract with environment variables") - .addOptionalParam("lbtc", "The address of the LBTC contract") - .addOptionalParam("btcb", "The address of the BTCB contract") - .addOptionalParam("admin", "The address of the admin") - .addOptionalParam("stakeLimit", "The stake limit") - .addOptionalParam("withdrawAddress", "The address to withdraw to") - .setAction(async (taskArgs, hre) => { - const { run, network } = hre; - const { lbtc, btcb, admin, stakeLimit, withdrawAddress } = taskArgs; - const addresses = getAddresses(network.name); - - const _lbtc = vars.get("LBTC_ADDRESS", lbtc || addresses.LBTC); - const _btcb = vars.get("BTCB_ADDRESS", btcb || addresses.BTCB); - const _admin = vars.get("ADMIN_ADDRESS", admin || addresses.Owner); - const _stakeLimit = vars.get("STAKE_LIMIT", stakeLimit); - const _withdrawAddress = vars.get("WITHDRAW_ADDRESS", withdrawAddress); - await run("deploy-btcbpmm", { - lbtc: _lbtc, - btcb: _btcb, - admin: _admin, - stakeLimit: _stakeLimit, - withdrawAddress: _withdrawAddress - }); - }); diff --git a/scripts/deploy-consortium.ts b/scripts/deploy-consortium.ts deleted file mode 100644 index 58e5fd1..0000000 --- a/scripts/deploy-consortium.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { verify} from "./helpers"; -import { task } from "hardhat/config"; - -task("deploy-consortium", "Deploys the LombardConsortium contract") - .addParam("owner", "The address of the owner") - .addParam("thresholdKey", "The address of LombardConsortium") - .setAction(async (taskArgs, hre) => { - - const { owner, thresholdKey } = taskArgs; - const { ethers, upgrades, run } = hre; - - const res = await upgrades.deployProxy( - await ethers.getContractFactory("LombardConsortium"), - [thresholdKey, owner] - ); - await res.waitForDeployment(); - - console.log(`Deployment address is ${await res.getAddress()}`); - - try { - await verify(run, await res.getAddress()); - } catch (e) { - console.error(`Verification failed: ${e}`); - } - }); diff --git a/scripts/index.ts b/scripts/index.ts index 0d297ad..d5f336e 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -1,5 +1,5 @@ -import "./deploy-btcbpmm"; +import "./btcbpmm"; import "./deploy-btcb-mock"; -import "./deploy-consortium"; +import "./consortium"; import "./lbtc"; import "./deploy-create3-factory"; \ No newline at end of file From 978246a39af339006ba769789856fd7504e30725 Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:12:21 +0300 Subject: [PATCH 6/8] update devnet contracts --- addresses-mainnet.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addresses-mainnet.json b/addresses-mainnet.json index 333eb06..59a10ad 100644 --- a/addresses-mainnet.json +++ b/addresses-mainnet.json @@ -16,12 +16,12 @@ }, "bscTestnet": { "ThresholdKey": "0xBF1eC504e525E1BdC2f0a9D3066F727b2fA6Fed9", - "LBTC": "0x045b61074568CD8a3210b3C634e5E5e647327dA6", + "LBTC": "0x731eFa688F3679688cf60A3993b8658138953ED6", "Owner": "0x62F10cE5b727edf787ea45776bD050308A611508", - "Consortium": "0x0c5fF93c30c201756C8066c73Cab697DC90DE6F7", + "Consortium": "0xF6D5a96BE0F5f7Bb0ABa0A63B38B7Ee874F5fA1E", "TimeLock": "", "BTCB": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", - "BTCPMM": "0x71162dCC16b321F9F2e321695e70d5774739f45C", + "BTCPMM": "0x440362b55D4a255EBA3c27C650d2dC1a91Db85bA", "ProxyFactory": "0xF3518F0582fA818Fb1a5F07dDE4C8707558C250a" }, "scroll_testnet": { From 499e7c1ba987690b6bb56c1cd201aebb9c863b34 Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:42:39 +0300 Subject: [PATCH 7/8] update gastald contracts --- addresses-gastald.json | 8 ++++---- addresses-mainnet.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addresses-gastald.json b/addresses-gastald.json index 6bc3be4..2b7c810 100644 --- a/addresses-gastald.json +++ b/addresses-gastald.json @@ -8,11 +8,11 @@ }, "btcTestnet": { "ThresholdKey": "0x91E5e2EFfFaB72e4368077F3B55f27fc95aeA8A5", - "LBTC": "0xD3f28A002EBA50315bFBd1880cf4511f34a94Fc6", + "LBTC": "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5", "Owner": "0xB6BbA517f32C75bE36500c7134ec000CFEE0893f", - "Consortium": "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2", + "Consortium": "0x05B942b57162c8901798e23507442FFFff8Be2Cc", "TimeLock": "", - "BTCBMock": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", - "BTCPMM": "0xD7377db0dCBA2f5641F294e57c1E85Da47A34fa8" + "BTCB": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", + "BTCBPMM": "0x63749Acfc2527A8406E8BC8c93A80f29FDD75e27" } } diff --git a/addresses-mainnet.json b/addresses-mainnet.json index 59a10ad..acd3d45 100644 --- a/addresses-mainnet.json +++ b/addresses-mainnet.json @@ -21,7 +21,7 @@ "Consortium": "0xF6D5a96BE0F5f7Bb0ABa0A63B38B7Ee874F5fA1E", "TimeLock": "", "BTCB": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", - "BTCPMM": "0x440362b55D4a255EBA3c27C650d2dC1a91Db85bA", + "BTCBPMM": "0x440362b55D4a255EBA3c27C650d2dC1a91Db85bA", "ProxyFactory": "0xF3518F0582fA818Fb1a5F07dDE4C8707558C250a" }, "scroll_testnet": { From 1bf6d1b593ae5c95a654ddb02be24ff2e947c1b4 Mon Sep 17 00:00:00 2001 From: hashxtree <145032760+hashxtree@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:43:35 +0300 Subject: [PATCH 8/8] add gastald proxy factorry --- addresses-gastald.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addresses-gastald.json b/addresses-gastald.json index 2b7c810..1839b2d 100644 --- a/addresses-gastald.json +++ b/addresses-gastald.json @@ -13,6 +13,7 @@ "Consortium": "0x05B942b57162c8901798e23507442FFFff8Be2Cc", "TimeLock": "", "BTCB": "0xdd48f288874c7226603cCC98cab0661b3bd5721A", - "BTCBPMM": "0x63749Acfc2527A8406E8BC8c93A80f29FDD75e27" + "BTCBPMM": "0x63749Acfc2527A8406E8BC8c93A80f29FDD75e27", + "ProxyFactory": "0xF3518F0582fA818Fb1a5F07dDE4C8707558C250a" } }