@dolomite-exchange/dolomite-margin 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/contracts/Account.json +11 -11
- package/build/contracts/Actions.json +11 -11
- package/build/contracts/Address.json +1 -1
- package/build/contracts/Admin.json +23 -23
- package/build/contracts/AdminImpl.json +35 -307
- package/build/contracts/AdvancedMath.json +7 -7
- package/build/contracts/AmmRebalancerProxy.json +577 -621
- package/build/contracts/AmmRebalancerProxyV1.json +78 -32
- package/build/contracts/Babylonian.json +1 -1
- package/build/contracts/Bits.json +9 -9
- package/build/contracts/Cache.json +13 -13
- package/build/contracts/ChainlinkPriceOracleV1.json +16 -16
- package/build/contracts/Context.json +1 -1
- package/build/contracts/CustomTestToken.json +9 -9
- package/build/contracts/Decimal.json +9 -9
- package/build/contracts/DelayedMultiSig.json +9 -9
- package/build/contracts/DolomiteAmmERC20.json +11 -11
- package/build/contracts/DolomiteAmmFactory.json +14 -52
- package/build/contracts/DolomiteAmmLibrary.json +24 -24
- package/build/contracts/DolomiteAmmPair.json +27 -27
- package/build/contracts/DolomiteAmmRouterProxy.json +30 -363
- package/build/contracts/DolomiteMargin.json +21 -67
- package/build/contracts/DoubleExponentInterestSetter.json +15 -21
- package/build/contracts/EnumerableSet.json +7 -7
- package/build/contracts/ErroringOmiseToken.json +9 -9
- package/build/contracts/ErroringToken.json +10 -10
- package/build/contracts/Events.json +17 -17
- package/build/contracts/ExcessivelySafeCall.json +35 -35
- package/build/contracts/Exchange.json +15 -15
- package/build/contracts/Expiry.json +36 -36
- package/build/contracts/Getters.json +33 -33
- package/build/contracts/IAutoTrader.json +9 -9
- package/build/contracts/ICallee.json +7 -7
- package/build/contracts/IChainlinkAggregator.json +5 -5
- package/build/contracts/IDolomiteAmmERC20.json +5 -5
- package/build/contracts/IDolomiteAmmFactory.json +9 -9
- package/build/contracts/IDolomiteAmmPair.json +9 -9
- package/build/contracts/IDolomiteMargin.json +23 -23
- package/build/contracts/IERC20.json +1 -1
- package/build/contracts/IERC20Detailed.json +5 -5
- package/build/contracts/IExchangeWrapper.json +5 -5
- package/build/contracts/IExpiry.json +9 -9
- package/build/contracts/IInterestSetter.json +7 -7
- package/build/contracts/ILiquidationCallback.json +7 -7
- package/build/contracts/IMakerOracle.json +5 -5
- package/build/contracts/IOasisDex.json +5 -5
- package/build/contracts/IPriceOracle.json +7 -7
- package/build/contracts/IRecyclable.json +9 -9
- package/build/contracts/ITransferProxy.json +5 -5
- package/build/contracts/IUniswapV2Callee.json +5 -5
- package/build/contracts/IUniswapV2Factory.json +5 -5
- package/build/contracts/IUniswapV2Pair.json +5 -5
- package/build/contracts/IUniswapV2Router.json +5 -5
- package/build/contracts/IWETH.json +5 -5
- package/build/contracts/Interest.json +15 -15
- package/build/contracts/LiquidateOrVaporizeImpl.json +32 -83
- package/build/contracts/LiquidatorProxyHelper.json +23 -23
- package/build/contracts/LiquidatorProxyV1.json +30 -36
- package/build/contracts/LiquidatorProxyV1WithAmm.json +49 -105
- package/build/contracts/Math.json +1 -1
- package/build/contracts/Migrations.json +8 -14
- package/build/contracts/Monetary.json +7 -7
- package/build/contracts/MultiCall.json +8 -14
- package/build/contracts/MultiSig.json +7 -7
- package/build/contracts/OmiseToken.json +8 -8
- package/build/contracts/OnlyDolomiteMargin.json +11 -11
- package/build/contracts/Operation.json +15 -15
- package/build/contracts/OperationImpl.json +39 -47
- package/build/contracts/Ownable.json +1 -1
- package/build/contracts/PartiallyDelayedMultiSig.json +9 -9
- package/build/contracts/PayableProxy.json +17 -23
- package/build/contracts/Permission.json +11 -11
- package/build/contracts/PolynomialInterestSetter.json +13 -13
- package/build/contracts/RecyclableTokenProxy.json +25 -25
- package/build/contracts/ReentrancyGuard.json +1 -1
- package/build/contracts/Require.json +7 -7
- package/build/contracts/SafeERC20.json +1 -1
- package/build/contracts/SafeETH.json +7 -7
- package/build/contracts/SafeLiquidationCallback.json +17 -17
- package/build/contracts/SafeMath.json +1 -1
- package/build/contracts/SignedOperationProxy.json +21 -104
- package/build/contracts/SimpleFeeOwner.json +18 -63
- package/build/contracts/State.json +9 -9
- package/build/contracts/Storage.json +37 -37
- package/build/contracts/TestAmmRebalancerProxy.json +32 -58
- package/build/contracts/TestAutoTrader.json +22 -22
- package/build/contracts/TestBtcUsdChainlinkAggregator.json +10 -10
- package/build/contracts/TestCallee.json +19 -19
- package/build/contracts/TestChainlinkPriceOracleV1.json +10 -94
- package/build/contracts/TestCounter.json +7 -7
- package/build/contracts/TestDaiUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestDolomiteMargin.json +22 -22
- package/build/contracts/TestDoubleExponentInterestSetter.json +10 -10
- package/build/contracts/TestEthUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestExchangeWrapper.json +28 -28
- package/build/contracts/TestInterestSetter.json +13 -13
- package/build/contracts/TestLib.json +22 -22
- package/build/contracts/TestLinkUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestLiquidateCallback.json +719 -719
- package/build/contracts/TestLiquidationCallback.json +13 -13
- package/build/contracts/TestLrcEthChainlinkAggregator.json +11 -11
- package/build/contracts/TestMakerOracle.json +10 -10
- package/build/contracts/TestMaticUsdChainlinkAggregator.json +10 -10
- package/build/contracts/TestOasisDex.json +12 -12
- package/build/contracts/TestOperationImpl.json +14 -14
- package/build/contracts/TestPolynomialInterestSetter.json +10 -10
- package/build/contracts/TestPriceAggregator.json +9 -9
- package/build/contracts/TestPriceOracle.json +13 -13
- package/build/contracts/TestRecyclableToken.json +9 -9
- package/build/contracts/TestSimpleCallee.json +15 -15
- package/build/contracts/TestToken.json +9 -9
- package/build/contracts/TestTrader.json +17 -17
- package/build/contracts/TestUniswapAmmRebalancerProxy.json +16 -16
- package/build/contracts/TestUsdcUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestWETH.json +9 -9
- package/build/contracts/Time.json +9 -9
- package/build/contracts/Token.json +9 -9
- package/build/contracts/TokenA.json +10 -10
- package/build/contracts/TokenB.json +10 -10
- package/build/contracts/TokenC.json +10 -10
- package/build/contracts/TokenD.json +10 -10
- package/build/contracts/TokenE.json +10 -10
- package/build/contracts/TokenF.json +10 -10
- package/build/contracts/TransferProxy.json +22 -28
- package/build/contracts/TypedSignature.json +9 -9
- package/build/contracts/Types.json +9 -9
- package/build/contracts/UQ112x112.json +7 -7
- package/build/contracts/UniswapV2ERC20.json +7 -7
- package/build/contracts/UniswapV2Factory.json +12 -12
- package/build/contracts/UniswapV2Library.json +20 -20
- package/build/contracts/UniswapV2Pair.json +17 -17
- package/build/contracts/UniswapV2Router02.json +16 -16
- package/build/contracts/WETH9.json +1 -1
- package/contracts/external/amm/DolomiteAmmERC20.sol +135 -0
- package/contracts/external/amm/DolomiteAmmFactory.sol +122 -0
- package/contracts/external/amm/DolomiteAmmPair.sol +573 -0
- package/contracts/external/amm/SimpleFeeOwner.sol +107 -0
- package/contracts/external/helpers/LiquidatorProxyHelper.sol +252 -0
- package/contracts/external/helpers/OnlyDolomiteMargin.sol +63 -0
- package/contracts/external/interestsetters/DoubleExponentInterestSetter.sol +212 -0
- package/contracts/external/interestsetters/PolynomialInterestSetter.sol +205 -0
- package/contracts/external/interfaces/IChainlinkAggregator.sol +33 -0
- package/contracts/external/interfaces/IDolomiteAmmERC20.sol +52 -0
- package/contracts/external/interfaces/IDolomiteAmmFactory.sol +42 -0
- package/contracts/external/interfaces/IDolomiteAmmPair.sol +116 -0
- package/contracts/external/interfaces/IExpiry.sol +70 -0
- package/contracts/external/interfaces/IMakerOracle.sol +52 -0
- package/contracts/external/interfaces/IOasisDex.sol +326 -0
- package/contracts/external/interfaces/ITransferProxy.sol +53 -0
- package/contracts/external/interfaces/IUniswapV2Router.sol +134 -0
- package/contracts/external/lib/AdvancedMath.sol +23 -0
- package/contracts/external/lib/DolomiteAmmLibrary.sol +323 -0
- package/contracts/external/lib/TypedSignature.sol +120 -0
- package/contracts/external/lib/UQ112x112.sol +22 -0
- package/contracts/external/multisig/DelayedMultiSig.sol +206 -0
- package/contracts/external/multisig/MultiSig.sol +571 -0
- package/contracts/external/multisig/PartiallyDelayedMultiSig.sol +174 -0
- package/contracts/external/oracles/ChainlinkPriceOracleV1.sol +197 -0
- package/contracts/external/oracles/TestChainlinkPriceOracleV1.sol +98 -0
- package/contracts/external/proxies/AmmRebalancerProxyV1.sol +465 -0
- package/contracts/external/proxies/DolomiteAmmRouterProxy.sol +877 -0
- package/contracts/external/proxies/LiquidatorProxyV1.sol +507 -0
- package/contracts/external/proxies/LiquidatorProxyV1WithAmm.sol +574 -0
- package/contracts/external/proxies/PayableProxy.sol +146 -0
- package/contracts/external/proxies/RecyclableTokenProxy.sol +463 -0
- package/contracts/external/proxies/SignedOperationProxy.sol +553 -0
- package/contracts/external/proxies/TransferProxy.sol +207 -0
- package/contracts/external/traders/Expiry.sol +532 -0
- package/contracts/external/uniswap-v2/UniswapV2ERC20.sol +118 -0
- package/contracts/external/uniswap-v2/UniswapV2Factory.sol +67 -0
- package/contracts/external/uniswap-v2/UniswapV2Pair.sol +283 -0
- package/contracts/external/uniswap-v2/UniswapV2Router02.sol +566 -0
- package/contracts/external/uniswap-v2/interfaces/IUniswapV2Callee.sol +13 -0
- package/contracts/external/uniswap-v2/interfaces/IUniswapV2Factory.sol +18 -0
- package/contracts/external/uniswap-v2/interfaces/IUniswapV2Pair.sol +67 -0
- package/contracts/external/uniswap-v2/interfaces/IWETH.sol +7 -0
- package/contracts/external/uniswap-v2/libraries/SafeETH.sol +29 -0
- package/contracts/external/uniswap-v2/libraries/UniswapV2Library.sol +117 -0
- package/contracts/external/utils/MultiCall.sol +95 -0
- package/contracts/protocol/impl/artifacts/OperationImpl.json +80 -0
- package/contracts/protocol/impl/artifacts/OperationImpl_metadata.json +193 -0
- package/dist/build/published_contracts/AdminImpl.json +2 -2
- package/dist/build/published_contracts/AmmRebalancerProxyV1.json +5 -0
- package/dist/build/published_contracts/ChainlinkPriceOracleV1.json +1 -1
- package/dist/build/published_contracts/DolomiteAmmFactory.json +1 -1
- package/dist/build/published_contracts/DolomiteAmmRouterProxy.json +1 -1
- package/dist/build/published_contracts/DoubleExponentInterestSetter.json +2 -2
- package/dist/build/published_contracts/Expiry.json +1 -1
- package/dist/build/published_contracts/LiquidatorProxyV1.json +1 -1
- package/dist/build/published_contracts/LiquidatorProxyV1WithAmm.json +1 -1
- package/dist/build/published_contracts/MultiCall.json +1 -1
- package/dist/build/published_contracts/PayableProxy.json +2 -2
- package/dist/build/published_contracts/SignedOperationProxy.json +2 -2
- package/dist/build/published_contracts/SimpleFeeOwner.json +1 -1
- package/dist/build/published_contracts/TestUniswapAmmRebalancerProxy.json +140 -0
- package/dist/build/published_contracts/TransferProxy.json +1 -1
- package/dist/src/lib/Contracts.d.ts +3 -1
- package/dist/src/lib/Contracts.js +7 -3
- package/dist/src/lib/Contracts.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
pragma solidity >=0.5.0;
|
|
2
|
+
|
|
3
|
+
import "@openzeppelin/contracts/math/SafeMath.sol";
|
|
4
|
+
|
|
5
|
+
import "../interfaces/IUniswapV2Factory.sol";
|
|
6
|
+
import "../interfaces/IUniswapV2Pair.sol";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
library UniswapV2Library {
|
|
10
|
+
using SafeMath for uint;
|
|
11
|
+
|
|
12
|
+
bytes32 private constant PAIR_INIT_CODE_HASH = 0x5a9f5c3574970dea87031a97b794f46fbe4a0f2c3bf2d6e322a3edfb9ff6d0b5;
|
|
13
|
+
|
|
14
|
+
function getPairInitCodeHash() internal pure returns (bytes32) {
|
|
15
|
+
return PAIR_INIT_CODE_HASH;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// returns sorted token addresses, used to handle return values from pairs sorted in this order
|
|
19
|
+
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
|
|
20
|
+
require(tokenA != tokenB, "UniswapV2Library: IDENTICAL_ADDRESSES");
|
|
21
|
+
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
|
|
22
|
+
require(token0 != address(0), "UniswapV2Library: ZERO_ADDRESS");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// calculates the CREATE2 address for a pair without making any external calls
|
|
26
|
+
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
|
|
27
|
+
(address token0, address token1) = sortTokens(tokenA, tokenB);
|
|
28
|
+
pair = address(
|
|
29
|
+
uint(
|
|
30
|
+
keccak256(
|
|
31
|
+
abi.encodePacked(
|
|
32
|
+
hex"ff",
|
|
33
|
+
factory,
|
|
34
|
+
keccak256(abi.encodePacked(token0, token1)),
|
|
35
|
+
PAIR_INIT_CODE_HASH
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// fetches and sorts the reserves for a pair
|
|
43
|
+
function getReserves(
|
|
44
|
+
address factory,
|
|
45
|
+
address tokenA,
|
|
46
|
+
address tokenB
|
|
47
|
+
)
|
|
48
|
+
internal
|
|
49
|
+
view
|
|
50
|
+
returns (uint reserveA, uint reserveB) {
|
|
51
|
+
(address token0,) = sortTokens(tokenA, tokenB);
|
|
52
|
+
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
|
|
53
|
+
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
|
|
57
|
+
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
|
|
58
|
+
require(amountA > 0, "UniswapV2Library: INSUFFICIENT_AMOUNT");
|
|
59
|
+
require(reserveA > 0 && reserveB > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
|
|
60
|
+
amountB = amountA.mul(reserveB) / reserveA;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
|
|
64
|
+
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
|
|
65
|
+
require(amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT");
|
|
66
|
+
require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
|
|
67
|
+
uint amountInWithFee = amountIn.mul(997);
|
|
68
|
+
uint numerator = amountInWithFee.mul(reserveOut);
|
|
69
|
+
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
|
|
70
|
+
amountOut = numerator / denominator;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
|
|
74
|
+
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
|
|
75
|
+
require(amountOut > 0, "UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT");
|
|
76
|
+
require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
|
|
77
|
+
uint numerator = reserveIn.mul(amountOut).mul(1000);
|
|
78
|
+
uint denominator = reserveOut.sub(amountOut).mul(997);
|
|
79
|
+
amountIn = (numerator / denominator).add(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// performs chained getAmountOut calculations on any number of pairs
|
|
83
|
+
function getAmountsOut(
|
|
84
|
+
address factory,
|
|
85
|
+
uint amountIn,
|
|
86
|
+
address[] memory path
|
|
87
|
+
)
|
|
88
|
+
internal
|
|
89
|
+
view
|
|
90
|
+
returns (uint[] memory amounts) {
|
|
91
|
+
require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
|
|
92
|
+
amounts = new uint[](path.length);
|
|
93
|
+
amounts[0] = amountIn;
|
|
94
|
+
for (uint i; i < path.length - 1; i++) {
|
|
95
|
+
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
|
|
96
|
+
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// performs chained getAmountIn calculations on any number of pairs
|
|
101
|
+
function getAmountsIn(
|
|
102
|
+
address factory,
|
|
103
|
+
uint amountOut,
|
|
104
|
+
address[] memory path
|
|
105
|
+
)
|
|
106
|
+
internal
|
|
107
|
+
view
|
|
108
|
+
returns (uint[] memory amounts) {
|
|
109
|
+
require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
|
|
110
|
+
amounts = new uint[](path.length);
|
|
111
|
+
amounts[amounts.length - 1] = amountOut;
|
|
112
|
+
for (uint i = path.length - 1; i > 0; i--) {
|
|
113
|
+
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
|
|
114
|
+
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.5.0;
|
|
4
|
+
pragma experimental ABIEncoderV2;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title MultiCall - Aggregate results from multiple read-only function calls
|
|
10
|
+
* @author Michael Elliot <mike@makerdao.com>
|
|
11
|
+
* @author Joshua Levine <joshua@makerdao.com>
|
|
12
|
+
* @author Nick Johnson <arachnid@notdot.net>
|
|
13
|
+
* @author Corey Caplan <corey@dolomite.io>
|
|
14
|
+
*/
|
|
15
|
+
contract MultiCall {
|
|
16
|
+
|
|
17
|
+
struct Call {
|
|
18
|
+
address target;
|
|
19
|
+
bytes callData;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function aggregate(Call[] memory calls) public returns (uint256 blockNumber, bytes[] memory returnData) {
|
|
23
|
+
blockNumber = block.number;
|
|
24
|
+
returnData = new bytes[](calls.length);
|
|
25
|
+
for (uint256 i = 0; i < calls.length; i++) {
|
|
26
|
+
// solium-disable-next-line security/no-low-level-calls
|
|
27
|
+
(bool success, bytes memory result) = calls[i].target.call(calls[i].callData);
|
|
28
|
+
if (!success) {
|
|
29
|
+
if (result.length < 68) {
|
|
30
|
+
string memory targetString = _addressToString(calls[i].target);
|
|
31
|
+
revert(string(abi.encodePacked("Multicall::aggregate: revert at <", targetString, ">")));
|
|
32
|
+
} else {
|
|
33
|
+
// solium-disable-next-line security/no-inline-assembly
|
|
34
|
+
assembly {
|
|
35
|
+
result := add(result, 0x04)
|
|
36
|
+
}
|
|
37
|
+
string memory targetString = _addressToString(calls[i].target);
|
|
38
|
+
revert(
|
|
39
|
+
string(
|
|
40
|
+
abi.encodePacked(
|
|
41
|
+
"Multicall::aggregate: revert at <",
|
|
42
|
+
targetString,
|
|
43
|
+
"> with reason: ",
|
|
44
|
+
abi.decode(result, (string))
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
returnData[i] = result;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Helper functions
|
|
55
|
+
function getEthBalance(address addr) public view returns (uint256 balance) {
|
|
56
|
+
balance = addr.balance;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) {
|
|
60
|
+
blockHash = blockhash(blockNumber);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getLastBlockHash() public view returns (bytes32 blockHash) {
|
|
64
|
+
blockHash = blockhash(block.number - 1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getCurrentBlockTimestamp() public view returns (uint256 timestamp) {
|
|
68
|
+
timestamp = block.timestamp;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getCurrentBlockDifficulty() public view returns (uint256 difficulty) {
|
|
72
|
+
difficulty = block.difficulty;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {
|
|
76
|
+
gaslimit = block.gaslimit;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getCurrentBlockCoinbase() public view returns (address coinbase) {
|
|
80
|
+
coinbase = block.coinbase;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _addressToString(address _address) internal pure returns(string memory) {
|
|
84
|
+
bytes32 _bytes = bytes32(uint256(_address));
|
|
85
|
+
bytes memory HEX = "0123456789abcdef";
|
|
86
|
+
bytes memory _string = new bytes(42);
|
|
87
|
+
_string[0] = "0";
|
|
88
|
+
_string[1] = "x";
|
|
89
|
+
for (uint i = 0; i < 20; i++) {
|
|
90
|
+
_string[2 + i * 2] = HEX[uint8(_bytes[i + 12] >> 4)];
|
|
91
|
+
_string[3 + i * 2] = HEX[uint8(_bytes[i + 12] & 0x0f)];
|
|
92
|
+
}
|
|
93
|
+
return string(_string);
|
|
94
|
+
}
|
|
95
|
+
}
|