@@ -68,33 +68,33 @@ const Staking: NextPage = () => {
6868 const [ mainStakeAccount , setMainStakeAccount ] = useState < StakeAccount > ( )
6969 const [ balance , setBalance ] = useState < PythBalance > ( )
7070 const [ pythBalance , setPythBalance ] = useState < PythBalance > (
71- new PythBalance ( new BN ( 0 ) )
71+ PythBalance . zero ( )
7272 )
7373 const [ lockedPythBalance , setLockedPythBalance ] = useState < PythBalance > (
74- new PythBalance ( new BN ( 0 ) )
74+ PythBalance . zero ( )
7575 )
7676 const [ unlockedPythBalance , setUnlockedPythBalance ] = useState < PythBalance > (
77- new PythBalance ( new BN ( 0 ) )
77+ PythBalance . zero ( )
7878 )
7979 const [ unvestedTotalPythBalance , setUnvestedTotalPythBalance ] =
80- useState < PythBalance > ( new PythBalance ( new BN ( 0 ) ) )
80+ useState < PythBalance > ( PythBalance . zero ( ) )
8181 const [ unvestedLockingPythBalance , setUnvestedLockingPythBalance ] =
82- useState < PythBalance > ( new PythBalance ( new BN ( 0 ) ) )
82+ useState < PythBalance > ( PythBalance . zero ( ) )
8383 const [ unvestedLockedPythBalance , setUnvestedLockedPythBalance ] =
84- useState < PythBalance > ( new PythBalance ( new BN ( 0 ) ) )
84+ useState < PythBalance > ( PythBalance . zero ( ) )
8585 const [ unvestedPreUnlockingPythBalance , setUnvestedPreUnlockingPythBalance ] =
86- useState < PythBalance > ( new PythBalance ( new BN ( 0 ) ) )
86+ useState < PythBalance > ( PythBalance . zero ( ) )
8787 const [ unvestedUnlockingPythBalance , setUnvestedUnlockingPythBalance ] =
88- useState < PythBalance > ( new PythBalance ( new BN ( 0 ) ) )
88+ useState < PythBalance > ( PythBalance . zero ( ) )
8989 const [ unvestedUnlockedPythBalance , setUnvestedUnlockedPythBalance ] =
90- useState < PythBalance > ( new PythBalance ( new BN ( 0 ) ) )
90+ useState < PythBalance > ( PythBalance . zero ( ) )
9191 const [ lockingPythBalance , setLockingPythBalance ] = useState < PythBalance > ( )
9292 const [ unlockingPythBalance , setUnlockingPythBalance ] =
9393 useState < PythBalance > ( )
9494 const [ amount , setAmount ] = useState < string > ( '' )
9595 const [ currentTab , setCurrentTab ] = useState < TabEnum > ( TabEnum . Lock )
9696 const [ nextVestingAmount , setNextVestingAmount ] = useState < PythBalance > (
97- new PythBalance ( new BN ( 0 ) )
97+ PythBalance . zero ( )
9898 )
9999 const [ nextVestingDate , setNextVestingDate ] = useState < Date > ( )
100100 const [ currentVestingAccountState , setCurrentVestingAccountState ] =
@@ -196,18 +196,18 @@ const Staking: NextPage = () => {
196196 ] )
197197
198198 const resetBalance = ( ) => {
199- setPythBalance ( new PythBalance ( new BN ( 0 ) ) )
200- setLockingPythBalance ( new PythBalance ( new BN ( 0 ) ) )
201- setLockedPythBalance ( new PythBalance ( new BN ( 0 ) ) )
202- setUnlockingPythBalance ( new PythBalance ( new BN ( 0 ) ) )
203- setUnvestedTotalPythBalance ( new PythBalance ( new BN ( 0 ) ) )
204- setUnvestedLockingPythBalance ( new PythBalance ( new BN ( 0 ) ) )
205- setUnvestedLockedPythBalance ( new PythBalance ( new BN ( 0 ) ) )
206- setUnvestedPreUnlockingPythBalance ( new PythBalance ( new BN ( 0 ) ) )
207- setUnvestedUnlockingPythBalance ( new PythBalance ( new BN ( 0 ) ) )
208- setUnvestedUnlockedPythBalance ( new PythBalance ( new BN ( 0 ) ) )
209- setUnlockedPythBalance ( new PythBalance ( new BN ( 0 ) ) )
210- setNextVestingAmount ( new PythBalance ( new BN ( 0 ) ) )
199+ setPythBalance ( PythBalance . zero ( ) )
200+ setLockingPythBalance ( PythBalance . zero ( ) )
201+ setLockedPythBalance ( PythBalance . zero ( ) )
202+ setUnlockingPythBalance ( PythBalance . zero ( ) )
203+ setUnvestedTotalPythBalance ( PythBalance . zero ( ) )
204+ setUnvestedLockingPythBalance ( PythBalance . zero ( ) )
205+ setUnvestedLockedPythBalance ( PythBalance . zero ( ) )
206+ setUnvestedPreUnlockingPythBalance ( PythBalance . zero ( ) )
207+ setUnvestedUnlockingPythBalance ( PythBalance . zero ( ) )
208+ setUnvestedUnlockedPythBalance ( PythBalance . zero ( ) )
209+ setUnlockedPythBalance ( PythBalance . zero ( ) )
210+ setNextVestingAmount ( PythBalance . zero ( ) )
211211 }
212212
213213 const refreshVestingAccountState = async ( ) => {
@@ -235,7 +235,7 @@ const Staking: NextPage = () => {
235235 return
236236 }
237237 const depositAmount = PythBalance . fromString ( amount )
238- if ( depositAmount . toBN ( ) . gt ( new BN ( 0 ) ) ) {
238+ if ( depositAmount . gt ( PythBalance . zero ( ) ) ) {
239239 try {
240240 await stakeConnection ?. depositAndLockTokens (
241241 mainStakeAccount ,
@@ -262,7 +262,7 @@ const Staking: NextPage = () => {
262262 return
263263 }
264264 const unlockAmount = PythBalance . fromString ( amount )
265- if ( unlockAmount . toBN ( ) . gt ( new BN ( 0 ) ) ) {
265+ if ( unlockAmount . gt ( PythBalance . zero ( ) ) ) {
266266 if ( mainStakeAccount ) {
267267 try {
268268 await stakeConnection ?. unlockTokens ( mainStakeAccount , unlockAmount )
@@ -291,7 +291,7 @@ const Staking: NextPage = () => {
291291 return
292292 }
293293 const withdrawAmount = PythBalance . fromString ( amount )
294- if ( withdrawAmount . toBN ( ) . gt ( new BN ( 0 ) ) ) {
294+ if ( withdrawAmount . gt ( PythBalance . zero ( ) ) ) {
295295 if ( mainStakeAccount ) {
296296 try {
297297 await stakeConnection ?. withdrawTokens (
@@ -322,7 +322,7 @@ const Staking: NextPage = () => {
322322 setLockingPythBalance ( locked . locking )
323323 setLockedPythBalance ( locked . locked )
324324 setUnlockingPythBalance (
325- new PythBalance ( locked . unlocking . toBN ( ) . add ( locked . preunlocking . toBN ( ) ) )
325+ locked . unlocking . add ( locked . preunlocking )
326326 )
327327 setUnvestedTotalPythBalance ( unvested . total )
328328 setUnvestedLockingPythBalance ( unvested . locking )
@@ -413,9 +413,9 @@ const Staking: NextPage = () => {
413413 try {
414414 await stakeConnection . unlockBeforeVestingEvent ( mainStakeAccount )
415415 toast . success (
416- `${ new PythBalance (
417- nextVestingAmount . toBN ( ) . add ( lockedPythBalance . toBN ( ) )
418- ) . toString ( ) } tokens have started unlocking. You will be able to withdraw them after ${ nextVestingDate ?. toLocaleString ( ) } `
416+ `${
417+ nextVestingAmount . add ( lockedPythBalance )
418+ . toString ( ) } tokens have started unlocking. You will be able to withdraw them after ${ nextVestingDate ?. toLocaleString ( ) } `
419419 )
420420 } catch ( e ) {
421421 toast . error ( capitalizeFirstLetter ( e . message ) )
@@ -777,7 +777,7 @@ const Staking: NextPage = () => {
777777 tokens.
778778 </ p >
779779 { lockingPythBalance &&
780- lockingPythBalance . toString ( ) !== '0' ? (
780+ ! lockingPythBalance . isZero ( ) ? (
781781 < p className = "font-poppins text-sm text-scampi" >
782782 { lockingPythBalance . toString ( ) } tokens will be locked
783783 from the beginning of the next epoch.
@@ -845,7 +845,7 @@ const Staking: NextPage = () => {
845845 unlocked tokens.
846846 </ p >
847847 { unlockingPythBalance &&
848- unlockingPythBalance . toString ( ) !== '0' ? (
848+ ! unlockingPythBalance . isZero ( ) ? (
849849 < p className = "font-poppins text-sm text-scampi" >
850850 { unlockingPythBalance . toString ( ) } tokens have to go
851851 through a cool-down period for 2 epochs before they can
@@ -906,7 +906,7 @@ const Staking: NextPage = () => {
906906 < p className = "font-poppins text-sm text-scampi" >
907907 You currently have { unvestedTotalPythBalance ?. toString ( ) } { ' ' }
908908 unvested tokens.{ ' ' }
909- { unvestedTotalPythBalance . toString ( ) !== '0'
909+ { ! unvestedTotalPythBalance . isZero ( )
910910 ? `${ nextVestingAmount . toString ( ) } tokens
911911 will vest on ${ nextVestingDate ?. toLocaleString ( ) } .`
912912 : null }
@@ -950,7 +950,7 @@ const Staking: NextPage = () => {
950950 < div className = "mx-auto flex text-sm sm:m-0" >
951951 { lockedPythBalance ?. toString ( ) } { ' ' }
952952 { lockingPythBalance &&
953- lockingPythBalance . toString ( ) !== '0' ? (
953+ ! lockingPythBalance . isZero ( ) ? (
954954 < div >
955955 < Tooltip content = "These tokens will be locked from the beginning of the next epoch." >
956956 < div className = "mx-1 text-scampi" >
@@ -1002,7 +1002,7 @@ const Staking: NextPage = () => {
10021002 < div className = "mx-auto flex text-sm sm:m-0" >
10031003 { unlockedPythBalance ?. toString ( ) } { ' ' }
10041004 { unlockingPythBalance &&
1005- unlockingPythBalance . toString ( ) !== '0' ? (
1005+ ! unlockingPythBalance . isZero ( ) ? (
10061006 < div >
10071007 < Tooltip content = "These tokens have to go through a cool-down period for 2 epochs before they can be withdrawn." >
10081008 < div className = "mx-1 text-scampi" >
0 commit comments