@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/package.json
CHANGED
package/src/settings.ts
CHANGED
|
@@ -614,6 +614,51 @@ export const availableCompensationMaximum = ({
|
|
|
614
614
|
return 0n
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
+
/**
|
|
618
|
+
* Determines if the bridge is undercompensated based on network costs vs compensation limit using desired compensation rate
|
|
619
|
+
* @param estimatedTokenNetworkCost - the estimated token network cost
|
|
620
|
+
* @param feeType - the fee type
|
|
621
|
+
* @param limit - the maximum compensation limit
|
|
622
|
+
* @param amountAfterBridgeFee - the amount after bridge fee
|
|
623
|
+
* @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
|
|
624
|
+
* @returns whether the bridge is undercompensated
|
|
625
|
+
*/
|
|
626
|
+
export const isUndercompensated = ({
|
|
627
|
+
estimatedTokenNetworkCost,
|
|
628
|
+
feeType,
|
|
629
|
+
limit,
|
|
630
|
+
amountAfterBridgeFee,
|
|
631
|
+
desiredExcessCompensationBasisPoints,
|
|
632
|
+
}: {
|
|
633
|
+
estimatedTokenNetworkCost: bigint | null
|
|
634
|
+
feeType: FeeType
|
|
635
|
+
limit: bigint
|
|
636
|
+
amountAfterBridgeFee: bigint | null
|
|
637
|
+
desiredExcessCompensationBasisPoints: bigint
|
|
638
|
+
}) => {
|
|
639
|
+
// No undercompensation if no amount to bridge
|
|
640
|
+
if (!amountAfterBridgeFee || amountAfterBridgeFee <= 0n) {
|
|
641
|
+
return false
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// GAS_TIP fee type doesn't have undercompensation issues
|
|
645
|
+
if (feeType === FeeType.GAS_TIP) {
|
|
646
|
+
return false
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// No network cost estimate means we can't determine undercompensation
|
|
650
|
+
if (!estimatedTokenNetworkCost) {
|
|
651
|
+
return false
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// Calculate desired compensation using the actual desired compensation ratio
|
|
655
|
+
const desiredCompensationRatio = oneEther + (desiredExcessCompensationBasisPoints * oneEther) / basisPoints
|
|
656
|
+
const desiredCompensationForNetworkCost = (estimatedTokenNetworkCost * desiredCompensationRatio) / oneEther
|
|
657
|
+
|
|
658
|
+
// Undercompensated if desired compensation exceeds the limit
|
|
659
|
+
return desiredCompensationForNetworkCost > limit
|
|
660
|
+
}
|
|
661
|
+
|
|
617
662
|
/**
|
|
618
663
|
* 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
|
|
619
664
|
* @param bridgePathway - the bridge pathway to use
|