Some renaming pool -> staking pool for readability

This commit is contained in:
Greg Hysen 2019-06-27 17:11:51 -07:00
parent eb1c48674a
commit 44c44a2b9c
12 changed files with 124 additions and 124 deletions

View File

@ -63,7 +63,7 @@ contract MixinExchangeFees is
onlyExchange
{
uint256 amount = msg.value;
bytes32 poolId = getPoolIdOfMaker(makerAddress);
bytes32 poolId = getStakingPoolIdOfMaker(makerAddress);
uint256 _feesCollectedThisEpoch = protocolFeesThisEpochByPool[poolId];
protocolFeesThisEpochByPool[poolId] = _feesCollectedThisEpoch._add(amount);
if (_feesCollectedThisEpoch == 0) {
@ -169,7 +169,7 @@ contract MixinExchangeFees is
// compute weighted stake
uint256 stakeDelegatedToPool = getStakeDelegatedToPool(poolId);
uint256 stakeHeldByPoolOperator = getActivatedAndUndelegatedStake(getPoolOperator(poolId));
uint256 stakeHeldByPoolOperator = getActivatedAndUndelegatedStake(getStakingPoolOperator(poolId));
uint256 weightedStake = stakeHeldByPoolOperator._add(
stakeDelegatedToPool
._mul(REWARD_PAYOUT_DELEGATED_STAKE_PERCENT_VALUE)

View File

@ -66,7 +66,7 @@ contract MixinStakingPool is
/// @param poolId Pool sender must be operator of.
modifier onlyStakingPoolOperator(bytes32 poolId) {
require(
msg.sender == getPoolOperator(poolId),
msg.sender == getStakingPoolOperator(poolId),
"ONLY_CALLABLE_BY_POOL_OPERATOR"
);
@ -78,7 +78,7 @@ contract MixinStakingPool is
/// @param makerAddress Address of a maker in the pool.
modifier onlyStakingPoolOperatorOrMaker(bytes32 poolId, address makerAddress) {
require(
msg.sender == getPoolOperator(poolId) || msg.sender == makerAddress,
msg.sender == getStakingPoolOperator(poolId) || msg.sender == makerAddress,
"ONLY_CALLABLE_BY_POOL_OPERATOR_OR_MAKER"
);
@ -89,7 +89,7 @@ contract MixinStakingPool is
/// Note that an operator must be payable.
/// @param operatorShare The percentage of any rewards owned by the operator.
/// @return poolId The unique pool id generated for this pool.
function createPool(uint8 operatorShare)
function createStakingPool(uint8 operatorShare)
external
returns (bytes32 poolId)
{
@ -98,7 +98,7 @@ contract MixinStakingPool is
// assign pool id and generate next id
poolId = nextPoolId;
nextPoolId = _computeNextPoolId(poolId);
nextPoolId = _computeNextStakingPoolId(poolId);
// store metadata about this pool
IStructs.Pool memory pool = IStructs.Pool({
@ -108,7 +108,7 @@ contract MixinStakingPool is
poolById[poolId] = pool;
// register pool in reward vault
_createPoolInStakingPoolRewardVault(poolId, operatorShare);
_createStakingPoolInStakingPoolRewardVault(poolId, operatorShare);
// notify
emit StakingPoolCreated(poolId, operatorAddress, operatorShare);
@ -119,7 +119,7 @@ contract MixinStakingPool is
/// @param poolId Unique id of pool.
/// @param makerAddress Address of maker.
/// @param makerSignature Signature proving that maker has agreed to join the pool.
function addMakerToPool(
function addMakerToStakingPool(
bytes32 poolId,
address makerAddress,
bytes calldata makerSignature
@ -133,7 +133,7 @@ contract MixinStakingPool is
"INVALID_MAKER_SIGNATURE"
);
require(
!isMakerAssignedToPool(makerAddress),
!isMakerAssignedToStakingPool(makerAddress),
"MAKER_ADDRESS_ALREADY_REGISTERED"
);
poolIdByMakerAddress[makerAddress] = poolId;
@ -151,7 +151,7 @@ contract MixinStakingPool is
/// at the sole discretion of the pool operator.
/// @param poolId Unique id of pool.
/// @param makerAddress Address of maker.
function removeMakerFromPool(
function removeMakerFromStakingPool(
bytes32 poolId,
address makerAddress
)
@ -159,7 +159,7 @@ contract MixinStakingPool is
external
{
require(
getPoolIdOfMaker(makerAddress) == poolId,
getStakingPoolIdOfMaker(makerAddress) == poolId,
"MAKER_ADDRESS_NOT_REGISTERED"
);
@ -234,7 +234,7 @@ contract MixinStakingPool is
}
/// @dev Returns the pool id of an input maker.
function getPoolIdOfMaker(address makerAddress)
function getStakingPoolIdOfMaker(address makerAddress)
public
view
returns (bytes32)
@ -245,18 +245,18 @@ contract MixinStakingPool is
/// @dev Returns true iff the maker is assigned to a staking pool.
/// @param makerAddress Address of maker
/// @return True iff assigned.
function isMakerAssignedToPool(address makerAddress)
function isMakerAssignedToStakingPool(address makerAddress)
public
view
returns (bool)
{
return getPoolIdOfMaker(makerAddress) != NIL_MAKER_ID;
return getStakingPoolIdOfMaker(makerAddress) != NIL_MAKER_ID;
}
/// @dev Returns the makers for a given pool.
/// @param poolId Unique id of pool.
/// @return _makerAddressesByPoolId Makers for pool.
function getMakersForPool(bytes32 poolId)
function getMakersForStakingPool(bytes32 poolId)
public
view
returns (address[] memory _makerAddressesByPoolId)
@ -276,7 +276,7 @@ contract MixinStakingPool is
/// @dev Returns the unique id that will be assigned to the next pool that is created.
/// @return Pool id.
function getNextPoolId()
function getNextStakingPoolId()
public
view
returns (bytes32)
@ -287,7 +287,7 @@ contract MixinStakingPool is
/// @dev Returns the pool operator
/// @param poolId Unique id of pool
/// @return operatorAddress Operator of the pool
function getPoolOperator(bytes32 poolId)
function getStakingPoolOperator(bytes32 poolId)
public
view
returns (address operatorAddress)
@ -298,7 +298,7 @@ contract MixinStakingPool is
/// @dev Convenience function for loading information on a pool.
/// @param poolId Unique id of pool.
/// @return pool Pool info.
function _getPool(bytes32 poolId)
function _getStakingPool(bytes32 poolId)
internal
view
returns (IStructs.Pool memory pool)
@ -310,7 +310,7 @@ contract MixinStakingPool is
/// @dev Computes the unique id that comes after the input pool id.
/// @param poolId Unique id of pool.
/// @return Next pool id after input pool.
function _computeNextPoolId(bytes32 poolId)
function _computeNextStakingPoolId(bytes32 poolId)
internal
pure
returns (bytes32)

View File

@ -65,10 +65,10 @@ contract MixinStakingPoolRewardVault is
return rewardVault.balanceOfPool(poolId);
}
function _createPoolInStakingPoolRewardVault(bytes32 poolId, uint8 operatorShare)
function _registerStakingPoolInRewardVault(bytes32 poolId, uint8 operatorShare)
internal
{
rewardVault.createPool(
rewardVault.createStakingPool(
poolId,
operatorShare
);

View File

@ -53,13 +53,13 @@ contract MixinStakingPoolRewards is
/// -- Member Balances --
/// Terminology:
/// Real Balance - The reward balance in ETH of a member.
/// Cumulative Real Balance - The sum total of reward balances in ETH across all members of a pool.
/// Total Real Balance - The sum total of reward balances in ETH across all members of a pool.
/// Shadow Balance - The realized reward balance of a member.
/// Cumulative Shadow Balance - The sum total of realized reward balances across all members of a pool.
/// Total Shadow Balance - The sum total of realized reward balances across all members of a pool.
/// How it works:
/// 1. When a member delegates, their ownership of the pool increases; however, this new ownership applies
/// only to future rewards and must not change the rewards currently owned by other members. Thus, when a
/// member delegates stake, we *increase* their Shadow Balance and the Cumulative Shadow Balance of the pool.
/// member delegates stake, we *increase* their Shadow Balance and the Total Shadow Balance of the pool.
///
/// 2. When a member withdraws a portion of their reward, their realized balance increases but their ownership
/// within the pool remains unchanged. Thus, we simultaneously *decrease* their Real Balance and
@ -67,11 +67,47 @@ contract MixinStakingPoolRewards is
///
/// 3. When a member undelegates, the portion of their reward that corresponds to that stake is also withdrawn. Thus,
/// their realized balance *increases* while their ownership of the pool *decreases*. To reflect this, we
/// decrease their Shadow Balance, the Cumulative Shadow Balance, their Real Balance, and the Cumulative Real Balance.
/// decrease their Shadow Balance, the Total Shadow Balance, their Real Balance, and the Total Real Balance.
function getRewardBalance(bytes32 poolId)
external
view
returns (uint256)
{
return getBalanceInStakingPoolRewardVault(poolId);
}
function getRewardBalanceOfOperator(bytes32 poolId)
external
view
returns (uint256)
{
return getBalanceOfOperatorInStakingPoolRewardVault(poolId);
}
function getRewardBalanceOfPool(bytes32 poolId)
external
view
returns (uint256)
{
return getBalanceOfPoolInStakingPoolRewardVault(poolId);
}
function computeRewardBalance(bytes32 poolId, address owner)
public
view
returns (uint256)
{
uint256 poolBalance = getBalanceOfPoolInStakingPoolRewardVault(poolId);
return LibRewardMath._computePayoutDenominatedInRealAsset(
delegatedStakeToPoolByOwner[owner][poolId],
delegatedStakeByPoolId[poolId],
shadowRewardsInPoolByOwner[owner][poolId],
shadowRewardsByPoolId[poolId],
poolBalance
);
}
function withdrawOperatorReward(bytes32 poolId, uint256 amount)
external
@ -126,44 +162,8 @@ contract MixinStakingPoolRewards is
return amount;
}
function getRewardBalance(bytes32 poolId)
external
view
returns (uint256)
{
return getBalanceInStakingPoolRewardVault(poolId);
}
function getRewardBalanceOfOperator(bytes32 poolId)
external
view
returns (uint256)
{
return getBalanceOfOperatorInStakingPoolRewardVault(poolId);
}
function getRewardBalanceOfPool(bytes32 poolId)
external
view
returns (uint256)
{
return getBalanceOfPoolInStakingPoolRewardVault(poolId);
}
function computeRewardBalance(bytes32 poolId, address owner)
public
view
returns (uint256)
{
uint256 poolBalance = getBalanceOfPoolInStakingPoolRewardVault(poolId);
return LibRewardMath._computePayoutDenominatedInRealAsset(
delegatedStakeToPoolByOwner[owner][poolId],
delegatedStakeByPoolId[poolId],
shadowRewardsInPoolByOwner[owner][poolId],
shadowRewardsByPoolId[poolId],
poolBalance
);
}
function getShadowBalanceByPoolId(bytes32 poolId)
public

View File

@ -42,7 +42,7 @@ interface IStakingPoolRewardVault {
function withdrawFromPool(bytes32 poolId, uint256 amount)
external;
function createPool(bytes32 poolId, uint8 poolOperatorShare)
function createStakingPool(bytes32 poolId, uint8 poolOperatorShare)
external;
function balanceOf(bytes32 poolId)

View File

@ -109,7 +109,7 @@ contract StakingPoolRewardVault is
stakingContractAddress.transfer(amount);
}
function createPool(bytes32 poolId, uint8 poolOperatorShare)
function createStakingPool(bytes32 poolId, uint8 poolOperatorShare)
external
onlyStakingContract
onlyNotInCatostrophicFailure

View File

@ -17,11 +17,11 @@ export class PoolOperatorActor extends BaseActor {
super(owner, stakingWrapper);
}
public async createPoolAsync(operatorShare: number, revertReason?: RevertReason): Promise<string> {
public async createStakingPoolAsync(operatorShare: number, revertReason?: RevertReason): Promise<string> {
// query next pool id
const nextPoolId = await this._stakingWrapper.getNextPoolIdAsync();
const nextPoolId = await this._stakingWrapper.getNextStakingPoolIdAsync();
// create pool
const poolIdPromise = this._stakingWrapper.createPoolAsync(this._owner, operatorShare);
const poolIdPromise = this._stakingWrapper.createStakingPoolAsync(this._owner, operatorShare);
if (revertReason !== undefined) {
await expectTransactionFailedAsync(poolIdPromise, revertReason);
return '';
@ -31,14 +31,14 @@ export class PoolOperatorActor extends BaseActor {
expect(poolId, 'pool id').to.be.bignumber.equal(nextPoolId);
return poolId;
}
public async addMakerToPoolAsync(
public async addMakerToStakingPoolAsync(
poolId: string,
makerAddress: string,
makerSignature: string,
revertReason?: RevertReason,
): Promise<void> {
// add maker
const txReceiptPromise = this._stakingWrapper.addMakerToPoolAsync(
const txReceiptPromise = this._stakingWrapper.addMakerToStakingPoolAsync(
poolId,
makerAddress,
makerSignature,
@ -50,29 +50,29 @@ export class PoolOperatorActor extends BaseActor {
}
await txReceiptPromise;
// check the pool id of the maker
const poolIdOfMaker = await this._stakingWrapper.getPoolIdOfMakerAsync(makerAddress);
const poolIdOfMaker = await this._stakingWrapper.getStakingPoolIdOfMakerAsync(makerAddress);
expect(poolIdOfMaker, 'pool id of maker').to.be.equal(poolId);
// check the list of makers for the pool
const makerAddressesForPool = await this._stakingWrapper.getMakersForPoolAsync(poolId);
const makerAddressesForPool = await this._stakingWrapper.getMakersForStakingPoolAsync(poolId);
expect(makerAddressesForPool, 'maker addresses for pool').to.include(makerAddress);
}
public async removeMakerFromPoolAsync(
public async removeMakerFromStakingPoolAsync(
poolId: string,
makerAddress: string,
revertReason?: RevertReason,
): Promise<void> {
// remove maker
const txReceiptPromise = this._stakingWrapper.removeMakerFromPoolAsync(poolId, makerAddress, this._owner);
const txReceiptPromise = this._stakingWrapper.removeMakerFromStakingPoolAsync(poolId, makerAddress, this._owner);
if (revertReason !== undefined) {
await expectTransactionFailedAsync(txReceiptPromise, revertReason);
return;
}
await txReceiptPromise;
// check the pool id of the maker
const poolIdOfMakerAfterRemoving = await this._stakingWrapper.getPoolIdOfMakerAsync(makerAddress);
const poolIdOfMakerAfterRemoving = await this._stakingWrapper.getStakingPoolIdOfMakerAsync(makerAddress);
expect(poolIdOfMakerAfterRemoving, 'pool id of maker').to.be.equal(stakingConstants.NIL_POOL_ID);
// check the list of makers for the pool
const makerAddressesForPoolAfterRemoving = await this._stakingWrapper.getMakersForPoolAsync(poolId);
const makerAddressesForPoolAfterRemoving = await this._stakingWrapper.getMakersForStakingPoolAsync(poolId);
expect(makerAddressesForPoolAfterRemoving, 'maker addresses for pool').to.not.include(makerAddress);
}
}

View File

@ -69,11 +69,11 @@ describe('Staking Pool Management', () => {
const operatorShare = 39;
const poolOperator = new PoolOperatorActor(operatorAddress, stakingWrapper);
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// check that the next pool id was incremented
const expectedNextPoolId = '0x0000000000000000000000000000000200000000000000000000000000000000';
const nextPoolId = await stakingWrapper.getNextPoolIdAsync();
const nextPoolId = await stakingWrapper.getNextStakingPoolIdAsync();
expect(nextPoolId).to.be.equal(expectedNextPoolId);
});
it('Should successfully add/remove a maker to a pool', async () => {
@ -84,13 +84,13 @@ describe('Staking Pool Management', () => {
const makerAddress = users[1];
const maker = new MakerActor(makerAddress, stakingWrapper);
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add maker to pool
const makerApproval = maker.signApprovalForStakingPool(poolId);
await poolOperator.addMakerToPoolAsync(poolId, makerAddress, makerApproval.signature);
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature);
// remove maker from pool
await poolOperator.removeMakerFromPoolAsync(poolId, makerAddress);
await poolOperator.removeMakerFromStakingPoolAsync(poolId, makerAddress);
});
it('Should successfully add/remove multipler makers to the same pool', async () => {
// test parameters
@ -104,7 +104,7 @@ describe('Staking Pool Management', () => {
new MakerActor(makerAddresses[2], stakingWrapper),
];
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add makers to pool
const makerApprovals = [
@ -112,13 +112,13 @@ describe('Staking Pool Management', () => {
makers[1].signApprovalForStakingPool(poolId),
makers[2].signApprovalForStakingPool(poolId),
];
await poolOperator.addMakerToPoolAsync(poolId, makerAddresses[0], makerApprovals[0].signature);
await poolOperator.addMakerToPoolAsync(poolId, makerAddresses[1], makerApprovals[1].signature);
await poolOperator.addMakerToPoolAsync(poolId, makerAddresses[2], makerApprovals[2].signature);
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddresses[0], makerApprovals[0].signature);
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddresses[1], makerApprovals[1].signature);
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddresses[2], makerApprovals[2].signature);
// remove maker from pool
await poolOperator.removeMakerFromPoolAsync(poolId, makerAddresses[0]);
await poolOperator.removeMakerFromPoolAsync(poolId, makerAddresses[1]);
await poolOperator.removeMakerFromPoolAsync(poolId, makerAddresses[2]);
await poolOperator.removeMakerFromStakingPoolAsync(poolId, makerAddresses[0]);
await poolOperator.removeMakerFromStakingPoolAsync(poolId, makerAddresses[1]);
await poolOperator.removeMakerFromStakingPoolAsync(poolId, makerAddresses[2]);
});
it('Should fail to add the same maker twice', async () => {
// test parameters
@ -128,13 +128,13 @@ describe('Staking Pool Management', () => {
const makerAddress = users[1];
const maker = new MakerActor(makerAddress, stakingWrapper);
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add maker to pool
const makerApproval = maker.signApprovalForStakingPool(poolId);
await poolOperator.addMakerToPoolAsync(poolId, makerAddress, makerApproval.signature);
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature);
// add same maker to pool again
await poolOperator.addMakerToPoolAsync(
await poolOperator.addMakerToStakingPoolAsync(
poolId,
makerAddress,
makerApproval.signature,
@ -148,10 +148,10 @@ describe('Staking Pool Management', () => {
const poolOperator = new PoolOperatorActor(operatorAddress, stakingWrapper);
const makerAddress = users[1];
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// remove non-existent maker from pool
await poolOperator.removeMakerFromPoolAsync(poolId, makerAddress, RevertReason.MakerAddressNotRegistered);
await poolOperator.removeMakerFromStakingPoolAsync(poolId, makerAddress, RevertReason.MakerAddressNotRegistered);
});
it('Should fail to add a maker who signed with the wrong private key', async () => {
// test parameters
@ -164,11 +164,11 @@ describe('Staking Pool Management', () => {
);
const maker = new MakerActor(makerAddress, stakingWrapper, badMakerPrivateKey);
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add maker to pool
const makerApproval = maker.signApprovalForStakingPool(poolId);
await poolOperator.addMakerToPoolAsync(
await poolOperator.addMakerToStakingPoolAsync(
poolId,
makerAddress,
makerApproval.signature,
@ -185,11 +185,11 @@ describe('Staking Pool Management', () => {
const notStakingContractAddress = users[2];
const maker = new MakerActor(makerAddress, stakingWrapper, forceMakerKeyLookup, notStakingContractAddress);
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add maker to pool
const makerApproval = maker.signApprovalForStakingPool(poolId);
await poolOperator.addMakerToPoolAsync(
await poolOperator.addMakerToStakingPoolAsync(
poolId,
makerAddress,
makerApproval.signature,
@ -213,11 +213,11 @@ describe('Staking Pool Management', () => {
badChainId,
);
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add maker to pool
const makerApproval = maker.signApprovalForStakingPool(poolId);
await poolOperator.addMakerToPoolAsync(
await poolOperator.addMakerToStakingPoolAsync(
poolId,
makerAddress,
makerApproval.signature,
@ -233,12 +233,12 @@ describe('Staking Pool Management', () => {
const maker = new MakerActor(makerAddress, stakingWrapper);
const notOperatorAddress = users[2];
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add maker to pool
const makerApproval = maker.signApprovalForStakingPool(poolId);
await expectTransactionFailedAsync(
stakingWrapper.addMakerToPoolAsync(poolId, makerAddress, makerApproval.signature, notOperatorAddress),
stakingWrapper.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature, notOperatorAddress),
RevertReason.OnlyCallableByPoolOperator,
);
});
@ -251,14 +251,14 @@ describe('Staking Pool Management', () => {
const maker = new MakerActor(makerAddress, stakingWrapper);
const notOperatorAddress = users[2];
// create pool
const poolId = await poolOperator.createPoolAsync(operatorShare);
const poolId = await poolOperator.createStakingPoolAsync(operatorShare);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// add maker to pool
const makerApproval = maker.signApprovalForStakingPool(poolId);
await poolOperator.addMakerToPoolAsync(poolId, makerAddress, makerApproval.signature);
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature);
// try to remove the maker address from an address other than the operator
await expectTransactionFailedAsync(
stakingWrapper.removeMakerFromPoolAsync(poolId, makerAddress, notOperatorAddress),
stakingWrapper.removeMakerFromStakingPoolAsync(poolId, makerAddress, notOperatorAddress),
RevertReason.OnlyCallableByPoolOperatorOrMaker,
);
});

View File

@ -92,7 +92,7 @@ describe('Staking & Delegating', () => {
const amountToWithdraw = StakingWrapper.toBaseUnitAmount(1.5);
const poolOperator = stakers[1];
const operatorShare = 39;
const poolId = await stakingWrapper.createPoolAsync(poolOperator, operatorShare);
const poolId = await stakingWrapper.createStakingPoolAsync(poolOperator, operatorShare);
// run test
const delegator = new DelegatorActor(stakers[0], stakingWrapper);
await delegator.depositAndDelegateAsync(poolId, amountToDelegate);

View File

@ -124,7 +124,7 @@ export class Simulation {
const poolOperator = new PoolOperatorActor(poolOperatorAddress, this._stakingWrapper);
this._poolOperators.push(poolOperator);
// create a pool id for this operator
const poolId = await poolOperator.createPoolAsync(p.poolOperatorShares[i]);
const poolId = await poolOperator.createStakingPoolAsync(p.poolOperatorShares[i]);
this._poolIds.push(poolId);
// each pool operator can also be a staker/delegator
const poolOperatorAsDelegator = new DelegatorActor(poolOperatorAddress, this._stakingWrapper);
@ -154,7 +154,7 @@ export class Simulation {
const maker = this._makers[makerIdx];
const makerApproval = maker.signApprovalForStakingPool(poolId);
const makerAddress = maker.getOwner();
await poolOperator.addMakerToPoolAsync(poolId, makerAddress, makerApproval.signature);
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature);
makerIdx += 1;
}
poolIdx += 1;

View File

@ -311,25 +311,25 @@ export class StakingWrapper {
return value;
}
///// POOLS /////
public async getNextPoolIdAsync(): Promise<string> {
const calldata = this.getStakingContract().getNextPoolId.getABIEncodedTransactionData();
public async getNextStakingPoolIdAsync(): Promise<string> {
const calldata = this.getStakingContract().getNextStakingPoolId.getABIEncodedTransactionData();
const nextPoolId = await this._callAsync(calldata);
return nextPoolId;
}
public async createPoolAsync(operatorAddress: string, operatorShare: number): Promise<string> {
const calldata = this.getStakingContract().createPool.getABIEncodedTransactionData(operatorShare);
public async createStakingPoolAsync(operatorAddress: string, operatorShare: number): Promise<string> {
const calldata = this.getStakingContract().createStakingPool.getABIEncodedTransactionData(operatorShare);
const txReceipt = await this._executeTransactionAsync(calldata, operatorAddress);
const createPoolLog = this._logDecoder.decodeLogOrThrow(txReceipt.logs[0]);
const poolId = (createPoolLog as any).args.poolId;
const createStakingPoolLog = this._logDecoder.decodeLogOrThrow(txReceipt.logs[0]);
const poolId = (createStakingPoolLog as any).args.poolId;
return poolId;
}
public async addMakerToPoolAsync(
public async addMakerToStakingPoolAsync(
poolId: string,
makerAddress: string,
makerSignature: string,
operatorAddress: string,
): Promise<TransactionReceiptWithDecodedLogs> {
const calldata = this.getStakingContract().addMakerToPool.getABIEncodedTransactionData(
const calldata = this.getStakingContract().addMakerToStakingPool.getABIEncodedTransactionData(
poolId,
makerAddress,
makerSignature,
@ -337,27 +337,27 @@ export class StakingWrapper {
const txReceipt = await this._executeTransactionAsync(calldata, operatorAddress);
return txReceipt;
}
public async removeMakerFromPoolAsync(
public async removeMakerFromStakingPoolAsync(
poolId: string,
makerAddress: string,
operatorAddress: string,
): Promise<TransactionReceiptWithDecodedLogs> {
const calldata = this.getStakingContract().removeMakerFromPool.getABIEncodedTransactionData(
const calldata = this.getStakingContract().removeMakerFromStakingPool.getABIEncodedTransactionData(
poolId,
makerAddress,
);
const txReceipt = await this._executeTransactionAsync(calldata, operatorAddress);
return txReceipt;
}
public async getPoolIdOfMakerAsync(makerAddress: string): Promise<string> {
const calldata = this.getStakingContract().getPoolIdOfMaker.getABIEncodedTransactionData(makerAddress);
public async getStakingPoolIdOfMakerAsync(makerAddress: string): Promise<string> {
const calldata = this.getStakingContract().getStakingPoolIdOfMaker.getABIEncodedTransactionData(makerAddress);
const poolId = await this._callAsync(calldata);
return poolId;
}
public async getMakersForPoolAsync(poolId: string): Promise<string[]> {
const calldata = this.getStakingContract().getMakersForPool.getABIEncodedTransactionData(poolId);
public async getMakersForStakingPoolAsync(poolId: string): Promise<string[]> {
const calldata = this.getStakingContract().getMakersForStakingPool.getABIEncodedTransactionData(poolId);
const returndata = await this._callAsync(calldata);
const makerAddresses = this.getStakingContract().getMakersForPool.getABIDecodedReturnData(returndata);
const makerAddresses = this.getStakingContract().getMakersForStakingPool.getABIDecodedReturnData(returndata);
return makerAddresses;
}
public async isValidMakerSignatureAsync(
@ -629,7 +629,7 @@ export class StakingWrapper {
poolOperatorShare: number,
stakingContractAddress: string,
): Promise<TransactionReceiptWithDecodedLogs> {
const calldata = this.getStakingPoolRewardVaultContract().createPool.getABIEncodedTransactionData(
const calldata = this.getStakingPoolRewardVaultContract().createStakingPool.getABIEncodedTransactionData(
poolId,
poolOperatorShare,
);

View File

@ -61,7 +61,7 @@ describe('Staking Vaults', () => {
// 1 setup test parameters
const poolOperator = users[0];
const operatorShare = 39;
const poolId = await stakingWrapper.createPoolAsync(poolOperator, operatorShare);
const poolId = await stakingWrapper.createStakingPoolAsync(poolOperator, operatorShare);
const stakingContractAddress = stakingWrapper.getStakingContract().address;
const notStakingContractAddress = poolOperator;
// create pool in vault