Skip to main content

Referral Operations

Methods for tracking referrals and distributing rewards.

recordAction

Records a user action that triggers referral rewards (partner-only method).
async recordAction(userAddress: Address, actionValue: bigint): Promise<Hex>

Parameters

NameTypeDescription
userAddressAddressAddress of the user performing the action
actionValuebigintValue of the action in wei (e.g., 100 * 10^18 for 1 cUSD)

Returns

Hex - Transaction hash of the action recording.

Example

// Record an action worth 1 cUSD
const actionValue = 1000000000000000000n; // 1 cUSD in wei
const txHash = await sdk.recordAction('0x1234...', actionValue);
console.log('Action recorded:', txHash);

Requirements

  • Only authorized partners can call this method
  • The caller must be registered as a partner with a valid subscription

getRewardRates

Gets the reward rates for a user based on their badge tier.
async getRewardRates(userAddress: Address): Promise<RewardRates>

Parameters

NameTypeDescription
userAddressAddressAddress of the user

Returns

RewardRates object containing reward percentages in basis points.

Example

const rates = await sdk.getRewardRates('0x1234...');
console.log('Level 1 rate (bps):', rates.level1Bps);
console.log('Level 2 rate (bps):', rates.level2Bps);

bpsToPercentage

Converts basis points to percentage.
bpsToPercentage(bps: bigint): number

Parameters

NameTypeDescription
bpsbigintValue in basis points

Returns

number - Percentage value.

Example

const percentage = sdk.bpsToPercentage(500n); // 500 basis points = 5%
console.log('Percentage:', percentage);

getCUSDBalance

Gets the cUSD balance of an address.
async getCUSDBalance(address: Address): Promise<bigint>

Parameters

NameTypeDescription
addressAddressAddress to check balance for

Returns

bigint - Balance in wei.

Example

const balance = await sdk.getCUSDBalance('0x1234...');
console.log('cUSD balance:', balance);

approveCUSDCustom

Approves a custom amount of cUSD for spending.
async approveCUSDCustom(amount: bigint): Promise<Hex>

Parameters

NameTypeDescription
amountbigintAmount to approve in wei

Returns

Hex - Transaction hash of the approval.

Example

const amount = 1000000000000000000n; // 1 cUSD
const txHash = await sdk.approveCUSDCustom(amount);
console.log('Approval transaction hash:', txHash);