@@ -999,12 +999,6 @@ struct MSVAULT : public ContractBase
999999 LOG_INFO (locals.logger );
10001000 return ;
10011001 }
1002-
1003- if (qpi.invocationReward () > (sint64)MSVAULT_REVOKE_FEE)
1004- {
1005- qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)MSVAULT_REVOKE_FEE);
1006- }
1007-
10081002 // must transfer a positive number of shares.
10091003 if (input.numberOfShares <= 0 )
10101004 {
@@ -1025,38 +1019,41 @@ struct MSVAULT : public ContractBase
10251019
10261020 if (locals.managedBalance < input.numberOfShares )
10271021 {
1028- // The user is trying to revoke more shares than are managed by MsVault.
1022+ qpi. transfer (qpi. invocator (), qpi. invocationReward ());
10291023 output.transferredNumberOfShares = 0 ;
10301024 output.status = 6 ; // FAILURE_INSUFFICIENT_BALANCE
10311025 locals.logger ._type = (uint32)output.status ;
10321026 LOG_INFO (locals.logger );
1027+ return ;
1028+ }
1029+
1030+ if (qpi.invocationReward () > (sint64)MSVAULT_REVOKE_FEE)
1031+ {
1032+ qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)MSVAULT_REVOKE_FEE);
1033+ }
1034+ // The balance check passed. Proceed to release the management rights.
1035+ locals.result = qpi.releaseShares (
1036+ input.asset ,
1037+ qpi.invocator (), // owner
1038+ qpi.invocator (), // possessor
1039+ input.numberOfShares ,
1040+ QX_CONTRACT_INDEX,
1041+ QX_CONTRACT_INDEX,
1042+ MSVAULT_REVOKE_FEE
1043+ );
1044+
1045+ if (locals.result < 0 )
1046+ {
1047+ output.transferredNumberOfShares = 0 ;
1048+ output.status = 8 ; // FAILURE_TRANSFER_FAILED
10331049 }
10341050 else
10351051 {
1036- // The balance check passed. Proceed to release the management rights.
1037- locals.result = qpi.releaseShares (
1038- input.asset ,
1039- qpi.invocator (), // owner
1040- qpi.invocator (), // possessor
1041- input.numberOfShares ,
1042- QX_CONTRACT_INDEX,
1043- QX_CONTRACT_INDEX,
1044- MSVAULT_REVOKE_FEE
1045- );
1046-
1047- if (locals.result < 0 )
1048- {
1049- output.transferredNumberOfShares = 0 ;
1050- output.status = 8 ; // FAILURE_TRANSFER_FAILED
1051- }
1052- else
1053- {
1054- output.transferredNumberOfShares = input.numberOfShares ;
1055- output.status = 1 ; // SUCCESS
1056- }
1057- locals.logger ._type = (uint32)output.status ;
1058- LOG_INFO (locals.logger );
1052+ output.transferredNumberOfShares = input.numberOfShares ;
1053+ output.status = 1 ; // SUCCESS
10591054 }
1055+ locals.logger ._type = (uint32)output.status ;
1056+ LOG_INFO (locals.logger );
10601057 }
10611058
10621059 PUBLIC_PROCEDURE_WITH_LOCALS (depositAsset)
@@ -1142,9 +1139,6 @@ struct MSVAULT : public ContractBase
11421139 return ;
11431140 }
11441141
1145- // All checks passed, now perform the transfer of ownership.
1146- state.mut ().totalRevenue += state.get ().liveDepositFee ;
1147-
11481142 locals.tempShares = qpi.numberOfShares (
11491143 input.asset ,
11501144 { SELF, SELF_INDEX },
@@ -1160,6 +1154,7 @@ struct MSVAULT : public ContractBase
11601154
11611155 if (locals.transferResult < 0 )
11621156 {
1157+ qpi.transfer (qpi.invocator (), state.get ().liveDepositFee );
11631158 output.status = 8 ; // FAILURE_TRANSFER_FAILED
11641159 locals.logger ._type = (uint32)output.status ;
11651160 LOG_INFO (locals.logger );
@@ -1170,12 +1165,15 @@ struct MSVAULT : public ContractBase
11701165
11711166 if (locals.transferedShares != (sint64)input.amount )
11721167 {
1168+ qpi.transfer (qpi.invocator (), state.get ().liveDepositFee );
11731169 output.status = 8 ; // FAILURE_TRANSFER_FAILED
11741170 locals.logger ._type = (uint32)output.status ;
11751171 LOG_INFO (locals.logger );
11761172 return ;
11771173 }
11781174
1175+ state.mut ().totalRevenue += state.get ().liveDepositFee ;
1176+
11791177 // If the transfer succeeds, update the vault's internal accounting.
11801178 if (locals.assetIndex != -1 )
11811179 {
@@ -1220,13 +1218,6 @@ struct MSVAULT : public ContractBase
12201218 return ;
12211219 }
12221220
1223- if (qpi.invocationReward () > (sint64)state.get ().liveReleaseFee )
1224- {
1225- qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseFee );
1226- }
1227-
1228- state.mut ().totalRevenue += state.get ().liveReleaseFee ;
1229-
12301221 locals.iv_in .vaultId = input.vaultId ;
12311222 isValidVaultId (qpi, state, locals.iv_in , locals.iv_out , locals.iv_locals );
12321223
@@ -1280,6 +1271,13 @@ struct MSVAULT : public ContractBase
12801271 return ;
12811272 }
12821273
1274+ if (qpi.invocationReward () > (sint64)state.get ().liveReleaseFee )
1275+ {
1276+ qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseFee );
1277+ }
1278+
1279+ state.mut ().totalRevenue += state.get ().liveReleaseFee ;
1280+
12831281 locals.fi_in .vault = locals.vault ;
12841282 locals.fi_in .ownerID = qpi.invocator ();
12851283 findOwnerIndexInVault (qpi, state, locals.fi_in , locals.fi_out , locals.fi_locals );
@@ -1358,13 +1356,6 @@ struct MSVAULT : public ContractBase
13581356 return ;
13591357 }
13601358
1361- if (qpi.invocationReward () > (sint64)state.get ().liveReleaseFee )
1362- {
1363- qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseFee );
1364- }
1365-
1366- state.mut ().totalRevenue += state.get ().liveReleaseFee ;
1367-
13681359 locals.iv_in .vaultId = input.vaultId ;
13691360 isValidVaultId (qpi, state, locals.iv_in , locals.iv_out , locals.iv_locals );
13701361
@@ -1448,6 +1439,13 @@ struct MSVAULT : public ContractBase
14481439 return ;
14491440 }
14501441
1442+ if (qpi.invocationReward () > (sint64)state.get ().liveReleaseFee )
1443+ {
1444+ qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseFee );
1445+ }
1446+
1447+ state.mut ().totalRevenue += state.get ().liveReleaseFee ;
1448+
14511449 // Record the release request
14521450 locals.fi_in .vault = locals.qubicVault ;
14531451 locals.fi_in .ownerID = qpi.invocator ();
@@ -1576,12 +1574,6 @@ struct MSVAULT : public ContractBase
15761574 LOG_INFO (locals.logger );
15771575 return ;
15781576 }
1579- if (qpi.invocationReward () > (sint64)state.get ().liveReleaseResetFee )
1580- {
1581- qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseResetFee );
1582- }
1583-
1584- state.mut ().totalRevenue += state.get ().liveReleaseResetFee ;
15851577
15861578 locals.iv_in .vaultId = input.vaultId ;
15871579 isValidVaultId (qpi, state, locals.iv_in , locals.iv_out , locals.iv_locals );
@@ -1618,6 +1610,13 @@ struct MSVAULT : public ContractBase
16181610 return ;
16191611 }
16201612
1613+ if (qpi.invocationReward () > (sint64)state.get ().liveReleaseResetFee )
1614+ {
1615+ qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseResetFee );
1616+ }
1617+
1618+ state.mut ().totalRevenue += state.get ().liveReleaseResetFee ;
1619+
16211620 locals.fi_in .vault = locals.vault ;
16221621 locals.fi_in .ownerID = qpi.invocator ();
16231622 findOwnerIndexInVault (qpi, state, locals.fi_in , locals.fi_out , locals.fi_locals );
@@ -1651,12 +1650,6 @@ struct MSVAULT : public ContractBase
16511650 LOG_INFO (locals.logger );
16521651 return ;
16531652 }
1654- if (qpi.invocationReward () > (sint64)state.get ().liveReleaseResetFee )
1655- {
1656- qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseResetFee );
1657- }
1658-
1659- state.mut ().totalRevenue += state.get ().liveReleaseResetFee ;
16601653
16611654 locals.iv_in .vaultId = input.vaultId ;
16621655 isValidVaultId (qpi, state, locals.iv_in , locals.iv_out , locals.iv_locals );
@@ -1694,6 +1687,13 @@ struct MSVAULT : public ContractBase
16941687 return ;
16951688 }
16961689
1690+ if (qpi.invocationReward () > (sint64)state.get ().liveReleaseResetFee )
1691+ {
1692+ qpi.transfer (qpi.invocator (), qpi.invocationReward () - (sint64)state.get ().liveReleaseResetFee );
1693+ }
1694+
1695+ state.mut ().totalRevenue += state.get ().liveReleaseResetFee ;
1696+
16971697 locals.fi_in .vault = locals.qubicVault ;
16981698 locals.fi_in .ownerID = qpi.invocator ();
16991699 findOwnerIndexInVault (qpi, state, locals.fi_in , locals.fi_out , locals.fi_locals );
@@ -1736,18 +1736,18 @@ struct MSVAULT : public ContractBase
17361736 LOG_INFO (locals.logger );
17371737 return ;
17381738 }
1739-
1739+
17401740 qpi.transfer (qpi.invocator (), qpi.invocationReward ());
17411741 locals.nShare = qpi.numberOfShares ({ NULL_ID, MSVAULT_ASSET_NAME }, AssetOwnershipSelect::byOwner (qpi.invocator ()), AssetPossessionSelect::byPossessor (qpi.invocator ()));
1742-
1742+
17431743 locals.fs .registeringFee = input.newRegisteringFee ;
17441744 locals.fs .releaseFee = input.newReleaseFee ;
17451745 locals.fs .releaseResetFee = input.newReleaseResetFee ;
17461746 locals.fs .holdingFee = input.newHoldingFee ;
17471747 locals.fs .depositFee = input.newDepositFee ;
17481748 // [TODO]: Turn this ON when MSVAULT_BURN_FEE > 0
17491749 // locals.fs.burnFee = input.burnFee;
1750-
1750+
17511751 locals.needNewRecord = true ;
17521752 for (locals.i = 0 ; locals.i < state.get ().feeVotesAddrCount ; locals.i = locals.i + 1 )
17531753 {
@@ -1767,7 +1767,7 @@ struct MSVAULT : public ContractBase
17671767 state.mut ().feeVotesScore .set (state.get ().feeVotesAddrCount , locals.nShare );
17681768 state.mut ().feeVotesAddrCount = state.get ().feeVotesAddrCount + 1 ;
17691769 }
1770-
1770+
17711771 locals.sumVote = 0 ;
17721772 for (locals.i = 0 ; locals.i < state.get ().feeVotesAddrCount ; locals.i = locals.i + 1 )
17731773 {
@@ -1780,7 +1780,7 @@ struct MSVAULT : public ContractBase
17801780 LOG_INFO (locals.logger );
17811781 return ;
17821782 }
1783-
1783+
17841784 state.mut ().uniqueFeeVotesCount = 0 ;
17851785 // Reset unique vote ranking
17861786 for (locals.i = 0 ; locals.i < MSVAULT_MAX_FEE_VOTES; locals.i = locals.i + 1 )
@@ -1822,7 +1822,7 @@ struct MSVAULT : public ContractBase
18221822 state.mut ().uniqueFeeVotesCount = state.get ().uniqueFeeVotesCount + 1 ;
18231823 }
18241824 }
1825-
1825+
18261826 for (locals.i = 0 ; locals.i < state.get ().uniqueFeeVotesCount ; locals.i = locals.i + 1 )
18271827 {
18281828 if (state.get ().uniqueFeeVotesRanking .get (locals.i ) >= QUORUM)
@@ -2041,7 +2041,7 @@ struct MSVAULT : public ContractBase
20412041
20422042 output.status = 1ULL ;
20432043 }
2044-
2044+
20452045 PUBLIC_FUNCTION_WITH_LOCALS (isShareHolder)
20462046 {
20472047 if (qpi.numberOfShares ({ NULL_ID, MSVAULT_ASSET_NAME }, AssetOwnershipSelect::byOwner (input.candidate ),
@@ -2153,6 +2153,7 @@ struct MSVAULT : public ContractBase
21532153 locals.qubicVault = state.get ().vaults .get (locals.i );
21542154 if (locals.qubicVault .isActive )
21552155 {
2156+
21562157 if (locals.qubicVault .qubicBalance >= state.get ().liveHoldingFee )
21572158 {
21582159 locals.qubicVault .qubicBalance -= state.get ().liveHoldingFee ;
@@ -2161,6 +2162,7 @@ struct MSVAULT : public ContractBase
21612162 }
21622163 else
21632164 {
2165+ locals.assetVault = state.get ().vaultAssetParts .get (locals.i );
21642166 // Not enough funds to pay holding fee
21652167 if (locals.qubicVault .qubicBalance > 0 )
21662168 {
@@ -2186,7 +2188,7 @@ struct MSVAULT : public ContractBase
21862188 // INVOKE_OTHER_CONTRACT_PROCEDURE(QX, TransferShareOwnershipAndPossession, locals.qx_in, locals.qx_out, 0);
21872189 // }
21882190 // }
2189-
2191+
21902192 locals.qubicVault .isActive = false ;
21912193 locals.qubicVault .qubicBalance = 0 ;
21922194 locals.qubicVault .requiredApprovals = 0 ;
0 commit comments