Skip to content

Adds TransferSharesToManyV1 to QUTIL#803

Open
double-k-3033 wants to merge 5 commits intoqubic:developfrom
double-k-3033:feature/qutil
Open

Adds TransferSharesToManyV1 to QUTIL#803
double-k-3033 wants to merge 5 commits intoqubic:developfrom
double-k-3033:feature/qutil

Conversation

@double-k-3033
Copy link
Copy Markdown
Contributor

No description provided.

cyber-pc and others added 3 commits March 11, 2026 15:32
Release v1.282.0 

Add QBridge contract (Vottun)
Add Oracle Documentation
Fix bug on loading execution fee after seamless epoch change
Fix problem during loading of assets from snapshot
Adjust TICK_DURATION_FOR_ALLOCATION_MS and TRANSACTION_SPARSENESS
Increase ADDITION_SOLUTION_THRESHOLD_DEFAULT to 74800
Copy link
Copy Markdown
Contributor

@philippwerner philippwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Overall, it looks good to me. Just the following comments:

Why did you change the DebugInformationFormat in the platform libraries? Is there any problem with the "ProgramDatabase" setting that is fixed by changing the value to "OldStyle"? If there isn't a good reason, please undo the changes in the *.vcxproj files.

If management rights are transferred to QUTIL, it also must offer a way to transfer the rights back to other contracts. So please add a procedure TransferShareManagementRights for that purpose to QUTIL.

@double-k-3033
Copy link
Copy Markdown
Contributor Author

I'm sorry. An error occurred during the build process, so I had no choice but to change it that way. I forgot that I shouldn't push the related files when I push.

@double-k-3033 double-k-3033 requested a review from krypdkat March 25, 2026 14:50
@double-k-3033 double-k-3033 requested a review from krypdkat March 25, 2026 15:25
@philippwerner philippwerner changed the title Feature/qutil Adds TransferSharesToManyV1 to QUTIL Apr 13, 2026
Copy link
Copy Markdown
Contributor

@philippwerner philippwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. Please address the following comments.

* @param list of 24 amounts (192 bytes): 8 bytes(sint64) for each amount, leave 0 for unused slots
* @return returnCode (0 means success)
*/
PUBLIC_PROCEDURE_WITH_LOCALS(TransferShareToManyV1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to "TransferSharesToManyV1" (plural shares)

LOG_INFO(locals.logger);

// Validate invocation fee
if (qpi.invocationReward() < state.get().smt1InvocationFee)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smt1InvocationFee is too low. After some discussion with JOETOM and Kavatak, we came to the conclusion that a good solution will be to:

  1. query the current transfer fee of QX = tf with CALL_OTHER_CONTRACT_FUNCTION(QX, Fees, ..., ...),
  2. compute the fee as tstmInvocationFee = 25 * tf,
  3. check if qpi.invocationReward() is sufficient (as done here, but with tstmInvocationFee),
  4. transfer the shares,
  5. transfer 24 * tf to QX,
  6. burn 1 * tf.

Asset asset;
sint64 numberOfShares;
uint32 newManagingContractIndex;
sint64 offeredTransferFee;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we need offeredTransferFee here. Just use the invocation reward as the offered fee for simplicity. For proper handling of the case that the offeredTransferFee is greater than the requested fee, you should store the return value of qpi.releaseShares(), which is the fee actually paid for releasing if the value is >= 0.

}

// Release management rights from QUTIL to destination contract
if (qpi.releaseShares(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function qpi.releaseShares() internally does all the checks that you have done above, so you may remove those.

// Safe refund: anything above the offered fee is definitely not needed
if (qpi.invocationReward() > input.offeredTransferFee)
{
qpi.transfer(qpi.invocator(), qpi.invocationReward() - input.offeredTransferFee);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you should refund the difference between the invocation reward and the fee that was actually paid (returned by qpi.releaseShares()). Or you should burn the difference. At the moment it will just remain in the balance of the contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants