-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…aim-contract feat: [GSW-469] Execute a Reward Claim Contract
- Loading branch information
Showing
11 changed files
with
226 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useWallet } from "@hooks/wallet/use-wallet"; | ||
import { PoolPositionModel } from "@models/position/pool-position-model"; | ||
import { useCallback } from "react"; | ||
import { useGnoswapContext } from "./use-gnoswap-context"; | ||
|
||
export const usePosition = (positions: PoolPositionModel[]) => { | ||
const { positionRepository } = useGnoswapContext(); | ||
const { account } = useWallet(); | ||
|
||
const claimAll = useCallback(() => { | ||
const address = account?.address; | ||
if (!address) { | ||
return null; | ||
} | ||
|
||
const lpTokenIds = positions | ||
.filter( | ||
position => | ||
position.unclaimedFee0Amount + position.unclaimedFee1Amount > 0, | ||
) | ||
.map(position => position.lpTokenId); | ||
return positionRepository.claimAll({ | ||
lpTokenIds, | ||
receipient: address, | ||
}); | ||
}, [account?.address, positionRepository, positions]); | ||
|
||
return { | ||
claimAll, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/web/src/repositories/position/position-repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import { PositionModel } from "@models/position/position-model"; | ||
import { ClaimAllRequest } from "./request/claim-all-request"; | ||
import { DecreaseLiquidityReqeust } from "./request/decrease-liquidity-request"; | ||
|
||
export interface PositionRepository { | ||
getPositionsByAddress: (address: string) => Promise<PositionModel[]>; | ||
|
||
claimAll: (request: ClaimAllRequest) => Promise<string | null>; | ||
|
||
decreaseLiquidity: ( | ||
request: DecreaseLiquidityReqeust, | ||
) => Promise<string | null>; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/web/src/repositories/position/request/claim-all-request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface ClaimAllRequest { | ||
lpTokenIds: string[]; | ||
|
||
receipient: string; | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/web/src/repositories/position/request/decrease-liquidity-request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface DecreaseLiquidityReqeust { | ||
lpTokenId: string; | ||
|
||
liquidity: string; | ||
|
||
amountAMin: string; | ||
|
||
amountBMax: string; | ||
|
||
deadline?: string; | ||
|
||
caller: string; | ||
} |