Skip to content

Commit

Permalink
Change swift comepnsation model
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlotfi authored and mrlotfi committed Dec 27, 2024
1 parent 7a13fd4 commit d219ea5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/utils/fees.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChainId, isEVMChain } from '@certusone/wormhole-sdk';
import axios from 'axios';
import * as mathjs from 'mathjs';
import {
Expand Down Expand Up @@ -238,10 +239,29 @@ export class FeeService {
unlockFee = unlock + batchPostCost;
}

const compensationsSol = {
evmToSolana: 0.0009,
evmToEvm: 0.0031,
solanaToEvm: 0.004,
};

let compensation = 0.0;
if (isEVMChain(qr.fromChainId as ChainId) && qr.toChainId === CHAIN_ID_SOLANA) {
compensation = compensationsSol.evmToSolana;
} else if (isEVMChain(qr.fromChainId as ChainId) && isEVMChain(qr.toChainId as ChainId)) {
compensation = compensationsSol.evmToEvm;
} else if (qr.fromChainId === CHAIN_ID_SOLANA && isEVMChain(qr.toChainId as ChainId)) {
compensation = compensationsSol.solanaToEvm;
}

let totalCost = fulfillCost + unlockFee;
totalCost = totalCost - (compensation * solPrice) / fromTokenPrice;
totalCost = Math.max(0.0, totalCost);

return {
fulfillCost: fulfillCost, //fulfillCost,
unlockSource: unlockFee, //unlockFee,
fulfillAndUnlock: fulfillCost + unlockFee,
fulfillAndUnlock: totalCost,
fromTokenPrice: fromTokenPrice,
};
}
Expand Down

0 comments on commit d219ea5

Please sign in to comment.