Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate with divvy protocol #6492

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
de4243d
chore: add redux params
kathaypacific Feb 6, 2025
0c90d29
fix: type
kathaypacific Feb 11, 2025
dcbf216
fix: knip
kathaypacific Feb 11, 2025
58c1886
fix: ensure transaction sagas can handle registration transactions
kathaypacific Feb 12, 2025
cbbc09a
feat: integrate with divvy protocol
kathaypacific Feb 12, 2025
d3984dd
chore: rename registrations variable
kathaypacific Feb 12, 2025
1b50b25
fix: type safe protocol ids
kathaypacific Feb 12, 2025
7c13a3c
Merge branch 'kathy/fl-integration-1' into kathy/fl-integration-2
kathaypacific Feb 12, 2025
883b938
fix: add try catch
kathaypacific Feb 12, 2025
bb9564e
fix: root schema
kathaypacific Feb 12, 2025
b887a35
Merge branch 'kathy/fl-integration-1' into kathy/fl-integration-2
kathaypacific Feb 12, 2025
eb22bcd
Merge branch 'kathy/fl-integration-2' into kathy/fl-integration-3
kathaypacific Feb 12, 2025
47e2a1d
fix: rename
kathaypacific Feb 12, 2025
ae376ff
fix: lint
kathaypacific Feb 12, 2025
e1627e9
chore: add first tests
kathaypacific Feb 12, 2025
87e2ff0
Merge branch 'main' into kathy/fl-integration-2
kathaypacific Feb 12, 2025
0761450
chore: add extra test
kathaypacific Feb 12, 2025
dd13d96
Merge branch 'kathy/fl-integration-2' into kathy/fl-integration-3
kathaypacific Feb 12, 2025
41707f0
chore: add more tests
kathaypacific Feb 12, 2025
e8c969e
fix: nonce
kathaypacific Feb 12, 2025
c7663f4
fix: test title
kathaypacific Feb 12, 2025
77397ce
chore: add test
kathaypacific Feb 12, 2025
80f271b
chore: test
kathaypacific Feb 12, 2025
9fa65f9
fix: comments
kathaypacific Feb 12, 2025
56ae601
Merge branch 'main' into kathy/fl-integration-3
kathaypacific Feb 12, 2025
b26e9e6
chore: spawn tx watcher
kathaypacific Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ export const showNotificationSpotlightSelector = (state: RootState) =>
export const hideWalletBalancesSelector = (state: RootState) => state.app.hideBalances

export const pendingDeepLinkSelector = (state: RootState) => state.app.pendingDeepLinks[0] ?? null

export const divviRegistrationsSelector = (state: RootState) => state.app.divviRegistrations
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LoggerLevel } from 'src/utils/LoggerLevels'
// eslint-disable-next-line import/no-relative-packages
import { TORUS_SAPPHIRE_NETWORK } from '@toruslabs/constants'
import { LaunchArguments } from 'react-native-launch-arguments'
import { SupportedProtocolId } from 'src/divviProtocol/constants'
import { HomeActionName } from 'src/home/types'
import { ToggleableOnboardingFeatures } from 'src/onboarding/types'
import { stringToBoolean } from 'src/utils/parsing'
Expand Down Expand Up @@ -226,3 +227,6 @@ export const ENABLED_QUICK_ACTIONS = (
export const FETCH_FIATCONNECT_QUOTES = true

export const WALLETCONNECT_UNIVERSAL_LINK = 'https://valoraapp.com/wc'

export const DIVVI_PROTOCOL_IDS: SupportedProtocolId[] = []
export const DIVVI_REFERRER_ID: string | undefined = undefined
251 changes: 251 additions & 0 deletions src/divviProtocol/abi/Registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
export const registryContractAbi = [
{
inputs: [
{
internalType: 'string',
name: 'protocolId',
type: 'string',
},
{
internalType: 'string',
name: 'referrerId',
type: 'string',
},
],
name: 'ReferrerNotRegistered',
type: 'error',
},
{
inputs: [
{
internalType: 'string',
name: 'protocolId',
type: 'string',
},
{
internalType: 'string',
name: 'referrerId',
type: 'string',
},
{
internalType: 'address',
name: 'userAddress',
type: 'address',
},
],
name: 'UserAlreadyRegistered',
type: 'error',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'string',
name: 'protocolId',
type: 'string',
},
{
indexed: true,
internalType: 'string',
name: 'referrerId',
type: 'string',
},
{
indexed: true,
internalType: 'address',
name: 'userAddress',
type: 'address',
},
],
name: 'ReferralRegistered',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'string',
name: 'referrerId',
type: 'string',
},
{
indexed: true,
internalType: 'string[]',
name: 'protocolIds',
type: 'string[]',
},
{
indexed: false,
internalType: 'uint256[]',
name: 'rewardRates',
type: 'uint256[]',
},
{
indexed: false,
internalType: 'address',
name: 'rewardAddress',
type: 'address',
},
],
name: 'ReferrerRegistered',
type: 'event',
},
{
inputs: [
{
internalType: 'string',
name: 'referrerId',
type: 'string',
},
],
name: 'getProtocols',
outputs: [
{
internalType: 'string[]',
name: '',
type: 'string[]',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'string',
name: 'protocolId',
type: 'string',
},
],
name: 'getReferrers',
outputs: [
{
internalType: 'string[]',
name: '',
type: 'string[]',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'string',
name: 'referrerId',
type: 'string',
},
],
name: 'getRewardAddress',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'string',
name: 'protocolId',
type: 'string',
},
{
internalType: 'string',
name: 'referrerId',
type: 'string',
},
],
name: 'getRewardRate',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'string',
name: 'protocolId',
type: 'string',
},
{
internalType: 'string',
name: 'referrerId',
type: 'string',
},
],
name: 'getUsers',
outputs: [
{
internalType: 'address[]',
name: '',
type: 'address[]',
},
{
internalType: 'uint256[]',
name: '',
type: 'uint256[]',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'string',
name: 'referrerId',
type: 'string',
},
{
internalType: 'string',
name: 'protocolId',
type: 'string',
},
],
name: 'registerReferral',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'string',
name: '_referrerId',
type: 'string',
},
{
internalType: 'string[]',
name: '_protocolIds',
type: 'string[]',
},
{
internalType: 'uint256[]',
name: '_rewardRates',
type: 'uint256[]',
},
{
internalType: 'address',
name: '_rewardAddress',
type: 'address',
},
],
name: 'registerReferrer',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
] as const
8 changes: 8 additions & 0 deletions src/divviProtocol/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { Address, keccak256, stringToHex } from 'viem'

export const REGISTRY_CONTRACT_ADDRESS: Address = '0x5a1a1027ac1d828e7415af7d797fba2b0cdd5575'

const supportedProtocolIds = [
'beefy',
'tether',
Expand All @@ -17,3 +21,7 @@ const supportedProtocolIds = [
] as const

export type SupportedProtocolId = (typeof supportedProtocolIds)[number]

export const supportedProtocolIdHashes = Object.fromEntries(
supportedProtocolIds.map((protocol) => [keccak256(stringToHex(protocol)), protocol])
)
Loading