-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: fkrevenue <fk@revenuecapital.io>
- Loading branch information
Showing
3 changed files
with
897 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {BindingScope, extensionFor, injectable} from '@loopback/core'; | ||
import {BigNumber} from 'ethers'; | ||
import {STAKING_ADAPTERS_EXTENSION_POINT} from '../keys.js'; | ||
import {BaseStakingContractAdapter, StakingAsset} from '../staking.js'; | ||
// Use the full path to import instead of `../types` | ||
import {Revenue__factory} from '../types/factories/Revenue__factory.js'; | ||
|
||
@injectable( | ||
{ | ||
scope: BindingScope.SINGLETON, // Mark the adapter as a singleton | ||
}, | ||
// Mark it as an extension to staking contracts service | ||
extensionFor(STAKING_ADAPTERS_EXTENSION_POINT), | ||
) | ||
export class RevenueCoinStakingContractAdapter extends BaseStakingContractAdapter { | ||
/** | ||
* The contract address | ||
*/ | ||
contractAddress = '0xd5a5874c9328d955440cb26aed57bce3fb998c0f'; | ||
chainId: number = 56; | ||
/** | ||
* Assets that can be staked to this contract | ||
*/ | ||
supportedAssets: StakingAsset[] = [ | ||
{ | ||
asset: 'ERC20:0xbcbdecf8e76A5C32Dba69De16985882ace1678c6', | ||
}, | ||
]; | ||
|
||
async getStakedTokenBalance(owner: string): Promise<BigNumber> { | ||
const contract = Revenue__factory.connect( | ||
this.contractAddress, | ||
this.provider, | ||
); | ||
const balance = BigNumber.from(0); | ||
for (let i = 0; i < 3; i++) { | ||
const amount = await contract.userInfo(i, owner); | ||
balance.add(amount.amount); | ||
} | ||
return balance; | ||
} | ||
} |
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
Oops, something went wrong.