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

Add Liquidity Pools methods #19

Merged
merged 57 commits into from
Dec 2, 2024
Merged

Add Liquidity Pools methods #19

merged 57 commits into from
Dec 2, 2024

Conversation

onnovisser
Copy link
Collaborator

Description

Adds a Vault entity with methods to query investments and place invest/redeem orders.

#17

Base automatically changed from queries to main November 20, 2024 15:31
@onnovisser onnovisser marked this pull request as ready for review November 21, 2024 14:58
src/Vault.ts Outdated Show resolved Hide resolved
Comment on lines +130 to +133
this.investmentCurrency(),
this.shareCurrency(),
this.network._investmentManager(),
this._restrictionManager(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be somehow magically combined into 1 big multicall, or will it be 4 separate calls?

If the latter, would it be worth combining more of these read calls into 1 method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Viem has the option to automatically batch these, which is awesome, so these will be done as a multicall 🥳

Copy link
Contributor

Choose a reason for hiding this comment

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

That is wild! 🔥

client,
})

const [isAllowedToInvest, maxDeposit, maxRedeem, investment] = await Promise.all([
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this will be multicall, right?

shareCurrency,
}
}).pipe(
repeatOnEvents(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice :)

src/Vault.ts Outdated

if (investment.pendingInvestCurrency.isZero()) throw new Error('No order to cancel')

yield* doTransaction('Cancel Invest Order', publicClient, () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Will these tx descriptions be passed through and shown in the UI? If so, I would stick to our pattern of not capitalizing:

Suggested change
yield* doTransaction('Cancel Invest Order', publicClient, () =>
yield* doTransaction('Cancel invest order', publicClient, () =>

src/Vault.ts Outdated
* Place an order to invest funds in the vault. If an order exists, it will increase the amount.
* @param investAmount - The amount to invest in the vault
*/
increaseInvestOrder(investAmount: bigint | number) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: param name here is investAmount, while for increaseRedeemOrder it is shares.

Would either use assets here, or redeemAmount in increaseRedeemOrder

src/Vault.ts Outdated
* Claim any outstanding fund shares after an investment has gone through, or funds after an redemption has gone through.
* @param receiver - The address that should receive the funds. If not provided, the investor's address is used.
*/
claim(receiver?: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to also add an optional controller param here, so we can actually use the SDK to build a bot to claim for others

import { context } from './tests/setup.js'
import { Vault } from './Vault.js'

const poolId = '2779829532'
Copy link
Contributor

Choose a reason for hiding this comment

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

Really love these impersonated fork tests!!

@onnovisser onnovisser merged commit c993f94 into main Dec 2, 2024
@onnovisser onnovisser deleted the lp branch December 2, 2024 13:42
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.

3 participants