Skip to content

Latest commit

 

History

History
107 lines (78 loc) · 6.19 KB

INCENTIVE_INTEGRATIONS.md

File metadata and controls

107 lines (78 loc) · 6.19 KB

Kyc, Dayswapper and TimeAlly Club Integration

The purpose of this document is to guide new platform contracts to call methods on KycDapp, Dayswappers and TimeAlly Club as per need.

There is an abstract contract (docs) called RegistryDependent. This contract needs to be imported in and inherited in your contract. (If you have a factory pattern, it is suggested to only inherit on factory contract and not in child contracts).

import { RegistryDependent } from "./RegistryDependent.sol";

contract MyDapp is RegistryDependent {

}

RegistryDependent basically means that your contract relies on KycDapp smart contract's Identity registry to get address of other contracts. Thats why for this to work, AFTER DEPLOYING YOUR CONTRACT, YOU NEED TO CALL setKycDapp METHOD PASSING IN ADDRESS OF KYC DAPP.

When you inherit RegistryDependent, this exposes a bunch of methods marked as public or internal in your contract which you can find in the RegistryDependent.sol file.

Kyc Integration

For example, there is a public method called kycDapp() that returns a IKycDapp contract object. Now we need to also know what methods exist in IKycDapp which you can see by finding the file from which it was imported ./IKycDapp.sol. There you can see some methods that you can call on kycDapp(). One of them is isKycLevel1 method.

import { RegistryDependent } from "./RegistryDependent.sol";

contract MyDapp is RegistryDependent {
  function myFunction() public {
    bool isKycDone = kycDapp().isKycLevel1(msg.sender); // This line makes a internal message call to kyc dapp contract.
    require(isKycDone, "Kyc is not done");
  }
}

Dayswapper Reward Integration

Similarly you can send dayswapper rewards using dayswappers() method that is exposed due to inheritance. It returns a IDayswappers object. So you need to browse to import path ../Dayswappers/IDayswappers.sol if you want to see what methods are available to call.

For example, you want to pay to the introducer of your user, you can use payToIntroducer method.

import { RegistryDependent } from "./RegistryDependent.sol";

contract MyCoffeeDapp is RegistryDependent {
  function buyCoffee() public payable { // Note that this function is payable and amount is important to be received here
    // sending 10% of amount received as incentive. Reward ratio as 50% liquid, 0% prepaid, 50% staked.
    dayswappers().payToIntroducer{value: msg.value.mul(10).div(100)}(msg.sender, [50, 0, 50]);
  }
}

Dayswapper Volume

You need to use the reportVolume function.

import { RegistryDependent } from "./RegistryDependent.sol";

contract MyCoffeeDapp is RegistryDependent {
  function buyCoffee() public payable { // Note that this function is payable and amount is important to be received here
    // pass the address for whom the volume is to be reported and the amount.
    dayswappers().reportVolume(msg.sender, 1000);
  }
}

NOTE: Your platform also needs to be Kyc Approved as well as authorised in Dayswappers. Please follow the bellow steps:

  1. Steps to register the KYC on KycDapp
  2. From admin wallet, the username needs to be added to authorised list on Dayswappers using updateAuthorisation function (which is available in Dayswappers contract by inheritance). Example of doing this thing is available here.

TimeAlly Club Integration

This is not a straight forward process. Your contract methods will revert while giving TimeAlly Club rewards if you contract is not authorized in TimeAlly Club.

  1. Your platform needs it's incentive structure set in TimeAlly Club (solidity, example js code in testcases).

Method that you can call for giving rewards are rewardToIntroducer and rewardToNetworker. But these methods are locked by onlyAuthorized modifier. Your contract needs to be authorized.

  1. Your smart contract needs it's Kyc to be done from Bhakti mam's wallet (admin/governance wallet). Is would be done using setIdentityOwner method on KycDApp (UI is also integrated in kyc's admin panel for this). This will create a username for your smart contract.

  2. Call updateAuthorization method which is available on TimeAlly Club smart contract (since Authorizable is inherited) using admin/governance wallet. Now your platform is authorized to give TimeAlly Club rewards.

It is highly suggested that you write test cases for your platform contract about this procedure for better clarity and prevent wasting time trying to figure this out manually on Remix. Also note that the order of the steps followed also matters.