Skip to content

Commit

Permalink
Merge pull request #24 from terra-money/feature/mito
Browse files Browse the repository at this point in the history
Feature/mito
  • Loading branch information
simke9445 authored Mar 19, 2024
2 parents 75ff61f + 0efd1c5 commit 6adeaea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
42 changes: 20 additions & 22 deletions src/examples/example_mito.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MnemonicKey, Wallet } from '@terra-money/feather.js';
import { WarpSdk } from '../sdk';
import { uint, cond, fn, msg, variable, job, ts, query, string } from '../composers';
import { cond, msg, variable, job, query, string, decimal } from '../composers';
import { ChainName, NetworkName } from 'modules';
import dotenv from 'dotenv';
import fs from 'fs';
Expand Down Expand Up @@ -32,35 +32,37 @@ const subaccount_id = variable

const next_subaccount_available_balance = variable
.query()
.kind('uint')
.value('0')
.kind('decimal')
.name('next_subaccount_available_balance')
.onInit({
query: {
custom: {
subaccount_deposit: {
subaccount_id: variable.ref(subaccount_id),
denom: vault_strategy_denom,
custom: JSON.stringify({
route: 'exchange',
query_data: {
subaccount_deposit: {
subaccount_id: variable.ref(subaccount_id),
denom: vault_strategy_denom,
},
},
},
} as any,
}),
},
selector: '$.deposits.available_balance',
})
.reinitialize(true)
.compose();

const prev_subaccount_available_balance = variable
.static()
.kind('uint')
.kind('decimal')
.name('prev_subaccount_available_balance')
.reinitialize(false)
.onInit({
uint: {
decimal: {
simple: '0',
},
})
.onSuccess({
uint: {
decimal: {
ref: variable.ref(next_subaccount_available_balance),
},
})
Expand Down Expand Up @@ -95,7 +97,7 @@ const prev_config = variable
.compose();

const condition = cond.or(
cond.uint(uint.ref(prev_subaccount_available_balance), 'lt', uint.ref(next_subaccount_available_balance)),
cond.decimal(decimal.ref(prev_subaccount_available_balance), 'lt', decimal.ref(next_subaccount_available_balance)),
cond.string(string.ref(prev_config), 'neq', string.ref(next_config))
);

Expand All @@ -110,7 +112,7 @@ const executions = [
},
];

const recurring = true;
const recurring = false;
const durationDays = '7';
// ordered in reference order (left to right, dfs)
const vars = [
Expand All @@ -137,8 +139,8 @@ const main = async () => {

const createJobMsg = job
.create()
.name('mito-market-make')
.description('Triggers market making on mito vaults.')
.name('mito-market-maker')
.description('Automated market maker for mito vaults.')
.labels([])
.recurring(recurring)
.reward(reward.amount.toString())
Expand All @@ -148,13 +150,9 @@ const main = async () => {
.executions(executions)
.compose();

const tx = await sdk.tx.createJob(sender, createJobMsg, [operationalAmount]);

console.log(JSON.stringify(tx.msgs, null, 2));
const resp = await sdk.createJob(sender, createJobMsg, [operationalAmount]);

// sdk.createJob(sender, createJobMsg, [operationalAmount]).then((response) => {
// console.log(response);
// });
console.log({ resp: JSON.stringify(resp) });
} catch (err) {
console.log(err);
}
Expand Down
16 changes: 8 additions & 8 deletions src/refs.injective.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"testnet": {
"warp-controller": {
"codeId": "7743",
"address": "inj17gcfj5k690rmuvh7czm4ns0jjkw0h60077vxv3"
"codeId": "7967",
"address": "inj1u56l96hs08hqznj0c202arftmh9j3c7m9dylpy"
},
"warp-resolver": {
"codeId": "7744",
"address": "inj1afhfhlraevt5peshg0u5h5rxle0n3r0r892mlk"
"codeId": "7971",
"address": "inj1pku5zgartl3xdlr509u3wjfs48k2lqylpscydf"
},
"warp-templates": {
"codeId": "7745",
"address": "inj1rmpv0suem978hclktmjvtrwl3j5ug0lcvjsp3n"
"codeId": "7966",
"address": "inj1tgmvl9tehyp4w2uddrgwea5pwvev8whr46ajgv"
},
"warp-account-tracker": {
"codeId": "7742",
"address": "inj1h3ufvxckhr77auvvgd8cnh9weqpfrzatmm6zjr"
"codeId": "7968",
"address": "inj1gf7dx0yp8dse8jxtg3e7dgjr4n0wq04dcjwd2j"
}
},
"mainnet": {
Expand Down

0 comments on commit 6adeaea

Please sign in to comment.