Skip to content

Commit

Permalink
Jonator/fixes (#3676)
Browse files Browse the repository at this point in the history
* fix param

* add invariant
  • Loading branch information
jonator authored Aug 5, 2024
1 parent a904c95 commit 580ffdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function calculatePercentAndFiatValues(
categories: Categories,
assetLists: AssetList[],
category: "total-assets" | "user-balances",
allocationLimit
allocationLimit = 5
) {
const totalAssets = categories[category];
const totalCap = new Dec(totalAssets.capitalization);
Expand Down
8 changes: 8 additions & 0 deletions packages/web/server/api/routers/bridge-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export const bridgeTransferRouter = createTRPCRouter({
/** If the bridge takes longer than 10 seconds to respond, we should timeout that quote. */
const quote = await timeout(quoteFn, 10 * 1000)();

// Basic circuit breaker to validate some invariants
// from input + given quote
if (input.fromAsset.address !== quote.input.address) {
throw new Error(
`Invalid quote: Expected fromAsset address ${input.fromAsset.address} but got ${quote.input.address} in quote`
);
}

/**
* Since transfer fee is deducted from input amount,
* we overwrite the transfer fee asset to be the input
Expand Down

0 comments on commit 580ffdc

Please sign in to comment.