Skip to content

Commit 4f64ad2

Browse files
committed
chore: remove workaround, fix lp token ordering, disable stable pools
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
1 parent b4112ca commit 4f64ad2

1 file changed

Lines changed: 88 additions & 101 deletions

File tree

scripts/init-testnet.ts

Lines changed: 88 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -265,36 +265,23 @@ function constructAnnuitySetup(api: ApiPromise) {
265265
}
266266

267267
async function constructAmmSetup(api: ApiPromise) {
268-
// workaround for broken is_exists check - TODO: remove once fixed.
269-
// see https://github.com/interlay/interbtc/blob/1a1afa90228f37c9ade4acbda8275c2f5cfe85ce/parachain/runtime/testnet-kintsugi/src/zenlink.rs#L43
270-
const isExistsWorkaround = [
271-
{ Token: "KBTC" }, // foreign assets also need issuance, but faucet already has those
272-
].map((token) => {
273-
return api.tx.tokens.setBalance(
274-
"a3ckVDnZwjdBhkq1KJodZj3iCgYMseWfLA5fpqExuEpMy8Y5q", // root
275-
token,
276-
0,
277-
1
278-
)
279-
});
280-
281-
const prices:Map<string, number> = new Map();
268+
const prices: Map<string, number> = new Map();
282269
prices.set(JSON.stringify({ Token: "KBTC" }), 22842.91);
283270
prices.set(JSON.stringify({ Token: "KSM" }), 36.05);
284271
prices.set(JSON.stringify({ Token: "KINT" }), 0.982574);
285272
prices.set(JSON.stringify({ ForeignAsset: 1 }), 1); // usdt
286273
prices.set(JSON.stringify({ ForeignAsset: 2 }), 8.94); // movr
287-
const decimals:Map<string, number> = new Map();
274+
const decimals: Map<string, number> = new Map();
288275
decimals.set(JSON.stringify({ Token: "KBTC" }), 8);
289276
decimals.set(JSON.stringify({ Token: "KSM" }), 12);
290277
decimals.set(JSON.stringify({ Token: "KINT" }), 12);
291278
decimals.set(JSON.stringify({ ForeignAsset: 1 }), 6); // usdt
292279
decimals.set(JSON.stringify({ ForeignAsset: 2 }), 18); // movr
293-
280+
294281
const pools: [{ Token: any; }, { Token: any; } | { ForeignAsset: any; }, number, number][] = [
295282
[
296-
{ Token: "KBTC" },
297283
{ Token: "KSM" },
284+
{ Token: "KBTC" },
298285
45_000,
299286
500_000, // liquidity in usd
300287
],
@@ -323,12 +310,12 @@ async function constructAmmSetup(api: ApiPromise) {
323310
// calculate liquidity amounts
324311
let decimals0 = new BN(decimals.get(JSON.stringify(token0)) as number);
325312
let price0 = prices.get(JSON.stringify(token0)) as number;
326-
let liquidity0 = new BN(liquidity/2).mul(new BN(10).pow(decimals0)).divn(price0);
313+
let liquidity0 = new BN(liquidity / 2).mul(new BN(10).pow(decimals0)).divn(price0);
327314

328315
let decimals1 = new BN(decimals.get(JSON.stringify(token1)) as number);
329316
let price1 = prices.get(JSON.stringify(token1)) as number;
330-
let liquidity1 = new BN(liquidity/2).mul(new BN(10).pow(decimals1)).divn(price1);
331-
317+
let liquidity1 = new BN(liquidity / 2).mul(new BN(10).pow(decimals1)).divn(price1);
318+
332319
return [
333320
api.tx.dexGeneral.createPair(token0, token1, 30),
334321
api.tx.farming.updateRewardSchedule(
@@ -353,89 +340,89 @@ async function constructAmmSetup(api: ApiPromise) {
353340
}).flat();
354341

355342

356-
const lKsmPrice = 4.72; // https://apps.karura.network/swap
357-
const vKsmPrice = prices.get(JSON.stringify({Token: "KSM"})) as number * 1.135658; // https://bifrost.app/vstaking/vKSM
358-
const sKsmPrice = 42.37; // https://analytics.parallel.fi/kusama/moneymarket/sKSM
359-
360-
let basePoolLiquidity = 1_100_000;
361-
let lKsmDeposit = new BN(basePoolLiquidity/3).mul(new BN(10).pow(new BN(12))).divn(lKsmPrice);
362-
let vKsmDeposit = new BN(basePoolLiquidity/3).mul(new BN(10).pow(new BN(12))).divn(vKsmPrice);
363-
let sKsmDeposit = new BN(basePoolLiquidity/3).mul(new BN(10).pow(new BN(12))).divn(sKsmPrice);
364-
365-
// note: this is before the batch is executed
366-
const basePoolId = (await api.query.dexStable.nextPoolId() as any).toNumber();
367-
const basePoolSetup = [
368-
api.tx.dexStable.createBasePool(
369-
[
370-
{ ForeignAsset: 3 }, // LKSM
371-
{ ForeignAsset: 4 }, // VKSM
372-
{ ForeignAsset: 5 }, // SKSM
373-
],
374-
[12, 12, 12], // decimals
375-
200, // amplification coefficient
376-
100_000_000, // max fee 1%
377-
0, // no admin fee
378-
treasuryAccount,
379-
"LKSM+VKSM+SKSM" // currency symbol
380-
),
381-
api.tx.farming.updateRewardSchedule(
382-
{ StableLpToken: basePoolId },
383-
{ Token: "KINT" },
384-
60 * 24 * 7 * 12, // three months, reward period is per minute
385-
new BN(10).pow(new BN(12)).muln(15_000),
386-
),
387-
api.tx.utility.dispatchAs(
388-
{ system: { Signed: treasuryAccount } },
389-
api.tx.dexStable.addLiquidity(
390-
basePoolId,
391-
[
392-
lKsmDeposit, // 77683.474576271190 LKSM
393-
vKsmDeposit, // 8956.076760709657 VKSM
394-
sKsmDeposit, // 8653.906065612462 SKSM
395-
],
396-
0, // min mint amount
397-
treasuryAccount, // recipient
398-
new BN(4294967295), // deadline
399-
),
400-
)
401-
];
343+
// const lKsmPrice = 4.72; // https://apps.karura.network/swap
344+
// const vKsmPrice = prices.get(JSON.stringify({ Token: "KSM" })) as number * 1.135658; // https://bifrost.app/vstaking/vKSM
345+
// const sKsmPrice = 42.37; // https://analytics.parallel.fi/kusama/moneymarket/sKSM
346+
347+
// let basePoolLiquidity = 1_100_000;
348+
// let lKsmDeposit = new BN(basePoolLiquidity / 3).mul(new BN(10).pow(new BN(12))).divn(lKsmPrice);
349+
// let vKsmDeposit = new BN(basePoolLiquidity / 3).mul(new BN(10).pow(new BN(12))).divn(vKsmPrice);
350+
// let sKsmDeposit = new BN(basePoolLiquidity / 3).mul(new BN(10).pow(new BN(12))).divn(sKsmPrice);
351+
352+
// // note: this is before the batch is executed
353+
// const basePoolId = (await api.query.dexStable.nextPoolId() as any).toNumber();
354+
// const basePoolSetup = [
355+
// api.tx.dexStable.createBasePool(
356+
// [
357+
// { ForeignAsset: 3 }, // LKSM
358+
// { ForeignAsset: 4 }, // VKSM
359+
// { ForeignAsset: 5 }, // SKSM
360+
// ],
361+
// [12, 12, 12], // decimals
362+
// 200, // amplification coefficient
363+
// 100_000_000, // max fee 1%
364+
// 0, // no admin fee
365+
// treasuryAccount,
366+
// "LKSM+VKSM+SKSM" // currency symbol
367+
// ),
368+
// api.tx.farming.updateRewardSchedule(
369+
// { StableLpToken: basePoolId },
370+
// { Token: "KINT" },
371+
// 60 * 24 * 7 * 12, // three months, reward period is per minute
372+
// new BN(10).pow(new BN(12)).muln(15_000),
373+
// ),
374+
// api.tx.utility.dispatchAs(
375+
// { system: { Signed: treasuryAccount } },
376+
// api.tx.dexStable.addLiquidity(
377+
// basePoolId,
378+
// [
379+
// lKsmDeposit, // 77683.474576271190 LKSM
380+
// vKsmDeposit, // 8956.076760709657 VKSM
381+
// sKsmDeposit, // 8653.906065612462 SKSM
382+
// ],
383+
// 0, // min mint amount
384+
// treasuryAccount, // recipient
385+
// new BN(4294967295), // deadline
386+
// ),
387+
// )
388+
// ];
402389

403-
const metaPoolId = basePoolId + 1;
404-
const metaPoolSetup = [
405-
api.tx.dexStable.createMetaPool(
406-
[
407-
{ Token: "KSM" },
408-
{ StableLpToken: basePoolId }, // LKSM+VKSM+SKSM
409-
],
410-
[12, 18], // decimals
411-
200, // amplification coefficient
412-
100_000_000, // max fee 1%
413-
0, // no admin fee
414-
treasuryAccount,
415-
"KSM+(LKSM+VKSM+SKSM)" // currency symbol
416-
),
417-
api.tx.farming.updateRewardSchedule(
418-
{ StableLpToken: metaPoolId },
419-
{ Token: "KINT" },
420-
60 * 24 * 7 * 12, // three months, reward period is per minute
421-
new BN(10).pow(new BN(12)).muln(33_000),
422-
),
423-
api.tx.utility.dispatchAs(
424-
{ system: { Signed: treasuryAccount } },
425-
api.tx.dexStable.addLiquidity(
426-
metaPoolId,
427-
[
428-
"10000000000000", // 10 KSM
429-
"60000000000000000000", // 80 LKSM
430-
],
431-
0, // min mint amount
432-
treasuryAccount, // recipient
433-
new BN(4294967295), // deadline
434-
),
435-
)
436-
];
390+
// const metaPoolId = basePoolId + 1;
391+
// const metaPoolSetup = [
392+
// api.tx.dexStable.createMetaPool(
393+
// [
394+
// { Token: "KSM" },
395+
// { StableLpToken: basePoolId }, // LKSM+VKSM+SKSM
396+
// ],
397+
// [12, 18], // decimals
398+
// 200, // amplification coefficient
399+
// 100_000_000, // max fee 1%
400+
// 0, // no admin fee
401+
// treasuryAccount,
402+
// "KSM+(LKSM+VKSM+SKSM)" // currency symbol
403+
// ),
404+
// api.tx.farming.updateRewardSchedule(
405+
// { StableLpToken: metaPoolId },
406+
// { Token: "KINT" },
407+
// 60 * 24 * 7 * 12, // three months, reward period is per minute
408+
// new BN(10).pow(new BN(12)).muln(33_000),
409+
// ),
410+
// api.tx.utility.dispatchAs(
411+
// { system: { Signed: treasuryAccount } },
412+
// api.tx.dexStable.addLiquidity(
413+
// metaPoolId,
414+
// [
415+
// "10000000000000", // 10 KSM
416+
// "60000000000000000000", // 80 LKSM
417+
// ],
418+
// 0, // min mint amount
419+
// treasuryAccount, // recipient
420+
// new BN(4294967295), // deadline
421+
// ),
422+
// )
423+
// ];
437424

438-
return isExistsWorkaround.concat(basicPoolSetup).concat(basePoolSetup).concat(metaPoolSetup);
425+
return basicPoolSetup; // .concat(basePoolSetup).concat(metaPoolSetup);
439426
}
440427

441428
function constructForeignAssetSetup(api: ApiPromise) {

0 commit comments

Comments
 (0)