# Profile
- cooldownRemainSeconds
- getLonBalance
- getOrdersHistory
- getOrderState
- getReferralPool
- getTokenAllowance
- getTokenBalance
- getTradableTokenAllowance
- getTradableTokenBalance
- getTradableTokenBalanceAndAllowance
- getXLonBalanceByAddr
- previewRageExit
- stakersCooldowns
# cooldownRemainSeconds
To get cooldown remaining seconds
# Parameters:
Name | Type |
---|---|
userAddress | string |
# Code sample:
const profile = new Profile(provider)
const cooldown = await profile.cooldownRemainSeconds('0x6b030f453e7e0f1447601ee757947286a60b0122')
# Response:
BigNumber { _hex: '0x00', _isBigNumber: true }
# getLonBalance
To get Lon balance by address
# Parameters:
Name | Type |
---|---|
userAddress | string |
# Code sample:
const profile = new Profile(provider)
const balance = await profile.getLonBalance('0x6b030f453e7e0f1447601ee757947286a60b0122')
# Response:
402628.200476395476408882
# getOrdersHistory
To get orders history for provided address
# Parameters:
Name | Type |
---|---|
userAddress | string |
page | number |
perpage | number |
# Code sample:
const profile = new Profile(provider)
const orders = await profile.getOrdersHistory('0x6b030f453e7e0f1447601ee757947286a60b0122', 1, 10)
# Response:
[
{
from: '0x7a250d5630b4cf539739df2c5dacb4c659f2488d',
to: '0x6b030f453e7e0f1447601ee757947286a60b0122',
fromToken: {
symbol: 'LON',
logo: 'https://v2-cdn-dev.token.im/app-production/tokens/icons/LON.png',
contractAddress: '0x6da0e6abd44175f50c563cd8b860dd988a7c3433',
decimal: 18,
precision: 6,
minTradeAmount: 1200,
maxTradeAmount: 100000,
},
toToken: {
symbol: 'ETH',
logo: 'https://v2-cdn.token.im/app-mainnet-production/tokens/icons/eth%403x.png',
contractAddress: '0x0000000000000000000000000000000000000000',
decimal: 18,
precision: 4,
minTradeAmount: 0.25,
maxTradeAmount: 888,
},
fromTokenAmountUnit: '444',
toTokenAmountUnit: '0.05752229',
executeTxHash: '0xf858ac9cf65216ba90d8f68f0f349517c916f3dc97982dad8c5ae4da60beaed5',
txHash: '0xc5dd37a0cd20dafb2b5246d91a03932879530b7aa245e05647b2e36a8a14c820',
status: 'success',
blockNumber: 5339935,
timestamp: 1629270121,
finishedTimestamp: 1629270162,
feeFactor: 355,
feeDetail: {
stdFee: 30,
tokenlonFee: 22,
gasFee: 355,
refuelSendETH: 0,
refuelApprove: 0,
vendorFee: 0,
},
feeTokenSymbol: 'ETH',
feeTokenAmountUnit: '0.002138659156955377',
actualTokenSymbol: 'ETH',
actualTokenUnit: '0.058105260757280569',
receiverAddress: '0x6b030f453e7e0f1447601ee757947286a60b0122',
protocol: 'AMMV2',
},
...
]
# getOrderState
To get order state with a transaction hash
# Parameters:
Name | Type |
---|---|
executeTxHash | string |
# Code sample:
const profile = new Profile(provider)
const orders = await profile.getOrdersHistory('0x6b030f453e7e0f1447601ee757947286a60b0122', 1, 10)
const orderState = await profile.getOrderState(orders[0].executeTxHash)
# Response:
{
status: 'success',
order: {
from: '0x7a250d5630b4cf539739df2c5dacb4c659f2488d',
to: '0x6b030f453e7e0f1447601ee757947286a60b0122',
fromToken: {
symbol: 'LON',
logo: 'https://v2-cdn-dev.token.im/app-production/tokens/icons/LON.png',
contractAddress: '0x6da0e6abd44175f50c563cd8b860dd988a7c3433',
decimal: 18,
precision: 6,
minTradeAmount: 1200,
maxTradeAmount: 100000
},
toToken: {
symbol: 'ETH',
logo: 'https://v2-cdn.token.im/app-mainnet-production/tokens/icons/eth%403x.png',
contractAddress: '0x0000000000000000000000000000000000000000',
decimal: 18,
precision: 4,
minTradeAmount: 0.25,
maxTradeAmount: 888
},
fromTokenAmountUnit: '444',
toTokenAmountUnit: '0.05752229',
executeTxHash: '0xf858ac9cf65216ba90d8f68f0f349517c916f3dc97982dad8c5ae4da60beaed5',
txHash: '0xc5dd37a0cd20dafb2b5246d91a03932879530b7aa245e05647b2e36a8a14c820',
status: 'success',
blockNumber: 5339935,
timestamp: 1629270121,
finishedTimestamp: 1629270162,
feeFactor: 355,
feeDetail: {
stdFee: 30,
tokenlonFee: 22,
gasFee: 355,
refuelSendETH: 0,
refuelApprove: 0,
vendorFee: 0
},
feeTokenSymbol: 'ETH',
feeTokenAmountUnit: '0.002138659156955377',
actualTokenSymbol: 'ETH',
actualTokenUnit: '0.058105260757280569',
receiverAddress: '0x6b030f453e7e0f1447601ee757947286a60b0122',
protocol: 'AMMV2'
}
}
# getReferralPool
To get referral data
# Parameters:
Name | Type |
---|---|
poolParams | ReferralPool |
# Code sample:
const profile = new Profile(provider)
const referral = await Profile.getReferralPool({
address: '0x6b030f453e7e0f1447601ee757947286a60b0122',
base: 'eth',
quote: 'lon',
chainId: chainId,
})
# Response:
{
address: '0x6b030f453e7e0f1447601ee757947286a60b0122',
boundCode: '',
feeFactor: 22,
holdTFT: false,
lonBalance: 704,
power: 0,
powerRatio: 0,
round: 67,
roundDate: 1635293280,
totalEqualLon: 99
}
# getTokenAllowance
To get token allowance by token address
# Parameters:
Name | Type |
---|---|
tokenAddress | string |
userAddress | string |
# Code sample:
const profile = new Profile(provider)
const tokenAllowance = await profile.getTokenAllowance(
'0x6da0e6abd44175f50c563cd8b860dd988a7c3433',
'0x6b030f453e7e0f1447601ee757947286a60b0122',
)
# Response:
0.0
# getTokenBalance
To get token balance by token address
# Parameters:
Name | Type |
---|---|
tokenAddress | string |
userAddress | string |
# Code sample:
const profile = new Profile(provider)
const tokenBalance = await profile.getTokenBalance(
'0x6da0e6abd44175f50c563cd8b860dd988a7c3433',
'0x6b030f453e7e0f1447601ee757947286a60b0122',
)
# Response:
3.0
# getTradableTokenAllowance
To get token allowance by token symbol
# Parameters:
Name | Type |
---|---|
tokenAddressOrSymbol | string |
userAddress | string |
protocols | Protocol[] |
# Code sample:
const profile = new Profile(provider)
const lonAllowance = await profile.getTradableTokenAllowance(
'LON',
'0x6b030f453e7e0f1447601ee757947286a60b0122',
[Protocol.AMMV1, Protocol.AMMV2, Protocol.PMMV5, Protocol.RFQV1],
)
# Response:
{
contractAddress: '0x6da0e6abd44175f50c563cd8b860dd988a7c3433',
decimal: 18,
isOptimal: true,
logo: 'https://v2-cdn-dev.token.im/app-production/tokens/icons/LON.png',
maxTradeAmount: '100000',
minTradeAmount: '900',
opposites: [ 'ETH', 'USDT', 'USDC', 'SUSHI', 'DAI' ],
precision: 6,
recommend: true,
symbol: 'LON',
balance: '0.0'
}
# getTradableTokenBalance
To get token balance by token symbol
# Parameters:
Name | Type |
---|---|
tokenAddressOrSymbol | string |
userAddress | string |
protocols | Protocol[] |
# Code sample:
const profile = new Profile(provider)
const ethBalance = await profile.getTradableTokenBalance(
'ETH',
'0x6b030f453e7e0f1447601ee757947286a60b0122',
[Protocol.AMMV1, Protocol.AMMV2, Protocol.PMMV5, Protocol.RFQV1],
)
# Response:
{
contractAddress: '0x0000000000000000000000000000000000000000',
decimal: 18,
isOptimal: true,
logo: 'https://v2-cdn.token.im/app-mainnet-production/tokens/icons/eth%403x.png',
maxTradeAmount: '888',
minTradeAmount: '0.195',
opposites: [ 'LON', 'UNI', 'USDT', 'DAI', 'SUSHI' ],
precision: 4,
recommend: true,
symbol: 'ETH',
balance: '10000.0'
}
# getTradableTokenBalanceAndAllowance
To get token balance and allowance by token address/symbol
# Parameters:
Name | Type |
---|---|
tokenAddressOrSymbol | string |
userAddress | string |
protocols | Protocol[] |
# Code sample:
const profile = new Profile(provider)
const ethBalance = await profile.getTradableTokenBalanceAndAllowance(
'ETH',
'0x6b030f453e7e0f1447601ee757947286a60b0122',
[Protocol.AMMV1, Protocol.AMMV2, Protocol.PMMV5, Protocol.RFQV1],
)
# Response:
{
contractAddress: '0x6da0e6abd44175f50c563cd8b860dd988a7c3433',
decimal: 18,
isOptimal: true,
logo: 'https://v2-cdn-dev.token.im/app-production/tokens/icons/LON.png',
maxTradeAmount: '100000',
minTradeAmount: '900',
opposites: [ 'ETH', 'USDT', 'USDC', 'SUSHI', 'DAI' ],
precision: 6,
recommend: true,
symbol: 'LON',
balance: '0.0',
allowance: '0.0'
}
# getXLonBalanceByAddr
To get XLon balance with address
# Parameters:
Name | Type |
---|---|
userAddress | string |
# Code sample:
const profile = new Profile(provider)
const balance = await profile.getXLonBalanceByAddr('0x6b030f453e7e0f1447601ee757947286a60b0122')
# Response:
2.48390543077192128
# previewRageExit
To preview rage exit with address
# Parameters:
Name | Type |
---|---|
userAddress | string |
# Code sample:
const profile = new Profile(provider)
const preview = await profile.previewRageExit('0x6b030f453e7e0f1447601ee757947286a60b0122')
# Response:
{ receiveAmount: '566.495636480689136732', penaltyAmount: '0.0' }
# stakersCooldowns
To get cooldowns with staking address
# Parameters:
Name | Type |
---|---|
userAddress | string |
# Code sample:
const profile = new Profile(provider)
const balance = await profile.stakersCooldowns('0x6b030f453e7e0f1447601ee757947286a60b0122')
# Response:
BigNumber { _hex: '0x00', _isBigNumber: true }