transfer

transfer(sender,recipient,amount)transfer(sender,recipient,amount)

  • Callable by any M holder

  • Allows a user to transfer M between both - yield earning and non-yield earning participants. Deducts amountamount from sendersender and Adds to recipientrecipient.

    • If sendersender and recipientrecipient are both yield earning or non-yield earning participants balanceOfMToken,sender=amountbalanceOf_{MToken, sender} -= amount balanceOfMToken,recipient+=amountbalanceOf_{MToken, recipient} += amount

    • If sendersender is yield earning and recipientrecipient is non-yield earning participantprincipalOfEarningSupplyMToken,sender=amount/indexnowparticipantprincipalOfEarningSupply_{MToken, sender} = amount / index_{now} balanceOfMToken,sender=principalOfEarningSupplyMToken,senderbalanceOf_{MToken, sender} -= principalOfEarningSupply_{MToken, sender} totalPrincipalOfEarningSupply=principalOfEarningSupplyMToken,sendertotalPrincipalOfEarningSupply -=principalOfEarningSupply_{MToken, sender} balanceOfMToken,recipient+=amountbalanceOf_{ MToken, recipient} += amount

      totalNonEarningSupply+=amounttotalNonEarningSupply += amount

    • If sendersender is non-yield earning and recipientrecipient is yield earning participant balanceOfMToken,sender=amountbalanceOf_{MToken, sender} -= amount totalNonEarningSupply=amounttotalNonEarningSupply -= amount principalOfEarningSupplyMToken,recipient=amount/indexnowprincipalOfEarningSupply_{MToken, recipient} = amount / index_{now} balanceOfMToken,recipient+=principalOfEarningSupplyMToken,recipientbalanceOf _{MToken, recipient} += principalOfEarningSupply_{MToken, recipient} totalPrincipalOfEarningSupply+=principalOfEarningSupplyMToken,recipienttotalPrincipalOfEarningSupply +=principalOfEarningSupply_{MToken, recipient}

    • Calls updateIndexupdateIndex.

Last updated

Copyright 2024 M^0 Foundation