GYSR documentation
  • GYSR
  • Benefits
  • History
  • 📖guide
    • Use cases
    • FAQ
    • Launching a Pool
    • Managing a Pool
    • Mechanisms
    • Staking
    • Integrations
  • 🧠Concepts
    • Pools
    • Modules
    • Factory
    • $GYSR token
  • 🛠️Developers
    • Core contracts
    • Core contract docs
    • Deployment addresses
    • Configuration
    • Interactions
    • Error codes
    • Subgraph
  • 🗃️Resources
    • Whitepapers
    • Safety
    • Media
Powered by GitBook
On this page
  1. Developers

Interactions

Example calls directly to the GYSR core contracts

User executes a simple stake of ERC20 tokens into a pool

// get addresses and connect to contracts
const pool = await Pool.at('0xpool');
const stk = await ERC20.at('0xtoken');
const stakingmodule = await Pool.stakingModule();

// make sure tokens are approved
await stk.approve(stakingmodule, toWei('100'), { from: alice });

// alice stakes 100 tokens
await pool.stake(toWei('100'), [], [], { from: alice });

Pool controller funds rewards tokens for a pool

// get addresses and connect to contracts
const pool = await Pool.at('0xpool');
const rew = await ERC20.at('0xtoken');
const rewardmodule = await ERC20FriendlyRewardModule.at(Pool.rewardModule());

// make sure tokens are approved
await rew.approve(this.rewardmodule.address, toWei('5000'), { from: controller });

// controller funds 5000 tokens
await rewardmodule.fund(toWei('5000'), [], [], { from: controller });

More examples coming soon!

PreviousConfigurationNextError codes

Last updated 1 year ago

🛠️