质押cec
This commit is contained in:
parent
d2443a055a
commit
02faaf2fb6
@ -1 +1,52 @@
|
|||||||
["constructor(string,string)","event Approval(address indexed,address indexed,uint256)","event Claim(address,uint256)","event Transfer(address indexed,address indexed,uint256)","function BASIS_POINTS_DIVISOR() view returns (uint256)","function PRECISION() view returns (uint256)","function allowance(address,address) view returns (uint256)","function approve(address,uint256) returns (bool)","function averageStakedAmounts(address) view returns (uint256)","function balanceOf(address) view returns (uint256)","function balances(address) view returns (uint256)","function claim(address) returns (uint256)","function claimForAccount(address,address) returns (uint256)","function claimable(address) view returns (uint256)","function claimableReward(address) view returns (uint256)","function cumulativeRewardPerToken() view returns (uint256)","function cumulativeRewards(address) view returns (uint256)","function decimals() view returns (uint8)","function depositBalances(address,address) view returns (uint256)","function distributor() view returns (address)","function gov() view returns (address)","function inPrivateClaimingMode() view returns (bool)","function inPrivateStakingMode() view returns (bool)","function inPrivateTransferMode() view returns (bool)","function initialize(address[],address)","function isDepositToken(address) view returns (bool)","function isHandler(address) view returns (bool)","function isInitialized() view returns (bool)","function name() view returns (string)","function previousCumulatedRewardPerToken(address) view returns (uint256)","function rewardToken() view returns (address)","function setDepositToken(address,bool)","function setGov(address)","function setHandler(address,bool)","function setInPrivateClaimingMode(bool)","function setInPrivateStakingMode(bool)","function setInPrivateTransferMode(bool)","function stake(address,uint256)","function stakeForAccount(address,address,address,uint256)","function stakedAmounts(address) view returns (uint256)","function symbol() view returns (string)","function tokensPerInterval() view returns (uint256)","function totalDepositSupply(address) view returns (uint256)","function totalSupply() view returns (uint256)","function transfer(address,uint256) returns (bool)","function transferFrom(address,address,uint256) returns (bool)","function unstake(address,uint256)","function unstakeForAccount(address,address,uint256,address)","function updateRewards()","function withdrawToken(address,address,uint256)"]
|
[
|
||||||
|
"constructor(string,string)",
|
||||||
|
"event Approval(address indexed,address indexed,uint256)",
|
||||||
|
"event Claim(address,uint256)",
|
||||||
|
"event Transfer(address indexed,address indexed,uint256)",
|
||||||
|
"function BASIS_POINTS_DIVISOR() view returns (uint256)",
|
||||||
|
"function PRECISION() view returns (uint256)",
|
||||||
|
"function allowance(address,address) view returns (uint256)",
|
||||||
|
"function approve(address,uint256) returns (bool)",
|
||||||
|
"function averageStakedAmounts(address) view returns (uint256)",
|
||||||
|
"function balanceOf(address) view returns (uint256)",
|
||||||
|
"function balances(address) view returns (uint256)",
|
||||||
|
"function claim(address) returns (uint256)",
|
||||||
|
"function claimForAccount(address,address) returns (uint256)",
|
||||||
|
"function claimable(address) view returns (uint256)",
|
||||||
|
"function claimableReward(address) view returns (uint256)",
|
||||||
|
"function cumulativeRewardPerToken() view returns (uint256)",
|
||||||
|
"function cumulativeRewards(address) view returns (uint256)",
|
||||||
|
"function decimals() view returns (uint8)",
|
||||||
|
"function depositBalances(address,address) view returns (uint256)",
|
||||||
|
"function distributor() view returns (address)",
|
||||||
|
"function gov() view returns (address)",
|
||||||
|
"function inPrivateClaimingMode() view returns (bool)",
|
||||||
|
"function inPrivateStakingMode() view returns (bool)",
|
||||||
|
"function inPrivateTransferMode() view returns (bool)",
|
||||||
|
"function initialize(address[],address)",
|
||||||
|
"function isDepositToken(address) view returns (bool)",
|
||||||
|
"function isHandler(address) view returns (bool)",
|
||||||
|
"function isInitialized() view returns (bool)",
|
||||||
|
"function name() view returns (string)",
|
||||||
|
"function previousCumulatedRewardPerToken(address) view returns (uint256)",
|
||||||
|
"function rewardToken() view returns (address)",
|
||||||
|
"function setDepositToken(address,bool)",
|
||||||
|
"function setGov(address)",
|
||||||
|
"function setHandler(address,bool)",
|
||||||
|
"function setInPrivateClaimingMode(bool)",
|
||||||
|
"function setInPrivateStakingMode(bool)",
|
||||||
|
"function setInPrivateTransferMode(bool)",
|
||||||
|
"function stake(address,uint256)",
|
||||||
|
"function stakeForAccount(address,address,address,uint256)",
|
||||||
|
"function stakedAmounts(address) view returns (uint256)",
|
||||||
|
"function symbol() view returns (string)",
|
||||||
|
"function tokensPerInterval() view returns (uint256)",
|
||||||
|
"function totalDepositSupply(address) view returns (uint256)",
|
||||||
|
"function totalSupply() view returns (uint256)",
|
||||||
|
"function transfer(address,uint256) returns (bool)",
|
||||||
|
"function transferFrom(address,address,uint256) returns (bool)",
|
||||||
|
"function unstake(address,uint256)",
|
||||||
|
"function unstakeForAccount(address,address,uint256,address)",
|
||||||
|
"function updateRewards()",
|
||||||
|
"function withdrawToken(address,address,uint256)"
|
||||||
|
]
|
@ -15,7 +15,7 @@ export class Staking {
|
|||||||
this.stakedEsCecTracker = cfg.stakedEsCecTracker
|
this.stakedEsCecTracker = cfg.stakedEsCecTracker
|
||||||
}
|
}
|
||||||
|
|
||||||
async execMethod({provider, address, method, params}) {
|
async execMethod({provider,account_address, address, method, params}) {
|
||||||
this.bc.checkAndChangeChain(chainId, provider);
|
this.bc.checkAndChangeChain(chainId, provider);
|
||||||
const contract = new Contract(address, routerAbi, provider.getSigner());
|
const contract = new Contract(address, routerAbi, provider.getSigner());
|
||||||
const tx = await contract[method](...params);
|
const tx = await contract[method](...params);
|
||||||
@ -23,7 +23,7 @@ export class Staking {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryMethod({provider, address, method, params}) {
|
async queryMethod({provider,account_address, address, method, params}) {
|
||||||
this.bc.checkAndChangeChain(chainId, provider);
|
this.bc.checkAndChangeChain(chainId, provider);
|
||||||
const contract = new Contract(address, trackerAbi, provider.getSigner());
|
const contract = new Contract(address, trackerAbi, provider.getSigner());
|
||||||
return contract[method](...params);
|
return contract[method](...params);
|
||||||
@ -33,10 +33,11 @@ export class Staking {
|
|||||||
* @param {*} amount 质押的数量, 单位为wei
|
* @param {*} amount 质押的数量, 单位为wei
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async stakeCec(amount) {
|
async stakeCec(address, amount) {
|
||||||
return this.execMethod({
|
return this.execMethod({
|
||||||
provider: this.bc.eoaProvider,
|
provider: this.bc.eoaProvider,
|
||||||
address: this.stakedCecRouter,
|
account_address: this.stakedCecRouter,
|
||||||
|
address: address,
|
||||||
method: 'stakeCec',
|
method: 'stakeCec',
|
||||||
params: [amount]
|
params: [amount]
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>CEC </div>
|
<div>CEC </div>
|
||||||
<p>{{localWalletStore.cecBalance != 0 ? priceCalculated(cecInfoData.cecBalance,18) : 0 }}</p>
|
<p>{{cecInfoData.cecBalance != '0' ? priceCalculated(cecInfoData.cecBalance,18) : 0 }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>CEC staking</div>
|
<div>CEC staking</div>
|
||||||
<p>{{ cecInfoData.CecStaked }}</p>
|
<p>{{ stakingStore.cecInfoData.CecStaked }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>CEC disarm</div>
|
<div>CEC disarm</div>
|
||||||
<p>{{ cecInfoData.CecDisarm }}</p>
|
<p>{{ stakingStore.cecInfoData.CecDisarm }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>CEC collection</div>
|
<div>CEC collection</div>
|
||||||
<p>{{ cecInfoData.CecCollection }}</p>
|
<p>{{ stakingStore.cecInfoData.CecCollection }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
@ -60,7 +60,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>esCEC</div>
|
<div>esCEC</div>
|
||||||
<p>{{ cecInfoData.esCecBalance }}</p>
|
<p>{{ stakingStore.cecInfoData.esCecBalance }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>esCEC Staking</div>
|
<div>esCEC Staking</div>
|
||||||
<p>{{ cecInfoData.esCecStaked }}</p>
|
<p>{{ stakingStore.cecInfoData.esCecStaked }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -82,7 +82,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>esCEC conversion</div>
|
<div>esCEC conversion</div>
|
||||||
<p>{{ cecInfoData.esCecConversion }}</p>
|
<p>{{ stakingStore.cecInfoData.esCecConversion }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -93,7 +93,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>esCEC collection</div>
|
<div>esCEC collection</div>
|
||||||
<p>{{ cecInfoData.esCecCollection }}</p>
|
<p>{{ stakingStore.cecInfoData.esCecCollection }}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
@ -163,6 +163,9 @@ const cecInfoData = ref({
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const getCecData = async () => {
|
const getCecData = async () => {
|
||||||
|
let address = localWalletStore.address
|
||||||
|
if(address) {
|
||||||
|
|
||||||
const bc = new BlockChain();
|
const bc = new BlockChain();
|
||||||
// console.log(await bc.staking.queryCECStaked())
|
// console.log(await bc.staking.queryCECStaked())
|
||||||
// return
|
// return
|
||||||
@ -175,14 +178,15 @@ const getCecData = async () => {
|
|||||||
// esCecStaked: 0,
|
// esCecStaked: 0,
|
||||||
// esCecConversion: 0,
|
// esCecConversion: 0,
|
||||||
// esCecCollection: 0,
|
// esCecCollection: 0,
|
||||||
let address = localWalletStore.address
|
|
||||||
let timer = setInterval( async () => {
|
let timer = setInterval( async () => {
|
||||||
cecInfoData.value.cecBalance = parseInt(await bc.erc20.balanceOf(address)).toString()
|
cecInfoData.value.cecBalance = parseInt(await bc.erc20.balanceOf(address)).toString()
|
||||||
cecInfoData.value.esCecBalance = parseInt(await bc.erc20.esCecBalanceOf(address)).toString()
|
cecInfoData.value.esCecBalance = parseInt(await bc.erc20.esCecBalanceOf(address)).toString()
|
||||||
cecInfoData.value.CecStaked = parseInt(await bc.staking.queryCECStaked()).toString()
|
cecInfoData.value.CecStaked = parseInt(await bc.staking.queryCECStaked()).toString()
|
||||||
cecInfoData.value.esCecStaked = parseInt(await bc.staking.queryEsCECStaked()).toString()
|
cecInfoData.value.esCecStaked = parseInt(await bc.staking.queryEsCECStaked()).toString()
|
||||||
|
let res = parseInt(await bc.staking.queryClaimableByCEC())
|
||||||
// let ClaimableByCEC = await bc.staking.queryCumulativeByCEC()
|
// let ClaimableByCEC = await bc.staking.queryCumulativeByCEC()
|
||||||
// let ClaimableByEsCEC = await bc.staking.queryClaimableByEsCEC()
|
// let ClaimableByEsCEC = await bc.staking.queryClaimableByEsCEC()
|
||||||
|
console.log(cecInfoData.value.CecStaked,res)
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
// let cec = await bc.staking.queryCECStaked()
|
// let cec = await bc.staking.queryCECStaked()
|
||||||
@ -190,6 +194,7 @@ const getCecData = async () => {
|
|||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
// console.log(e)
|
// console.log(e)
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +204,9 @@ const vipHandleClose = () => {
|
|||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getCecData()
|
if(localWalletStore.address) {
|
||||||
|
getCecData()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -145,6 +145,7 @@ import { BlockChain } from "@/components/chain/BlockChain"
|
|||||||
|
|
||||||
const localWalletStore = walletStore()
|
const localWalletStore = walletStore()
|
||||||
const stakingStore = useStakingStore()
|
const stakingStore = useStakingStore()
|
||||||
|
|
||||||
const bc = new BlockChain();
|
const bc = new BlockChain();
|
||||||
const chainId = parseInt(import.meta.env.VUE_APP_STAKING_CHAIN);
|
const chainId = parseInt(import.meta.env.VUE_APP_STAKING_CHAIN);
|
||||||
const cecDialogVisible = ref(false)
|
const cecDialogVisible = ref(false)
|
||||||
@ -153,22 +154,22 @@ const handleClose = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dialogUnstakeText = ref({
|
const dialogUnstakeText = ref({
|
||||||
title: "Unstake CEC",
|
title: "Stake CEC",
|
||||||
typeLabel: "Unstake",
|
typeLabel: "Stake",
|
||||||
// tips: "1111",
|
// tips: "1111",
|
||||||
typeName: "es CEC",
|
typeName: "CEC",
|
||||||
// conversion: "Reveres conversion esCEC",
|
// conversion: "Reveres conversion esCEC",
|
||||||
// conversionName: "CEC"
|
// conversionName: "CEC"
|
||||||
})
|
})
|
||||||
|
|
||||||
const unCecStaked = async () => {
|
const unCecStaked = async () => {
|
||||||
console.log(localWalletStore.address, STAKING_ADDRESSES[chainId].stakedCecTracker,(1*1e18).toString())
|
console.log(localWalletStore.address, STAKING_ADDRESSES[chainId].stakedCecTracker,stakingStore.cecInfoData.cecBalance)
|
||||||
// try{
|
// try{
|
||||||
// let res = await bc.erc20.approve(localWalletStore.address, STAKING_ADDRESSES[chainId].stakedCecTracker,(1*1e18).toString())
|
// let res = await bc.erc20.approve(STAKING_ADDRESSES[chainId].stakedCecTracker, STAKING_ADDRESSES[chainId].cec,(1*1e18).toString())
|
||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
// console.log(e)
|
// console.log(e)
|
||||||
// }
|
// }
|
||||||
let res = await bc.staking.stakeCec((1*1e18).toString())
|
let res = await bc.staking.stakeCec(localWalletStore.address,(1*1e18).toString())
|
||||||
console.log(res)
|
console.log(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ export const useStakingStore = defineStore('staking', () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// const updateOverviewStatus = (_connected) => {
|
const updateCecInfoDataStatus = (_connected) => {
|
||||||
// overview.value = _connected;
|
cecInfoData.value = _connected;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user