Skip to content

Commit 5a8f015

Browse files
committed
feat: add binance smart chain more platforms
acryptos apeSwap cafeSwap coralFarm kebab ramen slime
1 parent bbb46d9 commit 5a8f015

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/providers/BSCDeFi.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ async function getTokensEquivalent (lpAddress, lpTokenAmount) {
100100
}
101101

102102
class MasterChef {
103-
constructor (chefABI, address, pendingMethodName) {
103+
constructor (chefABI, address, pendingMethodName, pendingSymbol='') {
104104
this.address = address
105105
this.contract = new web3.eth.Contract(chefABI, address)
106106
this.decoder = new InputDataDecoder(chefABI)
107107
this.pendingMethodName = pendingMethodName
108+
this.pendingSymbol = pendingSymbol
108109
}
109110

110111
lpTransactions (walletTx, poolID) {
@@ -144,7 +145,10 @@ class MasterChef {
144145
async getPendingReward (poolID, walletAddress) {
145146
const pendingReward = await this.contract.methods[this.pendingMethodName](poolID, walletAddress).call()
146147

147-
const tokenName = this.pendingMethodName.replace('pending', '').toUpperCase()
148+
let tokenName = this.pendingSymbol
149+
if (tokenName === '') {
150+
tokenName = this.pendingMethodName.replace('pending', '').toUpperCase()
151+
}
148152

149153
const rewards = {}
150154
rewards[tokenName] = parseFloat(Web3.utils.fromWei(pendingReward))
@@ -245,7 +249,7 @@ class PancakeSwapChef extends MasterChef {
245249
}
246250

247251
class PancakeSwapCloneChef extends MasterChef {
248-
constructor (address, pendingMethodName) {
252+
constructor (address, pendingMethodName, tokenSymbol = '') {
249253
const newChefABI = pancakeSwapABI.map(method => {
250254
if (method.name !== 'pendingCake') {
251255
return method
@@ -259,12 +263,19 @@ class PancakeSwapCloneChef extends MasterChef {
259263
}
260264

261265
const defiPlatforms = {
266+
acryptos: new PancakeSwapCloneChef('0x96c8390BA28eB083A784280227C37b853bc408B7', 'pendingSushi', 'ACS'),
262267
alpaca: new PancakeSwapCloneChef('0xA625AB01B08ce023B2a342Dbb12a16f2C8489A8F', 'pendingAlpaca'),
268+
apeSwap: new PancakeSwapCloneChef('0x5c8D727b265DBAfaba67E050f2f739cAeEB4A6F9', 'pendingCake', 'BANANA'),
263269
autoFarm: new AutoFarmChef(),
264-
pancakeSwap: new PancakeSwapChef(),
265270
bVault: new BVaultChef(),
271+
cafeSwap: new PancakeSwapCloneChef('0xc772955c33088a97D56d0BBf473d05267bC4feBB', 'pendingCake', 'BREW'),
272+
coralFarm: new PancakeSwapCloneChef('0x713e34640ef300a0B178a9688458BbA8b1FA35A7', 'pendingCrl'),
266273
goose: new PancakeSwapCloneChef('0xe70E9185F5ea7Ba3C5d63705784D8563017f2E57', 'pendingEgg'),
267-
saltSwap: new PancakeSwapCloneChef('0xB4405445fFAcF2B86BC2bD7D1C874AC739265658', 'pendingSalt')
274+
kebab: new PancakeSwapCloneChef('0x76FCeffFcf5325c6156cA89639b17464ea833ECd', 'pendingCake', 'KEBAB'),
275+
pancakeSwap: new PancakeSwapChef(),
276+
ramen: new PancakeSwapCloneChef('0x97dd424b4628c8d3bd7fcf3a4e974cebba011651', 'pendingCake', 'RAMEN'),
277+
saltSwap: new PancakeSwapCloneChef('0xB4405445fFAcF2B86BC2bD7D1C874AC739265658', 'pendingSalt'),
278+
slime: new PancakeSwapCloneChef('0x4B0073A79f2b46Ff5a62fA1458AAc86Ed918C80C', 'pendingReward', 'SLIME')
268279
}
269280

270281
/**

test/BSCDeFiTest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ const BSCDeFi = require('../').providers[providerName]
66

77
test(`[${providerName}] platforms`, async t => {
88
const defi = new BSCDeFi()
9-
const platforms = ['pancakeSwap', 'autoFarm', 'saltSwap', 'goose', 'alpaca', 'bVault']
9+
const platforms = BSCDeFi.availablePlatforms
1010
const platformPools = await defi
1111
.address('0xD9d3dd56936F90ea4c7677F554dfEFD45eF6Df0F')
1212
.platforms(platforms)
1313
.exec()
14-
1514
t.is(platformPools.length, platforms.length)
1615
platformPools.forEach(pools => {
1716
pools.forEach(pool => {
@@ -35,7 +34,7 @@ test(`[${providerName}] platforms`, async t => {
3534
test(`[${providerName}] not supported platform`, async t => {
3635
const defi = new BSCDeFi()
3736
await t.throwsAsync(() => defi
38-
.address('0x8b631c499D0160aCD1163122FE14DF0e3FdC5521')
37+
.address('0xD9d3dd56936F90ea4c7677F554dfEFD45eF6Df0F')
3938
.platforms(['notSupported'])
4039
.exec(), { instanceOf: NotSupportedPlatformError })
4140
})

0 commit comments

Comments
 (0)