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

Include sort according to fAsset ids #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const isAppOptInRequired = isAccountOptedIntoApp({
accountAppsLocalState: account["apps-local-state"]
});

if (!hasOptedIn) {
if (isAppOptInRequired) {
const v1AppOptInTxns = await generateOptIntoValidatorTxns({
client: algodClient,
network: "mainnet",
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

97 changes: 7 additions & 90 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/folks-lending-pools/remove-liquidity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export async function generateTxns({
const poolAddress = pool.account.address();
const poolTokenId = pool.poolTokenID;

// Make sure to sort the assets according to the fAssetIds
const [asset1, asset2] = [asset1Out, asset2Out].sort((a, b) => b.fAssetId - a.fAssetId);

if (!poolTokenId) {
throw new Error("Pool token asset ID is missing");
}
Expand All @@ -59,12 +62,12 @@ export async function generateTxns({
appArgs: [
encodeString("remove_liquidity"),
decodeAddress(poolAddress).publicKey,
encodeUint64(asset1Out.lendingAppId),
encodeUint64(asset2Out.lendingAppId)
encodeUint64(asset1.lendingAppId),
encodeUint64(asset2.lendingAppId)
],
accounts: [poolAddress],
foreignAssets: [asset1Out.id, asset2Out.id, asset1Out.fAssetId, asset2Out.fAssetId],
foreignApps: [asset1Out.lendingAppId, asset2Out.lendingAppId, lendingManagerId],
foreignAssets: [asset1.id, asset2.id, asset1.fAssetId, asset2.fAssetId],
foreignApps: [asset1.lendingAppId, asset2.lendingAppId, lendingManagerId],
suggestedParams
});

Expand All @@ -77,7 +80,7 @@ export async function generateTxns({
appIndex: FOLKS_WRAPPER_APP_ID[network],
appArgs: [encodeString("noop")],
accounts: [poolAddress],
foreignAssets: [poolTokenId, asset1Out.fAssetId, asset2Out.fAssetId],
foreignAssets: [poolTokenId, asset1.fAssetId, asset2.fAssetId],
foreignApps: [validatorAppID],
suggestedParams
});
Expand Down