Skip to content

Commit

Permalink
change order of operations for sol deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
penemue698 committed Jun 15, 2023
1 parent 18a0709 commit 8e31159
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions scripts/eth_sol/sol_deposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ async function updateDeposits () {
const newDeposits = bridgesToInsert.filter(tx => !txidsOfAlreadyProcessedDeposits.includes(tx[3]))

for (let deposit of newDeposits) {
console.log(`inserting deposit: ${deposit[3]} - ${deposit[2]} SOL`)
await db.query(`UPDATE sol_deposits SET completed = true WHERE id=$1`, [request.id])
await db.query(
`INSERT INTO bridges (deposit_currency, deposit_address, deposit_amount, deposit_txid, deposit_timestamp, outgoing_currency, outgoing_address)
VALUES ($1,$2,$3,$4,NOW(),$5,$6)
ON CONFLICT (deposit_txid) DO NOTHING`,
deposit
);

transferFromDepositAddressToLiquidityPool(request.id)
try {
await transferFromDepositAddressToLiquidityPool(request.id)
console.log(`inserting deposit: ${deposit[3]} - ${deposit[2]} SOL`)
await db.query(`UPDATE sol_deposits SET completed = true WHERE id=$1`, [request.id])
await db.query(
`INSERT INTO bridges (deposit_currency, deposit_address, deposit_amount, deposit_txid, deposit_timestamp, outgoing_currency, outgoing_address)
VALUES ($1,$2,$3,$4,NOW(),$5,$6)
ON CONFLICT (deposit_txid) DO NOTHING`,
deposit
);
} catch (error) {
console.log(`error sending sol back to liquidity pool: `, JSON.stringify(error))
}
}
}
}
Expand Down

0 comments on commit 8e31159

Please sign in to comment.