Skip to content

Commit fc76859

Browse files
add usdc and usdt on movement
1 parent 6a43c83 commit fc76859

File tree

6 files changed

+63
-2
lines changed

6 files changed

+63
-2
lines changed

src/adapters/peggedAssets/helper/aptos.ts

+24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const axios = require("axios");
22
const retry = require("async-retry");
33
const endpoint = "https://fullnode.mainnet.aptoslabs.com";
4+
import http from "../helper/http";
45

56
export async function aQuery(api: string) {
67
const query = await retry(
@@ -38,4 +39,27 @@ export async function getTokenSupply(token: string) {
3839
const coinInfo = data.find((coin: any) => coin.type.startsWith('0x1::coin::CoinInfo'));
3940

4041
return coinInfo.data.supply.vec[0].integer.vec[0].value / 10 ** coinInfo.data.decimals;
42+
}
43+
44+
const MOVEMENT_RPC = "https://mainnet.movementnetwork.xyz";
45+
46+
export async function function_view({
47+
functionStr,
48+
type_arguments = [],
49+
args = [],
50+
ledgerVersion,
51+
}: {
52+
functionStr: string;
53+
type_arguments?: string[];
54+
args?: any[];
55+
ledgerVersion?: number;
56+
}) {
57+
let path = `${MOVEMENT_RPC}/v1/view`;
58+
if (ledgerVersion !== undefined) path += `?ledger_version=${ledgerVersion}`;
59+
const response = await http.post(path, {
60+
function: functionStr,
61+
type_arguments,
62+
arguments: args,
63+
});
64+
return response.length === 1 ? response[0] : response;
4165
}

src/adapters/peggedAssets/helper/chains.json

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"morph",
110110
"moonbeam",
111111
"moonriver",
112+
"move",
112113
"nahmii",
113114
"near",
114115
"neo",

src/adapters/peggedAssets/tether/config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,7 @@ export const chainContracts: ChainContracts = {
378378
corn: {
379379
bridgedFromETH: ["0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb"], // USDT0
380380
},
381+
move: {
382+
bridgedFromETH: ["0x38cdb3f0afabee56a3393793940d28214cba1f5781e13d5db18fa7079f60ab55"], // OFT native bridge
383+
}
381384
};

src/adapters/peggedAssets/tether/index.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const sdk = require("@defillama/sdk");
22
import { ChainApi } from "@defillama/sdk";
3-
import { getTotalSupply as aptosGetTotalSupply } from "../helper/aptos";
3+
import { getTotalSupply as aptosGetTotalSupply, function_view } from "../helper/aptos";
44
import { sumMultipleBalanceFunctions, sumSingleBalance } from "../helper/generalUtil";
55
import {
66
bridgedSupply,
@@ -458,6 +458,18 @@ async function suiBridged(): Promise<Balances> {
458458
return balances;
459459
}
460460

461+
async function moveNativeBridge(): Promise<Balances> {
462+
const balances = {} as Balances;
463+
464+
const resp = await function_view({
465+
functionStr: `${chainContracts.move.bridgedFromETH}::oft_fa::supply`,
466+
args: [],
467+
});
468+
balances["peggedUSD"] = Number(resp) / 1e6; // adjust if decimals ≠ 6
469+
470+
return balances;
471+
}
472+
461473

462474
async function polyNetworkBridged(
463475
chainID: number,
@@ -1091,6 +1103,9 @@ const adapter: PeggedIssuanceAdapter = {
10911103
},
10921104
corn: {
10931105
ethereum: bridgedSupply("corn", 6, chainContracts.corn.bridgedFromETH)
1106+
},
1107+
move: {
1108+
ethereum: moveNativeBridge,
10941109
}
10951110
};
10961111

src/adapters/peggedAssets/usd-coin/config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,7 @@ export const chainContracts: ChainContracts = {
485485
flare: {
486486
bridgedFromETH: ["0xFbDa5F676cB37624f28265A144A48B0d6e87d3b6"],
487487
},
488+
move: {
489+
bridgedFromETH: ["0x4d2969d384e440db9f1a51391cfc261d1ec08ee1bdf7b9711a6c05d485a4110a"], // oft native bridge
490+
},
488491
};

src/adapters/peggedAssets/usd-coin/index.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
getBalance as ontologyGetBalance,
2222
} from "../helper/ontology";
2323
import { getTotalSupply as kavaGetTotalSupply } from "../helper/kava";
24-
import { getTotalSupply as aptosGetTotalSupply } from "../helper/aptos";
24+
import { getTotalSupply as aptosGetTotalSupply, function_view } from "../helper/aptos";
2525
import { call as nearCall } from "../helper/near";
2626
import {
2727
ChainBlocks,
@@ -500,6 +500,18 @@ async function flowBridged(address: string, decimals: number) {
500500
};
501501
}
502502

503+
async function moveNativeBridge(): Promise<Balances> {
504+
const balances = {} as Balances;
505+
506+
const resp = await function_view({
507+
functionStr: `${chainContracts.move.bridgedFromETH}::oft_fa::supply`,
508+
args: [],
509+
});
510+
balances["peggedUSD"] = Number(resp) / 1e6; // adjust if decimals ≠ 6
511+
512+
return balances;
513+
}
514+
503515

504516
const adapter: PeggedIssuanceAdapter = {
505517
ethereum: {
@@ -1035,6 +1047,9 @@ const adapter: PeggedIssuanceAdapter = {
10351047
chainContracts.xdc.bridgeOnARB[0],
10361048
6
10371049
)
1050+
},
1051+
move: {
1052+
ethereum: moveNativeBridge,
10381053
}
10391054
};
10401055

0 commit comments

Comments
 (0)