The RewardPool API is used to interact with tally (an offchain service similar to relayer) and the reward pool contract. As customers use their prepaid card they will be given rewards based the amount of spend they use and a reward-based algorithm.

Hierarchy

  • RewardPoolClass

Constructors

Properties

rewardPool: undefined | Contract
layer2Web3: default
layer2Signer?: Signer

Methods

  • The GetProofs API is used to retrieve proofs that are used to claim rewards from tally; proofs are similar arcade coupons that are collected to claim a prize. A proof can only be used by the EOA-owner. Once a proof is used (i.e. knownClaimed=true) it cannot be re-used. isValid is a flag that checks if a proof is still valid. Assuming a proof has not been claimed, isValid=false means that a proof can no longer be claimed -- typically, to mean that the proof has expired.

    Example

    let rewardPool = await getSDK('RewardPool', web3);
    await rewardPool.getProofs(address, rewardProgramId, safeAddress?, tokenAddress?, knownClaimed?)

    Parameters

    • address: string
    • rewardProgramId: string
    • safeAddress: string
    • Optional tokenAddress: string
    • Optional knownClaimed: boolean
    • Optional offset: number
    • Optional limit: number

    Returns Promise<WithSymbol<ClaimableProof>[]>

  • Parameters

    • address: string
    • rewardProgramId: string
    • safeAddress: undefined
    • Optional tokenAddress: string
    • Optional knownClaimed: boolean
    • Optional offset: number
    • Optional limit: number

    Returns Promise<WithSymbol<Proof>[]>

  • Returns

    the balance of ALL tokens in the RewardPool for prepaid card owners address. This function takes in a parameter of the prepaid card owner address and , reward token address, and reward program id. This balance also accounts for the claims of a prepaid card owner in the past. The tokens that are part of the rewards are CARDPXD and DAICPXD -- federated tokens of the card protocol. The RewardPool API is used to interact with tally (an offchain service similar to relayer) and the reward pool contract. As customers use their prepaid card they will be given rewards based the amount of spend they use and a reward-based algorithm.

    Example

    let rewardPool = await getSDK('RewardPool', web3);
    let balanceForAllTokens = await rewardPool.rewardTokenBalances(address, rewardProgramId)

    Parameters

    • address: string
    • rewardProgramId: string

    Returns Promise<WithSymbol<RewardTokenBalance>[]>

  • This call is exactly the same as RewardPool.rewardTokenBalances except it excludes rewardAmount < gasFees (crypto dust).

    Example

    let rewardPool = await getSDK('RewardPool', web3);
    let balanceForAllTokens = await rewardPool.rewardTokenBalancesWithoutDust(address, rewardProgramId, rewardSafe)

    Parameters

    • address: string
    • rewardProgramId: string
    • safeAddress: string

    Returns Promise<WithSymbol<RewardTokenBalance>[]>

  • The AddRewardTokens API is used to refill the reward pool for a particular reward program with any single owner safe. Currently, the sdk supports using single-owner safe like depot safe or merchant safe to send funds (the protocol supports prepaid card payments too). If a reward program doesn't have any funds inside of the pool rewardees will be unable to claim. Anyone can call this function not only the rewardProgramAdmin.

    Example

    let rewardPool = await getSDK('RewardPool', web3);
    await rewardPool.addRewardTokens(safe, rewardProgramId, tokenAddress, amount)

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • safeAddress: string
    • rewardProgramId: string
    • tokenAddress: string
    • amount: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • The Claim API is used by the rewardee to claim rewards from an associated reward program. Pre-requisite for this action:

    • reward program has to be registered
    • rewardee has to register and create safe for that particular reward program. The funds will be claimed into this safe -- reward safe
    • rewardee must get an existing proof and leaf from tally api -- look at rewardPool.getProofs
    • reward pool has to be filled with reward token for that reward program

    Example

    let rewardPool = await getSDK('RewardPool', web3);
    await rewardPool.claim(safe, leaf, proofArray, acceptPartialClaim)

    The leaf item contains most information about the claim, such as the reward program (rewardProgramId), the expiry of the proof (validFrom, validTo), the type of token of the reward (tokenType, transferData), the eoa owner of the safe (payee). This information can be decoded easily. acceptPartialClaim is a special scenario whereby a rewardee is willing to compromise his full reward compensation for a partial one. This scneario occurs, for example, when rewardee has 10 card in his proof but the reward pool only has 5 card, the rewardee may opt to just accepting that 5 card by setting acceptPartialClaim=true.

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • safeAddress: string
    • leaf: string
    • proofBytes: string[]
    • acceptPartialClaim: boolean
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • The claimAll is used by the rewardee to claim all rewards from a list of proofs. The looping occurs as separate transactions so the failure of one transaction will lead to the failure of all transactions after it (transactions before it will stil succeed). Proofs which have claims rewardAmount < gasFees (crypto dust) will be excluded; this filter is to decrease the probability of claimAll failing.

    Example

    let rewardManagerAPI = await getSDK('RewardManager', web3);
    await rewardManagerAPI.claimAll(rewardSafe, rewardProgramId, tokenAddress?)

    Parameters

    • safeAddress: string
    • rewardProgramId: string
    • Optional tokenAddress: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt[]>

  • Parameters

    • rewardProgramId: string
    • amount: BN
    • token: string
    • Optional acceptPartialClaim: boolean

    Returns Promise<any>

  • The claimGasEstimate returns a gas estimate a claim of a reward. The gas is paid out in tokens of the reward received. For example, if a person recieves 10 CARD, they will receive 10 CARD - (gas fees in CARD) into their reward safe.

    Example

    let rewardManagerAPI = await getSDK('RewardManager', web3);
    await rewardManagerAPI.claimGasEstimate(rewardSafeAddress, leaf, proofArray, acceptPartialClaim)

    Parameters

    • rewardSafeAddress: string
    • leaf: string
    • proofBytes: string[]
    • Optional acceptPartialClaim: boolean

    Returns Promise<GasEstimate>

  • Parameters

    • rewardSafeAddress: string
    • rewardProgramId: string
    • tokenAddress: string

    Returns Promise<GasEstimate>

  • The RecoverTokens API is used by the rewardProgramAdmin to recover the tokens that are previously added inside the pool. This function can be called at anytime throughout the lifecycle of the reward program. The funds recovered will be used to pay for the gas fees to execute the transaction.

    Example

    let rewardPool = await getSDK('RewardPool', web3);
    await rewardPool.recoverTokens(safe, rewardProgramId, tokenAddress, amount?)

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • safeAddress: string
    • rewardProgramId: string
    • tokenAddress: string
    • Optional amount: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • The rewardProgramBalances API is used to query the token balances inside the reward pool for a particular reward program. This is useful if a rewardProgramAdmin wants to assess how much is left inside the pool for the reward program they manage.

    Example

    let rewardPool = await getSDK('RewardPool', web3);
    await rewardPool.rewardProgramBalances(rewardProgramId)

    Parameters

    • rewardProgramId: string

    Returns Promise<WithSymbol<RewardTokenBalance>[]>

  • Parameters

    • rewardProgramId: string
    • tokenAddress: string
    • amount: BN

    Returns Promise<string>

Generated using TypeDoc