Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worldes rwa token commit #8415

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions coins/src/adapters/moneyMarkets/worldes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import getTokenPrices from "./worldes";

export function worldes(timestamp: number = 0) {
return getTokenPrices("arbitrum", timestamp);
}
48 changes: 48 additions & 0 deletions coins/src/adapters/moneyMarkets/worldes/worldes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Write, } from "../../utils/dbInterfaces";
import { getApi } from "../../utils/sdk";
import { addToDBWritesList, getTokenAndRedirectDataMap } from "../../utils/database";

export const config = {
arbitrum: {
lps: [
'0x80c89197ba29c0ad921ad0f7c2e1403579d36c65',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where can we see how much liquidity is in this lp? why is this contract used instead of the one shown on the UI (0x378B6a8bAe0767B714dF136FABE388DfcC623352)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can obtain LP from the website and verify: https://app.worldes.io/liquid-pool

],
tokens:[
'0xcEab5Af10D5376016c8C352ea77F8Bc6a88bDa11',
]

},
} as any
const nullAddress: string = "0x0000000000000000000000000000000000000000";
export default async function getTokenPrices(chain: string, timestamp: number) {
const api = await getApi(chain, timestamp)

const { lps } = config[chain]
const { tokens } = config[chain]
const writes: Write[] = [];
await _getWrites()

return writes

async function _getWrites() {
if (!lps.length) return;
const [
decimals, symbols, uBalances
] = await Promise.all([
api.multiCall({ abi: 'erc20:decimals', calls: tokens }),
api.multiCall({ abi: "string:symbol", calls: tokens }),
api.multiCall({ abi: 'function querySellBase(address trader, uint256 payBaseAmount) public view returns (uint256 receiveQuoteAmount, uint256 mtFee)', calls: lps.map((address: string )=>({params:[nullAddress,1000000],target: address})) }),
])
const coinData = await getTokenAndRedirectDataMap([...tokens], chain, timestamp)

uBalances.forEach(({ quoteAmount }: any, i: number) => {
const tData = coinData[tokens[i].toLowerCase()]

if (!tData ) return;

const price = quoteAmount / (10 ** decimals[i])
const confidence = 0.8
addToDBWritesList(writes, chain, tokens[i], price, decimals[i], symbols[i], timestamp, 'worldes', confidence)
})
}
}