Skip to content

Commit

Permalink
fix: make ibc hook tx
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseRFelix committed Oct 29, 2024
1 parent 6c86d2f commit fbbddcc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/bridge/src/nomic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class NomicBridgeProvider implements BridgeProvider {
| Awaited<ReturnType<typeof getRouteTokenOutGivenIn>>
| undefined;

if (fromAsset.address !== this.nBTCMinimalDenom) {
if (fromAsset.address === this.allBtcMinimalDenom) {
swapRoute = await getRouteTokenOutGivenIn({
assetLists: this.ctx.assetLists,
tokenInAmount: fromAmount,
Expand Down Expand Up @@ -333,6 +333,10 @@ export class NomicBridgeProvider implements BridgeProvider {
const userWantsAllBtc =
this.allBtcMinimalDenom && toAsset.address === this.allBtcMinimalDenom;

const now = Date.now();
const timeoutTimestampFiveDaysFromNow =
BigInt(now + 86400 * 5 * 1000 - (now % (60 * 60 * 1000))) *
BigInt(1000000);
const swapMemo = userWantsAllBtc
? makeSkipIbcHookSwapMemo({
denomIn: this.nBTCMinimalDenom,
Expand All @@ -345,7 +349,7 @@ export class NomicBridgeProvider implements BridgeProvider {
? "1868" // nBTC/allBTC pool on Osmosis
: "654", // nBTC/osmo pool on Osmosis. Since there's no alloyed btc in testnet, we'll use these pool instead
receiverOsmoAddress: toAddress,
timeoutTimestamp: 0,
timeoutTimestamp: timeoutTimestampFiveDaysFromNow.toString(),
})
: undefined;

Expand Down
7 changes: 5 additions & 2 deletions packages/tx/src/message-composers/complex/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export function makeSkipIbcHookSwapMemo({
denomOut: string;
minAmountOut: string;
poolId: string;
timeoutTimestamp: number;
timeoutTimestamp: string;
receiverOsmoAddress: string;
env: "testnet" | "mainnet";
}) {
Expand All @@ -273,7 +273,10 @@ export function makeSkipIbcHookSwapMemo({
swap_and_action: {
user_swap: {
swap_exact_asset_in: {
swap_venue_name: "osmosis-poolmanager",
swap_venue_name:
env === "testnet"
? "testnet-osmosis-poolmanager"
: "osmosis-poolmanager",
operations: [
{
denom_in: denomIn,
Expand Down

0 comments on commit fbbddcc

Please sign in to comment.