Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single atomicRearrange for liquidityPool repay #11059

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Chris-Hibbert
Copy link
Contributor

Description

Repaying the liquidity pool was being done with two sequential calls to zcf.atomicRearrange(). This refactors so that each of the calls on repay() includes a TransferPart to indicate the source of the funds. There was no need to rearrange the funds into matching keywords with a separate rearrange.

Security Considerations

None.

Scaling Considerations

None

Documentation Considerations

Could we have done a better job of explaining atomicRearrange()?

Testing Considerations

Cleaned up existing tests. settler.test.js does extensive tracing, and records and verifies many calls, so this had to be updated, since a call to atomicRearrange was dropped, and the signature of repay() changed.

Upgrade Considerations

There is no urgency to getting this change onto master. The behavior should be interchangeable for all successful transactions.

@Chris-Hibbert Chris-Hibbert added the Zoe Contract Contracts within Zoe label Feb 26, 2025
@Chris-Hibbert Chris-Hibbert self-assigned this Feb 26, 2025
@Chris-Hibbert Chris-Hibbert requested a review from a team as a code owner February 26, 2025 19:49
Copy link

cloudflare-workers-and-pages bot commented Feb 26, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6973a09
Status: ✅  Deploy successful!
Preview URL: https://b581cbf3.agoric-sdk.pages.dev
Branch Preview URL: https://cth-atomicrepay.agoric-sdk.pages.dev

View logs

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

a few notes

[fromSeat, feeSeat, { ContractFee }, { USDC: ContractFee }],
]),
);
zcf.atomicRearrange([
Copy link
Member

Choose a reason for hiding this comment

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

I could swear zcf throws when this harden(...) is missing. But maybe only the individual parts need to be hardened?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Do you believe that even though tests all passed?

Copy link
Member

Choose a reason for hiding this comment

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

I think fast-usdc.contract.test.ts is sufficiently high fidelity that if the tests pass, the code would work on chain without harden(...).

Comment on lines -566 to +533
const actual = repayCalc(
shareWorth,
fromSeatAllocation,
amounts,
encumberedBalance,
poolStats,
);
const actual = repayCalc(shareWorth, amounts, encumberedBalance, poolStats);
Copy link
Member

Choose a reason for hiding this comment

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

getting these all on one line makes me happy 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Zoe Contract Contracts within Zoe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants