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

Lend vault messages #125

Merged
merged 25 commits into from
Apr 22, 2024
Merged

Lend vault messages #125

merged 25 commits into from
Apr 22, 2024

Conversation

AustinWoetzel
Copy link
Collaborator

@AustinWoetzel AustinWoetzel commented Apr 5, 2024

Shade Lend Vault queries, tests, docs (public queries only)

Copy link

changeset-bot bot commented Apr 5, 2024

🦋 Changeset detected

Latest commit: ec570eb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@shadeprotocol/shadejs Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@AustinWoetzel AustinWoetzel marked this pull request as draft April 5, 2024 21:43
@AustinWoetzel AustinWoetzel marked this pull request as ready for review April 19, 2024 20:50
@AustinWoetzel
Copy link
Collaborator Author

note to self: squash and merge this

Copy link
Collaborator

@SissonJ SissonJ left a comment

Choose a reason for hiding this comment

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

Nice PR 😎

* @param startingPage The data is paginated and returned
* for the starting page and all pages after. Use 1 to query all vaults.
*/
const msgGetVaults = (startingPage: number) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like this to be string and have the casting happen in the services

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also have you tried this query with a string? it could be a u128 type

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

string works, this is what we do on front end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to string

vaultId,
}: {
borrowAmount: string,
maxBorrowFee: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be optional? maxBorrowFee?:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

collateralAddress: string,
silkMaxAllowance: string,
silkAllowanceUsed: string,
maxLtv: number,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a percent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

adding clarity in the docs

lastUpdatedAt: Date,
},
liquidationFee: {
discount: number,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Percent?


type BatchVaults = BatchVaultsItem[]

type VaultUserData = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we adding user data queries?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copy paste from front end, put a note in the services layer that they are Experimental and not tested for production use. I could split them out if you think that makes sense to do.

/**
* Parse lend vault response
*/
function parseLendVault(vault: VaultResponse, vaultVersion: VaultVersion) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make vaultVersion optional and have it default to v3, the most up to date version?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there really no way to programatically determine the version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there is no way to programatically determine, unfortunately.... that would have been a great feature that should have been included when we started making new vaults.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd rather not set defaults.

// Collateral is expressed differently depending on vault type
collateral: {
total:
(vaultVersion === VaultVersion.V1 || vaultVersion === VaultVersion.V2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason that V2 is included in this check? Why did V3 get the big change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's different math for the collateral display. I don't know why it was such a big change, i wish it would have been consistent.

},
debt,
collateral_addr: collateralAddress,
is_protocol: isProtocol,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: isProtocol -> isProtocolOnly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

...prev,
[vaultId]: parseLendVault(vault, vaultVersion),
};
}, {} as Vaults);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this type declaration to line 140 please

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

*/
const parseBatchQueryVaultsInfo = (
response: BatchQueryParsedResponse,
vaultVersions: VaultVersion[],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really dislike that vaultVersions is a required argument.... we really should find a way to make it work without it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also dislike it, but we have no choice and need to be clear about the differences between the different vaults.

@AustinWoetzel AustinWoetzel merged commit a8b185f into develop Apr 22, 2024
4 checks passed
@AustinWoetzel AustinWoetzel deleted the lend-vault-messages branch April 22, 2024 19:12
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.

2 participants