-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: aqf extra price feeds and add test
- Loading branch information
Showing
19 changed files
with
507 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
-------- | ||
CREATE TABLE debt_sync ( | ||
last_calculated_at integer, | ||
field_set boolean PRIMARY KEY | ||
); | ||
|
||
CREATE TABLE debts ( | ||
block_num integer, | ||
cal_health_factor varchar(80), | ||
cal_threshold_value_bi character varying(80), | ||
cal_borrowed_amt_with_interest_bi character varying(80), | ||
cal_total_value_bi character varying(80), | ||
profit_underlying DOUBLE PRECISION, | ||
profit_usd DOUBLE PRECISION, | ||
collateral_usd DOUBLE PRECISION, | ||
collateral_underlying DOUBLE PRECISION, | ||
id SERIAL NOT NULL, | ||
session_id character varying(100), | ||
total_value_usd DOUBLE PRECISION | ||
); | ||
create index debts_block_num on debts using BTREE (block_num); | ||
create index debts_session_id on debts using BTREE (session_id); | ||
|
||
|
||
CREATE TABLE current_debts ( | ||
session_id varchar(80) PRIMARY KEY, | ||
block_num integer, | ||
cal_health_factor varchar(80), | ||
cal_threshold_value DOUBLE PRECISION, | ||
cal_threshold_value_bi varchar(80), | ||
cal_borrowed_amt_with_interest DOUBLE PRECISION, | ||
cal_borrowed_amt_with_interest_bi varchar(80), | ||
cal_total_value DOUBLE PRECISION, | ||
cal_total_value_bi varchar(80), | ||
profit_usd DOUBLE PRECISION, | ||
profit_underlying DOUBLE PRECISION, | ||
collateral_usd DOUBLE PRECISION, | ||
collateral_underlying DOUBLE PRECISION, | ||
repay_amount DOUBLE PRECISION, | ||
repay_amount_bi varchar(80)); | ||
|
||
ALTER TABLE ONLY current_debts | ||
ADD CONSTRAINT current_debts_block_num_fkey FOREIGN KEY (block_num) REFERENCES blocks(id) ON DELETE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
update sync_adapters set last_sync=18020893-1 where type='PriceOracle'; -- priceoracle | ||
delete from token_oracle where block_num>=18020893; | ||
delete from price_feeds where block_num>=18020893; | ||
delete from sync_adapters where type in ('QueryPriceFeed', 'ChainlinkPriceFeed', 'CompositeChainlinkPF') and discovered_at>=18020893; | ||
update sync_adapters set last_sync= 18020893-1 , disabled='f' where type in ('QueryPriceFeed', 'ChainlinkPriceFeed', 'CompositeChainlinkPF') and last_sync>=18020893; | ||
|
||
|
||
delete from debts where block_num>=18020893; | ||
delete from current_debts where block_num>=18020893; | ||
update debt_sync set last_calculated_at=18020893-1 where last_calculated_at>=18020893; | ||
|
||
-- check if for QueryPriceFeed there is an entry of closure for tokens |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
{ | ||
data: [ | ||
{ | ||
blockNum: 4, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001004, | ||
priceBI: '1004', | ||
roundId: 0, | ||
token: '#Token_2', | ||
}, | ||
{ | ||
blockNum: 4, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001004, | ||
priceBI: '1004', | ||
roundId: 0, | ||
token: '#Token_3', | ||
}, | ||
{ | ||
blockNum: 4, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001004, | ||
priceBI: '1004', | ||
roundId: 0, | ||
token: '#Token_4', | ||
}, | ||
{ | ||
blockNum: 11, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001011, | ||
priceBI: '1011', | ||
roundId: 0, | ||
token: '#Token_2', | ||
}, | ||
{ | ||
blockNum: 11, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001011, | ||
priceBI: '1011', | ||
roundId: 0, | ||
token: '#Token_3', | ||
}, | ||
{ | ||
blockNum: 11, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001011, | ||
priceBI: '1011', | ||
roundId: 0, | ||
token: '#Token_4', | ||
}, | ||
{ | ||
blockNum: 26, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001026, | ||
priceBI: '1026', | ||
roundId: 0, | ||
token: '#Token_2', | ||
}, | ||
{ | ||
blockNum: 26, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001026, | ||
priceBI: '1026', | ||
roundId: 0, | ||
token: '#Token_3', | ||
}, | ||
{ | ||
blockNum: 26, | ||
feed: '#YearnFeed_1', | ||
isPriceInUSD: true, | ||
price: 0.00001026, | ||
priceBI: '1026', | ||
roundId: 0, | ||
token: '#Token_4', | ||
}, | ||
{ | ||
blockNum: 51, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003051, | ||
priceBI: '3051', | ||
roundId: 0, | ||
token: '#Token_2', | ||
}, | ||
{ | ||
blockNum: 51, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003051, | ||
priceBI: '3051', | ||
roundId: 0, | ||
token: '#Token_3', | ||
}, | ||
{ | ||
blockNum: 51, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003051, | ||
priceBI: '3051', | ||
roundId: 0, | ||
token: '#Token_4', | ||
}, | ||
{ | ||
blockNum: 53, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003053, | ||
priceBI: '3053', | ||
roundId: 0, | ||
token: '#Token_2', | ||
}, | ||
{ | ||
blockNum: 53, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003053, | ||
priceBI: '3053', | ||
roundId: 0, | ||
token: '#Token_3', | ||
}, | ||
{ | ||
blockNum: 53, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003053, | ||
priceBI: '3053', | ||
roundId: 0, | ||
token: '#Token_4', | ||
}, | ||
{ | ||
blockNum: 56, | ||
feed: '#YearnFeed_4', | ||
isPriceInUSD: true, | ||
price: 0.0001647, | ||
priceBI: '16470', | ||
roundId: 0, | ||
token: '#Token_4', | ||
}, | ||
{ | ||
blockNum: 58, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003058, | ||
priceBI: '3058', | ||
roundId: 0, | ||
token: '#Token_2', | ||
}, | ||
{ | ||
blockNum: 58, | ||
feed: '#YearnFeed_3', | ||
isPriceInUSD: true, | ||
price: 0.00003058, | ||
priceBI: '3058', | ||
roundId: 0, | ||
token: '#Token_3', | ||
}, | ||
{ | ||
blockNum: 58, | ||
feed: '#YearnFeed_4', | ||
isPriceInUSD: true, | ||
price: 0.00004058, | ||
priceBI: '4058', | ||
roundId: 0, | ||
token: '#Token_4', | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
local utils = import '../utils.libsonnet'; | ||
local borrowedAmount = 4000; | ||
local extraBorrowedAmount = 1000; | ||
local initialAmount = 1000; | ||
local newCollateral = 1; | ||
{ | ||
mocks: { | ||
syncAdapters: 'mocks/yearn_feed.json', | ||
}, | ||
blocks: { | ||
'4': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_1': utils.bigIntTopic(1004, 0), | ||
'#YearnFeed_3': utils.bigIntTopic(3004, 0), | ||
}, | ||
}, | ||
}, | ||
}, | ||
'11': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_1': utils.bigIntTopic(1011, 0), | ||
}, | ||
}, | ||
}, | ||
}, | ||
'26': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_1': utils.bigIntTopic(1026, 0), | ||
'#YearnFeed_3': utils.bigIntTopic(3026, 0), | ||
}, | ||
}, | ||
}, | ||
}, | ||
'31': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_3': utils.bigIntTopic(3031, 0), | ||
}, | ||
}, | ||
}, | ||
}, | ||
'51': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_1': utils.bigIntTopic(1051, 0), | ||
'#YearnFeed_3': utils.bigIntTopic(3051, 0), | ||
}, | ||
}, | ||
}, | ||
}, | ||
'53': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_1': utils.bigIntTopic(1053, 0), | ||
'#YearnFeed_3': utils.bigIntTopic(3053, 0), | ||
}, | ||
}, | ||
}, | ||
}, | ||
'56': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_4': utils.latestRoundData('4056'), | ||
}, | ||
}, | ||
}, | ||
}, | ||
'58': { | ||
calls: { | ||
others: { | ||
feaf968c: { | ||
'#YearnFeed_3': utils.bigIntTopic(3058, 0), | ||
'#YearnFeed_4': utils.bigIntTopic(4058, 0), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |
Oops, something went wrong.