diff --git a/contracts/OpenSTUtility.sol b/contracts/OpenSTUtility.sol index b6cb7dce..1a205452 100644 --- a/contracts/OpenSTUtility.sol +++ b/contracts/OpenSTUtility.sol @@ -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 @@ -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]; diff --git a/contracts/OpenSTValue.sol b/contracts/OpenSTValue.sol index 7b43757c..5c4a9dfe 100644 --- a/contracts/OpenSTValue.sol +++ b/contracts/OpenSTValue.sol @@ -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 @@ -64,7 +66,7 @@ contract OpenSTValue is OpsManaged, Hasher { uint256 conversionRate; uint8 decimals; uint256 chainIdUtility; - address simpleStake; + SimpleStake simpleStake; address stakingAccount; } @@ -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 @@ -261,7 +291,7 @@ contract OpenSTValue is OpsManaged, Hasher { conversionRate: _conversionRate, decimals: TOKEN_DECIMALS, chainIdUtility: _chainIdUtility, - simpleStake: address(simpleStake), + simpleStake: simpleStake, stakingAccount: _stakingAccount }); diff --git a/contracts/STPrime.sol b/contracts/STPrime.sol index 216c6788..131e294d 100644 --- a/contracts/STPrime.sol +++ b/contracts/STPrime.sol @@ -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