Skip to content

Commit

Permalink
Merge pull request #1569 from ReflectiveChimp/fix/zap-fee-skip-zero-a…
Browse files Browse the repository at this point in the history
…ddress

Skip 0x0 address when determining zap fee receiver
  • Loading branch information
ReflectiveChimp authored Oct 21, 2024
2 parents 09c5992 + fcdc9e1 commit 4c7ddb1
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/api/zap/fees.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
import { addressBook } from '../../../packages/address-book/src/address-book';
import { ApiChain } from '../../utils/chain';
import { ProviderId } from './swap/providers';
import { ZERO_ADDRESS } from '../../utils/address';

export type ZapFee = {
value: number;
receiver?: string;
};

const DEFAULT_ZAP_FEE = 0.0005;
export const getZapProviderFee = (provider: ProviderId, chain: ApiChain) => {
if (provider === 'odos')

export const getZapProviderFee = (provider: ProviderId, chain: ApiChain): ZapFee => {
if (provider === 'odos') {
// It's static to the odos code config, we can't make it dynamic
return {
value: DEFAULT_ZAP_FEE,
}; //It's static to the odos code config, we can't make it dynamic
};
}

const beefyPlatform = addressBook[chain].platforms.beefyfinance;
if (!beefyPlatform) {
throw new Error('No Beefy Platform found for chain ' + chain);
throw new Error(`No Beefy Platform found for chain ${chain}`);
}

const receiver = [
beefyPlatform.treasurySwapper,
beefyPlatform.treasuryMultisig,
beefyPlatform.treasury,
].find(a => !!a && a !== ZERO_ADDRESS);

if (!receiver) {
throw new Error(
`No fee receiver (treasurySwapper, or treasuryMultisig, or treasury) found for ${provider} on ${chain}`
);
}

const receiver = beefyPlatform.treasurySwapper || beefyPlatform.treasuryMultisig || beefyPlatform.treasury;
return {
value: DEFAULT_ZAP_FEE,
receiver: receiver,
Expand Down

0 comments on commit 4c7ddb1

Please sign in to comment.