Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

[KAVA] Stored CDP, HARD, incentive and auctions details in db #547

Open
wants to merge 25 commits into
base: kava
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move meteor cdp methods
  • Loading branch information
MonikaCat committed Jul 12, 2021
commit 476d066cb85e6d6d8cdadff27dbdda5c7112c818
20 changes: 1 addition & 19 deletions imports/api/accounts/server/methods.js
Original file line number Diff line number Diff line change
@@ -278,23 +278,5 @@ Meteor.methods({
console.log(e)
}
return cdp
},

'cdp.getCDPList': function (collateralType) {
this.unblock();
let url = LCD + '/cdp/cdps/collateralType/' + collateralType;
try {
let result = HTTP.get(url);
if (result.statusCode == 200) {
let list = JSON.parse(result.content).result;
return list

}
else{
console.log("No CDP for collateral type " + collateralType)
}
} catch (e) {
console.log(e)
}
},
}
})
82 changes: 82 additions & 0 deletions imports/api/cdp/server/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { CDP } from '../cdp';


Meteor.methods({
'cdp.getCDPList': function () {
this.unblock();
let collateralTypes = ['ukava-a', 'bnb-a', 'hard-a', 'btcb-a', 'xrpb-b', 'busd-a', 'busd-b']
for(let collateral in collateralTypes){
let url = LCD + '/cdp/cdps/collateralType/' + collateralTypes[collateral];
try {
let result = HTTP.get(url);
if (result.statusCode == 200) {
let list = JSON.parse(result.content).result[0];
console.log(list)
for (let c = 0; c < list.length; c++) {
CDP.upsert({ cdpId: list[c].cdp.id }, list[c]);
}
return list

}
else {
console.log("No CDP for collateral type " + collateralTypes[collateral])
}
} catch (e) {
console.log(e)
}
}

},
'cdp.getCDPParams': function () {
this.unblock();
let url = LCD + '/cdp/parameters';
let cdpParams = {};

try {
let response = HTTP.get(url);
if (response.statusCode == 200) {
cdpParams = JSON.parse(response.content).result;
return cdpParams
}
}
catch (e) {
console.log(e)
}
},

'cdp.getCDPPrice': function (market) {
this.unblock();
let url = LCD + '/pricefeed/price/' + market;
let cdpPrice = null;

try {
let response = HTTP.get(url);
if (response.statusCode == 200) {
cdpPrice = JSON.parse(response.content).result.price;
return cdpPrice
}
}
catch (e) {
console.log(e)
}
},

'cdp.getDeposits': function (address, collateral) {
this.unblock();
let url = LCD + '/cdp/cdps/cdp/deposits/' + address + '/' + collateral;

try {
let response = HTTP.get(url);
if (response.statusCode == 200) {
return JSON.parse(response.content).result
}
}
catch (e) {
console.log(url);
console.log(e)
}
},

})
50 changes: 0 additions & 50 deletions imports/api/ledger/server/methods.js
Original file line number Diff line number Diff line change
@@ -60,56 +60,6 @@ Meteor.methods({
let validator = Validators.findOne({ delegator_address: address })
return validator;
},
'cdp.getCDPParams': function () {
this.unblock();
let url = LCD + '/cdp/parameters';
let cdpParams = {};

try {
let response = HTTP.get(url);
if (response.statusCode == 200) {
cdpParams = JSON.parse(response.content).result;
return cdpParams
}
}
catch (e) {
console.log(e)
}
},

'cdp.getCDPPrice': function (market) {
this.unblock();
let url = LCD + '/pricefeed/price/' + market;
let cdpPrice = null;

try {
let response = HTTP.get(url);
if (response.statusCode == 200) {
cdpPrice = JSON.parse(response.content).result.price;
return cdpPrice
}
}
catch (e) {
console.log(e)
}
},

'cdp.getDeposits': function (address, collateral) {
this.unblock();
let url = LCD + '/cdp/cdps/cdp/deposits/' + address + '/' + collateral;

try {
let response = HTTP.get(url);
if (response.statusCode == 200) {
return JSON.parse(response.content).result
}
}
catch (e) {
console.log(url);
console.log(e)
}
},

'account.getIncentive': function () {
this.unblock();
let url = LCD + '/incentive/rewards'
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.