Skip to content

Commit

Permalink
Fix reward splitters (#154)
Browse files Browse the repository at this point in the history
* [temporary-fix] changes

* [temporary-fix] change getRewardSplitters

* [temporary-fix] change addresses
  • Loading branch information
Cast0001 authored Aug 23, 2024
1 parent 9b338bb commit a8cee59
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ To use a reward splitter, its address should be added to the vault as a fee reci
| Name | Type | Type | Description |
|------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------------|
| vaultAddress | `string` | **Yes** | The address of the vault |
| owner | `string` | **Yes** | The owner of the reward splitter |
| rewardSplitterAddress | `string` | **No** | The address of the reward splitter (optional) |
| vaultAddress | `string` | **Yes** | The address of the vault |
| id | `string` | **No** | Reward splitter address |
| owner | `string` | **No** | The owner of the reward splitter |
#### Returns:
Expand Down Expand Up @@ -450,7 +450,7 @@ type Output = {
```ts
await sdk.vault.getRewardSplitters({
owner: '0x...',
owner: '0x...', // OR id: '0x...'
vaultAddress: '0x...',
})
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ export const commonLogic = async (values: UpdateFeeRecipientsInput) => {

if (!oldFeeRecipients) {
const { rewardSplitters } = await vault.requests.getRewardSplitters({
owner: userAddress,
options,
id: rewardSplitterAddress,
vaultAddress,
rewardSplitterAddress,
options,
})

if (rewardSplitters) {
Expand Down
27 changes: 17 additions & 10 deletions src/methods/vault/requests/getRewardSplitters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,35 @@ import modifyRewardSplitters from './modifyRewardSplitters'


type GetRewardSplittersInput = {
owner: string
id?: string
owner?: string
vaultAddress: string
rewardSplitterAddress?: string
options: StakeWise.Options
}

const getRewardSplitters = (input: GetRewardSplittersInput) => {
const { owner, vaultAddress, rewardSplitterAddress, options } = input
const { id, owner, vaultAddress, options } = input

validateArgs.address({ owner, vaultAddress })

if (typeof rewardSplitterAddress !== 'undefined') {
validateArgs.address({ rewardSplitterAddress })
if (!id && !owner) {
throw new Error('You must pass either ID or OWNER to get a response')
}

validateArgs.address({ vaultAddress })

const where = {
vault: vaultAddress.toLowerCase(),
owner: owner.toLowerCase(),
} as RewardSplittersQueryVariables['where']

if (rewardSplitterAddress) {
where.id = rewardSplitterAddress.toLowerCase()
if (typeof owner !== 'undefined') {
validateArgs.address({ owner })

where.owner = owner.toLowerCase()
}

if (typeof id !== 'undefined') {
validateArgs.address({ id })

where.id = id.toLowerCase()
}

return fetchRewardSplittersQuery({
Expand Down

0 comments on commit a8cee59

Please sign in to comment.