@gibs/bridge-sdk 1.9.1 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/settings.d.ts +16 -0
- package/dist/src/settings.js +28 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/settings.ts +45 -0
package/dist/src/settings.d.ts
CHANGED
|
@@ -285,6 +285,22 @@ export declare const availableCompensationMaximum: ({ amountAfterBridgeFee, perc
|
|
|
285
285
|
fixedFee: bigint | null;
|
|
286
286
|
limit: bigint;
|
|
287
287
|
}) => bigint | null;
|
|
288
|
+
/**
|
|
289
|
+
* Determines if the bridge is undercompensated based on network costs vs compensation limit using desired compensation rate
|
|
290
|
+
* @param estimatedTokenNetworkCost - the estimated token network cost
|
|
291
|
+
* @param feeType - the fee type
|
|
292
|
+
* @param limit - the maximum compensation limit
|
|
293
|
+
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
294
|
+
* @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
|
|
295
|
+
* @returns whether the bridge is undercompensated
|
|
296
|
+
*/
|
|
297
|
+
export declare const isUndercompensated: ({ estimatedTokenNetworkCost, feeType, limit, amountAfterBridgeFee, desiredExcessCompensationBasisPoints, }: {
|
|
298
|
+
estimatedTokenNetworkCost: bigint | null;
|
|
299
|
+
feeType: FeeType;
|
|
300
|
+
limit: bigint;
|
|
301
|
+
amountAfterBridgeFee: bigint | null;
|
|
302
|
+
desiredExcessCompensationBasisPoints: bigint;
|
|
303
|
+
}) => boolean;
|
|
288
304
|
/**
|
|
289
305
|
* Calculates the transaction inputs from the bridge pathway, asset in, recipient, account, asset link, destination data param, amount to bridge, fee director struct encoded, and should deliver
|
|
290
306
|
* @param bridgePathway - the bridge pathway to use
|
package/dist/src/settings.js
CHANGED
|
@@ -408,6 +408,34 @@ export const availableCompensationMaximum = ({ amountAfterBridgeFee, percentFee,
|
|
|
408
408
|
}
|
|
409
409
|
return 0n;
|
|
410
410
|
};
|
|
411
|
+
/**
|
|
412
|
+
* Determines if the bridge is undercompensated based on network costs vs compensation limit using desired compensation rate
|
|
413
|
+
* @param estimatedTokenNetworkCost - the estimated token network cost
|
|
414
|
+
* @param feeType - the fee type
|
|
415
|
+
* @param limit - the maximum compensation limit
|
|
416
|
+
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
417
|
+
* @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
|
|
418
|
+
* @returns whether the bridge is undercompensated
|
|
419
|
+
*/
|
|
420
|
+
export const isUndercompensated = ({ estimatedTokenNetworkCost, feeType, limit, amountAfterBridgeFee, desiredExcessCompensationBasisPoints, }) => {
|
|
421
|
+
// No undercompensation if no amount to bridge
|
|
422
|
+
if (!amountAfterBridgeFee || amountAfterBridgeFee <= 0n) {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
// GAS_TIP fee type doesn't have undercompensation issues
|
|
426
|
+
if (feeType === FeeType.GAS_TIP) {
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
// No network cost estimate means we can't determine undercompensation
|
|
430
|
+
if (!estimatedTokenNetworkCost) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
// Calculate desired compensation using the actual desired compensation ratio
|
|
434
|
+
const desiredCompensationRatio = oneEther + (desiredExcessCompensationBasisPoints * oneEther) / basisPoints;
|
|
435
|
+
const desiredCompensationForNetworkCost = (estimatedTokenNetworkCost * desiredCompensationRatio) / oneEther;
|
|
436
|
+
// Undercompensated if desired compensation exceeds the limit
|
|
437
|
+
return desiredCompensationForNetworkCost > limit;
|
|
438
|
+
};
|
|
411
439
|
/**
|
|
412
440
|
* Calculates the transaction inputs from the bridge pathway, asset in, recipient, account, asset link, destination data param, amount to bridge, fee director struct encoded, and should deliver
|
|
413
441
|
* @param bridgePathway - the bridge pathway to use
|