-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat/added retrieval info functions #28
Conversation
package.json
Outdated
@@ -27,6 +27,10 @@ | |||
"format": "prettier --write .", | |||
"typecheck": "tsc --noEmit" | |||
}, | |||
"dependencies": { | |||
"dnum": "^2.12.0", | |||
"viem": "^2.10.5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
viem version should be "^2.13.2"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -84,3 +116,409 @@ export async function getSendTokenAdapterFees( | |||
// get return adapter fee | |||
return await hubBridgeRouter.read.getSendFee([returnMessage]); | |||
} | |||
|
|||
export async function loanTypeInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call this getLoanTypeInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/chains/evm/hub/types/loan.ts
Outdated
export type AbiLoanPool = { | ||
collateralUsed: bigint; | ||
borrowUsed: bigint; | ||
collateralCap: bigint; | ||
borrowCap: bigint; | ||
collateralFactor: number; | ||
borrowFactor: number; | ||
liquidationBonus: number; | ||
liquidationFee: number; | ||
isAdded: boolean; | ||
isDeprecated: boolean; | ||
reward: { | ||
lastUpdateTimestamp: bigint; | ||
minimumAmount: bigint; | ||
collateralSpeed: bigint; | ||
borrowSpeed: bigint; | ||
collateralRewardIndex: bigint; | ||
borrowRewardIndex: bigint; | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could updata it with ReadContractReturnType<typeof LoanManagerAbi, "getLoanPool">;
, same with others ts(2589)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
], | ||
allowFailure: false, | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defining return types (e.g. ReadContractReturnType<typeof LoanManagerAbi, "getLoanPool">
) for each of these returns we can avoid unknown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}; | ||
} | ||
|
||
export async function getUserLoanIds( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use fetch/get naming convention as https://github.com/Folks-Finance/folks-finance-xchain-js-sdk/blob/feat/account-id-info/src/chains/evm/hub/modules/folks-hub-account.ts#L82 , creating utils methods so that we can further filter events if needed e.g. CreateUserLoan with loanTypeId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ae13a30 with added ability to filter on loan type
Co-authored-by: Stefano Faieta <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Includes: