The Xend Finance SDK arms python developers with the ability to build DeFi applications with Xend Finance without needing to understand the complexities of the underlying blockchain or layer2 infrastructure.
Note: For easier navigation, please use the documentation hosted on the Github Repository.
Contributions are welcome! Kindly refer to the contribution guidelines.
To install this sdk, run the command:
pip install xend-python-sdk
import xend_finance
from xend_finance import XendFinance
Instantiate 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 examples
- Use one general address for all your transactions
- Create a new address for each of your users and use for their transactions
Note:
- The env field is one of
local
,testnet
andmainnet
. - 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.
This 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": "",
}
}
Refer to the official documentation for more information about the exposed strategies
The following services are available with this SDK
1. General
- Flexible Deposit
- Fixed Deposit
- Get fixed deposit record
- Get flexible deposit record
- Fixed Withdrawal
- Flexible Withdrawal
3. Esusu
- Create Esusu Cycle
- Get Cycles Count
- Get Cycle Id
- Get Esusu Info
- Join Esusu Group
- Start Esusu Cycle
- Withdraw Interest
- Withdraw Capital
- Is Member
- Accrue Interest Capital
- Create Esusu Group
- Get Esusu Group
- Esusu Contributions
- No of Contributions
- Get cycles in group
- Create Cooperative Cylce
- Join Cooperative Cycle
- Get Cooperative Info
- Is Cooperative Member
- Start Cooperative Cycle
- Withdraw From Ongoing Cycle
- Withdraw From Completed Cycle
- Create Cooperative Group
- Get Cooperative Group
- Cooperative Contributions
- Cooperative cycles in group
5. Groups
6. Xauto
7. Xvault
This strategy provides utility methods such as creating a wallet, getting wallet balance and getting price per full share.
This method allows a user to create a wallet on a specific node.
create_wallet = xend.create_wallet()
This method allows a user retrieve the details of a wallet such as wallet address and private key.
retrieve_wallet = xend.retrieve_wallet()
This method allows a user retrieve the balance details of a wallet
wallet_balance = xend.wallet_balance()
This method allows a user retrieve the price per full share of his/her wallet
get_ppfs = xend.get_ppfs()
This strategy provides methods for users to interact with their savings from Xend finance.
This method allows users to create a flexible deposit on their wallet
create_flexible_deposit = xend.personal.flexible_deposit("20")
Parameters | Data type | Required | Description |
---|---|---|---|
deposit_amount |
string | true | The amount to be deposited. |
This method allows users to create a fixed deposit on their wallet for a specific period of time
create_fixed_deposit = xend.personal.fixed_deposit("40", 30000)
Parameters | Data type | Required | Description |
---|---|---|---|
deposit_amount |
string | true | The amount to be deposited. |
lock_period |
integer | true | The lock period in seconds. |
This method allows users to get a list of all fixed deposits on their wallet
fixed_deposit_record = xend.personal.get_fixed_deposit_record()
This method allows users to get a list of all flexible deposits on their wallet
flexible_deposit_record = xend.personal.get_flexible_deposit_record()
This method allows users to perform fixed withdrawals on their wallet
fixed_withdrawal = xend.personal.fixed_withdrawal(10)
Parameters | Data type | Required | Description |
---|---|---|---|
record_id |
string | true | The id of the savings to be withdrawn from. |
This method allows users to perform flexible withdrawals on their wallet
flexible_withdrawal = xend.personal.flexible_withdrawal("30.0")
Parameters | Data type | Required | Description |
---|---|---|---|
amount |
string or float | true | The amount a user wants to withdraw. |
This strategy provides methods for users to interact with an esusu style of contributions/savings from Xend finance.
This method allows users to create esusu cycles
args = {
"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 | Data type | Required | Description |
---|---|---|---|
group_id |
integer | true | The group a user wants to create the cycle on |
deposit_amount |
string | true | The amount a user wants to deposit while creating the cycle |
payout_interval_in_seconds |
integer | true | The payout interval in seconds. |
start_time_in_seconds |
integer | true | The start time in seconds. |
max_members |
integer | true | The maximum number of members in the cycle. |
This method returns the number of esusu cycles a user has/is present in
get_esusu_cycles_count = xend.esusu.get_cycles_count()
This method returns the cycle id of a cycle at the specified position in the list of cycles created by the user
get_esusu_cycle_id = xend.esusu.get_cycle_id_from_cycles_created(6)
Parameters | Data type | Required | Description |
---|---|---|---|
position |
integer | true | The position of the cycle |
This method returns the information about an esusu cycle/group
get_esusu_info = xend.esusu.get_esusu_info(5)
Parameters | Data type | Required | Description |
---|---|---|---|
esusu_id |
integer | true | The id of the esusu group/cycle |
This method allows users to join an esusu group or cycle
join_esusu_cycle = xend.esusu.join(9)
Parameters | Data type | Required | Description |
---|---|---|---|
id |
integer | true | The id of the esusu group/cycle |
This method allows users to start an esusu cycle
start_esusu_cycle = xend.esusu.start(3)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of the esusu cycle |
This method allows users to withdraw their interest from an esusu group/cycle
withdraw_interest = xend.esusu.withdraw_interest(8)
Parameters | Data type | Required | Description |
---|---|---|---|
esusu_id |
integer | true | The id of the esusu group/cycle |
This method allows users to withdraw their capital from an esusu group/cycle
withdraw_capital = xend.esusu.withdraw_capital(14)
Parameters | Data type | Required | Description |
---|---|---|---|
esusu_id |
integer | true | The id of the esusu group/cycle |
This method checks if a particular user is in an esusu cycle
is_member_of_esusu_cycle = xend.esusu.is_member_of_cycle(9)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of the esusu cycle |
This method returns the accrued interest and capital of a user from an esusu cycle
get_interest_capital = xend.esusu.accrue_interest_capital(16)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of the esusu cycle |
This methods allows users to create an esusu group
create_esusu_group = xend.esusu.create_group('test', 'TXT')
Parameters | Data type | Required | Description |
---|---|---|---|
group_name |
string | true | The name of the group |
symbol |
string | true | The group's symbol |
This method returns all the esusu groups a user is associated with
get_esusu_group = xend.esusu.get_groups()
This methods returns all the contributions a user has made in the esusu groups/cycles he is associated with
esusu_contributions = xend.esusu.contributions()
This methods returns the contributions count of a user in the groups/cycles he is associated with
no_of_contributions = xend.esusu.no_of_contributions()
This method returns the esusu cycles present in a particular esusu group
esusu_cycles_in_group = xend.esusu.cycles_in_group(11)
Parameters | Data type | Required | Description |
---|---|---|---|
group_id |
integer | true | The id of the esusu group |
This strategy provides methods for users to interact with cooperative savings and contributions from Xend finance.
This method allows users to create cooperative cycles
args = {
"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 | Data type | Required | Description |
---|---|---|---|
group_id |
integer | true | The group the user wants to create the cycle on |
cycle_stake_amount |
string | true | The stake amount the user wants to deposit while creating the cycle |
payout_interval_in_seconds |
integer | true | The payout interval in seconds. |
start_time_in_seconds |
integer | true | The start time in seconds. |
max_members |
integer | true | The maximum number of members in the cycle. |
This method allows users to join a cooperative cycle
join_cooperative = xend.cooperative.join(10,25)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of to the cooperative cycle |
number_of_stakes |
integer | true | The stake amount the user wants to deposit while joining the cycle |
This method returns the information about a cooperatve cycle
cooperative_cycle_info = xend.cooperative.info(5)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of to the cooperative cycle |
This method checks if a particular user is in a cooperative cycle
does_member_exist = xend.cooperative.cycle_member_exist(5)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of to the cooperative cycle |
This method allows users to start a cooperative cycle
start_cycle = xend.cooperative.start_cyle(5)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of to the cooperative cycle |
This method allows users to withdraw tokens from an ongoing cooperative cycle
withdraw_ongoing_cycle = xend.cooperative.withdraw_from_ongoing_cycle(7)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of to the cooperative cycle |
This method allows users to withdraw tokens from a completed cooperative cycle
withdraw_completed_cycle = xend.cooperative.withdraw_completed(10)
Parameters | Data type | Required | Description |
---|---|---|---|
cycle_id |
integer | true | The id of to the cooperative cycle |
This method allows users to create a cooperative group
create_cooperative_group = xend.cooperative.create_group('test', 'TST')
Parameters | Data type | Required | Description |
---|---|---|---|
group_name |
string | true | The name of the group |
symbol |
string | true | The group's symbol |
This method returns all the cooperative groups a user is associated with
get_cooperative_groups = xend.cooperative.get_cooperative_groups()
This methods returns all the contributions a user has made in the cooperative groups/cycles he is associated with
cooperative_cycles_contributions = xend.cooperative.contributions()
This method returns the cooperative cycles present in a particular cooperative group
cycles_in_cooperative_group = xend.cooperative.cycles_in_group(1)
Parameters | Data type | Required | Description |
---|---|---|---|
group_id |
integer | true | The id of the cooperative group |
This strategy provides utility methods for groups related operations such as creating a group, getting a group/groups and getting group rewards
This method allows a user to create a group.
create_group = xend.group.create('mnt', 'MNT')
Parameters | Data type | Required | Description |
---|---|---|---|
group_name |
string | true | The name of the group |
symbol |
string | true | The group's symbol |
This method allows a user retrieve the details of a group.
get_single_group = xend.group.get_single_group(3)
Parameters | Data type | Required | Description |
---|---|---|---|
group_id |
integer | true | The id of the cooperative group |
This method returns all the groups a user is associated with
get_groups = xend.group.get_groups()
This method allows a user redeem any xend rewards earned
get_xend_rewards = xend.group.get_xend_rewards()
This strategy provides utility methods for auto yield related operations on the xAuto protocol.
This method approves the amount of tokens to be spent from a user's wallet
approve_token = xend.xauto.approve("TNT", 300)
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token to be approved |
amount |
integer | true | The amount of tokens to be approved |
This method deposits an amount of tokens to a user's wallet
deposit_token = xend.xauto.deposit("BSC",150)
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token to be deposited |
amount |
integer | true | The amount of tokens to be deposited |
This method withdraws an amount of tokens from a user's wallet
withdraw_token = xend.xauto.withdraw("DAI",240)
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token to be withdrawn |
amount |
integer | true | The amount of tokens to be withdrawn |
This method returns the price per share of a token
get_ppfs = xend.xauto.ppfs("DAI")
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token name |
This method returns the balance of a token in a user's wallet
get_share_balance = xend.xauto.share_balance("DAI")
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token name |
This strategy provides utility methods for auto yield related operations on the xVault protocol
This method approves the amount of tokens to be spent from a user's wallet
approve_token = xend.xvault.approve("BSC", 250)
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token to be approved |
amount |
integer | true | The amount of tokens to be approved |
This method deposits an amount of tokens to a user's wallet
deposit_token = xend.xvault.deposit("BSC",150)
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token to be deposited |
amount |
integer | true | The amount of tokens to be deposited |
This method withdraws an amount of tokens from a user's wallet
withdraw_token = xend.xvault.withdraw("DAI",240)
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token to be withdrawn |
amount |
integer | true | The amount of tokens to be withdrawn |
This method returns the price per share of a token
get_ppfs = xend.xvault.ppfs("DAI")
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token name |
This method returns the balance of a token in a user's wallet
get_share_balance = xend.xvault.share_balance("DAI")
Parameters | Data type | Required | Description |
---|---|---|---|
token |
string | true | The token name |