Skip to content

Commit

Permalink
allow for custom zap fee amounts per chain
Browse files Browse the repository at this point in the history
  • Loading branch information
seguido committed Sep 19, 2024
1 parent 5589e1b commit a30d84c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/api/zap/api/kyber/KyberApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ import { ApiResponse, isErrorApiResponse } from '../common';
import { ApiChain } from '../../../../utils/chain';
import { addressBook } from '../../../../../packages/address-book/src/address-book';

const DEFAULT_ZAP_FEE = 0.0005;
const customFeeConfig: Partial<Record<ApiChain, number>> = {};
export class KyberApi implements IKyberApi {
readonly feeReceiver: string;
readonly ZAP_FEE = 0.0005;
readonly ZAP_FEE: number;
constructor(protected readonly baseUrl: string, protected readonly clientId: string, chain: ApiChain) {
const beefyPlatform = addressBook[chain].platforms.beefyfinance;
if (!beefyPlatform) {
throw new Error(`No Beefy platform found for chain ${chain}`);
}
this.feeReceiver =
beefyPlatform.treasurySwapper || beefyPlatform.treasuryMultisig || beefyPlatform.treasury;
this.ZAP_FEE = customFeeConfig[chain] || DEFAULT_ZAP_FEE;
}

protected buildUrl<T extends {}>(path: string, request?: T) {
Expand Down
6 changes: 5 additions & 1 deletion src/api/zap/api/one-inch/OneInchSwapApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ import { isErrorApiResponse, ApiResponse } from '../common';
import { ApiChain } from '../../../../utils/chain';
import { addressBook } from '../../../../../packages/address-book/src/address-book';

const DEFAULT_ZAP_FEE = 0.0005;
const customFeeConfig: Partial<Record<ApiChain, number>> = {};

export class OneInchSwapApi implements IOneInchSwapApi {
readonly feeReceiver: string;
readonly ZAP_FEE = 0.0005;
readonly ZAP_FEE: number;
constructor(protected readonly baseUrl: string, protected readonly apiKey: string, chain: ApiChain) {
const beefyPlatform = addressBook[chain].platforms.beefyfinance;
if (!beefyPlatform) {
throw new Error(`No Beefy platform found for chain ${chain}`);
}
this.feeReceiver =
beefyPlatform.treasurySwapper || beefyPlatform.treasuryMultisig || beefyPlatform.treasury;
this.ZAP_FEE = customFeeConfig[chain] || DEFAULT_ZAP_FEE;
}

protected buildUrl<T extends {}>(path: string, request?: T) {
Expand Down

0 comments on commit a30d84c

Please sign in to comment.