Skip to content

Commit

Permalink
contracts: OpenSTValue.processStaking. Addresses #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbollen committed Nov 24, 2017
1 parent 53fb298 commit 5d7fdf9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
7 changes: 4 additions & 3 deletions contracts/OpenSTUtility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ contract OpenSTUtility is Hasher, OpsManaged {
bytes32 _uuid, string _symbol, string _name, uint256 _conversionRate, address _requester);
event StakingIntentConfirmed(bytes32 indexed _uuid, bytes32 indexed _stakingIntentHash,
address _staker, address _beneficiary, uint256 _amountST, uint256 _amountUT, uint256 unlockHeight);
event ProcessedMint(bytes32 indexed _uuid, bytes32 indexed _stakingIntentHash, address _staker,
address _beneficiary, uint256 _amount);
event ProcessedMint(bytes32 indexed _uuid, bytes32 indexed _stakingIntentHash, address _token,
address _staker, address _beneficiary, uint256 _amount);

/*
* Constants
Expand Down Expand Up @@ -369,7 +369,8 @@ contract OpenSTUtility is Hasher, OpsManaged {

require(token.mint(mint.beneficiary, mint.amount));

ProcessedMint(mint.uuid, _stakingIntentHash, mint.staker, mint.beneficiary, mint.amount);
ProcessedMint(mint.uuid, _stakingIntentHash, tokenAddress, mint.staker,
mint.beneficiary, mint.amount);

delete mints[_stakingIntentHash];

Expand Down
34 changes: 32 additions & 2 deletions contracts/OpenSTValue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ contract OpenSTValue is OpsManaged, Hasher {
event StakingIntentDeclared(bytes32 indexed _uuid, address indexed _staker,
uint256 _stakerNonce, address _beneficiary, uint256 _amountST,
uint256 _amountUT, uint256 _escrowUnlockHeight, bytes32 _stakingIntentHash);
event ProcessedStake(bytes32 indexed _uuid, bytes32 indexed _stakingIntentHash,
address _stake, address _staker, uint256 _amountST, uint256 _amountUT);

/*
* Constants
Expand All @@ -64,7 +66,7 @@ contract OpenSTValue is OpsManaged, Hasher {
uint256 conversionRate;
uint8 decimals;
uint256 chainIdUtility;
address simpleStake;
SimpleStake simpleStake;
address stakingAccount;
}

Expand Down Expand Up @@ -200,6 +202,34 @@ contract OpenSTValue is OpsManaged, Hasher {
return (amountUT, nonce, unlockHeight, stakingIntentHash);
}

function processStaking(
bytes32 _stakingIntentHash)
external
returns (address stakeAddress)
{
require(_stakingIntentHash != "");

Stake storage stake = stakes[_stakingIntentHash];
require(stake.staker == msg.sender);
// as this bears the cost, there is no need to require
// that the stake.unlockHeight is not yet surpassed
// as is required on processMinting

UtilityToken storage utilityToken = utilityTokens[stake.uuid];
stakeAddress = address(utilityToken.simpleStake);
require(stakeAddress != address(0));

assert(valueToken.balanceOf(address(this)) > stake.amountST);
require(valueToken.transfer(stakeAddress, stake.amountST));

ProcessedStake(stake.uuid, _stakingIntentHash, stakeAddress, stake.staker,
stake.amountST, stake.amountUT);

delete stakes[_stakingIntentHash];

return stakeAddress;
}


/*
* Registrar functions
Expand Down Expand Up @@ -261,7 +291,7 @@ contract OpenSTValue is OpsManaged, Hasher {
conversionRate: _conversionRate,
decimals: TOKEN_DECIMALS,
chainIdUtility: _chainIdUtility,
simpleStake: address(simpleStake),
simpleStake: simpleStake,
stakingAccount: _stakingAccount
});

Expand Down
1 change: 0 additions & 1 deletion contracts/STPrime.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ contract STPrime is UtilityTokenAbstract, STPrimeConfig {
initialized = true;
}


/// @dev transfer full claim to beneficiary
/// claim can be called publicly as the beneficiary
/// and amount are set, and this allows for reduced
Expand Down

0 comments on commit 5d7fdf9

Please sign in to comment.