Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reward to the ProofSubmitted events #237

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions abi/ProofManagerV1.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@
"internalType": "uint72",
"name": "identityId",
"type": "uint72"
},
{
"indexed": false,
"internalType": "uint96",
"name": "reward",
"type": "uint96"
}
],
"name": "ProofSubmitted",
Expand Down
6 changes: 6 additions & 0 deletions abi/ProofManagerV1U1.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@
"internalType": "uint72",
"name": "identityId",
"type": "uint72"
},
{
"indexed": false,
"internalType": "uint96",
"name": "reward",
"type": "uint96"
}
],
"name": "ProofSubmitted",
Expand Down
6 changes: 6 additions & 0 deletions abi/StakingV2.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "agreementId",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "uint72",
Expand Down
18 changes: 10 additions & 8 deletions contracts/v1/ProofManagerV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ contract ProofManagerV1 is Named, Versioned, ContractStatus, Initializable {
bytes keyword,
uint8 hashFunctionId,
uint16 epoch,
uint72 indexed identityId
uint72 indexed identityId,
uint96 reward
);

string private constant _NAME = "ProofManagerV1";
string private constant _VERSION = "1.0.2";
string private constant _VERSION = "1.0.3";

bool[4] public reqs = [false, false, false, false];

Expand Down Expand Up @@ -191,20 +192,21 @@ contract ProofManagerV1 is Named, Versioned, ContractStatus, Initializable {
challenge
);

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

emit ProofSubmitted(
args.assetContract,
args.tokenId,
args.keyword,
args.hashFunctionId,
args.epoch,
identityId
identityId,
reward
);

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

stakingContract.addReward(agreementId, identityId, reward);
sasProxy.setAgreementTokenAmount(agreementId, sasProxy.getAgreementTokenAmount(agreementId) - reward);
sasProxy.incrementAgreementRewardedNodesNumber(agreementId, args.epoch);
Expand Down
18 changes: 10 additions & 8 deletions contracts/v1/ProofManagerV1U1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ contract ProofManagerV1U1 is Named, Versioned, ContractStatus, Initializable {
uint8 hashFunctionId,
uint16 epoch,
uint256 stateIndex,
uint72 indexed identityId
uint72 indexed identityId,
uint96 reward
);

string private constant _NAME = "ProofManagerV1U1";
string private constant _VERSION = "1.0.2";
string private constant _VERSION = "1.0.3";

bool[4] public reqs = [false, false, false, false];

Expand Down Expand Up @@ -200,21 +201,22 @@ contract ProofManagerV1U1 is Named, Versioned, ContractStatus, Initializable {
challenge
);

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

emit ProofSubmitted(
args.assetContract,
args.tokenId,
args.keyword,
args.hashFunctionId,
args.epoch,
latestFinalizedStateIndex,
identityId
identityId,
reward
);

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

stakingContract.addReward(agreementId, identityId, reward);
sasProxy.setAgreementTokenAmount(agreementId, sasProxy.getAgreementTokenAmount(agreementId) - reward);
sasProxy.incrementAgreementRewardedNodesNumber(agreementId, args.epoch);
Expand Down
10 changes: 9 additions & 1 deletion contracts/v2/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
uint256 newTotalSupply
);
event RewardCollected(
bytes32 indexed agreementId,
uint72 indexed identityId,
bytes nodeId,
address serviceAgreementAddress,
Expand Down Expand Up @@ -225,7 +226,14 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
else sasAddress = sasProxy.agreementV1U1StorageAddress();

emit StakeIncreased(identityId, ps.getNodeId(identityId), sasAddress, oldStake, oldStake + delegatorsReward);
emit RewardCollected(identityId, ps.getNodeId(identityId), sasAddress, operatorFee, delegatorsReward);
emit RewardCollected(
agreementId,
identityId,
ps.getNodeId(identityId),
sasAddress,
operatorFee,
delegatorsReward
);
}

// solhint-disable-next-line no-empty-blocks
Expand Down
4 changes: 2 additions & 2 deletions test/v1/unit/ProofManagerV1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ describe('@v1 @unit ProofManagerV1 contract', function () {
expect(await ProofManagerV1.name()).to.equal('ProofManagerV1');
});

it('The contract is version "1.0.2"', async () => {
expect(await ProofManagerV1.version()).to.equal('1.0.2');
it('The contract is version "1.0.3"', async () => {
expect(await ProofManagerV1.version()).to.equal('1.0.3');
});

it('Create a new asset, teleport to the proof phase and check if window is open, expect true', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/v1/unit/ProofManagerV1U1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ describe('@v1 @unit ProofManagerV1U1 contract', function () {
expect(await ProofManagerV1U1.name()).to.equal('ProofManagerV1U1');
});

it('The contract is version "1.0.2"', async () => {
expect(await ProofManagerV1U1.version()).to.equal('1.0.2');
it('The contract is version "1.0.3"', async () => {
expect(await ProofManagerV1U1.version()).to.equal('1.0.3');
});

it('Create a new asset, update and finalize update, teleport to the proof phase and check if window is open, expect true', async () => {
Expand Down
Loading