Package: xend-python-sdk
Xend-python SDKThe Xend Finance SDK arms python developers with the ability to build DeFi applications withXend Financewithout needing to understand the complexities of the underlying blockchain or layer2 infrastructure.Note: For easier navigation, please use the documentation hosted on theGithub Repository.Table of contentWant to ContributeInstallationUsageAvailable Strategies exposed by the SDKWant to contribute?Contributions are welcome! Kindly refer to thecontribution guidelines.InstallationTo install this sdk, run the command:pip install xend-python-sdkUsageimportxend_financefromxend_financeimportXendFinanceInstantiate the XendFinance class like so:xend=XendFinance(your_chain_id,private_key,{"env":"testnet"})You can use Xend Finance in as many scenario's you can come up with, but there are 2 examplesUse one general address for all your transactionsCreate a new address for each of your users and use for their transactionsNote:The env field is one oflocal,testnetandmainnet.the chain_id of the network. a chain id of 1 represents the ethereum mainnet, 56 represents the Binance Smart Chain(BSC) mainnet, 137 represents the polygon mainnet while 0 denotes a localnet.Protocol TypeThis is the structure of a protocol to be used by the SDK and will be helpful when using the SDK on your local machine with an instance of tools like ganache.{"name":"","code":"","addresses":{"PROTOCOL_ADAPTER":"","PROTOCOL_SERVICE":"","GROUPS":"","CYCLES":"","ESUSU_SERVICE":"","ESUSU_STORAGE":"","ESUSU_ADAPTER":"","COOPERATIVE":"","PERSONAL":"","CLIENT_RECORD":"","XEND_TOKEN":"","TOKEN":"","PROTOCOL_CURRENCY":"",}}Available Strategies exposed by the SDKRefer to the officialdocumentationfor more information about the exposed strategiesThe following services are available with this SDK1.GeneralCreate WalletRetrieve WalletWallet BalanceGet PPFS2.Personal SavingsFlexible DepositFixed DepositGet fixed deposit recordGet flexible deposit recordFixed WithdrawalFlexible Withdrawal3.EsusuCreate Esusu CycleGet Cycles CountGet Cycle IdGet Esusu InfoJoin Esusu GroupStart Esusu CycleWithdraw InterestWithdraw CapitalIs MemberAccrue Interest CapitalCreate Esusu GroupGet Esusu GroupEsusu ContributionsNo of ContributionsGet cycles in group4.Cooperative SavingsCreate Cooperative CylceJoin Cooperative CycleGet Cooperative InfoIs Cooperative MemberStart Cooperative CycleWithdraw From Ongoing CycleWithdraw From Completed CycleCreate Cooperative GroupGet Cooperative GroupCooperative ContributionsCooperative cycles in group5.GroupsCreate GroupGet GroupGet GroupsGet rewards6.XautoApproveDepositWithdrawGet Price per shareShare Balance7.XvaultApprove vaultDeposit vaultWithdraw vaultGet Price per share vaultShare Balance vault1. GeneralThis strategy provides utility methods such as creating a wallet, getting wallet balance and getting price per full share.Create WalletThis method allows a user to create a wallet on a specific node.create_wallet=xend.create_wallet()Retrieve WalletThis method allows a user retrieve the details of a wallet such as wallet address and private key.retrieve_wallet=xend.retrieve_wallet()Wallet BalanceThis method allows a user retrieve the balance details of a walletwallet_balance=xend.wallet_balance()Get PPFSThis method allows a user retrieve the price per full share of his/her walletget_ppfs=xend.get_ppfs()2. Personal SavingsThis strategy provides methods for users to interact with their savings from Xend finance.Flexible DepositThis method allows users to create a flexible deposit on their walletcreate_flexible_deposit=xend.personal.flexible_deposit("20")Parameters supportedParametersData typeRequiredDescriptiondeposit_amountstringtrueThe amount to be deposited.Fixed DepositThis method allows users to create a fixed deposit on their wallet for a specific period of timecreate_fixed_deposit=xend.personal.fixed_deposit("40",30000)Parameters supportedParametersData typeRequiredDescriptiondeposit_amountstringtrueThe amount to be deposited.lock_periodintegertrueThe lock period in seconds.Get fixed deposit recordThis method allows users to get a list of all fixed deposits on their walletfixed_deposit_record=xend.personal.get_fixed_deposit_record()Get flexible deposit recordThis method allows users to get a list of all flexible deposits on their walletflexible_deposit_record=xend.personal.get_flexible_deposit_record()Fixed WithdrawalThis method allows users to perform fixed withdrawals on their walletfixed_withdrawal=xend.personal.fixed_withdrawal(10)Parameters supportedParametersData typeRequiredDescriptionrecord_idstringtrueThe id of the savings to be withdrawn from.Flexible WithdrawalThis method allows users to perform flexible withdrawals on their walletflexible_withdrawal=xend.personal.flexible_withdrawal("30.0")Parameters supportedParametersData typeRequiredDescriptionamountstring or floattrueThe amount a user wants to withdraw.3. EsusuThis strategy provides methods for users to interact with an esusu style of contributions/savings from Xend finance.Create Esusu CycleThis method allows users to create esusu cyclesargs={"group_id":1,"deposit_amount":"300","payout_interval_in_seconds":3600,"start_time_in_seconds":1579014400,"max_members":10}create_esusu_cycle=xend.esusu.create_esusu(args)Parameters supportedParametersData typeRequiredDescriptiongroup_idintegertrueThe group a user wants to create the cycle ondeposit_amountstringtrueThe amount a user wants to deposit while creating the cyclepayout_interval_in_secondsintegertrueThe payout interval in seconds.start_time_in_secondsintegertrueThe start time in seconds.max_membersintegertrueThe maximum number of members in the cycle.Get Cycles CountThis method returns the number of esusu cycles a user has/is present inget_esusu_cycles_count=xend.esusu.get_cycles_count()Get Cycle IdThis method returns the cycle id of a cycle at the specified position in the list of cycles created by the userget_esusu_cycle_id=xend.esusu.get_cycle_id_from_cycles_created(6)Parameters supportedParametersData typeRequiredDescriptionpositionintegertrueThe position of the cycleGet Esusu InfoThis method returns the information about an esusu cycle/groupget_esusu_info=xend.esusu.get_esusu_info(5)Parameters supportedParametersData typeRequiredDescriptionesusu_idintegertrueThe id of the esusu group/cycleJoin Esusu GroupThis method allows users to join an esusu group or cyclejoin_esusu_cycle=xend.esusu.join(9)Parameters supportedParametersData typeRequiredDescriptionidintegertrueThe id of the esusu group/cycleStart Esusu CycleThis method allows users to start an esusu cyclestart_esusu_cycle=xend.esusu.start(3)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of the esusu cycleWithdraw InterestThis method allows users to withdraw their interest from an esusu group/cyclewithdraw_interest=xend.esusu.withdraw_interest(8)Parameters supportedParametersData typeRequiredDescriptionesusu_idintegertrueThe id of the esusu group/cycleWithdraw CapitalThis method allows users to withdraw their capital from an esusu group/cyclewithdraw_capital=xend.esusu.withdraw_capital(14)Parameters supportedParametersData typeRequiredDescriptionesusu_idintegertrueThe id of the esusu group/cycleIs MemberThis method checks if a particular user is in an esusu cycleis_member_of_esusu_cycle=xend.esusu.is_member_of_cycle(9)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of the esusu cycleAccrue Interest CapitalThis method returns the accrued interest and capital of a user from an esusu cycleget_interest_capital=xend.esusu.accrue_interest_capital(16)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of the esusu cycleCreate Esusu GroupThis methods allows users to create an esusu groupcreate_esusu_group=xend.esusu.create_group('test','TXT')Parameters supportedParametersData typeRequiredDescriptiongroup_namestringtrueThe name of the groupsymbolstringtrueThe group's symbolGet Esusu GroupThis method returns all the esusu groups a user is associated withget_esusu_group=xend.esusu.get_groups()Esusu ContributionsThis methods returns all the contributions a user has made in the esusu groups/cycles he is associated withesusu_contributions=xend.esusu.contributions()No Of ContributionsThis methods returns the contributions count of a user in the groups/cycles he is associated withno_of_contributions=xend.esusu.no_of_contributions()Get cycles in GroupThis method returns the esusu cycles present in a particular esusu groupesusu_cycles_in_group=xend.esusu.cycles_in_group(11)Parameters supportedParametersData typeRequiredDescriptiongroup_idintegertrueThe id of the esusu group4. Cooperative SavingsThis strategy provides methods for users to interact with cooperative savings and contributions from Xend finance.Create Cooperative CycleThis method allows users to create cooperative cyclesargs={"group_id":1,"cycle_stake_amount":"0.1","payout_interval_in_seconds":3600,"start_time_in_seconds":1579014400,"max_members":10}create_cooperate=xend.cooperative.create(args)Parameters supportedParametersData typeRequiredDescriptiongroup_idintegertrueThe group the user wants to create the cycle oncycle_stake_amountstringtrueThe stake amount the user wants to deposit while creating the cyclepayout_interval_in_secondsintegertrueThe payout interval in seconds.start_time_in_secondsintegertrueThe start time in seconds.max_membersintegertrueThe maximum number of members in the cycle.Join Cooperative CycleThis method allows users to join a cooperative cyclejoin_cooperative=xend.cooperative.join(10,25)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of to the cooperative cyclenumber_of_stakesintegertrueThe stake amount the user wants to deposit while joining the cycleGet Cooperative InfoThis method returns the information about a cooperatve cyclecooperative_cycle_info=xend.cooperative.info(5)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of to the cooperative cycleIs Cooperative MemberThis method checks if a particular user is in a cooperative cycledoes_member_exist=xend.cooperative.cycle_member_exist(5)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of to the cooperative cycleStart Cooperative CycleThis method allows users to start a cooperative cyclestart_cycle=xend.cooperative.start_cyle(5)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of to the cooperative cycleWithdraw From Ongoing CycleThis method allows users to withdraw tokens from an ongoing cooperative cyclewithdraw_ongoing_cycle=xend.cooperative.withdraw_from_ongoing_cycle(7)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of to the cooperative cycleWithdraw From Completed CycleThis method allows users to withdraw tokens from a completed cooperative cyclewithdraw_completed_cycle=xend.cooperative.withdraw_completed(10)Parameters supportedParametersData typeRequiredDescriptioncycle_idintegertrueThe id of to the cooperative cycleCreate Cooperative GroupThis method allows users to create a cooperative groupcreate_cooperative_group=xend.cooperative.create_group('test','TST')Parameters supportedParametersData typeRequiredDescriptiongroup_namestringtrueThe name of the groupsymbolstringtrueThe group's symbolGet Cooperative GroupThis method returns all the cooperative groups a user is associated withget_cooperative_groups=xend.cooperative.get_cooperative_groups()Cooperative ContributionsThis methods returns all the contributions a user has made in the cooperative groups/cycles he is associated withcooperative_cycles_contributions=xend.cooperative.contributions()Cooperative cycles in groupThis method returns the cooperative cycles present in a particular cooperative groupcycles_in_cooperative_group=xend.cooperative.cycles_in_group(1)Parameters supportedParametersData typeRequiredDescriptiongroup_idintegertrueThe id of the cooperative group5. GroupsThis strategy provides utility methods for groups related operations such as creating a group, getting a group/groups and getting group rewardsCreate GroupThis method allows a user to create a group.create_group=xend.group.create('mnt','MNT')Parameters supportedParametersData typeRequiredDescriptiongroup_namestringtrueThe name of the groupsymbolstringtrueThe group's symbolGet GroupThis method allows a user retrieve the details of a group.get_single_group=xend.group.get_single_group(3)Parameters supportedParametersData typeRequiredDescriptiongroup_idintegertrueThe id of the cooperative groupGet GroupsThis method returns all the groups a user is associated withget_groups=xend.group.get_groups()Get rewardsThis method allows a user redeem any xend rewards earnedget_xend_rewards=xend.group.get_xend_rewards()6. XautoThis strategy provides utility methods for auto yield related operations on the xAuto protocol.ApproveThis method approves the amount of tokens to be spent from a user's walletapprove_token=xend.xauto.approve("TNT",300)Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token to be approvedamountintegertrueThe amount of tokens to be approvedDepositThis method deposits an amount of tokens to a user's walletdeposit_token=xend.xauto.deposit("BSC",150)Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token to be depositedamountintegertrueThe amount of tokens to be depositedWithdrawThis method withdraws an amount of tokens from a user's walletwithdraw_token=xend.xauto.withdraw("DAI",240)Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token to be withdrawnamountintegertrueThe amount of tokens to be withdrawnGet Price per ShareThis method returns the price per share of a tokenget_ppfs=xend.xauto.ppfs("DAI")Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token nameShare BalanceThis method returns the balance of a token in a user's walletget_share_balance=xend.xauto.share_balance("DAI")Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token name7. XvaultThis strategy provides utility methods for auto yield related operations  on the xVault protocolApprove vaultThis method approves the amount of tokens to be spent from a user's walletapprove_token=xend.xvault.approve("BSC",250)Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token to be approvedamountintegertrueThe amount of tokens to be approvedDeposit vaultThis method deposits an amount of tokens to a user's walletdeposit_token=xend.xvault.deposit("BSC",150)Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token to be depositedamountintegertrueThe amount of tokens to be depositedWithdraw vaultThis method withdraws an amount of tokens from a user's walletwithdraw_token=xend.xvault.withdraw("DAI",240)Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token to be withdrawnamountintegertrueThe amount of tokens to be withdrawnGet Price per Share vaultThis method returns the price per share of a tokenget_ppfs=xend.xvault.ppfs("DAI")Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token nameShare Balance vaultThis method returns the balance of a token in a user's walletget_share_balance=xend.xvault.share_balance("DAI")Parameters supportedParametersData typeRequiredDescriptiontokenstringtrueThe token name