@zebec-fintech/sui-silver-card-sdk
v1.3.0
Published
An sdk for interacting with zebec silver card sui contract
Downloads
304
Keywords
Readme
Silvercard SUI Package SDK
An sdk for interacting with silvercard sui chain package.
Usage
Create Instance of SuiSilverCardService
To use this sdk, you are required to create a instance of SuiSilverCardService.
const network = "mainnet";
const url = getFullnodeUrl(network);
const suiClient = new SuiClient({ url });
const packageInfo = new SuiSilverCardPackageInfo(network);
const signTransaction = ...; // retrieve from wallet
const service = await SuiSilverCardService.create(packageInfo, suiClient, {
address: "<wallet address>",
signTransaction,
});Get Purchase Profile
const result = await service.getPurchaseProfile({
user: "<wallet address>",
});
console.log("result:", result);Create Purchase Profile
const payload = await service.createPurchaseProfile();
const result = await payload.execute();
console.log("result:", result.digest);Get Card Config
const result = await service.getCardConfig();
console.log("result:", result);Get Fee Tier
const result = await adminService.getFeeTierList();
console.log("result:", result);Add Fee Tier
const fee = 1.5;
const minAmount = "501";
const maxAmount = "1500";
const payload = await adminService.addFeeTier({
fee,
maxAmount,
minAmount,
});
const result = await payload.execute();
console.log("result:", result.digest);Remove Fee Tier
const minAmount = "100";
const maxAmount = "5";
const payload = await adminService.removeFeeTier({ maxAmount, minAmount });
const result = await payload.execute();
console.log("result:", result.digest);Update Fee Tier
const fee = 5;
const minAmount = "11";
const maxAmount = "200";
const payload = await adminService.updateFeeTier({
fee,
maxAmount,
minAmount,
});
const result = await payload.execute();
console.log("result:", result.digest);Get Swap Fee List
const result = await adminService.getSwapFeeList();
console.log("result:", result);Add Swap Fee
const fee = 0;
const tokenType =
"0x51b7f6cdd5a99d8a2d8338440255db2ccfc98d77c8b4b0a376b7d6d4a6a489f6::sui_generic_coins::SUI_GENERIC_COINS";
const payload = await adminService.addSwapFee({ fee, tokenType });
const result = await payload.execute();
console.log("result:", result.digest);Update Swap Fee
const fee = 5;
const tokenType =
"0x98b2f7290927c7f1008294f568d2745df22c2b35f96a1325f8a960058daf852b::sui_generic_coins::SUI_GENERIC_COINS";
const payload = await adminService.updateSwapFee({ fee, tokenType });
const result = await payload.execute();
console.log("result:", result.digest);Remove Swap Fee
const tokenType =
"0x98b2f7290927c7f1008294f568d2745df22c2b35f96a1325f8a960058daf852b::sui_generic_coins::SUI_GENERIC_COINS";
const payload = await adminService.removeSwapFee({ tokenType });
const result = await payload.execute();
console.log("result:", result.digest);Set Card Vault
const vaultAddress =
"0x4b4123283c95fb6c57e72da3e6f21f895fc42dbcb7635da0c30ffd933288bbf4";
const payload = await adminService.setCardVault({ vaultAddress });
const result = await payload.execute();
console.log("result:", result.digest);Set Revenue Vault
const vaultAddress =
"0x3f1bc889eb58146ca6b141c637c26b2e0ef92a459f5cc66edf1e00af76038fda";
const payload = await adminService.setRevenueVault({ vaultAddress });
const result = await payload.execute();
console.log("result:", result.digest);Set Daily Limit
const dailyLimit = "1500";
const payload = await adminService.setDailyLimit({ dailyLimit });
const result = await payload.execute();
console.log("result:", result.digest);Set Max Card Limit
const maxCardAmount = "1500";
const payload = await adminService.setMaxCardAmount({ maxCardAmount });
const result = await payload.execute();
console.log("result:", result.digest);Set Min Card Amount
const minCardAmount = "1";
const payload = await adminService.setMinCardAmount({ minCardAmount });
const result = await payload.execute();
console.log("result:", result.digest);Set Native Fee
const payload = await adminService.setNativeFee({ feePercent: 2.5 });
const result = await payload.execute();
console.log("result:", result.digest);Set NonNative Fee
const payload = await adminService.setNonNativeFee({ feePercent: 5.5 });
const result = await payload.execute();
console.log("result:", result.digest);Set Revenue Fee
const payload = await adminService.setRevenueFee({ feePercent: 3.5 });
const result = await payload.execute();
console.log("result:", result.digest);