stable-layer-sdk 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +24639 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.mjs +24635 -0
- package/dist/index.mjs.map +7 -0
- package/dist/{generated/stable_vault_farm → types/generated/stable_layer}/deps/bucket_v2_framework/liability.d.ts +2 -2
- package/dist/{generated → types/generated}/stable_layer/deps/std/type_name.d.ts +1 -1
- package/dist/{generated → types/generated}/stable_layer/deps/sui/balance.d.ts +1 -1
- package/dist/{generated/yield_usdb → types/generated/stable_layer}/deps/sui/object.d.ts +1 -1
- package/dist/{generated → types/generated}/stable_layer/stable_layer.d.ts +28 -28
- package/dist/{generated/stable_layer → types/generated/stable_vault_farm}/deps/bucket_v2_framework/liability.d.ts +2 -2
- package/dist/{generated → types/generated}/stable_vault_farm/deps/std/type_name.d.ts +1 -1
- package/dist/{generated → types/generated}/stable_vault_farm/deps/sui/balance.d.ts +1 -1
- package/dist/{generated → types/generated}/stable_vault_farm/deps/sui/object.d.ts +1 -1
- package/dist/{generated → types/generated}/stable_vault_farm/deps/sui/table.d.ts +2 -2
- package/dist/{generated → types/generated}/stable_vault_farm/stable_vault_farm.d.ts +13 -13
- package/dist/{generated → types/generated}/yield_usdb/buffer.d.ts +3 -3
- package/dist/{generated → types/generated}/yield_usdb/deps/bucket_v2_framework/account.d.ts +2 -2
- package/dist/{generated → types/generated}/yield_usdb/deps/bucket_v2_framework/double.d.ts +1 -1
- package/dist/{generated → types/generated}/yield_usdb/deps/sui/balance.d.ts +2 -2
- package/dist/{generated/stable_layer → types/generated/yield_usdb}/deps/sui/object.d.ts +1 -1
- package/dist/{generated → types/generated}/yield_usdb/yield_usdb.d.ts +28 -28
- package/dist/types/index.d.ts +16 -0
- package/dist/types/interface.d.ts +32 -0
- package/dist/{libs → types/libs}/constants.d.ts +1 -1
- package/package.json +35 -18
- package/dist/client.test.js +0 -146
- package/dist/generated/stable_layer/deps/bucket_v2_framework/liability.js +0 -13
- package/dist/generated/stable_layer/deps/bucket_v2_framework/sheet.js +0 -16
- package/dist/generated/stable_layer/deps/std/type_name.js +0 -19
- package/dist/generated/stable_layer/deps/sui/balance.js +0 -14
- package/dist/generated/stable_layer/deps/sui/coin.js +0 -15
- package/dist/generated/stable_layer/deps/sui/object.js +0 -10
- package/dist/generated/stable_layer/deps/sui/vec_map.js +0 -27
- package/dist/generated/stable_layer/deps/sui/vec_set.js +0 -19
- package/dist/generated/stable_layer/stable_layer.js +0 -365
- package/dist/generated/stable_vault_farm/deps/bucket_v2_framework/liability.js +0 -13
- package/dist/generated/stable_vault_farm/deps/bucket_v2_framework/sheet.js +0 -16
- package/dist/generated/stable_vault_farm/deps/std/type_name.js +0 -19
- package/dist/generated/stable_vault_farm/deps/sui/balance.js +0 -14
- package/dist/generated/stable_vault_farm/deps/sui/object.js +0 -10
- package/dist/generated/stable_vault_farm/deps/sui/table.js +0 -32
- package/dist/generated/stable_vault_farm/deps/sui/vec_map.js +0 -27
- package/dist/generated/stable_vault_farm/deps/sui/vec_set.js +0 -19
- package/dist/generated/stable_vault_farm/stable_vault_farm.js +0 -163
- package/dist/generated/utils/index.js +0 -131
- package/dist/generated/yield_usdb/buffer.js +0 -157
- package/dist/generated/yield_usdb/deps/bucket_v2_framework/account.js +0 -12
- package/dist/generated/yield_usdb/deps/bucket_v2_framework/double.js +0 -10
- package/dist/generated/yield_usdb/deps/sui/balance.js +0 -17
- package/dist/generated/yield_usdb/deps/sui/coin.js +0 -15
- package/dist/generated/yield_usdb/deps/sui/object.js +0 -10
- package/dist/generated/yield_usdb/deps/sui/vec_set.js +0 -19
- package/dist/generated/yield_usdb/yield_usdb.js +0 -444
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -238
- package/dist/interface.d.ts +0 -24
- package/dist/interface.js +0 -1
- package/dist/libs/constants.js +0 -18
- /package/dist/{client.test.d.ts → types/client.test.d.ts} +0 -0
- /package/dist/{generated → types/generated}/stable_layer/deps/bucket_v2_framework/sheet.d.ts +0 -0
- /package/dist/{generated → types/generated}/stable_layer/deps/sui/coin.d.ts +0 -0
- /package/dist/{generated → types/generated}/stable_layer/deps/sui/vec_map.d.ts +0 -0
- /package/dist/{generated → types/generated}/stable_layer/deps/sui/vec_set.d.ts +0 -0
- /package/dist/{generated → types/generated}/stable_vault_farm/deps/bucket_v2_framework/sheet.d.ts +0 -0
- /package/dist/{generated → types/generated}/stable_vault_farm/deps/sui/vec_map.d.ts +0 -0
- /package/dist/{generated → types/generated}/stable_vault_farm/deps/sui/vec_set.d.ts +0 -0
- /package/dist/{generated → types/generated}/utils/index.d.ts +0 -0
- /package/dist/{generated → types/generated}/yield_usdb/deps/sui/coin.d.ts +0 -0
- /package/dist/{generated → types/generated}/yield_usdb/deps/sui/vec_set.d.ts +0 -0
package/dist/client.test.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { StableLayerClient } from "./index";
|
|
11
|
-
import { Transaction } from "@mysten/sui/transactions";
|
|
12
|
-
import { getFullnodeUrl, SuiClient } from "@mysten/sui/client";
|
|
13
|
-
import { describe, it, expect, beforeAll } from "vitest";
|
|
14
|
-
import * as constants from "./libs/constants";
|
|
15
|
-
const testConfig = {
|
|
16
|
-
network: "mainnet",
|
|
17
|
-
sender: "0x2b986d2381347d9e1c903167cf9b36da5f8eaba6f0db44e0c60e40ea312150ca",
|
|
18
|
-
};
|
|
19
|
-
describe("StableLayerSDK", () => {
|
|
20
|
-
let sdk;
|
|
21
|
-
let suiClient;
|
|
22
|
-
beforeAll(() => {
|
|
23
|
-
sdk = new StableLayerClient(testConfig);
|
|
24
|
-
suiClient = new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
25
|
-
});
|
|
26
|
-
describe("constructor", () => {
|
|
27
|
-
it("should initialize with correct config", () => {
|
|
28
|
-
expect(sdk).toBeInstanceOf(StableLayerClient);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("buildMintTx", () => {
|
|
32
|
-
it("should build a valid mint transaction", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
const tx = new Transaction();
|
|
34
|
-
const params = {
|
|
35
|
-
tx,
|
|
36
|
-
coinName: "BTC_USD",
|
|
37
|
-
amount: BigInt(10),
|
|
38
|
-
sender: testConfig.sender,
|
|
39
|
-
};
|
|
40
|
-
const builtTx = yield sdk.buildMintTx(params);
|
|
41
|
-
expect(builtTx).toBeInstanceOf(Transaction);
|
|
42
|
-
// Dev inspect the transaction to validate it's well-formed
|
|
43
|
-
const result = yield suiClient.devInspectTransactionBlock({
|
|
44
|
-
transactionBlock: builtTx,
|
|
45
|
-
sender: testConfig.sender,
|
|
46
|
-
});
|
|
47
|
-
// Should not have execution errors in the transaction structure
|
|
48
|
-
expect(result.error).toBeUndefined();
|
|
49
|
-
expect(result.effects.status.status).toBe("success");
|
|
50
|
-
}));
|
|
51
|
-
it("should throw error when neither amount nor all is provided for burn", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
const tx = new Transaction();
|
|
53
|
-
const params = {
|
|
54
|
-
tx,
|
|
55
|
-
coinName: "BTC_USD",
|
|
56
|
-
sender: testConfig.sender,
|
|
57
|
-
};
|
|
58
|
-
yield expect(sdk.buildBurnTx(params)).rejects.toThrow("Amount or all must be provided");
|
|
59
|
-
}));
|
|
60
|
-
});
|
|
61
|
-
describe("buildBurnTx", () => {
|
|
62
|
-
it("should build a valid burn transaction with amount", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
const tx = new Transaction();
|
|
64
|
-
const params = {
|
|
65
|
-
tx,
|
|
66
|
-
coinName: "BTC_USD",
|
|
67
|
-
amount: BigInt(10),
|
|
68
|
-
sender: testConfig.sender,
|
|
69
|
-
};
|
|
70
|
-
const builtTx = yield sdk.buildBurnTx(params);
|
|
71
|
-
expect(builtTx).toBeInstanceOf(Transaction);
|
|
72
|
-
// Dev inspect the transaction
|
|
73
|
-
try {
|
|
74
|
-
const result = yield suiClient.devInspectTransactionBlock({
|
|
75
|
-
transactionBlock: builtTx,
|
|
76
|
-
sender: testConfig.sender,
|
|
77
|
-
});
|
|
78
|
-
expect(result.error).toBeUndefined();
|
|
79
|
-
expect(result.effects.status.status).toBe("success");
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
const balance = yield suiClient.getBalance({
|
|
83
|
-
owner: testConfig.sender,
|
|
84
|
-
coinType: constants.BTC_USD_TYPE,
|
|
85
|
-
});
|
|
86
|
-
if (BigInt(balance.totalBalance) <= BigInt(10)) {
|
|
87
|
-
expect(error.message).toContain(`Not enough coins of type ${constants.BTC_USD_TYPE} to satisfy requested balance`);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
expect(error.message).toBeUndefined();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}));
|
|
94
|
-
it("should build a valid burn transaction with all flag", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
-
const tx = new Transaction();
|
|
96
|
-
const params = {
|
|
97
|
-
tx,
|
|
98
|
-
coinName: "BTC_USD",
|
|
99
|
-
all: true,
|
|
100
|
-
sender: testConfig.sender,
|
|
101
|
-
};
|
|
102
|
-
const builtTx = yield sdk.buildBurnTx(params);
|
|
103
|
-
expect(builtTx).toBeInstanceOf(Transaction);
|
|
104
|
-
try {
|
|
105
|
-
const result = yield suiClient.devInspectTransactionBlock({
|
|
106
|
-
transactionBlock: builtTx,
|
|
107
|
-
sender: testConfig.sender,
|
|
108
|
-
});
|
|
109
|
-
expect(result.error).toBeUndefined();
|
|
110
|
-
expect(result.effects.status.status).toBe("success");
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
const balance = yield suiClient.getBalance({
|
|
114
|
-
owner: testConfig.sender,
|
|
115
|
-
coinType: constants.BTC_USD_TYPE,
|
|
116
|
-
});
|
|
117
|
-
if (BigInt(balance.totalBalance) <= BigInt(10)) {
|
|
118
|
-
console.log(error);
|
|
119
|
-
expect(error.message).toBeDefined();
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
expect(error.message).toBeUndefined();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}));
|
|
126
|
-
});
|
|
127
|
-
describe("buildClaimTx", () => {
|
|
128
|
-
it("should build a valid claim transaction", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
-
const tx = new Transaction();
|
|
130
|
-
const params = {
|
|
131
|
-
tx,
|
|
132
|
-
coinName: "BTC_USD",
|
|
133
|
-
sender: testConfig.sender,
|
|
134
|
-
};
|
|
135
|
-
const builtTx = yield sdk.buildClaimTx(params);
|
|
136
|
-
expect(builtTx).toBeInstanceOf(Transaction);
|
|
137
|
-
// Dev inspect the transaction
|
|
138
|
-
const result = yield suiClient.devInspectTransactionBlock({
|
|
139
|
-
transactionBlock: builtTx,
|
|
140
|
-
sender: testConfig.sender,
|
|
141
|
-
});
|
|
142
|
-
expect(result.error).toBeUndefined();
|
|
143
|
-
expect(result.effects.status.status).toBe("success");
|
|
144
|
-
}));
|
|
145
|
-
});
|
|
146
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
/** Module for managing Credit and Debt for DeFi protocol usage */
|
|
5
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
7
|
-
const $moduleName = 'bucket_v2_framework::liability';
|
|
8
|
-
export const Credit = new MoveStruct({ name: `${$moduleName}::Credit`, fields: {
|
|
9
|
-
value: bcs.u64()
|
|
10
|
-
} });
|
|
11
|
-
export const Debt = new MoveStruct({ name: `${$moduleName}::Debt`, fields: {
|
|
12
|
-
value: bcs.u64()
|
|
13
|
-
} });
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
/** Module for the record of Credit and Debt of certain entity */
|
|
5
|
-
import { MoveTuple, MoveStruct } from '../../../utils/index.js';
|
|
6
|
-
import * as type_name from '../std/type_name.js';
|
|
7
|
-
import * as vec_map from '../sui/vec_map.js';
|
|
8
|
-
import * as liability from './liability.js';
|
|
9
|
-
import * as vec_set from '../sui/vec_set.js';
|
|
10
|
-
const $moduleName = 'bucket_v2_framework::sheet';
|
|
11
|
-
export const Entity = new MoveTuple({ name: `${$moduleName}::Entity`, fields: [type_name.TypeName] });
|
|
12
|
-
export const Sheet = new MoveStruct({ name: `${$moduleName}::Sheet`, fields: {
|
|
13
|
-
credits: vec_map.VecMap(Entity, liability.Credit),
|
|
14
|
-
debts: vec_map.VecMap(Entity, liability.Debt),
|
|
15
|
-
blacklist: vec_set.VecSet(Entity)
|
|
16
|
-
} });
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
/** Functionality for converting Move types into values. Use with care! */
|
|
5
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
7
|
-
const $moduleName = 'std::type_name';
|
|
8
|
-
export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: {
|
|
9
|
-
/**
|
|
10
|
-
* String representation of the type. All types are represented using their source
|
|
11
|
-
* syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types.
|
|
12
|
-
* Struct types are represented as fully qualified type names; e.g.
|
|
13
|
-
* `00000000000000000000000000000001::string::String` or
|
|
14
|
-
* `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>>`
|
|
15
|
-
* Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or
|
|
16
|
-
* 32 depending on the Move platform)
|
|
17
|
-
*/
|
|
18
|
-
name: bcs.string()
|
|
19
|
-
} });
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
/**
|
|
5
|
-
* A storable handler for Balances in general. Is used in the `Coin` module to
|
|
6
|
-
* allow balance operations and can be used to implement custom coins with `Supply`
|
|
7
|
-
* and `Balance`s.
|
|
8
|
-
*/
|
|
9
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
10
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
11
|
-
const $moduleName = '0x2::balance';
|
|
12
|
-
export const Supply = new MoveStruct({ name: `${$moduleName}::Supply`, fields: {
|
|
13
|
-
value: bcs.u64()
|
|
14
|
-
} });
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
/**
|
|
5
|
-
* Defines the `Coin` type - platform wide representation of fungible tokens and
|
|
6
|
-
* coins. `Coin` can be described as a secure wrapper around `Balance` type.
|
|
7
|
-
*/
|
|
8
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
9
|
-
import * as object from './object.js';
|
|
10
|
-
import * as balance from './balance.js';
|
|
11
|
-
const $moduleName = '0x2::coin';
|
|
12
|
-
export const TreasuryCap = new MoveStruct({ name: `${$moduleName}::TreasuryCap`, fields: {
|
|
13
|
-
id: object.UID,
|
|
14
|
-
total_supply: balance.Supply
|
|
15
|
-
} });
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
/** Sui object identifiers */
|
|
5
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
7
|
-
const $moduleName = '0x2::object';
|
|
8
|
-
export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: {
|
|
9
|
-
id: bcs.Address
|
|
10
|
-
} });
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
-
const $moduleName = '0x2::vec_map';
|
|
7
|
-
/** An entry in the map */
|
|
8
|
-
export function Entry(...typeParameters) {
|
|
9
|
-
return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
|
|
10
|
-
key: typeParameters[0],
|
|
11
|
-
value: typeParameters[1]
|
|
12
|
-
} });
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
16
|
-
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
17
|
-
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
18
|
-
* of this data structure is only to provide the convenience of programming against
|
|
19
|
-
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
20
|
-
* Maps that need sorted iteration rather than insertion order iteration should
|
|
21
|
-
* also be handwritten.
|
|
22
|
-
*/
|
|
23
|
-
export function VecMap(...typeParameters) {
|
|
24
|
-
return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
|
|
25
|
-
contents: bcs.vector(Entry(typeParameters[0], typeParameters[1]))
|
|
26
|
-
} });
|
|
27
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
-
const $moduleName = '0x2::vec_set';
|
|
7
|
-
/**
|
|
8
|
-
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
9
|
-
* duplicate keys. All operations are O(N) in the size of the set
|
|
10
|
-
*
|
|
11
|
-
* - the intention of this data structure is only to provide the convenience of
|
|
12
|
-
* programming against a set API. Sets that need sorted iteration rather than
|
|
13
|
-
* insertion order iteration should be handwritten.
|
|
14
|
-
*/
|
|
15
|
-
export function VecSet(...typeParameters) {
|
|
16
|
-
return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name}>`, fields: {
|
|
17
|
-
contents: bcs.vector(typeParameters[0])
|
|
18
|
-
} });
|
|
19
|
-
}
|
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
5
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
-
import * as sheet_1 from './deps/bucket_v2_framework/sheet.js';
|
|
7
|
-
import * as object from './deps/sui/object.js';
|
|
8
|
-
import * as vec_set from './deps/sui/vec_set.js';
|
|
9
|
-
import * as coin from './deps/sui/coin.js';
|
|
10
|
-
const $moduleName = '@local-pkg/stable_factory.move::stable_layer';
|
|
11
|
-
export const NewStable = new MoveStruct({ name: `${$moduleName}::NewStable`, fields: {
|
|
12
|
-
u_type: bcs.string(),
|
|
13
|
-
stable_type: bcs.string(),
|
|
14
|
-
factory_id: bcs.Address,
|
|
15
|
-
factory_cap_id: bcs.Address
|
|
16
|
-
} });
|
|
17
|
-
export const Mint = new MoveStruct({ name: `${$moduleName}::Mint`, fields: {
|
|
18
|
-
u_type: bcs.string(),
|
|
19
|
-
stable_type: bcs.string(),
|
|
20
|
-
mint_amount: bcs.u64(),
|
|
21
|
-
farm_type: bcs.string()
|
|
22
|
-
} });
|
|
23
|
-
export const Burn = new MoveStruct({ name: `${$moduleName}::Burn`, fields: {
|
|
24
|
-
u_type: bcs.string(),
|
|
25
|
-
stable_type: bcs.string(),
|
|
26
|
-
burn_amount: bcs.u64(),
|
|
27
|
-
farm_types: bcs.vector(sheet_1.Entity),
|
|
28
|
-
repayment_amounts: bcs.vector(bcs.u64())
|
|
29
|
-
} });
|
|
30
|
-
export const StableFactoryEntity = new MoveStruct({ name: `${$moduleName}::StableFactoryEntity`, fields: {
|
|
31
|
-
dummy_field: bcs.bool()
|
|
32
|
-
} });
|
|
33
|
-
export const StableRegistry = new MoveStruct({ name: `${$moduleName}::StableRegistry`, fields: {
|
|
34
|
-
id: object.UID,
|
|
35
|
-
versions: vec_set.VecSet(bcs.u16()),
|
|
36
|
-
total_supply: bcs.u64()
|
|
37
|
-
} });
|
|
38
|
-
export const AdminCap = new MoveStruct({ name: `${$moduleName}::AdminCap`, fields: {
|
|
39
|
-
id: object.UID
|
|
40
|
-
} });
|
|
41
|
-
export const StableFactory = new MoveStruct({ name: `${$moduleName}::StableFactory`, fields: {
|
|
42
|
-
id: object.UID,
|
|
43
|
-
treasury_cap: coin.TreasuryCap,
|
|
44
|
-
max_supply: bcs.u64(),
|
|
45
|
-
sheet: sheet_1.Sheet,
|
|
46
|
-
managers: vec_set.VecSet(bcs.Address)
|
|
47
|
-
} });
|
|
48
|
-
export const FactoryCap = new MoveStruct({ name: `${$moduleName}::FactoryCap`, fields: {
|
|
49
|
-
id: object.UID,
|
|
50
|
-
factory_id: bcs.Address
|
|
51
|
-
} });
|
|
52
|
-
export function packageVersion(options = {}) {
|
|
53
|
-
var _a;
|
|
54
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
55
|
-
return (tx) => tx.moveCall({
|
|
56
|
-
package: packageAddress,
|
|
57
|
-
module: 'stable_layer',
|
|
58
|
-
function: 'package_version',
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/** Admin Funs */
|
|
62
|
-
export function _new(options) {
|
|
63
|
-
var _a;
|
|
64
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
65
|
-
const argumentsTypes = [
|
|
66
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
67
|
-
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::TreasuryCap<${options.typeArguments[0]}>`,
|
|
68
|
-
'u64'
|
|
69
|
-
];
|
|
70
|
-
const parameterNames = ["registry", "treasuryCap", "maxSupply"];
|
|
71
|
-
return (tx) => tx.moveCall({
|
|
72
|
-
package: packageAddress,
|
|
73
|
-
module: 'stable_layer',
|
|
74
|
-
function: 'new',
|
|
75
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
76
|
-
typeArguments: options.typeArguments
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
export function _default(options) {
|
|
80
|
-
var _a;
|
|
81
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
82
|
-
const argumentsTypes = [
|
|
83
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
84
|
-
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::TreasuryCap<${options.typeArguments[0]}>`,
|
|
85
|
-
'u64'
|
|
86
|
-
];
|
|
87
|
-
const parameterNames = ["registry", "treasuryCap", "maxSupply"];
|
|
88
|
-
return (tx) => tx.moveCall({
|
|
89
|
-
package: packageAddress,
|
|
90
|
-
module: 'stable_layer',
|
|
91
|
-
function: 'default',
|
|
92
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
93
|
-
typeArguments: options.typeArguments
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
/** Admin Funs */
|
|
97
|
-
export function addVersion(options) {
|
|
98
|
-
var _a;
|
|
99
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
100
|
-
const argumentsTypes = [
|
|
101
|
-
`${packageAddress}::stable_layer::AdminCap`,
|
|
102
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
103
|
-
'u16'
|
|
104
|
-
];
|
|
105
|
-
const parameterNames = ["AdminCap", "registry", "version"];
|
|
106
|
-
return (tx) => tx.moveCall({
|
|
107
|
-
package: packageAddress,
|
|
108
|
-
module: 'stable_layer',
|
|
109
|
-
function: 'add_version',
|
|
110
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
export function removeVersion(options) {
|
|
114
|
-
var _a;
|
|
115
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
116
|
-
const argumentsTypes = [
|
|
117
|
-
`${packageAddress}::stable_layer::AdminCap`,
|
|
118
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
119
|
-
'u16'
|
|
120
|
-
];
|
|
121
|
-
const parameterNames = ["AdminCap", "registry", "version"];
|
|
122
|
-
return (tx) => tx.moveCall({
|
|
123
|
-
package: packageAddress,
|
|
124
|
-
module: 'stable_layer',
|
|
125
|
-
function: 'remove_version',
|
|
126
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/** Factory Cap Funs */
|
|
130
|
-
export function addEntity(options) {
|
|
131
|
-
var _a;
|
|
132
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
133
|
-
const argumentsTypes = [
|
|
134
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
135
|
-
`${packageAddress}::stable_layer::FactoryCap<${options.typeArguments[0]}, ${options.typeArguments[1]}>`
|
|
136
|
-
];
|
|
137
|
-
const parameterNames = ["registry", "FactoryCap"];
|
|
138
|
-
return (tx) => tx.moveCall({
|
|
139
|
-
package: packageAddress,
|
|
140
|
-
module: 'stable_layer',
|
|
141
|
-
function: 'add_entity',
|
|
142
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
143
|
-
typeArguments: options.typeArguments
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
export function banEntity(options) {
|
|
147
|
-
var _a;
|
|
148
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
149
|
-
const argumentsTypes = [
|
|
150
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
151
|
-
`${packageAddress}::stable_layer::FactoryCap<${options.typeArguments[0]}, ${options.typeArguments[1]}>`
|
|
152
|
-
];
|
|
153
|
-
const parameterNames = ["registry", "FactoryCap"];
|
|
154
|
-
return (tx) => tx.moveCall({
|
|
155
|
-
package: packageAddress,
|
|
156
|
-
module: 'stable_layer',
|
|
157
|
-
function: 'ban_entity',
|
|
158
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
159
|
-
typeArguments: options.typeArguments
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
export function addManager(options) {
|
|
163
|
-
var _a;
|
|
164
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
165
|
-
const argumentsTypes = [
|
|
166
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
167
|
-
`${packageAddress}::stable_layer::FactoryCap<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
168
|
-
'address'
|
|
169
|
-
];
|
|
170
|
-
const parameterNames = ["registry", "FactoryCap", "manager"];
|
|
171
|
-
return (tx) => tx.moveCall({
|
|
172
|
-
package: packageAddress,
|
|
173
|
-
module: 'stable_layer',
|
|
174
|
-
function: 'add_manager',
|
|
175
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
176
|
-
typeArguments: options.typeArguments
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
export function removeManager(options) {
|
|
180
|
-
var _a;
|
|
181
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
182
|
-
const argumentsTypes = [
|
|
183
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
184
|
-
`${packageAddress}::stable_layer::FactoryCap<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
185
|
-
'address'
|
|
186
|
-
];
|
|
187
|
-
const parameterNames = ["registry", "FactoryCap", "manager"];
|
|
188
|
-
return (tx) => tx.moveCall({
|
|
189
|
-
package: packageAddress,
|
|
190
|
-
module: 'stable_layer',
|
|
191
|
-
function: 'remove_manager',
|
|
192
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
193
|
-
typeArguments: options.typeArguments
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
export function setMaxSupply(options) {
|
|
197
|
-
var _a;
|
|
198
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
199
|
-
const argumentsTypes = [
|
|
200
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
201
|
-
`${packageAddress}::stable_layer::FactoryCap<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
202
|
-
'u64'
|
|
203
|
-
];
|
|
204
|
-
const parameterNames = ["registry", "FactoryCap", "maxSupply"];
|
|
205
|
-
return (tx) => tx.moveCall({
|
|
206
|
-
package: packageAddress,
|
|
207
|
-
module: 'stable_layer',
|
|
208
|
-
function: 'set_max_supply',
|
|
209
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
210
|
-
typeArguments: options.typeArguments
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
/** Public Funs */
|
|
214
|
-
export function mint(options) {
|
|
215
|
-
var _a;
|
|
216
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
217
|
-
const argumentsTypes = [
|
|
218
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
219
|
-
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[1]}>`
|
|
220
|
-
];
|
|
221
|
-
const parameterNames = ["registry", "uCoin"];
|
|
222
|
-
return (tx) => tx.moveCall({
|
|
223
|
-
package: packageAddress,
|
|
224
|
-
module: 'stable_layer',
|
|
225
|
-
function: 'mint',
|
|
226
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
227
|
-
typeArguments: options.typeArguments
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
export function requestBurn(options) {
|
|
231
|
-
var _a;
|
|
232
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
233
|
-
const argumentsTypes = [
|
|
234
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
235
|
-
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[0]}>`
|
|
236
|
-
];
|
|
237
|
-
const parameterNames = ["registry", "stableCoin"];
|
|
238
|
-
return (tx) => tx.moveCall({
|
|
239
|
-
package: packageAddress,
|
|
240
|
-
module: 'stable_layer',
|
|
241
|
-
function: 'request_burn',
|
|
242
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
243
|
-
typeArguments: options.typeArguments
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
export function fulfillBurn(options) {
|
|
247
|
-
var _a;
|
|
248
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
249
|
-
const argumentsTypes = [
|
|
250
|
-
`${packageAddress}::stable_layer::StableRegistry`,
|
|
251
|
-
`${packageAddress}::sheet::Request<${options.typeArguments[1]}, ${packageAddress}::stable_layer::StableFactoryEntity<${options.typeArguments[0]}, ${options.typeArguments[1]}>>`
|
|
252
|
-
];
|
|
253
|
-
const parameterNames = ["registry", "burnRequest"];
|
|
254
|
-
return (tx) => tx.moveCall({
|
|
255
|
-
package: packageAddress,
|
|
256
|
-
module: 'stable_layer',
|
|
257
|
-
function: 'fulfill_burn',
|
|
258
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
259
|
-
typeArguments: options.typeArguments
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
/** Getter Fun */
|
|
263
|
-
export function versions(options) {
|
|
264
|
-
var _a;
|
|
265
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
266
|
-
const argumentsTypes = [
|
|
267
|
-
`${packageAddress}::stable_layer::StableRegistry`
|
|
268
|
-
];
|
|
269
|
-
const parameterNames = ["registry"];
|
|
270
|
-
return (tx) => tx.moveCall({
|
|
271
|
-
package: packageAddress,
|
|
272
|
-
module: 'stable_layer',
|
|
273
|
-
function: 'versions',
|
|
274
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
export function totalSupply(options) {
|
|
278
|
-
var _a;
|
|
279
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
280
|
-
const argumentsTypes = [
|
|
281
|
-
`${packageAddress}::stable_layer::StableRegistry`
|
|
282
|
-
];
|
|
283
|
-
const parameterNames = ["registry"];
|
|
284
|
-
return (tx) => tx.moveCall({
|
|
285
|
-
package: packageAddress,
|
|
286
|
-
module: 'stable_layer',
|
|
287
|
-
function: 'total_supply',
|
|
288
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
export function borrowFactory(options) {
|
|
292
|
-
var _a;
|
|
293
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
294
|
-
const argumentsTypes = [
|
|
295
|
-
`${packageAddress}::stable_layer::StableRegistry`
|
|
296
|
-
];
|
|
297
|
-
const parameterNames = ["registry"];
|
|
298
|
-
return (tx) => tx.moveCall({
|
|
299
|
-
package: packageAddress,
|
|
300
|
-
module: 'stable_layer',
|
|
301
|
-
function: 'borrow_factory',
|
|
302
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
303
|
-
typeArguments: options.typeArguments
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
export function sheet(options) {
|
|
307
|
-
var _a;
|
|
308
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
309
|
-
const argumentsTypes = [
|
|
310
|
-
`${packageAddress}::stable_layer::StableFactory<${options.typeArguments[0]}, ${options.typeArguments[1]}>`
|
|
311
|
-
];
|
|
312
|
-
const parameterNames = ["factory"];
|
|
313
|
-
return (tx) => tx.moveCall({
|
|
314
|
-
package: packageAddress,
|
|
315
|
-
module: 'stable_layer',
|
|
316
|
-
function: 'sheet',
|
|
317
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
318
|
-
typeArguments: options.typeArguments
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
export function stableSupply(options) {
|
|
322
|
-
var _a;
|
|
323
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
324
|
-
const argumentsTypes = [
|
|
325
|
-
`${packageAddress}::stable_layer::StableFactory<${options.typeArguments[0]}, ${options.typeArguments[1]}>`
|
|
326
|
-
];
|
|
327
|
-
const parameterNames = ["factory"];
|
|
328
|
-
return (tx) => tx.moveCall({
|
|
329
|
-
package: packageAddress,
|
|
330
|
-
module: 'stable_layer',
|
|
331
|
-
function: 'stable_supply',
|
|
332
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
333
|
-
typeArguments: options.typeArguments
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
export function maxSupply(options) {
|
|
337
|
-
var _a;
|
|
338
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
339
|
-
const argumentsTypes = [
|
|
340
|
-
`${packageAddress}::stable_layer::StableFactory<${options.typeArguments[0]}, ${options.typeArguments[1]}>`
|
|
341
|
-
];
|
|
342
|
-
const parameterNames = ["factory"];
|
|
343
|
-
return (tx) => tx.moveCall({
|
|
344
|
-
package: packageAddress,
|
|
345
|
-
module: 'stable_layer',
|
|
346
|
-
function: 'max_supply',
|
|
347
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
348
|
-
typeArguments: options.typeArguments
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
export function managers(options) {
|
|
352
|
-
var _a;
|
|
353
|
-
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_factory.move';
|
|
354
|
-
const argumentsTypes = [
|
|
355
|
-
`${packageAddress}::stable_layer::StableFactory<${options.typeArguments[0]}, ${options.typeArguments[1]}>`
|
|
356
|
-
];
|
|
357
|
-
const parameterNames = ["factory"];
|
|
358
|
-
return (tx) => tx.moveCall({
|
|
359
|
-
package: packageAddress,
|
|
360
|
-
module: 'stable_layer',
|
|
361
|
-
function: 'managers',
|
|
362
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
363
|
-
typeArguments: options.typeArguments
|
|
364
|
-
});
|
|
365
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
/** Module for managing Credit and Debt for DeFi protocol usage */
|
|
5
|
-
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
7
|
-
const $moduleName = 'bucket_v2_framework::liability';
|
|
8
|
-
export const Credit = new MoveStruct({ name: `${$moduleName}::Credit`, fields: {
|
|
9
|
-
value: bcs.u64()
|
|
10
|
-
} });
|
|
11
|
-
export const Debt = new MoveStruct({ name: `${$moduleName}::Debt`, fields: {
|
|
12
|
-
value: bcs.u64()
|
|
13
|
-
} });
|