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

fix: incorrect looping deposit amount #1005

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ class MarginfiAccountWrapper {
wrapAndUnwrapSol: false,
}
);

const { instructions: updateFeedIxs, luts: feedLuts } = await this.makeUpdateFeedIx([
depositBankAddress,
borrowBankAddress,
Expand Down
5 changes: 3 additions & 2 deletions packages/mrgn-utils/src/actions/flashloans/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ export async function calculateLoopingTransaction(props: LoopingProps): Promise<
*/
export async function loopingBuilder({
marginfiAccount,
depositAmount,
// depositAmount,
actualDepositAmount,
borrowAmount,
depositBank,
borrowBank,
Expand Down Expand Up @@ -378,7 +379,7 @@ export async function loopingBuilder({
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");

const { flashloanTx, additionalTxs, txOverflown } = await marginfiAccount.makeLoopTxV2({
depositAmount,
depositAmount: actualDepositAmount,
borrowAmount,
depositBankAddress: depositBank.address,
borrowBankAddress: borrowBank.address,
Expand Down
2 changes: 1 addition & 1 deletion packages/mrgn-utils/src/actions/flashloans/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export function getLoopingParamsForAccount(
amount: number,
slippageBps: number
) {
const principalBufferAmountUi = amount * targetLeverage * (slippageBps / 10000);
const principalBufferAmountUi = amount * targetLeverage * ((slippageBps + 30) / 10000);
const adjustedPrincipalAmountUi = amount - principalBufferAmountUi;

const { borrowAmount, totalDepositAmount: depositAmount } = marginfiAccount.computeLoopingParams(
Expand Down
Loading