Skip to content

Commit

Permalink
fix(earn): use statsig dynamic config for app fee (#6062)
Browse files Browse the repository at this point in the history
### Description

Uses the Statsig dynamic config to determine if swap fees should be
waived.

### Test plan

- [x] Unit tests updated
- [x] Tested locally with current backend

### Related issues

Part of ACT-1379

### Backwards compatibility

Yes

### Network scalability

N/A
  • Loading branch information
MuckT authored Sep 21, 2024
1 parent 49761d5 commit 7c0ff79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/earn/prepareTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
} from 'src/earn/prepareTransactions'
import { isGasSubsidizedForNetwork } from 'src/earn/utils'
import { triggerShortcutRequest } from 'src/positions/saga'
import { getDynamicConfigParams } from 'src/statsig'
import { StatsigDynamicConfigs } from 'src/statsig/types'
import { TokenBalance } from 'src/tokens/slice'
import { NetworkId } from 'src/transactions/types'
import { prepareTransactions } from 'src/viem/prepareTransactions'
Expand Down Expand Up @@ -57,6 +59,14 @@ describe('prepareTransactions', () => {
feeCurrency: mockFeeCurrency,
}))
jest.mocked(isGasSubsidizedForNetwork).mockReturnValue(false)
jest.mocked(getDynamicConfigParams).mockImplementation(({ configName }) => {
if (configName === StatsigDynamicConfigs.SWAP_CONFIG) {
return {
enableAppFee: true,
}
}
return {} as any
})
})

describe('prepareDepositTransactions', () => {
Expand Down Expand Up @@ -198,6 +208,7 @@ describe('prepareTransactions', () => {
expect(triggerShortcutRequest).toHaveBeenCalledWith('https://hooks.api', {
address: '0x1234',
appId: mockEarnPositions[0].appId,
enableSwapFee: true,
networkId: mockEarnPositions[0].networkId,
shortcutId: 'swap-deposit',
swapFromToken: {
Expand Down
7 changes: 7 additions & 0 deletions src/earn/prepareTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { triggerShortcutRequest } from 'src/positions/saga'
import { RawShortcutTransaction } from 'src/positions/slice'
import { rawShortcutTransactionsToTransactionRequests } from 'src/positions/transactions'
import { EarnPosition } from 'src/positions/types'
import { getDynamicConfigParams } from 'src/statsig'
import { DynamicConfigs } from 'src/statsig/constants'
import { StatsigDynamicConfigs } from 'src/statsig/types'
import { SwapTransaction } from 'src/swap/types'
import { TokenBalance } from 'src/tokens/slice'
import Logger from 'src/utils/Logger'
Expand All @@ -33,6 +36,9 @@ export async function prepareDepositTransactions({
hooksApiUrl: string
shortcutId: EarnDepositMode
}) {
const enableSwapFee = getDynamicConfigParams(
DynamicConfigs[StatsigDynamicConfigs.SWAP_CONFIG]
).enableAppFee
const args =
shortcutId === 'deposit'
? {
Expand All @@ -51,6 +57,7 @@ export async function prepareDepositTransactions({
address: token.address,
isNative: token.isNative ?? false,
},
enableSwapFee,
}

const {
Expand Down

0 comments on commit 7c0ff79

Please sign in to comment.