diff --git a/.changeset/violet-insects-sleep.md b/.changeset/violet-insects-sleep.md new file mode 100644 index 0000000..b03e2ab --- /dev/null +++ b/.changeset/violet-insects-sleep.md @@ -0,0 +1,5 @@ +--- +"@folks-finance/xchain-sdk": patch +--- + +increased send token adapter fees by 1% diff --git a/src/chains/evm/common/constants/contract.ts b/src/chains/evm/common/constants/contract.ts index 8e970fd..6b5c8ac 100644 --- a/src/chains/evm/common/constants/contract.ts +++ b/src/chains/evm/common/constants/contract.ts @@ -8,3 +8,4 @@ export const defaultEventParams: EventParams = { export const GAS_LIMIT_ESTIMATE_INCREASE = 10_000n; export const SEND_TOKEN_ACTION_RETURN_GAS_LIMIT = 500_000n; +export const RECEIVER_VALUE_SLIPPAGE = 0.01; diff --git a/src/chains/evm/hub/modules/folks-hub-loan.ts b/src/chains/evm/hub/modules/folks-hub-loan.ts index f35d185..97ccbc6 100644 --- a/src/chains/evm/hub/modules/folks-hub-loan.ts +++ b/src/chains/evm/hub/modules/folks-hub-loan.ts @@ -19,9 +19,13 @@ import { toFAmount, toUnderlyingAmount, } from "../../../../common/utils/formulae.js"; -import { bigIntMin, compoundEverySecond } from "../../../../common/utils/math-lib.js"; +import { bigIntMin, compoundEverySecond, increaseByPercent } from "../../../../common/utils/math-lib.js"; import { exhaustiveCheck } from "../../../../utils/exhaustive-check.js"; -import { defaultEventParams, GAS_LIMIT_ESTIMATE_INCREASE } from "../../common/constants/contract.js"; +import { + defaultEventParams, + GAS_LIMIT_ESTIMATE_INCREASE, + RECEIVER_VALUE_SLIPPAGE, +} from "../../common/constants/contract.js"; import { getEvmSignerAccount } from "../../common/utils/chain.js"; import { buildEvmMessageData, @@ -161,8 +165,8 @@ export async function getSendTokenAdapterFees( extraArgs: buildSendTokenExtraArgsWhenRemoving(spokeTokenData.spokeAddress, hubTokenData.token, amount), }; - // get return adapter fee - return await hubBridgeRouter.read.getSendFee([returnMessage]); + // get return adapter fee increased by 1% + return increaseByPercent(await hubBridgeRouter.read.getSendFee([returnMessage]), RECEIVER_VALUE_SLIPPAGE); } export async function getLoanTypeInfo( diff --git a/src/common/utils/math-lib.ts b/src/common/utils/math-lib.ts index e467ca4..b0e5467 100644 --- a/src/common/utils/math-lib.ts +++ b/src/common/utils/math-lib.ts @@ -44,3 +44,7 @@ export function compoundEveryHour(rate: Dnum): Dnum { export const bigIntMax = (...args: Array) => args.reduce((m, e) => (e > m ? e : m)); export const bigIntMin = (...args: Array) => args.reduce((m, e) => (e < m ? e : m)); + +export const increaseByPercent = (value: bigint, percent: number) => { + return value + (value * BigInt(10_000 * percent)) / BigInt(10_000); +};