Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
offshiftXFT
protocol-main
Commits
7668a5a2
Commit
7668a5a2
authored
3 years ago
by
XFT-dev
Browse files
Options
Download
Email Patches
Plain Diff
added bsc code
parent
855c2207
master
No related merge requests found
Changes
189
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
6641 additions
and
0 deletions
+6641
-0
BSC/farm/frontend/package.json
BSC/farm/frontend/package.json
+24
-0
BSC/farm/frontend/pages/_abi.js
BSC/farm/frontend/pages/_abi.js
+514
-0
BSC/farm/frontend/pages/_app.js
BSC/farm/frontend/pages/_app.js
+8
-0
BSC/farm/frontend/pages/index.css
BSC/farm/frontend/pages/index.css
+23
-0
BSC/farm/frontend/pages/index.js
BSC/farm/frontend/pages/index.js
+356
-0
BSC/farm/frontend/postcss.config.js
BSC/farm/frontend/postcss.config.js
+8
-0
BSC/farm/frontend/public/favicon.ico
BSC/farm/frontend/public/favicon.ico
+0
-0
BSC/farm/frontend/tailwind.config.js
BSC/farm/frontend/tailwind.config.js
+12
-0
BSC/farm/frontend/yarn.lock
BSC/farm/frontend/yarn.lock
+5696
-0
No files found.
BSC/farm/frontend/package.json
0 → 100644
View file @
7668a5a2
{
"name"
:
"with-tailwindcss"
,
"version"
:
"0.1.0"
,
"private"
:
true
,
"scripts"
:
{
"dev"
:
"next dev"
,
"build"
:
"next build && next export"
,
"start"
:
"next start"
},
"dependencies"
:
{
"@headlessui/react"
:
"^1.3.0"
,
"@heroicons/react"
:
"^1.0.1"
,
"@walletconnect/web3-provider"
:
"^1.4.1"
,
"next"
:
"latest"
,
"react"
:
"^17.0.2"
,
"react-dom"
:
"^17.0.2"
,
"web3"
:
"^1.4.0"
},
"devDependencies"
:
{
"autoprefixer"
:
"^10.2.6"
,
"postcss"
:
"^8.3.5"
,
"tailwindcss"
:
"^2.2.4"
}
}
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/pages/_abi.js
0 → 100644
View file @
7668a5a2
let
lp
=
[
{
"
inputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
constructor
"
},
{
"
anonymous
"
:
false
,
"
inputs
"
:
[
{
"
indexed
"
:
true
,
"
internalType
"
:
"
address
"
,
"
name
"
:
"
owner
"
,
"
type
"
:
"
address
"
},
{
"
indexed
"
:
true
,
"
internalType
"
:
"
address
"
,
"
name
"
:
"
spender
"
,
"
type
"
:
"
address
"
},
{
"
indexed
"
:
false
,
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
value
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
Approval
"
,
"
type
"
:
"
event
"
},
{
"
anonymous
"
:
false
,
"
inputs
"
:
[
{
"
indexed
"
:
true
,
"
internalType
"
:
"
address
"
,
"
name
"
:
"
from
"
,
"
type
"
:
"
address
"
},
{
"
indexed
"
:
true
,
"
internalType
"
:
"
address
"
,
"
name
"
:
"
to
"
,
"
type
"
:
"
address
"
},
{
"
indexed
"
:
false
,
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
value
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
Transfer
"
,
"
type
"
:
"
event
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
owner
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
spender
"
,
"
type
"
:
"
address
"
}
],
"
name
"
:
"
allowance
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
""
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
spender
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
amount
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
approve
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
bool
"
,
"
name
"
:
""
,
"
type
"
:
"
bool
"
}
],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
account
"
,
"
type
"
:
"
address
"
}
],
"
name
"
:
"
balanceOf
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
""
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
decimals
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint8
"
,
"
name
"
:
""
,
"
type
"
:
"
uint8
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
spender
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
subtractedValue
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
decreaseAllowance
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
bool
"
,
"
name
"
:
""
,
"
type
"
:
"
bool
"
}
],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
spender
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
addedValue
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
increaseAllowance
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
bool
"
,
"
name
"
:
""
,
"
type
"
:
"
bool
"
}
],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
amount
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
mint
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
name
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
string
"
,
"
name
"
:
""
,
"
type
"
:
"
string
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
symbol
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
string
"
,
"
name
"
:
""
,
"
type
"
:
"
string
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
totalSupply
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
""
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
recipient
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
amount
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
transfer
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
bool
"
,
"
name
"
:
""
,
"
type
"
:
"
bool
"
}
],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
sender
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
recipient
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
amount
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
transferFrom
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
bool
"
,
"
name
"
:
""
,
"
type
"
:
"
bool
"
}
],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
}
]
let
farm
=
[
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
_xft
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
_LP
"
,
"
type
"
:
"
address
"
},
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
_perBlock
"
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
constructor
"
},
{
"
anonymous
"
:
false
,
"
inputs
"
:
[
{
"
indexed
"
:
true
,
"
internalType
"
:
"
address
"
,
"
name
"
:
"
previousOwner
"
,
"
type
"
:
"
address
"
},
{
"
indexed
"
:
true
,
"
internalType
"
:
"
address
"
,
"
name
"
:
"
newOwner
"
,
"
type
"
:
"
address
"
}
],
"
name
"
:
"
OwnershipTransferred
"
,
"
type
"
:
"
event
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
""
,
"
type
"
:
"
address
"
}
],
"
name
"
:
"
Stakers
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
amount
"
,
"
type
"
:
"
uint256
"
},
{
"
internalType
"
:
"
int256
"
,
"
name
"
:
"
rewardDebt
"
,
"
type
"
:
"
int256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
perBlock
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
adjustPerBlock
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
amount
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
deposit
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
emergencyWithdraw
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
getPending
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
""
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
harvest
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
lastBlock
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
""
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
owner
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
""
,
"
type
"
:
"
address
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
renounceOwnership
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
stop
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
address
"
,
"
name
"
:
"
newOwner
"
,
"
type
"
:
"
address
"
}
],
"
name
"
:
"
transferOwnership
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
update_farm
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
"
amount
"
,
"
type
"
:
"
uint256
"
}
],
"
name
"
:
"
withdraw
"
,
"
outputs
"
:
[],
"
stateMutability
"
:
"
nonpayable
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
xftPerBlock
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
""
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
},
{
"
inputs
"
:
[],
"
name
"
:
"
xftPerShare
"
,
"
outputs
"
:
[
{
"
internalType
"
:
"
uint256
"
,
"
name
"
:
""
,
"
type
"
:
"
uint256
"
}
],
"
stateMutability
"
:
"
view
"
,
"
type
"
:
"
function
"
}
]
export
{
lp
,
farm
};
export
default
()
=>
{
return
"
Show page working !
"
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/pages/_app.js
0 → 100644
View file @
7668a5a2
import
'
tailwindcss/tailwind.css
'
import
"
./index.css
"
;
function
MyApp
({
Component
,
pageProps
})
{
return
<
Component
{...
pageProps
}
/
>
}
export
default
MyApp
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/pages/index.css
0 → 100644
View file @
7668a5a2
.modal
{
max-width
:
30rem
;
background
:
#355c7d
;
/* fallback for old browsers */
background
:
-webkit-linear-gradient
(
to
right
,
#2A5470
,
#4C4177
);
/* Chrome 10-25, Safari 5.1-6 */
background
:
linear-gradient
(
to
right
,
#2A5470
,
#4C4177
);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.connect
{
background-image
:
linear-gradient
(
to
right
,
rgb
(
1
,
110
,
218
),
rgb
(
217
,
0
,
192
));
}
input
{
background
:
#355c7d
;
/* fallback for old browsers */
background
:
-webkit-linear-gradient
(
to
right
,
#2A5470
,
#4C4177
);
/* Chrome 10-25, Safari 5.1-6 */
background
:
linear-gradient
(
to
right
,
#2A5470
,
#4C4177
);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
body
{
/*background-color: #161621;*/
background
:
#355c7d
;
/* fallback for old browsers */
background
:
-webkit-linear-gradient
(
to
right
,
#2A5470
,
#4C4177
);
/* Chrome 10-25, Safari 5.1-6 */
background
:
linear-gradient
(
to
right
,
#2A5470
,
#4C4177
);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/pages/index.js
0 → 100644
View file @
7668a5a2
/* This example requires Tailwind CSS v2.0+ */
import
{
Fragment
,
useState
}
from
'
react
'
import
{
Disclosure
,
Dialog
,
Transition
}
from
'
@headlessui/react
'
;
import
{
MenuIcon
,
XIcon
}
from
'
@heroicons/react/outline
'
;
import
{
LockClosedIcon
}
from
'
@heroicons/react/solid
'
import
React
from
'
react
'
;
import
WalletConnectProvider
from
"
@walletconnect/web3-provider
"
;
import
Web3
from
"
web3
"
;
import
{
lp
,
farm
}
from
"
./_abi.js
"
;
let
lp_address
=
"
0xAD217ECc017b179cA0E238E08dF60ACf22C86C47
"
;
let
farm_address
=
"
0xC5d4B6FAd11BF3ac46862155a79DBBb7ee621D93
"
;
let
bnb_address
=
"
0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
"
;
const
provider
=
new
WalletConnectProvider
({
rpc
:
{
56
:
"
https://bsc-dataseed.binance.org/
"
,
},
});
let
web3
=
new
Web3
(
provider
);
function
classNames
(...
classes
)
{
return
classes
.
filter
(
Boolean
).
join
(
'
'
)
}
class
Header
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
navigation
:
[
{
name
:
'
Stake
'
,
href
:
'
#Farm
'
,
current
:
true
},
{
name
:
'
UnStake
'
,
href
:
'
#Withdraw
'
,
current
:
false
},
{
name
:
'
Rewards
'
,
href
:
'
#Claim
'
,
current
:
false
},
],
}
}
updateThing
=
()
=>
{
let
n
=
[
{
name
:
'
Stake
'
,
href
:
'
#Farm
'
,
current
:
true
},
{
name
:
'
UnStake
'
,
href
:
'
#Withdraw
'
,
current
:
false
},
{
name
:
'
Rewards
'
,
href
:
'
#Claim
'
,
current
:
false
},
];
n
.
forEach
(
r
=>
{
if
(
r
.
href
==
window
.
location
.
hash
)
{
r
.
current
=
true
;
}
else
{
r
.
current
=
false
;
}
});
this
.
setState
({
navigation
:
n
,
});
}
async
componentDidMount
()
{
window
.
addEventListener
(
"
hashchange
"
,
this
.
updateThing
,
false
);
}
render
()
{
return
(
<
Disclosure
as
=
"
nav
"
className
=
""
>
{({
open
})
=>
(
<>
<
div
className
=
"
max-w-7xl mx-auto px-2 sm:px-6 lg:px-8
"
>
<
div
className
=
"
relative flex items-center justify-between h-16
"
>
<
div
className
=
"
absolute inset-y-0 left-0 flex items-center sm:hidden
"
>
{
/* Mobile menu button*/
}
<
Disclosure
.
Button
className
=
"
inline-flex items-center justify-center p-2 rounded-md text-white hover:text-gray-100 hover:bg-pink-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white
"
>
<
span
className
=
"
sr-only
"
>
Open
main
menu
<
/span
>
{
open
?
(
<
XIcon
className
=
"
block h-6 w-6
"
aria
-
hidden
=
"
true
"
/>
)
:
(
<
MenuIcon
className
=
"
block h-6 w-6
"
aria
-
hidden
=
"
true
"
/>
)}
<
/Disclosure.Button
>
<
/div
>
<
div
className
=
"
flex-1 flex items-center justify-center sm:items-stretch sm:justify-start
"
>
<
div
className
=
"
flex-shrink-0 flex items-center
"
>
<
img
className
=
"
block lg:hidden h-8 w-auto
"
src
=
"
https://dashboard.offshift.io/assets/img/logo-icon.svg
"
alt
=
"
Offshift
"
/>
<
img
className
=
"
hidden lg:block h-8 w-auto
"
src
=
"
https://dashboard.offshift.io/assets/img/logo-icon.svg
"
alt
=
"
Offshift
"
/>
<
/div
>
<
div
className
=
"
hidden sm:block sm:ml-6
"
>
<
div
className
=
"
flex space-x-4
"
>
{
this
.
state
.
navigation
.
map
((
item
)
=>
(
<
a
key
=
{
item
.
name
}
href
=
{
item
.
href
}
className
=
{
classNames
(
item
.
current
?
'
bg-purple-900 text-white
'
:
'
text-white hover:bg-pink-700 hover:text-white
'
,
'
px-3 py-2 rounded-md text-sm font-medium
'
)}
aria
-
current
=
{
item
.
current
?
'
page
'
:
undefined
}
>
{
item
.
name
}
<
/a
>
))}
<
/div
>
<
/div
>
<
/div
>
{
this
.
props
.
bttn
==
"
hidden
"
?
''
:
<
button
className
=
{
classNames
(
'
connect px-3 py-2 rounded-full text-white
'
)}
onClick
=
{
this
.
props
.
connect
}
>
Connect
Wallet
<
/button
>
}
<
/div
>
<
/div
>
<
Disclosure
.
Panel
className
=
"
sm:hidden
"
>
<
div
className
=
"
px-2 pt-2 pb-3 space-y-1
"
>
{
this
.
state
.
navigation
.
map
((
item
)
=>
(
<
a
key
=
{
item
.
name
}
href
=
{
item
.
href
}
className
=
{
classNames
(
item
.
current
?
'
bg-gray-900 text-white
'
:
'
text-gray-300 hover:bg-gray-700 hover:text-white
'
,
'
block px-3 py-2 rounded-md text-base font-medium
'
)}
aria
-
current
=
{
item
.
current
?
'
page
'
:
undefined
}
>
{
item
.
name
}
<
/a
>
))}
<
/div
>
<
/Disclosure.Panel
>
<
/
>
)}
<
/Disclosure
>
)
}
}
class
Main
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
selected
:
"
Farm
"
,
step
:
"
Approve
"
,
}
this
.
handle
=
this
.
handle
.
bind
(
this
);
}
setup
()
{
this
.
props
.
update
();
}
async
claim_rewards
()
{
const
accounts
=
await
web3
.
eth
.
getAccounts
();
let
farm_contract
=
new
web3
.
eth
.
Contract
(
farm
,
farm_address
);
await
farm_contract
.
methods
.
harvest
().
send
({
from
:
accounts
[
0
]
});
}
async
withdraw_tokens
()
{
const
accounts
=
await
web3
.
eth
.
getAccounts
();
let
farm_contract
=
new
web3
.
eth
.
Contract
(
farm
,
farm_address
);
let
amount
=
web3
.
utils
.
toWei
(
tokenAmount
.
value
);
await
farm_contract
.
methods
.
withdraw
(
amount
).
send
({
from
:
accounts
[
0
]
});
}
async
handle
()
{
const
accounts
=
await
web3
.
eth
.
getAccounts
();
let
lp_contract
=
new
web3
.
eth
.
Contract
(
lp
,
lp_address
);
let
farm_contract
=
new
web3
.
eth
.
Contract
(
farm
,
farm_address
);
let
amount
=
web3
.
utils
.
toWei
(
tokenAmount
.
value
);
if
(
this
.
state
.
step
==
"
Approve
"
)
{
this
.
setState
({
step
:
"
Processing ...
"
})
let
allowance
=
await
lp_contract
.
methods
.
allowance
(
accounts
[
0
],
farm_address
).
call
();
if
(
allowance
<=
amount
)
{
await
lp_contract
.
methods
.
approve
(
farm_address
,
amount
).
send
({
from
:
accounts
[
0
]
});
}
this
.
setState
({
step
:
"
Stake
"
,
});
this
.
setup
();
}
else
if
(
this
.
state
.
step
==
"
Stake
"
)
{
this
.
setState
({
step
:
"
Processing ...
"
})
await
farm_contract
.
methods
.
deposit
(
amount
).
send
({
from
:
accounts
[
0
]
});
alert
(
"
Successfully Staked the tokens :)
"
);
this
.
setState
({
step
:
"
Approve
"
,
})
window
.
location
.
reload
();
}
else
if
(
this
.
state
.
step
==
"
Withdraw
"
)
{
await
farm_contract
.
methods
.
withdraw
(
amount
).
send
({
from
:
accounts
[
0
]
});
alert
(
"
Withdrawal Complete
"
);
}
else
if
(
this
.
state
.
step
==
"
Claim
"
)
{
await
farm_contract
.
methods
.
harvest
().
send
({
from
:
accounts
[
0
]
});
}
}
updateThing
=
()
=>
{
this
.
setState
({
selected
:
window
.
location
.
hash
.
slice
(
1
),
})
if
(
this
.
state
.
selected
==
"
Farm
"
)
{
this
.
setState
({
step
:
"
Approve
"
,
})
}
else
{
this
.
setState
({
step
:
this
.
state
.
step
,
});
}
}
async
componentDidMount
()
{
window
.
addEventListener
(
"
hashchange
"
,
this
.
updateThing
,
false
);
}
render
()
{
if
(
this
.
state
.
selected
==
"
Farm
"
)
{
return
(
<
div
className
=
"
min-h-scree text-center
"
>
<
div
className
=
"
modal pt-20 mt-9 text-white w-full mx-auto rounded-3xl shadow-lg px-10
"
>
<
h1
className
=
"
font-semibold text-xl
"
>
Offshift
PancakeSwap
Farm
<
/h1
>
<
p
className
=
"
mt-4
"
>
Staked
Tokens
:
{
this
.
props
.
balance
}
LP
<
/p
>
<
p
className
=
""
>
Total
Rewards
:
{
this
.
props
.
Rewards
}
XFT
<
/p
>
<
p
className
=
"
mb-10
"
>
APY
:
{
this
.
props
.
APY
}
%<
/p
>
<
input
id
=
"
tokenAmount
"
placeholder
=
"
Amount of Tokens
"
type
=
"
number
"
className
=
"
border-gray-800 focus:ring-2 bg-gray-600 shadow appearance-none border rounded py-2 px-16 text-grey-darker
"
><
/input
>
<
div
className
=
"
pt-6 pb-10
"
>
<
button
className
=
"
bg-gradient-to-r from-purple-800 to-blue-500 hover:to-yellow-500 text-white font-sans font-semibold text-xl border-blue btn-primary hover:text-white hover:bg-blue-light focus:outline-none active:shadow-none justify-center px-7 py-3 shadow-md no-underline rounded-full
"
onClick
=
{
this
.
handle
}
>
{
this
.
state
.
step
}
<
/button
>
<
/div
>
<
/div
>
<
/div
>
);
}
else
if
(
this
.
state
.
selected
==
"
Withdraw
"
)
{
return
(
<
div
className
=
"
min-h-screen text-center
"
>
<
div
className
=
"
modal pt-20 mt-9 text-white w-full mx-auto rounded-3xl shadow-lg px-10
"
>
<
h1
className
=
"
font-semibold text-xl
"
>
Withdraw
your
tokens
<
/h1
>
<
p
className
=
"
mt-4
"
>
Staked
Tokens
:
{
this
.
props
.
balance
}
LP
<
/p
>
<
p
className
=
""
>
Total
Rewards
:
{
this
.
props
.
Rewards
}
XFT
<
/p
>
<
p
className
=
"
mb-10
"
>
APY
:
{
this
.
props
.
APY
}
%<
/p
>
<
input
id
=
"
tokenAmount
"
placeholder
=
"
Amount of Tokens
"
type
=
"
number
"
className
=
"
shadow appearance-none border rounded py-2 px-20
"
><
/input
>
<
div
className
=
"
pt-6 pb-10
"
>
<
button
className
=
"
bg-gradient-to-r from-purple-800 to-blue-500 hover:to-yellow-500 text-white font-sans font-semibold text-xl border-blue btn-primary hover:text-white hover:bg-blue-light focus:outline-none active:shadow-none justify-center px-7 py-3 shadow-md no-underline rounded-full
"
onClick
=
{
this
.
withdraw_tokens
}
>
Withdraw
<
/button
>
<
/div
>
<
/div
>
<
/div
>
);
}
else
if
(
this
.
state
.
selected
==
"
Claim
"
)
{
return
(
<
div
className
=
"
min-h-screen text-center
"
>
<
div
className
=
"
modal pt-20 mt-9 text-white w-full mx-auto rounded-3xl shadow-lg px-10
"
>
<
h1
className
=
"
font-semibold text-xl
"
>
Claim
Your
Rewards
<
/h1
>
<
p
className
=
""
>
Total
Rewards
:
{
this
.
props
.
Rewards
}
XFT
<
/p
>
<
div
className
=
"
pt-6 pb-10
"
>
<
button
className
=
"
bg-gradient-to-r from-purple-800 to-blue-500 hover:to-yellow-500 text-white font-sans font-semibold text-xl border-blue btn-primary hover:text-white hover:bg-blue-light focus:outline-none active:shadow-none justify-center px-7 py-3 shadow-md no-underline rounded-full
"
onClick
=
{
this
.
claim_rewards
}
>
Claim
<
/button
>
<
/div
>
<
/div
>
<
/div
>
)
}
else
{
return
(
<
h1
>
soo
?
<
/h1>
)
}
}
}
export
default
class
Home
extends
React
.
Component
{
constructor
()
{
super
();
this
.
state
=
{
bttn
:
""
,
balance
:
""
,
APY
:
""
,
Rewards
:
""
,
connected
:
true
,
}
this
.
connect
=
this
.
connect
.
bind
(
this
);
this
.
update
=
this
.
update
.
bind
(
this
);
}
async
update
()
{
const
accounts
=
await
web3
.
eth
.
getAccounts
();
let
farm_contract
=
new
web3
.
eth
.
Contract
(
farm
,
farm_address
);
let
balance
=
await
farm_contract
.
methods
.
Stakers
(
accounts
[
0
]).
call
();
balance
=
web3
.
utils
.
fromWei
(
balance
.
amount
);
let
reward
=
web3
.
utils
.
fromWei
(
await
farm_contract
.
methods
.
getPending
().
call
({
from
:
accounts
[
0
]
}));
let
perShare
=
web3
.
utils
.
fromWei
(
await
farm_contract
.
methods
.
xftPerShare
().
call
());
const
blockPerYear
=
365
*
43200
let
roi
=
blockPerYear
*
perShare
/
(
total_stakes
*
100
)
;
roi
=
roi
.
toFixed
(
2
);
this
.
setState
({
balance
:
balance
,
Rewards
:
reward
,
APY
:
roi
,
});
}
async
connect
()
{
if
(
typeof
ethereum
!==
'
undefined
'
)
{
await
window
.
ethereum
.
request
({
method
:
'
eth_requestAccounts
'
});
web3
=
new
Web3
(
window
.
ethereum
);
}
else
{
// Enable session (triggers QR Code modal)
await
provider
.
enable
();
}
const
accounts
=
await
web3
.
eth
.
getAccounts
();
let
farm_contract
=
new
web3
.
eth
.
Contract
(
farm
,
farm_address
);
let
lp_contract
=
new
web3
.
eth
.
Contract
(
lp
,
lp_address
);
let
bnb_contract
=
new
web3
.
eth
.
Contract
(
lp
,
bnb_address
);
let
balance
=
await
farm_contract
.
methods
.
Stakers
(
accounts
[
0
]).
call
();
balance
=
web3
.
utils
.
fromWei
(
balance
.
amount
);
let
reward
=
web3
.
utils
.
fromWei
(
await
farm_contract
.
methods
.
getPending
().
call
({
from
:
accounts
[
0
]}));
let
response
=
await
fetch
(
"
https://api.coingecko.com/api/v3/simple/price?ids=offshift,binancecoin&vs_currencies=usd
"
);
response
=
await
response
.
json
();
let
xft_price
=
response
[
"
offshift
"
][
"
usd
"
];
let
bnb_price
=
response
[
"
binancecoin
"
][
"
usd
"
];
let
pool_amount
=
web3
.
utils
.
fromWei
(
await
bnb_contract
.
methods
.
balanceOf
(
lp_address
).
call
())
*
bnb_price
*
2
;
console
.
log
(
pool_amount
)
let
ratio
=
(
xft_price
*
48000
)
/
(
pool_amount
);
let
roi
=
((
1
+
(
ratio
/
365
))
**
365
)
-
1
;
roi
=
(
roi
*
100
).
toFixed
(
2
);
this
.
setState
({
bttn
:
"
hidden
"
,
connected
:
true
,
balance
:
balance
,
Rewards
:
reward
,
APY
:
roi
,
});
alert
(
"
Connected !
"
);
}
render
()
{
return
(
<
div
>
<
Header
connect
=
{
this
.
connect
}
bttn
=
{
this
.
state
.
bttn
}
/
>
<
Main
{...
this
.
state
}
update
=
{
this
.
update
}
/
>
<
/div
>
);
}
}
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/postcss.config.js
0 → 100644
View file @
7668a5a2
// If you want to use other PostCSS plugins, see the following:
// https://tailwindcss.com/docs/using-with-preprocessors
module
.
exports
=
{
plugins
:
{
tailwindcss
:
{},
autoprefixer
:
{},
},
}
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/public/favicon.ico
0 → 100644
View file @
7668a5a2
175 KB
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/tailwind.config.js
0 → 100644
View file @
7668a5a2
module
.
exports
=
{
mode
:
'
jit
'
,
purge
:
[
'
./pages/**/*.{js,ts,jsx,tsx}
'
,
'
./components/**/*.{js,ts,jsx,tsx}
'
],
darkMode
:
false
,
// or 'media' or 'class'
theme
:
{
extend
:
{},
},
variants
:
{
extend
:
{},
},
plugins
:
[],
}
This diff is collapsed.
Click to expand it.
BSC/farm/frontend/yarn.lock
0 → 100644
View file @
7668a5a2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
This diff is collapsed.
Click to expand it.
Prev
1
…
6
7
8
9
10
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help