Skip to content

Commit

Permalink
Deploy
Browse files Browse the repository at this point in the history
3.4.8
  • Loading branch information
arietrouw committed Feb 19, 2025
1 parent a74eb12 commit c1588f4
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 58 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion packages/open-zeppelin-typechain/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion packages/solidity/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
7 changes: 4 additions & 3 deletions packages/solidity/src/xyo-chain/StakedXyoChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@ pragma solidity ^0.8.20;

import "./XyoChain/XyoChain.sol";
import "./AddressStaking/AddressStaking.sol";
import "./XyoChain/IXyoChainRewards.sol";

contract StakedXyoChain is XyoChain, AddressStaking {
// ========== CONSTRUCTOR ==========

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)
{}
Expand Down
20 changes: 4 additions & 16 deletions packages/solidity/src/xyo-chain/XyoChain/IXyoChain.sol
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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
Expand All @@ -36,6 +23,7 @@ interface IXyoChain {
uint256 chainSigningPrivateKey,
address indexed forkedChainId,
uint256 forkedAtLastBlockNumber,
uint256 forkedAtLastHash
uint256 forkedAtLastHash,
IXyoChainRewards rewardsContract
);
}
21 changes: 21 additions & 0 deletions packages/solidity/src/xyo-chain/XyoChain/IXyoChainRewards.sol
Original file line number Diff line number Diff line change
@@ -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);
}
40 changes: 9 additions & 31 deletions packages/solidity/src/xyo-chain/XyoChain/XyoChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.20;

import "./IXyoChain.sol";
import "./IXyoChainRewards.sol";

contract XyoChain is IXyoChain {
// The signing address (from _privateKey)
Expand All @@ -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
);
}

Expand Down Expand Up @@ -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;
}
}
52 changes: 52 additions & 0 deletions packages/solidity/src/xyo-chain/XyoChain/XyoChainRewards.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion packages/typechain/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion packages/uniswap-solidity/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion packages/uniswap-typechain/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion packages/world-solidity/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion packages/world-typechain/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down

0 comments on commit c1588f4

Please sign in to comment.