Skip to content

Commit 7b4a2d4

Browse files
Merge pull request #409 from dev-protocol/fix-onB
Fix: onBeforeMint external Calls by only SwapAndStake & STokenManger & create: new unified SlotCollections
2 parents 928c749 + 7090c0d commit 7b4a2d4

16 files changed

Lines changed: 1523 additions & 2064 deletions

.DS_Store

6 KB
Binary file not shown.

.openzeppelin/polygon-mumbai.json

Lines changed: 719 additions & 0 deletions
Large diffs are not rendered by default.

contracts/ERC20SimpleCollections.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ contract ERC20SimpleCollections is ITokenURIDescriptor, OwnableUpgradeable {
2424
mapping(address => mapping(uint256 => uint256)) public stakedAmountAtMinted;
2525
mapping(address => bool) public allowlistedTokens;
2626
address public dev;
27+
address public sTokenManager;
2728

2829
function initialize(address _contract) external initializer {
2930
__Ownable_init();
@@ -56,6 +57,10 @@ contract ERC20SimpleCollections is ITokenURIDescriptor, OwnableUpgradeable {
5657
dev = _dev;
5758
}
5859

60+
function setSTokenManager(address _sTokenManager) external onlyOwner {
61+
sTokenManager = _sTokenManager;
62+
}
63+
5964
function image(
6065
uint256 id,
6166
address,
@@ -126,6 +131,7 @@ contract ERC20SimpleCollections is ITokenURIDescriptor, OwnableUpgradeable {
126131
ISTokensManagerStruct.StakingPositions memory _positions,
127132
bytes32 key
128133
) external returns (bool) {
134+
require(msg.sender == sTokenManager, "illegal access");
129135
Image memory img = propertyImages[_positions.property][key];
130136

131137
// When not defined the key

contracts/FiatSimpleCollections.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ contract FiatSimpleCollections is ITokenURIDescriptor, OwnableUpgradeable {
123123
delete propertyImages[_propertyAddress][_key];
124124
}
125125

126-
function getNativePriceInUsdc() internal view returns (uint) {
126+
function getNativePriceInUsdc() internal view returns (uint256) {
127127
IUniswapV2Pair pair = IUniswapV2Pair(uniswapPair);
128128

129129
(uint112 reserve0, uint112 reserve1, ) = pair.getReserves();
@@ -141,7 +141,7 @@ contract FiatSimpleCollections is ITokenURIDescriptor, OwnableUpgradeable {
141141
*/
142142
function nativeToFiat() external view returns (uint256) {
143143
// get the price of ETH/Matic in USD
144-
uint nativePriceUsd = getNativePriceInUsdc();
144+
uint256 nativePriceUsd = getNativePriceInUsdc();
145145

146146
// Check fiat value vs USD (ie JPY/USD)
147147
uint256 fiatCurrencyToUsd = uint256(
@@ -173,7 +173,7 @@ contract FiatSimpleCollections is ITokenURIDescriptor, OwnableUpgradeable {
173173
img.gateway
174174
);
175175

176-
uint maticPrice = getNativePriceInUsdc();
176+
uint256 maticPrice = getNativePriceInUsdc();
177177

178178
// calculate stake amount in USD
179179
UsdAmount memory stakeViaUsd = UsdAmount({
@@ -186,8 +186,9 @@ contract FiatSimpleCollections is ITokenURIDescriptor, OwnableUpgradeable {
186186
IPriceOracle(fiatOracle).latestAnswer() * 1e10
187187
);
188188

189-
uint stakeInputTargetFiat = (stakeViaUsd.amount / currencyToUsd) * 1e18;
190-
uint stakeFeeTargetFiat = (stakeViaUsd.fee / currencyToUsd) * 1e18;
189+
uint256 stakeInputTargetFiat = (stakeViaUsd.amount / currencyToUsd) *
190+
1e18;
191+
uint256 stakeFeeTargetFiat = (stakeViaUsd.fee / currencyToUsd) * 1e18;
191192

192193
// Validate the staking position.
193194
bool valid = img.requiredFiatAmount <= stakeInputTargetFiat &&

contracts/MembersCollection.sol

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)