-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
2,201 additions
and
33 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
abi-bindings/go/staking/ERC20TokenStakingManager/ERC20TokenStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
35 changes: 33 additions & 2 deletions
35
abi-bindings/go/staking/NativeTokenStakingManager/NativeTokenStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
2,091 changes: 2,091 additions & 0 deletions
2,091
abi-bindings/go/staking/NativeTokenStakingManager/NativeTokenStakingManager.go.orig
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
pragma solidity 0.8.25; | ||
|
||
import {INativeTokenStakingManager} from "./interfaces/INativeTokenStakingManager.sol"; | ||
import {INativeMinter} from | ||
"@avalabs/[email protected]/contracts/interfaces/INativeMinter.sol"; | ||
import {Address} from "@openzeppelin/[email protected]/utils/Address.sol"; | ||
import {Initializable} from | ||
"@openzeppelin/[email protected]/proxy/utils/Initializable.sol"; | ||
|
@@ -20,6 +22,9 @@ contract NativeTokenStakingManager is | |
{ | ||
using Address for address payable; | ||
|
||
INativeMinter public constant NATIVE_MINTER = | ||
INativeMinter(0x0200000000000000000000000000000000000001); | ||
|
||
constructor(ICMInitializable init) { | ||
if (init == ICMInitializable.Disallowed) { | ||
_disableInitializers(); | ||
|
@@ -85,6 +90,6 @@ contract NativeTokenStakingManager is | |
|
||
// solhint-disable-next-line no-empty-blocks | ||
function _reward(address account, uint256 amount) internal virtual override { | ||
// TODO: call the native minter precompile to mint `amount` for `account` | ||
NATIVE_MINTER.mintNativeCoin(account, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,10 @@ import {PoSValidatorManagerTest} from "./PoSValidatorManagerTests.t.sol"; | |
import {NativeTokenStakingManager} from "../NativeTokenStakingManager.sol"; | ||
import {ValidatorManagerSettings} from "../interfaces/IValidatorManager.sol"; | ||
import {PoSValidatorManagerSettings} from "../interfaces/IPoSValidatorManager.sol"; | ||
import {IRewardCalculator} from "../interfaces/IRewardCalculator.sol"; | ||
import {ExampleRewardCalculator} from "../ExampleRewardCalculator.sol"; | ||
import {ICMInitializable} from "../../utilities/ICMInitializable.sol"; | ||
import {INativeMinter} from | ||
"@avalabs/[email protected]/contracts/interfaces/INativeMinter.sol"; | ||
|
||
// TODO: Remove this once all unit tests implemented | ||
// solhint-disable no-empty-blocks | ||
|
@@ -21,6 +22,7 @@ contract NativeTokenStakingManagerTest is PoSValidatorManagerTest { | |
function setUp() public virtual { | ||
// Construct the object under test | ||
app = new NativeTokenStakingManager(ICMInitializable.Allowed); | ||
rewardCalculator = new ExampleRewardCalculator(DEFAULT_REWARD_RATE); | ||
app.initialize( | ||
PoSValidatorManagerSettings({ | ||
baseSettings: ValidatorManagerSettings({ | ||
|
@@ -31,25 +33,13 @@ contract NativeTokenStakingManagerTest is PoSValidatorManagerTest { | |
minimumStakeAmount: DEFAULT_MINIMUM_STAKE, | ||
maximumStakeAmount: DEFAULT_MAXIMUM_STAKE, | ||
minimumStakeDuration: DEFAULT_MINIMUM_STAKE_DURATION, | ||
rewardCalculator: IRewardCalculator(new ExampleRewardCalculator(DEFAULT_REWARD_RATE)) | ||
rewardCalculator: rewardCalculator | ||
}) | ||
); | ||
validatorManager = app; | ||
posValidatorManager = app; | ||
} | ||
|
||
function testCompleteEndValidation() public override { | ||
// TODO: get native token staking rewards working, then remove this | ||
// method and let the implementation in PosValidatorManagerTests do the | ||
// test, and remove the `virtual` modifier from that implementation. | ||
} | ||
|
||
function testCompleteEndDelegation() public override { | ||
// TODO: get native token staking rewards working, then remove this | ||
// method and let the implementation in PosValidatorManagerTests do the | ||
// test, and remove the `virtual` modifier from that implementation. | ||
} | ||
|
||
// Helpers | ||
function _initializeValidatorRegistration( | ||
bytes32 nodeID, | ||
|
@@ -82,7 +72,21 @@ contract NativeTokenStakingManagerTest is PoSValidatorManagerTest { | |
vm.expectCall(account, amount, ""); | ||
} | ||
|
||
function _expectRewardIssuance(address account, uint256 amount) internal override {} | ||
function _expectRewardIssuance(address account, uint256 amount) internal override { | ||
vm.mockCall( | ||
address(app.NATIVE_MINTER()), | ||
abi.encodeCall(INativeMinter.mintNativeCoin, (account, amount)), | ||
"" | ||
); | ||
// empty calldata implies the receive function will be called: | ||
vm.mockCall({ | ||
callee: account, | ||
msgValue: amount, | ||
data: "", // implies receive() | ||
returnData: "" | ||
}); | ||
vm.deal(account, account.balance + amount); | ||
} | ||
|
||
function _getStakeAssetBalance(address account) internal view override returns (uint256) { | ||
return account.balance; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters