8.4 KiB
@oceanprotocol/lib / Exports / DfRewards
Class: DfRewards
Provides an interface for DFRewards contract
Hierarchy
-
↳
DfRewards
Table of contents
Constructors
Properties
Methods
- allocateRewards
- amountToUnits
- claimRewards
- getAvailableRewards
- getContract
- getDefaultAbi
- getFairGasPrice
- unitsToAmount
Constructors
constructor
• new DfRewards(address
, signer
, network?
, config?
, abi?
)
Instantiate the smart contract.
Parameters
Name | Type | Description |
---|---|---|
address |
string |
The address of the contract. |
signer |
Signer |
The signer object. |
network? |
string | number |
Network id or name |
config? |
Config |
The configuration object. |
abi? |
AbiItem [] |
ABI array of the smart contract |
Inherited from
SmartContractWithAddress.constructor
Defined in
contracts/SmartContractWithAddress.ts:17
Properties
abi
• abi: AbiItem
[]
Inherited from
Defined in
address
• address: string
Inherited from
SmartContractWithAddress.address
Defined in
contracts/SmartContractWithAddress.ts:6
config
• config: Config
Inherited from
SmartContractWithAddress.config
Defined in
contract
• contract: Contract
Inherited from
SmartContractWithAddress.contract
Defined in
contracts/SmartContractWithAddress.ts:7
signer
• signer: Signer
Inherited from
SmartContractWithAddress.signer
Defined in
Methods
allocateRewards
▸ allocateRewards<G
>(userAddresses
, amounts
, tokenAddress
, estimateGas?
): Promise
<ReceiptOrEstimate
<G
>>
allocate rewards to address. An approve must exist before calling this function.
Type parameters
Name | Type |
---|---|
G |
extends boolean = false |
Parameters
Name | Type | Description |
---|---|---|
userAddresses |
string [] |
array of users that will receive rewards |
amounts |
string [] |
array of amounts |
tokenAddress |
string |
token address |
estimateGas? |
G |
if True, return gas estimate |
Returns
Promise
<ReceiptOrEstimate
<G
>>
Defined in
amountToUnits
▸ Protected
amountToUnits(token
, amount
, tokenDecimals?
): Promise
<string
>
Converts an amount of tokens to units
Parameters
Name | Type | Description |
---|---|---|
token |
string |
The token to convert |
amount |
string |
The amount of tokens to convert |
tokenDecimals? |
number |
The number of decimals of the token |
Returns
Promise
<string
>
- The converted amount in units
Inherited from
SmartContractWithAddress.amountToUnits
Defined in
claimRewards
▸ claimRewards<G
>(userAddress
, tokenAddress
, estimateGas?
): Promise
<ReceiptOrEstimate
<G
>>
claim rewards for any address
Type parameters
Name | Type |
---|---|
G |
extends boolean = false |
Parameters
Name | Type | Description |
---|---|---|
userAddress |
string |
user address to claim |
tokenAddress |
string |
token address |
estimateGas? |
G |
if True, return gas estimate |
Returns
Promise
<ReceiptOrEstimate
<G
>>
Defined in
getAvailableRewards
▸ getAvailableRewards(userAddress
, tokenAddress
): Promise
<string
>
Get available DF Rewards for a token
Parameters
Name | Type | Description |
---|---|---|
userAddress |
string |
user address |
tokenAddress |
string |
token address |
Returns
Promise
<string
>
Defined in
getContract
▸ Protected
getContract(address
, abi?
): Contract
Returns a contract instance for the given address
Parameters
Name | Type | Description |
---|---|---|
address |
string |
The address of the contract |
abi? |
AbiItem [] |
The ABI of the contract |
Returns
Contract
- The contract instance
Inherited from
SmartContractWithAddress.getContract
Defined in
getDefaultAbi
▸ getDefaultAbi(): AbiItem
[]
Returns
AbiItem
[]
Overrides
SmartContractWithAddress.getDefaultAbi
Defined in
getFairGasPrice
▸ Protected
getFairGasPrice(): Promise
<string
>
Retruns the gas price
Returns
Promise
<string
>
- The fair gas price
Inherited from
SmartContractWithAddress.getFairGasPrice
Defined in
unitsToAmount
▸ Protected
unitsToAmount(token
, amount
, tokenDecimals?
): Promise
<string
>
Converts an amount of units to tokens
Parameters
Name | Type | Description |
---|---|---|
token |
string |
The token to convert |
amount |
string |
The amount of units to convert |
tokenDecimals? |
number |
The number of decimals in the token |
Returns
Promise
<string
>
- The converted amount in tokens
Inherited from
SmartContractWithAddress.unitsToAmount