From c1588f437b897357587a6a47a4c32a08ff213f5d Mon Sep 17 00:00:00 2001 From: Arie Trouw Date: Tue, 18 Feb 2025 17:10:18 -0800 Subject: [PATCH] Deploy 3.4.8 --- package.json | 2 +- packages/open-zeppelin-typechain/package.json | 2 +- packages/solidity/package.json | 2 +- .../solidity/src/xyo-chain/StakedXyoChain.sol | 7 +-- .../src/xyo-chain/XyoChain/IXyoChain.sol | 20 ++----- .../xyo-chain/XyoChain/IXyoChainRewards.sol | 21 ++++++++ .../src/xyo-chain/XyoChain/XyoChain.sol | 40 ++++---------- .../xyo-chain/XyoChain/XyoChainRewards.sol | 52 +++++++++++++++++++ packages/typechain/package.json | 2 +- packages/uniswap-solidity/package.json | 2 +- packages/uniswap-typechain/package.json | 2 +- packages/world-solidity/package.json | 2 +- packages/world-typechain/package.json | 2 +- 13 files changed, 98 insertions(+), 58 deletions(-) create mode 100644 packages/solidity/src/xyo-chain/XyoChain/IXyoChainRewards.sol create mode 100644 packages/solidity/src/xyo-chain/XyoChain/XyoChainRewards.sol diff --git a/package.json b/package.json index 2df996a..1b1d5c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/sdk-xyo-typechain", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network" diff --git a/packages/open-zeppelin-typechain/package.json b/packages/open-zeppelin-typechain/package.json index 3d8e5d1..7ea4062 100644 --- a/packages/open-zeppelin-typechain/package.json +++ b/packages/open-zeppelin-typechain/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/open-zeppelin-typechain", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network" diff --git a/packages/solidity/package.json b/packages/solidity/package.json index 5875887..268add3 100644 --- a/packages/solidity/package.json +++ b/packages/solidity/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/solidity", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network" diff --git a/packages/solidity/src/xyo-chain/StakedXyoChain.sol b/packages/solidity/src/xyo-chain/StakedXyoChain.sol index bfaf772..98bcd00 100644 --- a/packages/solidity/src/xyo-chain/StakedXyoChain.sol +++ b/packages/solidity/src/xyo-chain/StakedXyoChain.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.20; import "./XyoChain/XyoChain.sol"; import "./AddressStaking/AddressStaking.sol"; +import "./XyoChain/IXyoChainRewards.sol"; contract StakedXyoChain is XyoChain, AddressStaking { // ========== CONSTRUCTOR ========== @@ -10,20 +11,20 @@ contract StakedXyoChain is XyoChain, AddressStaking { constructor( address _chainSigningAddress, // The address of the privateKey supplied uint256 _chainSigningPrivateKey, // The private key that is used to cosign the chain for continuity in XYO - BlockRewardConfig memory _blockRewardConfig, address _forkFromChainId, // The chain id from which the chain is forked (zero if it is a genesis chain) uint256 _forkFromLastBlockNumber, uint256 _forkFromLastHash, + IXyoChainRewards _rewardsContract, uint256 _minWithdrawalBlocks, // The minimum number of blocks that must pass before a pending stake can be withdrawn address _stakingTokenAddress // The token that is used for staking ) XyoChain( _chainSigningAddress, _chainSigningPrivateKey, - _blockRewardConfig, _forkFromChainId, _forkFromLastBlockNumber, - _forkFromLastHash + _forkFromLastHash, + _rewardsContract ) AddressStaking(_minWithdrawalBlocks, _stakingTokenAddress) {} diff --git a/packages/solidity/src/xyo-chain/XyoChain/IXyoChain.sol b/packages/solidity/src/xyo-chain/XyoChain/IXyoChain.sol index 22245e1..a2d30d4 100644 --- a/packages/solidity/src/xyo-chain/XyoChain/IXyoChain.sol +++ b/packages/solidity/src/xyo-chain/XyoChain/IXyoChain.sol @@ -1,13 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.20; -struct BlockRewardConfig { - uint256 initialReward; - uint256 stepSize; - uint256 stepFactorNumerator; - uint256 stepFactorDenominator; - uint256 minRewardPerBlock; -} +import "./IXyoChainRewards.sol"; interface IXyoChain { function chainId() external view returns (address); @@ -16,14 +10,7 @@ interface IXyoChain { function forkedChainId() external view returns (address); function forkedAtBlockNumber() external view returns (uint256); function forkedAtHash() external view returns (uint256); - function calcBlockRewardPure( - uint256 blockNumber, - BlockRewardConfig calldata config - ) external pure returns (uint256); - - function calcBlockReward( - uint256 blockNumber - ) external view returns (uint256); + function rewardsContract() external view returns (IXyoChainRewards); /* The Genesis block will have a block id of 0 and a block number of 0 @@ -36,6 +23,7 @@ interface IXyoChain { uint256 chainSigningPrivateKey, address indexed forkedChainId, uint256 forkedAtLastBlockNumber, - uint256 forkedAtLastHash + uint256 forkedAtLastHash, + IXyoChainRewards rewardsContract ); } diff --git a/packages/solidity/src/xyo-chain/XyoChain/IXyoChainRewards.sol b/packages/solidity/src/xyo-chain/XyoChain/IXyoChainRewards.sol new file mode 100644 index 0000000..111c63f --- /dev/null +++ b/packages/solidity/src/xyo-chain/XyoChain/IXyoChainRewards.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.20; + +struct BlockRewardConfig { + uint256 initialReward; + uint256 stepSize; + uint256 stepFactorNumerator; + uint256 stepFactorDenominator; + uint256 minRewardPerBlock; +} + +interface IXyoChainRewards { + function calcBlockRewardPure( + uint256 blockNumber, + BlockRewardConfig calldata config + ) external pure returns (uint256); + + function calcBlockReward( + uint256 blockNumber + ) external view returns (uint256); +} diff --git a/packages/solidity/src/xyo-chain/XyoChain/XyoChain.sol b/packages/solidity/src/xyo-chain/XyoChain/XyoChain.sol index 50c37e7..6d0d1f5 100644 --- a/packages/solidity/src/xyo-chain/XyoChain/XyoChain.sol +++ b/packages/solidity/src/xyo-chain/XyoChain/XyoChain.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.20; import "./IXyoChain.sol"; +import "./IXyoChainRewards.sol"; contract XyoChain is IXyoChain { // The signing address (from _privateKey) @@ -19,29 +20,30 @@ contract XyoChain is IXyoChain { // The last hash from which the chain is forked (zero if it is a genesis chain) uint256 private __forkedAtHash; - BlockRewardConfig private __blockRewardConfig; + IXyoChainRewards private __rewardsContract; constructor( address _chainSigningAddress, uint256 _chainSigningPrivateKey, - BlockRewardConfig memory _blockRewardConfig, address _forkedChainId, uint256 _forkedAtLastBlockNumber, - uint256 _forkedAtLastHash + uint256 _forkedAtLastHash, + IXyoChainRewards _rewardsContract ) { __chainSigningAddress = _chainSigningAddress; __chainSigningPrivateKey = _chainSigningPrivateKey; - __blockRewardConfig = _blockRewardConfig; __forkedChainId = _forkedChainId; __forkedAtBlockNumber = _forkedAtLastBlockNumber; __forkedAtHash = _forkedAtLastHash; + __rewardsContract = _rewardsContract; emit ChainCreated( address(this), _chainSigningAddress, _chainSigningPrivateKey, _forkedChainId, _forkedAtLastBlockNumber, - _forkedAtLastHash + _forkedAtLastHash, + _rewardsContract ); } @@ -69,31 +71,7 @@ contract XyoChain is IXyoChain { return __forkedAtHash; } - function calcBlockReward( - uint256 blockNumber - ) public view returns (uint256) { - return internalBlockRewardCalc(blockNumber, __blockRewardConfig); - } - - function calcBlockRewardPure( - uint256 blockNumber, - BlockRewardConfig memory config - ) public pure returns (uint256) { - return internalBlockRewardCalc(blockNumber, config); - } - - function internalBlockRewardCalc( - uint256 blockNumber, - BlockRewardConfig memory config - ) internal pure returns (uint256) { - uint256 step = blockNumber / config.stepSize; - uint256 poweredNumerator = config.stepFactorNumerator ** step; - uint256 poweredDenominator = config.stepFactorDenominator ** step; - uint256 calcReward = (config.initialReward * poweredNumerator) / - poweredDenominator; - if (calcReward < config.minRewardPerBlock) { - return config.minRewardPerBlock; - } - return calcReward; + function rewardsContract() external view returns (IXyoChainRewards) { + return __rewardsContract; } } diff --git a/packages/solidity/src/xyo-chain/XyoChain/XyoChainRewards.sol b/packages/solidity/src/xyo-chain/XyoChain/XyoChainRewards.sol new file mode 100644 index 0000000..3142348 --- /dev/null +++ b/packages/solidity/src/xyo-chain/XyoChain/XyoChainRewards.sol @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.20; + +import "./IXyoChainRewards.sol"; + +contract XyoChainRewards is IXyoChainRewards { + BlockRewardConfig private __blockRewardConfig; + + constructor( + uint256 _initialReward, + uint256 _stepSize, + uint256 _stepFactorNumerator, + uint256 _stepFactorDenominator, + uint256 _minRewardPerBlock + ) { + __blockRewardConfig = BlockRewardConfig( + _initialReward, + _stepSize, + _stepFactorNumerator, + _stepFactorDenominator, + _minRewardPerBlock + ); + } + + function calcBlockReward( + uint256 blockNumber + ) public view returns (uint256) { + return internalBlockRewardCalc(blockNumber, __blockRewardConfig); + } + + function calcBlockRewardPure( + uint256 blockNumber, + BlockRewardConfig memory config + ) public pure returns (uint256) { + return internalBlockRewardCalc(blockNumber, config); + } + + function internalBlockRewardCalc( + uint256 blockNumber, + BlockRewardConfig memory config + ) internal pure returns (uint256) { + uint256 step = blockNumber / config.stepSize; + uint256 poweredNumerator = config.stepFactorNumerator ** step; + uint256 poweredDenominator = config.stepFactorDenominator ** step; + uint256 calcReward = (config.initialReward * poweredNumerator) / + poweredDenominator; + if (calcReward < config.minRewardPerBlock) { + return config.minRewardPerBlock; + } + return calcReward; + } +} diff --git a/packages/typechain/package.json b/packages/typechain/package.json index d0305c6..fa0bcb7 100644 --- a/packages/typechain/package.json +++ b/packages/typechain/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/typechain", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network" diff --git a/packages/uniswap-solidity/package.json b/packages/uniswap-solidity/package.json index 45e9a94..1c2328f 100644 --- a/packages/uniswap-solidity/package.json +++ b/packages/uniswap-solidity/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/uniswap-solidity", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network" diff --git a/packages/uniswap-typechain/package.json b/packages/uniswap-typechain/package.json index 19ef678..864b1b7 100644 --- a/packages/uniswap-typechain/package.json +++ b/packages/uniswap-typechain/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/uniswap-typechain", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network" diff --git a/packages/world-solidity/package.json b/packages/world-solidity/package.json index d32358c..c407faa 100644 --- a/packages/world-solidity/package.json +++ b/packages/world-solidity/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/world-solidity", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network" diff --git a/packages/world-typechain/package.json b/packages/world-typechain/package.json index 6c3676b..74c6c01 100644 --- a/packages/world-typechain/package.json +++ b/packages/world-typechain/package.json @@ -1,6 +1,6 @@ { "name": "@xyo-network/world-typechain", - "version": "3.4.7", + "version": "3.4.8", "bugs": { "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-typechain/issues", "email": "support@xyo.network"