Skip to content

Unofficial Python SDK for the Folks Finance protocol

License

Notifications You must be signed in to change notification settings

algolog/ff-py-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ff-py-sdk

Unofficial Python SDK for the Folks Finance v2 lending protocol on the Algorand blockchain. Direct translation of most functions from the folks-finance-js-sdk and folks-router-js-sdk into Python.

  • Function names and arguments are preserved from the JS SDK. Camel case and snake case code styles are often mixed.
  • currentRound field was dropped from the returned data types.

Functions overview

Lending v2
  • Deposit

    • retrievePoolManagerInfo
    • retrievePoolInfo
    • retrieveUserDepositsInfo
    • retrieveUserDepositsFullInfo
    • retrieveUserDepositInfo
    • prepareAddDepositEscrowToDeposits
    • prepareOptDepositEscrowIntoAssetInDeposits
    • prepareDepositIntoPool
    • prepareWithdrawFromDepositEscrowInDeposits
    • prepareWithdrawFromPool
    • prepareUpdatePoolInterestIndexes
    • prepareOptOutDepositEscrowFromAssetInDeposits
    • prepareRemoveDepositEscrowFromDeposits
  • DepositStaking

    • retrieveDepositStakingInfo
    • retrieveUserDepositStakingsLocalState
    • retrieveUserDepositStakingLocalState
    • prepareAddDepositStakingEscrow
    • prepareOptDepositStakingEscrowIntoAsset
    • prepareSyncStakeInDepositStakingEscrow
    • prepareClaimRewardsOfDepositStakingEscrow
    • prepareWithdrawFromDepositStakingEscrow
    • prepareOptOutDepositStakingEscrowFromAsset
    • prepareRemoveDepositStakingEscrow
  • Loan

    • retrieveLoanInfo
    • retrieveLoansLocalState
    • retrieveLoanLocalState
    • retrieveUserLoansInfo
    • retrieveUserLoanInfo
    • retrieveLiquidatableLoans
    • getMaxReduceCollateralForBorrowUtilisationRatio
    • getMaxBorrowForBorrowUtilisationRatio
    • getUserLoanAssets NEW
    • prepareCreateUserLoan
    • prepareAddCollateralToLoan
    • prepareSyncCollateralInLoan
    • prepareReduceCollateralFromLoan
    • prepareSwapCollateralInLoanBegin
    • prepareSwapCollateralInLoanEnd
    • prepareRemoveCollateralFromLoan
    • prepareBorrowFromLoan
    • prepareSwitchBorrowTypeInLoan
    • prepareRepayLoanWithTxn
    • prepareRepayLoanWithCollateral
    • prepareLiquidateLoan
    • prepareRebalanceUpLoan
    • prepareRebalanceDownLoan
    • prepareRemoveUserLoan
    • prepareFlashLoanBegin
    • prepareFlashLoanEnd
    • wrapWithFlashLoan
  • Oracle

    • parseOracleValue
    • parseLPTokenOracleValue
    • getTinymanLPPrice
    • getPactLPPrice
    • getOraclePrices (partial, without LP tokens)
    • prepareRefreshPricesInOracleAdapter (partial, without LPPools oracle update)
  • Utils

    • getEscrows
    • getAppEscrowsWithState NEW
    • depositStakingLocalState
    • depositStakingProgramsInfo
    • userDepositStakingInfo
    • loanLocalState
    • userLoanInfo
  • AMM

    • retrievePactLendingPoolInfo (TODO: farming APRs)
Algo liquid governance
  • Common

    • getDispenserInfo
  • Governance v2

    • getDistributorLogicSig
    • getDistributorInfo
    • getUserLiquidGovernanceInfo
    • getEscrowGovernanceStatus
    • prepareAddLiquidGovernanceEscrowTransactions
    • prepareMintTransactions
    • prepareUnmintPremintTransaction
    • prepareUnmintTransactions
    • prepareClaimPremintTransaction
    • prepareRegisterEscrowOnlineTransaction
    • prepareRegisterEscrowOfflineTransaction
    • prepareCommitOrVoteTransaction
    • prepareRemoveLiquidGovernanceEscrowTransactions
    • prepareBurnTransactions
xAlgo liquid governance
  • getXAlgoInfo
  • prepareMintXAlgoTransactions
  • prepareBurnXAlgoTransactions
Folks Router
  • fetchSwapQuote
  • prepareSwapTransactions
  • getReferrerLogicSig
  • prepareReferrerOptIntoAsset
  • prepareClaimReferrerFees
  • prepareEnableAssetToBeSwapped

Installation

pip install git+https://github.com/algolog/ff-py-sdk

Example

from ffsdk.client import FFMainnetClient
from ffsdk.lending.v2.deposit import retrievePoolManagerInfo, retrievePoolInfo
from ffsdk.lending.v2.depositStaking import retrieveDepositStakingInfo
from ffsdk.lending.v2.utils import depositStakingProgramsInfo
from ffsdk.lending.v2.oracle import getOraclePrices
from ffsdk.lending.v2.mathlib import ONE_14_DP


client = FFMainnetClient().lending
pmi = retrievePoolManagerInfo(client.indexer, client.pool_manager_app_id)
oracle_prices = getOraclePrices(client.indexer, client.oracle)

# deposit pool info
pool_info = retrievePoolInfo(client.indexer, client.pools["ALGO"])
deposit_yield = pool_info.interest.depositInterestYield / ONE_14_DP
print(f'ALGO deposit APY: {deposit_yield:.2f}%')

# deposit staking programs info
dsi = retrieveDepositStakingInfo(client.indexer, client.deposit_staking_app_id)
dpi = depositStakingProgramsInfo(dsi, pmi, client.pools, oracle_prices)

About

Unofficial Python SDK for the Folks Finance protocol

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages