-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from lidofinance/feature/si-772-withdrawals-re…
…quest-demo Feature/si 772 withdrawals request demo
- Loading branch information
Showing
10 changed files
with
220 additions
and
32 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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { CoreDemo } from './core'; | ||
import { StakeDemo } from './stake'; | ||
import { WithdrawalsRequestDemo, WithdrawalsViewsDemo } from './withdrawals'; | ||
|
||
export const Demo = () => { | ||
return ( | ||
<> | ||
<StakeDemo /> | ||
<CoreDemo /> | ||
<WithdrawalsRequestDemo /> | ||
<WithdrawalsViewsDemo /> | ||
</> | ||
); | ||
}; |
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,2 @@ | ||
export { WithdrawalsRequestDemo } from './request'; | ||
export { WithdrawalsViewsDemo } from './views'; |
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,90 @@ | ||
import { Accordion } from '@lidofinance/lido-ui'; | ||
import { useWeb3 } from '@reef-knot/web3-react'; | ||
import { Action } from 'components/action'; | ||
import TokenInput from 'components/tokenInput/tokenInput'; | ||
import { useLidoSDK } from 'providers/sdk'; | ||
import { useState } from 'react'; | ||
import { parseEther } from '@ethersproject/units'; | ||
|
||
export const WithdrawalsRequestDemo = () => { | ||
const { account: web3account = '0x0' } = useWeb3(); | ||
const [requestValue, setRequestValue] = useState('0.001'); | ||
const { withdrawals } = useLidoSDK(); | ||
|
||
const account = web3account as `0x{string}`; | ||
|
||
return ( | ||
<Accordion summary="Withdrawals requests"> | ||
<Action | ||
title="Request stETH" | ||
action={() => | ||
withdrawals.request({ | ||
account, | ||
amount: requestValue, | ||
requests: [BigInt(parseEther(requestValue).toString())], | ||
token: 'stETH', | ||
}) | ||
} | ||
> | ||
<TokenInput | ||
label="value" | ||
value={requestValue} | ||
placeholder="0.0" | ||
onChange={(e) => setRequestValue(e.currentTarget.value)} | ||
/> | ||
</Action> | ||
<Action | ||
title="Request Without Permit" | ||
action={() => | ||
withdrawals.requestWithoutPermit({ | ||
account, | ||
requests: [BigInt(parseEther(requestValue).toString())], | ||
token: 'stETH', | ||
}) | ||
} | ||
/> | ||
<Action | ||
title="Approve stETH" | ||
action={() => | ||
withdrawals.approval.approveSteth({ | ||
account, | ||
amount: requestValue, | ||
}) | ||
} | ||
/> | ||
<Action | ||
title="Approve wstETH" | ||
action={() => | ||
withdrawals.approval.approveWsteth({ | ||
account, | ||
amount: requestValue, | ||
}) | ||
} | ||
/> | ||
<Action | ||
title="Get allowance stETH" | ||
action={() => | ||
withdrawals.approval.getAllowanceByToken({ account, token: 'stETH' }) | ||
} | ||
/> | ||
<Action | ||
title="Get allowance wsStETH" | ||
action={() => | ||
withdrawals.approval.getAllowanceByToken({ account, token: 'wstETH' }) | ||
} | ||
/> | ||
<Action | ||
title="Check stETH allowance by amount" | ||
action={() => | ||
withdrawals.approval.checkAllowanceSteth(requestValue, account) | ||
} | ||
/> | ||
<Action | ||
title="Check wstETH allowance by amount" | ||
action={() => | ||
withdrawals.approval.checkAllowanceWsteth(requestValue, account) | ||
} | ||
/> | ||
</Accordion> | ||
); | ||
}; |
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,45 @@ | ||
import { Accordion } from '@lidofinance/lido-ui'; | ||
import { useWeb3 } from '@reef-knot/web3-react'; | ||
import { Action } from 'components/action'; | ||
import { useLidoSDK } from 'providers/sdk'; | ||
|
||
export const WithdrawalsViewsDemo = () => { | ||
const { account: web3account = '0x0' } = useWeb3(); | ||
const { withdrawals } = useLidoSDK(); | ||
|
||
const account = web3account as `0x{string}`; | ||
|
||
return ( | ||
<Accordion summary="Withdrawals views"> | ||
<Action | ||
title="Get request ids" | ||
action={() => withdrawals.views.getWithdrawalRequestsIds({ account })} | ||
/> | ||
<Action | ||
title="Get last checkpoint index" | ||
action={() => withdrawals.views.getLastCheckpointIndex()} | ||
/> | ||
<Action | ||
title="Get unfinalized stETH" | ||
action={() => withdrawals.views.getUnfinalizedStETH()} | ||
/> | ||
<Action | ||
title="Get MIN stETH withdrawal amount" | ||
action={() => withdrawals.views.minStethWithdrawalAmount()} | ||
/> | ||
<Action | ||
title="Get MAX stETH withdrawal amount" | ||
action={() => withdrawals.views.maxStethWithdrawalAmount()} | ||
/> | ||
<Action title="Is paused" action={() => withdrawals.views.isPaused()} /> | ||
<Action | ||
title="Is Bunker mode" | ||
action={() => withdrawals.views.isBunkerModeActive()} | ||
/> | ||
<Action | ||
title="Is Turbo mode" | ||
action={() => withdrawals.views.isTurboModeActive()} | ||
/> | ||
</Accordion> | ||
); | ||
}; |