|
|
@@ -14,41 +14,7 @@ const v2ToolBy410 = new web3.eth.Contract(v2ToolBy410Abi, contracts.V2_TOOLS_BY_
|
|
|
export class LpMaintenance {
|
|
|
tokenInstance: any = {}
|
|
|
maxMemoryOfByte: number = 0
|
|
|
- maxMemoryChanged: boolean = false
|
|
|
-
|
|
|
- async handleToken(pool: any, zero: boolean) {
|
|
|
- const token = {
|
|
|
- 'address': zero ? pool.token0 : pool.token1,
|
|
|
- 'symbol': zero ? pool.symbol0 : pool.symbol1,
|
|
|
- 'decimals': zero ? pool.decimals0 : pool.decimals1,
|
|
|
- 'name': 'xxxxxxxx'
|
|
|
- }
|
|
|
-
|
|
|
- let tokenObj = this.tokenInstance[token.address]
|
|
|
- if (!tokenObj) {
|
|
|
- tokenObj = new web3.eth.Contract(ierc20abi, token.address)
|
|
|
- this.tokenInstance[token.address] = tokenObj
|
|
|
- }
|
|
|
-
|
|
|
- token.name = await tokenObj.methods.name().call()
|
|
|
- token.name = token.name.replace(/[^A-Za-z0-9 ]+/g, '').substring(0, 37)
|
|
|
-
|
|
|
- return token
|
|
|
- }
|
|
|
-
|
|
|
- async saveToken(lp: any, type='token') {
|
|
|
- try {
|
|
|
- const token = await this.handleToken(lp, true)
|
|
|
-
|
|
|
- await history.appendOrUpdate(type, token.address, token)
|
|
|
- } catch (e) {}
|
|
|
-
|
|
|
- try {
|
|
|
- const token = await this.handleToken(lp, false)
|
|
|
-
|
|
|
- await history.appendOrUpdate(type, token.address, token)
|
|
|
- } catch (e) {}
|
|
|
- }
|
|
|
+ maxMemoryChanged: boolean = true
|
|
|
|
|
|
async saveLp(lp: any, type='0') {
|
|
|
await History.appendOrUpdate(type, lp.LP, lp)
|