Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOV-1370: Remove Bridge Related Code #13

Merged
merged 38 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4c1e359
upgrade .prettier and plugins
tjcloa Jun 2, 2023
e88dcb0
remove bridge related code
tjcloa Jun 6, 2023
e272452
update dist dir
tjcloa Jun 6, 2023
902c71c
remove bridge code: fix MM _redeemTo, scripts, tests
tjcloa Jun 6, 2023
2949353
remove callTokensReceived used by bridge code
tjcloa Jun 6, 2023
45227c9
update 'dist' folder
tjcloa Jun 6, 2023
662efda
revert switching to JsonRpcProvider in hh config
tjcloa Jun 8, 2023
137d239
fixes, sip-0064 creation scripts & refactoring
tjcloa Jun 9, 2023
7eecf90
update hh config and sip & deployent scripts
tjcloa Jun 10, 2023
04d77c8
update sip-0064: add contracts upgrade & test
tjcloa Jun 10, 2023
6dac568
sip-0064 clean-up testnet deployment
tjcloa Jun 13, 2023
0d86ec6
update: disable deployment initializing scripts
tjcloa Jun 13, 2023
e0829ac
fix tasks, add multisig:execute-txs task
tjcloa Jun 13, 2023
1b288c4
fix DeployMocBAssets script
tjcloa Jun 13, 2023
feee076
sip-0064 mainnet deployment
tjcloa Jun 13, 2023
e814777
sip-0064: update description in script
tjcloa Jun 13, 2023
b0e0bfb
SOV-2537: replace injectHre with hre as param
tjcloa Jun 14, 2023
140c41a
update reset block number in sip-0064 on-chain test
tjcloa Jun 14, 2023
492c016
fixing typos to enable exporting hardhat tasks
Jun 15, 2023
52afa9e
renaming hh-tasks with similar name than in core repo
Jun 15, 2023
fe4c969
also needed to rename multisig hh-tasks
Jun 15, 2023
f389b47
re-introduce import hh tasks from gh package
tjcloa Jun 15, 2023
c8f9974
mynt tasks: use multisig from the core protocol repo
tjcloa Jun 18, 2023
6321537
add testnet script: transfer ownership to multisig
tjcloa Jun 18, 2023
ac600bf
fix multisigCheckTx helper
tjcloa Jun 22, 2023
555b22f
improve sips creation script & test
tjcloa Jun 22, 2023
4a78ee6
update 'dist' content
tjcloa Jun 26, 2023
cc38caf
bump hh version to v2.01.16
tjcloa Jun 26, 2023
afad241
SOV-2597: transfer ownership of contracts to multisig
tjcloa Jun 26, 2023
72a250b
update hh patch v2.16.0
tjcloa Jun 26, 2023
5c7f936
improve events in MocIntegration and MetaAssetToken
tjcloa Aug 10, 2023
7cbba6a
update scripts from SIP-0064 to SIP-0072
tjcloa Dec 13, 2023
fa60608
fix sip-0072 onchain test
tjcloa Dec 18, 2023
16687b6
update hh config: add .env proposal creator to named accounts
tjcloa Dec 20, 2023
0076223
Merge remote-tracking branch 'origin/development' into SOV-1370-remov…
tjcloa Dec 21, 2023
a17dd2c
bump gh action scripts to v16.20.2
tjcloa Dec 21, 2023
750c345
revert event change TransferWithPermit
tjcloa Dec 21, 2023
e509376
update dist and docs
tjcloa Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ _flat/
*.code-workspace

# local deployment
deployments/development/
deployments/localhost/
deployments/rskDev
deployments/rskForkedTestnet
deployments/rskForkedMainnet
deployment/deployments/development/
deployment/deployments/localhost/
deployment/deployments/rskDev
deployment/deployments/rskForkedTestnet
deployment/deployments/rskForkedMainnet

.openzeppelin

tmp/
deployment/deployments/localhost
tmp/
23 changes: 13 additions & 10 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{
"overrides": [
{
"files": [
"*.sol",
"*.js",
"*.test.js",
"*.json",
"*.test.ts"
],
"files": ["*.js", ".ts", "*.test.js", "*.json"],
"options": {
"printWidth": 99,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": true,
"explicitTypes": "always"
"bracketSpacing": true
}
},
{
"files": "*.sol",
"options": {
"printWidth": 99,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": true
}
}
]
}
}
117 changes: 9 additions & 108 deletions contracts/interfaces/IMassetManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.17;
/**
* @title MassetManager
* @dev Contract is responsible for managing mAsset and bAsset.
* Used for minting and burning tokens, calculating fees and calling the bridge
* Used for minting and burning tokens and calculating fees
* if transaction based on token from another blockchain.
*/

Expand Down Expand Up @@ -43,33 +43,6 @@ interface IMassetManager {
uint256 bassetQuantity
);

/**
* @dev Emitted when tokensReceived method is called by the bridge.
* @param operator Address operator requesting the transfer.
* @param from Address token holder address.
* @param to Address recipient address.
* @param amount uint256 amount of tokens to transfer.
* @param userData Bytes extra information provided by the token holder (if any).
* @param operatorData Bytes extra information provided by the operator (if any).
*/
event onTokensReceivedCalled(
address operator,
address from,
address to,
uint256 amount,
bytes userData,
bytes operatorData
);

/**
* @dev Emitted when onTokensMinted method is called by the bridge.
* @param sender Address of the sender.
* @param orderAmount Units of the masset to redeem.
* @param tokenAddress Address of the bAsset to redeem.
* @param userData Address of the final recipient as ABI encoded bytes.
*/
event onTokensMintedCalled(address indexed sender, uint256 orderAmount, address tokenAddress, bytes userData);

/***************************************
MINTING (PUBLIC)
****************************************/
Expand All @@ -81,7 +54,10 @@ interface IMassetManager {
* @param _bAssetQuantity Quantity in bAsset units.
* @return massetMinted Quantity of newly minted mAsset.
*/
function mint(address _bAsset, uint256 _bAssetQuantity) external returns (uint256 massetMinted);
function mint(
address _bAsset,
uint256 _bAssetQuantity
) external returns (uint256 massetMinted);

/**
* @dev Mint a single mAsset to recipient address, at a 1:1 ratio with the bAsset.
Expand All @@ -108,7 +84,10 @@ interface IMassetManager {
* @param _massetQuantity Units of the masset to redeem.
* @return massetRedeemed Relative number of mAsset units burned to pay for the bAssets.
*/
function redeem(address _bAsset, uint256 _massetQuantity) external returns (uint256 massetRedeemed);
function redeem(
address _bAsset,
uint256 _massetQuantity
) external returns (uint256 massetRedeemed);

/**
* @dev Credits a recipient with a certain quantity of selected bAsset, in exchange for burning the
Expand All @@ -124,84 +103,6 @@ interface IMassetManager {
address _recipient
) external returns (uint256 massetRedeemed);

// For the BRIDGE

/**
* @dev Credits a recipient with a certain quantity of selected bAsset, in exchange for burning the
* relative mAsset quantity from the sender. Sender also incurs a small fee, if any.
* This function is designed to also call the bridge in order to have the basset tokens sent to
* another blockchain.
* @param _basset Address of the bAsset to redeem.
* @param _massetQuantity Units of the mAsset to redeem.
* @param _recipient Address to credit with withdrawn bAssets.
* @param _bridgeAddress This is ignored and is left here for backward compatibility with the FE.
* @return massetRedeemed Relative number of mAsset units burned to pay for the bAssets.
*/
function redeemToBridge(
address _basset,
uint256 _massetQuantity,
address _recipient,
address _bridgeAddress // IGNORED! for backward compatibility
) external returns (uint256 massetRedeemed);

/**
* @dev Credits a recipient with a certain quantity of selected bAsset, in exchange for burning the
* relative mAsset quantity from the sender. Sender also incurs a small fee, if any.
* This function is designed to also call the bridge in order to have the basset tokens sent to
* another blockchain.
* @param _basset Address of the bAsset to redeem.
* @param _massetQuantity Units of the mAsset to redeem.
* @param _recipient Address to credit with withdrawn bAssets.
* @return massetRedeemed Relative number of mAsset units burned to pay for the bAssets.
*/
function redeemToBridge(
address _basset,
uint256 _massetQuantity,
address _recipient
) external returns (uint256 massetRedeemed);

/**
* @dev Credits a recipient with a certain quantity of selected bAsset, in exchange for burning the
* relative mAsset quantity from the sender. Sender also incurs a small fee, if any.
* This function is designed to be called by the bridge in order to have diffrent fees.
* @param _basset Address of the bAsset to redeem.
* @param _massetQuantity Units of the mAsset to redeem.
* @param _recipient Address to credit with withdrawn bAssets.
* @return massetRedeemed Relative number of mAsset units burned to pay for the bAssets.
*/
function redeemByBridge(
address _basset,
uint256 _massetQuantity,
address _recipient
) external returns (uint256 massetRedeemed);

/**
* @dev This is called by the bridge to let us know tokens have been received.
* @param _operator Address operator requesting the transfer.
* @param _from Address token holder address.
* @param _to Address recipient address.
* @param _amount uint256 amount of tokens to transfer.
* @param _userData Bytes extra information provided by the token holder (if any).
* @param _operatorData Bytes extra information provided by the operator (if any).
*/
function tokensReceived(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes calldata _userData,
bytes calldata _operatorData
) external;

/**
* @dev This is called by the bridge to let us know the user has sent tokens through it and
* into the mAsset.
* @param _orderAmount Units of the mAsset to redeem.
* @param _tokenAddress Address of the bAsset to redeem.
* @param _userData Address of the final recipient as ABI encoded bytes.
*/
function onTokensMinted(uint256 _orderAmount, address _tokenAddress, bytes calldata _userData) external;

// Getters

function getFeesVault() external view returns (address);
Expand Down
28 changes: 3 additions & 25 deletions contracts/masset/BasketManagerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradea
* @dev Contract is responsible for mAsset and bAsset exchange process and
* managing basket with bAsset tokens.
* Allows to add and/or remove bAsset, calculate balances, converts tokens quantity
* to adjust precisions or set/get parameters: bridge, factor, range and paused.
* to adjust precisions or set/get parameters: factor, range and paused.
*/

contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {
Expand All @@ -38,13 +38,6 @@ contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {
*/
event FactorChanged(address basset, int256 factor);

/**
* @dev Event emitted when bridge is changed.
* @param basset Address of the bAsset contract.
* @param bridge Address of bridge.
*/
event BridgeChanged(address basset, address bridge);

/**
* @dev Event emitted when range is changed.
* @param basset Address of the bAsset contract.
Expand All @@ -67,7 +60,7 @@ contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {
address massetManager;
address[] private bassetsArray;
mapping(address => int256) private factorMap;
mapping(address => address) private bridgeMap;
mapping(address => address) private DEPRECATED_bridgeMap;
mapping(address => uint256) private minMap;
mapping(address => uint256) private maxMap;
mapping(address => bool) private pausedMap;
Expand Down Expand Up @@ -259,10 +252,6 @@ contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {
return factorMap[_basset];
}

function getBridge(address _basset) public view validBasset(_basset) returns (address) {
return bridgeMap[_basset];
}

function getRange(
address _basset
) public view validBasset(_basset) returns (uint256 min, uint256 max) {
Expand All @@ -280,15 +269,13 @@ contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {
* @dev Adds a new bAsset.
* @param _basset Address of bAsset.
* @param _factor Factor amount.
* @param _bridge Address of bridge.
* @param _min Minimum ratio in basket.
* @param _max Maximum ratio in basket.
* @param _paused Flag to determine if basset should be paused.
*/
function addBasset(
address _basset,
int256 _factor,
address _bridge,
uint256 _min,
uint256 _max,
bool _paused
Expand All @@ -301,7 +288,6 @@ contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {

setFactor(_basset, _factor);
setRange(_basset, _min, _max);
setBridge(_basset, _bridge);
setPaused(_basset, _paused);

emit BassetAdded(_basset);
Expand All @@ -314,23 +300,21 @@ contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {
function addBassets(
address[] memory _bassets,
int256[] memory _factors,
address[] memory _bridges,
uint256[] memory _mins,
uint256[] memory _maxs,
bool[] memory _pausedFlags
) public onlyOwner {
uint256 length = _bassets.length;
require(
_factors.length == length &&
_bridges.length == length &&
_mins.length == length &&
_maxs.length == length &&
_pausedFlags.length == length,
"invalid lengths"
);

for (uint256 i = 0; i < length; i++) {
addBasset(_bassets[i], _factors[i], _bridges[i], _mins[i], _maxs[i], _pausedFlags[i]);
addBasset(_bassets[i], _factors[i], _mins[i], _maxs[i], _pausedFlags[i]);
}
}

Expand Down Expand Up @@ -374,12 +358,6 @@ contract BasketManagerV3 is OwnableUpgradeable, ERC1967UpgradeUpgradeable {
emit FactorChanged(_basset, _factor);
}

function setBridge(address _basset, address _bridge) public validBasset(_basset) onlyOwner {
bridgeMap[_basset] = _bridge;

emit BridgeChanged(_basset, _bridge);
}

function setPaused(address _basset, bool _flag) public validBasset(_basset) onlyOwner {
pausedMap[_basset] = _flag;

Expand Down
Loading