Skip to content

Commit

Permalink
Merge pull request #20 from MoonSHRD/refactor/getters
Browse files Browse the repository at this point in the history
Refactor/getters
  • Loading branch information
JackBekket committed Jan 11, 2023
2 parents 8e59ca5 + 89d929a commit 54f8313
Show file tree
Hide file tree
Showing 21 changed files with 685 additions and 85 deletions.
3 changes: 2 additions & 1 deletion addresses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Singleton Collection deployed to: 0xEbE648689E98abA446e38621E5a3491db03a7621
Factory NFT deployed to: 0xd8bD8B58Ad057a2D7dC835cDE41397151490dA79
Our currency deployed to: 0xA25d4cb14742a408B7421A259c96cE29F6113B3d
Currencies util contract deployed to: 0xB85D9f60241798e53BB9bCac58447f0aaAA071C1
MetaMarketplace deployed to: 0x8CeC1dD2802C820574b34357b4AdD49aaF100fAD
calculator lib deployed to: 0xF2FbfAAE0cF9a2b266BCc0aF5d96731BC175429B
MetaMarketplace deployed to: 0x087313C2c161c814C4270f07Ebd455AB902a0c10


1 change: 1 addition & 0 deletions artifacts/build-info/7f5e4a5ac7db7775e3609208f4790b27.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions artifacts/build-info/b23dcfaa16e52cbf3213a37041bb8b66.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions artifacts/build-info/f67bdb8d1ba28198b20d62c2e1663fbc.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/619187956ce695f2b317596a966187a7.json"
"buildInfo": "../../build-info/b23dcfaa16e52cbf3213a37041bb8b66.json"
}
4 changes: 2 additions & 2 deletions artifacts/contracts/CurrenciesERC20.sol/CurrenciesERC20.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/f67bdb8d1ba28198b20d62c2e1663fbc.json"
}
40 changes: 40 additions & 0 deletions artifacts/contracts/FeesCalculator.sol/FeesCalculator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "FeesCalculator",
"sourceName": "contracts/FeesCalculator.sol",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "scale",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "promille_fee_",
"type": "uint256"
}
],
"name": "calculateAbstractFee",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
}
],
"bytecode": "0x6103bc610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c806336ea61781461003a575b600080fd5b610054600480360381019061004f9190610148565b61006a565b60405161006191906101a6565b60405180910390f35b60008083856100799190610217565b90506000848661008991906102e0565b9050600085856100999190610217565b9050600086866100a991906102e0565b90508660018883866100bb9190610248565b6100c591906101c1565b6100cf91906102a2565b6100d99190610217565b82846100e59190610248565b82866100f19190610248565b8985886100fe9190610248565b6101089190610248565b61011291906101c1565b61011c91906101c1565b61012691906101c1565b9450505050509392505050565b6000813590506101428161036f565b92915050565b60008060006060848603121561015d57600080fd5b600061016b86828701610133565b935050602061017c86828701610133565b925050604061018d86828701610133565b9150509250925092565b6101a0816102d6565b82525050565b60006020820190506101bb6000830184610197565b92915050565b60006101cc826102d6565b91506101d7836102d6565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561020c5761020b610311565b5b828201905092915050565b6000610222826102d6565b915061022d836102d6565b92508261023d5761023c610340565b5b828204905092915050565b6000610253826102d6565b915061025e836102d6565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561029757610296610311565b5b828202905092915050565b60006102ad826102d6565b91506102b8836102d6565b9250828210156102cb576102ca610311565b5b828203905092915050565b6000819050919050565b60006102eb826102d6565b91506102f6836102d6565b92508261030657610305610340565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b610378816102d6565b811461038357600080fd5b5056fea264697066735822122061f11dcb80709bea7eaf31c9dd8ddbf388f7ed6c6e6932d47b6fcbf7d786742a64736f6c63430008040033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c806336ea61781461003a575b600080fd5b610054600480360381019061004f9190610148565b61006a565b60405161006191906101a6565b60405180910390f35b60008083856100799190610217565b90506000848661008991906102e0565b9050600085856100999190610217565b9050600086866100a991906102e0565b90508660018883866100bb9190610248565b6100c591906101c1565b6100cf91906102a2565b6100d99190610217565b82846100e59190610248565b82866100f19190610248565b8985886100fe9190610248565b6101089190610248565b61011291906101c1565b61011c91906101c1565b61012691906101c1565b9450505050509392505050565b6000813590506101428161036f565b92915050565b60008060006060848603121561015d57600080fd5b600061016b86828701610133565b935050602061017c86828701610133565b925050604061018d86828701610133565b9150509250925092565b6101a0816102d6565b82525050565b60006020820190506101bb6000830184610197565b92915050565b60006101cc826102d6565b91506101d7836102d6565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561020c5761020b610311565b5b828201905092915050565b6000610222826102d6565b915061022d836102d6565b92508261023d5761023c610340565b5b828204905092915050565b6000610253826102d6565b915061025e836102d6565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561029757610296610311565b5b828202905092915050565b60006102ad826102d6565b91506102b8836102d6565b9250828210156102cb576102ca610311565b5b828203905092915050565b6000819050919050565b60006102eb826102d6565b91506102f6836102d6565b92508261030657610305610340565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b610378816102d6565b811461038357600080fd5b5056fea264697066735822122061f11dcb80709bea7eaf31c9dd8ddbf388f7ed6c6e6932d47b6fcbf7d786742a64736f6c63430008040033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/619187956ce695f2b317596a966187a7.json"
"buildInfo": "../../build-info/b23dcfaa16e52cbf3213a37041bb8b66.json"
}
156 changes: 134 additions & 22 deletions artifacts/contracts/MetaMarketplace.sol/MetaMarketplace.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/619187956ce695f2b317596a966187a7.json"
"buildInfo": "../../../build-info/7f5e4a5ac7db7775e3609208f4790b27.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/619187956ce695f2b317596a966187a7.json"
"buildInfo": "../../../build-info/b23dcfaa16e52cbf3213a37041bb8b66.json"
}
25 changes: 25 additions & 0 deletions contracts/FeesCalculator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pragma solidity ^0.8.0;

// SPDX-License-Identifier: UNLICENSED


/**
* @author Jack Bekket
* ALL RIGHTS RESERVED
*/
library FeesCalculator {

/**
* Calculate fee (UnSafeMath) -- use it only if it ^0.8.0
* @dev calculate fee
* @param amount number from whom we take fee
* @param scale scale for rounding. 100 is 1/100 (percent). we can encreace scale if we want better division (like we need to take 0.5% instead of 5%, then scale = 1000)
*/
function calculateAbstractFee(uint256 amount, uint256 scale, uint256 promille_fee_) public pure returns(uint256) {
uint a = amount / scale;
uint b = amount % scale;
uint c = promille_fee_ / scale;
uint d = promille_fee_ % scale;
return a * c * scale + a * d + b * c + (b * d + scale - 1) / scale;
}
}

1 comment on commit 54f8313

@vercel
Copy link

@vercel vercel bot commented on 54f8313 Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.